User:MrDolomite/monobook.js
Jump to navigation
Jump to search
Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
- Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac);
- Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5;
- Konqueror: simply click the Reload button, or press F5;
- Opera users may need to completely clear their cache in Tools→Preferences.
Warning: Malicious code can compromise your account. Page preview will cause your web browser to execute this page's content as code under some skins, including Monobook. If you have any questions about any code you plan to add, you can ask at the appropriate reading room. |
The accompanying .css page for this skin can be added at User:MrDolomite/monobook.css. |
//////////////added 2006-07-25 from User:Where/commentLocalize
//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;
}*/
});
///////////////////////////////
//////////////added 2006-07-25 from User:Misza13/Scripts/View source
// VIEW SOURCE
$(function () {
if (location.href.indexOf('viewsource=1') != -1) {
sl = document.getElementById('wpSummaryLabel'); sl.parentNode.removeChild(sl);
ed = document.getElementById('wpSummary').parentNode; ed.parentNode.removeChild(ed);
return;
}
editbutton = document.getElementById('ca-edit');
if (editbutton && location.href.indexOf('action=edit')==-1) {
editlink = editbutton.getElementsByTagName('a')[0].href + '&viewsource=1';
tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
na = document.createElement('a');
na.href = editlink; na.appendChild(document.createTextNode('view source'));
li = document.createElement('li'); li.id = 'ca-viewsource'; li.appendChild(na);
tabs.insertBefore(li,editbutton);
}
});
////////////////////////////
///////////////added 2006-07-25
// This will add an [edit top] link at the top of all pages except preview pages
// by User:Pile0nades
// Add an [edit top] link to pages
$(function () {
// if this is preview page or generated page, stop
if(document.getElementById("wikiPreview") || window.location.href.indexOf("/wiki/Special:") != -1) return;
// get the page title
var pageTitle = document.title.split(" - ")[0].replace(" ", "_");
// create div and set innerHTML to link
var divContainer = document.createElement("div");
divContainer.innerHTML = '<div class="editsection" style="float:right;margin-left:5px;margin-right:15px;margin-top:3px;">[<a href="/w/index.php?title='+pageTitle+'&action=edit§ion=0" title="'+document.title.split(" - ")[0]+'">edit top</a>]</div>';
// insert divContainer into the DOM before the h1
if(window.location.href.indexOf("&action=edit") == -1)
document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
if(window.location.href.indexOf("&action=edit§ion=0") != -1)
document.getElementById("wpSummary").value = "/* Intro */ ";
});
///////////////////////////////////////////////////////////////