User:Rillke/logo 2013 voy.js

From Meta, a Wikimedia project coordination wiki

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/**
 * Enhaced POTY - convenient voting!
 *
 * Features: [[:commons:Help:EnhancedPOTY.js]]
 *  
 * Configuration for a Meta-Logo vote.
 *
 * Thanks to all translators!
 *
 * <nowiki>
 * jshint validation, please
 *
 * @rev 1 (2013-07-11)
 * @author
 *   [[User:Rillke]], 2013
 * @license 
 *   GPL v.3
 */
 
/*global jQuery:false, mediaWiki:false, Geo:false, importStylesheet:false, importScript:false, wpAvailableLanguages:false, GallerySlide:false*/
/*jshint curly:false */
(function($, mw, undefined) {
'use strict';
 
if (window.POTY || 'view' !== mw.config.get('wgAction') || !/Wikivoyage\/Logo\/2013\//.test(mw.config.get('wgPageName'))) return;

// Register Commons RL modules
mw.loader.addSource({"commonswiki":{ "loadScript":"https://commons.wikimedia.org/w/load.php", "apiScript":"//commons.wikimedia.org/w/api.php"}});

// https://git.wikimedia.org/blob/mediawiki%2Fcore.git/1d3a2e87b79c1113c5b3f1bf356fe7ff1378c11a/resources%2Fmediawiki%2Fmediawiki.js
// register: function ( module, version, dependencies, group, source ) 
/*
// Create reg
$.each(r, function(i, m) {
m[2] = m[2] || [];
m[3] = m[3] || null;
m[4] = 'commonswiki';
})
*/
mw.loader.register([
	["ext.gadget.LanguageSelect", "1364400202", ["jquery.cookie", "mediawiki.user", "mediawiki.util", "site", "user"], null, "commonswiki"],
	["ext.gadget.GlobalUsage", "1347062400", ["mediawiki.api"], null, "commonswiki"],
	["ext.gadget.GlobalReplace", "1359929894", ["ext.gadget.libWikiDOM"], null, "commonswiki"],
	["ext.gadget.SettingsUI", "1348591320", ["jquery.ui", "mediawiki.user", "ext.gadget.libJQuery"], null, "commonswiki"],
	["ext.gadget.SettingsManager", "1369392947", ["jquery.json", "mediawiki.user", "user.options", "mediawiki.api"], null, "commonswiki"],
	["ext.gadget.libAPI", "1371814662", ["mediawiki.util", "mediawiki.user"], null, "commonswiki"],
	["ext.gadget.libUtil", "1350850217", ["mediawiki.util"], null, "commonswiki"],
	["ext.gadget.libCommons", "1356998174", [], null, "commonswiki"],
	["ext.gadget.libJQuery", "1369403932", [], null, "commonswiki"],
	["ext.gadget.libWikiDOM", "1371169895", [], null, "commonswiki"],
	["ext.gadget.editDropdown", "1368450610", ["mediawiki.util", "jquery.client"], null, "commonswiki"],
	["ext.gadget.jquery.blockUI", "1354795695", [], null, "commonswiki"],
	["ext.gadget.jquery.in-view", "1348587706", [], null, "commonswiki"],
	["ext.gadget.jquery.fullscreen", "1370005206", [], null, "commonswiki"],
	["ext.gadget.jquery.mousewheel", "1355500828", [], null, "commonswiki"],
	["ext.gadget.jquery.rotate", "1370953397", [], null, "commonswiki"],
	["ext.gadget.jquery.jqplot", "1360076689", [], null, "commonswiki"],
	["ext.gadget.jquery.sparkline", "1373559634", [], null, "commonswiki"],
	["ext.gadget.math.seedrandom", "1373545220", [], null, "commonswiki"]
]);



var iphp = document.location.protocol + '//commons.wikimedia.org/w/index.php';
var commonsLoad = function(s, type) {
	mw.loader.load(iphp + '?' + $.param({
		title: s,
		action: 'raw',
		ctype: type,
		maxage: 86400,
		smaxage: 86400
	}), type);
};

window.potyconfig = {
	// The key to be used to store the data in the user's browser
	storageKey: '2013voylogo_test',
	// POTY <year>
	year: 2013,
	// Will be retrieved from the template $('#potyVotingState')
	state: 'R1',
	// Required e.g. for digging the contribs to a specific date
	startDate: '2013-07-26T00:00:00Z',
	
	appName: 'Cutelect',

	// Eligibility requirements
	required: {
		minEditCount: 1,
		editsBefore: '2013-06-31T00:00:00Z',
		editsDaysAgo: 6000,
		registeredBefore: '2013-06-31T00:00:00Z',
		includeDeleted: false
	},
	
	// Max votes
	maxVotes: {
		'R1': 3,
		'R2': 1,
		'novote': 0
	},
	votingSummaryAdd: '+1 vote - eligible on %wiki% with %edits% edits - Vote through [[%VoteFrom%]] - [[:commons:Help:EnhancedPOTY.js|Cutelect]]',
	votingSummaryRemove: '-1 vote - Vote through [[%VoteFrom%]] - [[:commons:Help:EnhancedPOTY.js|Cutelect]]',
	reportPage: 'User talk:Rillke/logo 2013 voy.js/reports',

	availableImageSizes: [{w: 400, h: 400}, {w: 335, h: 250}, {w: 300, h: 300}, {w: 250, h: 250}, {w: 200, h: 200}, {w: 180, h: 180}, {w: 150, h: 150}, {w: 120, h: 120}, {w: 64, h: 64}],
	

	// For which round is this gallery?
	galleryType: mw.config.get('wgPageName').match(/\d{4}\/(R\d)/)[1],
	votingPageRegExp: /^Wikivoyage\/Logo\/\d{4}\/(R\d)\/v\/([^\/]{5,})$/,
	galleryRegExp: /^Wikivoyage\/Logo\/\d{4}\/(?:(?:Galleries|R\d)\/([^\/]+)|(Finalists)|(Round \d))/,
	pageNamespace: 0,
	pageBase: 'Wikivoyage/Logo',
	statsPage: 'User:Rillke/logoVoyStats',
	
	// Style & CSS
	stylesheet: 'MediaWiki:EnhancedPOTY.css',
	logo: '//upload.wikimedia.org/wikipedia/commons/thumb/8/8a/Wikivoyage-logo.svg/150px-Wikivoyage-logo.svg.png',
	
	// Global functions to be used
	importScript: function(s) {
		commonsLoad(s, 'text/javascript');
	},
	importStylesheet: function(s) {
		commonsLoad(s, 'text/css');
	},
	wikiScript: iphp,
	loadTranslationDone: function() {
		// Overriding translation
		var msgs = {
			'poty-poty-year':          "Cutelect $1",
			'poty-poty-full-year':     "Wikivoyage Logo Election $1",
			'poty-poty-full-commons':  "Wikivoyage Logo Election",
			'poty-welcome-banner':     "Welcome $1! Loading Cutelect $2.",

			'poty-vote-limited':       "You can vote for {{Plural:$1|ONE logo|$1 logos}} in total. {{Plural:$1||If you vote for more than one logo, please vote for them in order of your preference.",
		 
			'poty-anonymous-no-vote-msg':   "You are currently not logged in. Only registered users can vote in Wikivoyage Logo Election.",
		 
			'poty-my-poty-link':         "Cutelect",
			'poty-my-poty-link-tooltip': "All about your participation in Wikivoyage Logo Election $1",
			'poty-my-poty-h1':           "Wikivoyage Logo Election $1 and You",
		 
			'poty-my-poty-state':        "Wikivoyage Logo Election - State"
		};
		// Now reading the local translation
		$.each(msgs, function(k) {
			var $m = $('#' + k),
				t = $.trim($m.text());
				
			if (t) msgs[k] = t;
		});		
		
		mw.messages.set(msgs);
		this.nextTask();
	},
	installSlideshow: function () {
		this.nextTask();
	}
};

window.potyconfig.importScript('MediaWiki:EnhancedPOTY.js');
})(jQuery, mediaWiki);
// </nowiki>