User:Diriector Doc/Scripts/QuickDate.js

var addButton = function{ $("#wpTextbox1").wikiEditor("addToToolbar", {		section: "main",		group: "insert",		tools: {			"Month and Year": {				label: "Insert the current month and year",				type: "button",				// This is a simple .svg of a clock. No need to upload it somewhere, it works like this.				icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgoKPHN2ZwogICB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iCiAgIHhtbG5zOmNjPSJodHRwOi8vY3JlYXRpdmVjb21tb25zLm9yZy9ucyMiCiAgIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyIKICAgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgogICB4bWxuczpzb2RpcG9kaT0iaHR0cDovL3NvZGlwb2RpLnNvdXJjZWZvcmdlLm5ldC9EVEQvc29kaXBvZGktMC5kdGQiCiAgIHhtbG5zOmlua3NjYXBlPSJodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy9uYW1lc3BhY2VzL2lua3NjYXBlIgogICB3aWR0aD0iNS4yOTE2NjY1bW0iCiAgIGhlaWdodD0iNS4yOTE2NjY1bW0iCiAgIHZpZXdCb3g9IjAgMCA1LjI5MTY2NjUgNS4yOTE2NjY4IgogICB2ZXJzaW9uPSIxLjEiCiAgIGlkPSJzdmc4IgogICBpbmtzY2FwZTp2ZXJzaW9uPSIwLjkyLjQgKDVkYTY4OWMzMTMsIDIwMTktMDEtMTQpIgogICBzb2RpcG9kaTpkb2NuYW1lPSJjbG9jay5zd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QuNzk4ODI4MSw2LjczNjMyODEgNC4xNTgyMDMxLDguMDkzNzUgYyAyLjAwMjY5NTIsMC45NDU3Njk2IDQuMDA3MzMyNCwxLjg4NzQ2MTkgNi4wMDc4MTE5LDIuODM3ODkgMS42MDk1MTgsLTEuODk1NTQ4NSAzLjE0MDAyLC0zLjg1OTQwNzMgNC42OTkyMTksLTUuNzk2ODc0NCB6IgogICAgICAgdHJhbnNmb3JtPSJtYXRyaXgoMC4yNjQ1ODMzMywwLDAsMC4yNjQ1ODMzMywwLDI5MS43MDgzMikiCiAgICAgICBpZD0icmVjdDEzOTYiCiAgICAgICBpbmtzY2FwZTpjb25uZWN0b3ItY3VydmF0dXJlPSIwIgogICAgICAgc29kaXBvZGk6bm9kZXR5cGVzPSJjY2NjY2NjIiAvPgogIDwvZz4KPC9zdmc+Cg==", action: { type: "encapsulate", options: { pre: "", post: "{" + "{" + "subst:CURRENTMONTHNAME}} " + "{" + "{" + "subst:CURRENTYEAR}}" }				}			}		}	}); };

/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */ if(['edit', 'submit'].indexOf(mw.config.get('wgAction')) !== -1){ mw.loader.using('user.options').then(function{		// This can be the string "0" if the user disabled the preference (T54542)		if(mw.user.options.get('usebetatoolbar') == 1){			$.when(mw.loader.using('ext.wikiEditor'), $.ready).then(addButton);		}	} ); }