User:Alan Isherwood/monobook.js

/* User:Lupin/popups.js */

mw.loader.load(

'https://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js'

+ '&action=raw&ctype=text/javascript&dontcountme=s');

/* Interiot's javascript edit counter */

if (document.title.indexOf('User:Interiot/Tool2/code.js') != -1) {

mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js&action=raw&ctype=text/javascript'); }

importScript('Wikipedia:WikiProject User scripts/Scripts/Time');

function unverified() {

// Find the edit box

var txt = document.editform.wpTextbox1;

// The tag to be included is an unverified image template

var tag = '\u007b\u007b' + 'unverified' + '\u007d\u007d';

// If the edit box doesn't already have this tag...

if (txt.value.indexOf(tag) == -1) {

// Append the tag

txt.value += tag;

// Add an edit summary

document.editform.wpSummary.value = 'Needs a source and copyright tag — see Wikipedia:Image copyright tags';

// Press the Save page button

document.editform.submit();

}

// If the tag was already there, turn the tab background red to indicate

// that the script is functioning properly, but that there is no action

// to do. This doesn't interrupt the user's work like an alert() would.

else {

document.getElementById('ca-unverified').firstChild.style.backgroundColor = "#ff4444";

document.getElementById('ca-unverified').style.backgroundColor = "#ff4444";

}

}

// Create a tab that calls this function when pressed

$(function () {

if(document.title.indexOf("Editing Image:") == 0) {

addLink('p-cactions', 'javascript:unverified()', 'tag', 'ca-unverified', 'Adds a tag to an unverified image', , );

}

});

//Localized time/date script

function numToMonth(num) {

if (num==0) {return "Janurary";}

else if (num==1) {return "February";}

else if (num==2) {return "March";}

else if (num==3) {return "April";}

else if (num==4) {return "May";}

else if (num==5) {return "June";}

else if (num==6) {return "July";}

else if (num==7) {return "August";}

else if (num==8) {return "September";}

else if (num==9) {return "October";}

else if (num==10) {return "November";}

else if (num==11) {return "December";}

}

function monthToNum(month) {

var tmp = new Date(month + " 1, 2006");

return tmp.getMonth();

}

function adjustTime(str, hour, minute, day, month, year, offset, s) {

var time = new Date();

time.setUTCHours(hour);

time.setUTCMinutes(minute);

time.setUTCDate(day);

time.setUTCMonth(monthToNum(month));

time.setUTCFullYear(year);

var timeStr = "";

if (time.getHours()<10) {timeStr += "0";}

timeStr += parseInt(time.getHours()) + ":";

if (time.getMinutes()<10) {timeStr += "0";}

timeStr += parseInt(time.getMinutes());

timeStr += ", ";

timeStr += time.getDate();

timeStr += " ";

timeStr += numToMonth(time.getMonth());

timeStr += " ";

timeStr += time.getFullYear();

timeStr += " (UTC";

var offset = -1*time.getTimezoneOffset()/60;

if (offset >= 0) {timeStr += "+";}

timeStr += offset + ")";

return timeStr;

}

function adjustTime2(str, hour, minute, month, day, year, offset, s) {

return adjustTime(str, hour, minute, day, month, year, offset, s);

}

$(function() {

if (document.title.indexOf("Editing ") == 0) {

return;

}

if (document.location.href.indexOf("action=history") != -1) {

return;

}

if (document.title.indexOf("Talk:") == 0 || document.title.indexOf("talk:") != -1 || document.title.indexOf("Wikipedia:") == 0) {

var newDoc = document.getElementById("column-content").innerHTML.replace(/(\d\d):(\d\d), (\d{1,2}) ([A-Z][a-z]+) (\d{4}) \(UTC\)/g, adjustTime);

document.getElementById("column-content").innerHTML = newDoc;

}

/* if (document.location.href.indexOf("&action=history") != -1) {

var newDoc = document.getElementById("bodyContent").innerHTML.replace(/(\d\d):(\d\d), ([A-Z][a-z]+) (\d{1,2}), (\d{4})/g, adjustTime2);

document.getElementById("bodyContent").innerHTML = newDoc;

}*/

});