m (added buttons) |
m (removing unnecessary stuff) |
||
Line 24: | Line 24: | ||
oldPageTitle.innerHTML = newPageTitle.innerHTML; // Set the title |
oldPageTitle.innerHTML = newPageTitle.innerHTML; // Set the title |
||
}); |
}); |
||
− | |||
− | function addAlternatingRowColors() { |
||
− | var infoboxes = getElementsByClass('infobox', document.getElementById('content')); |
||
− | |||
− | if( infoboxes.length == 0 ) |
||
− | return; |
||
− | |||
− | for( var k = 0; k < infoboxes.length; k++ ) { |
||
− | var infobox = infoboxes[k]; |
||
− | |||
− | var rows = infobox.getElementsByTagName('tr'); |
||
− | var changeColor = false; |
||
− | |||
− | for( var i = 0; i < rows.length; i++ ) { |
||
− | if(rows[i].className.indexOf('infoboxstopalt') != -1) |
||
− | break; |
||
− | |||
− | var ths = rows[i].getElementsByTagName('th'); |
||
− | |||
− | if( ths.length > 0 ) { |
||
− | continue; |
||
− | } |
||
− | |||
− | if(changeColor) |
||
− | rows[i].style.backgroundColor = '#f9f9f9'; |
||
− | changeColor = !changeColor; |
||
− | } |
||
− | } |
||
− | } |
||
function addHideButtons() { |
function addHideButtons() { |
||
Line 120: | Line 91: | ||
} |
} |
||
} |
} |
||
− | |||
− | // JavaScript Measurements and Date Selectors |
||
− | function makeDate(fmt,fulldate) { |
||
− | if(fulldate.match(/[a-z]+, [0-9]+ [a-z]+ [0-9]{4}/gi)) { // dddd dd mmmm yyyy |
||
− | var day = fulldate.match(/[a-z]+/gi)[0], |
||
− | date = fulldate.match(/[0-9]+/)[0], |
||
− | month = fulldate.match(/[a-z]+/gi)[1], |
||
− | year = fulldate.match(/[0-9]{4}/)[0]; |
||
− | if(fmt === "dmy") { |
||
− | return day+", "+date+" "+month+" "+year; |
||
− | } else if(fmt === "mdy") { |
||
− | return day+", "+month+" "+date+", "+year; |
||
− | } else if(fmt === "ymd") { |
||
− | return year+" "+month+" "+date+" ("+day+")"; |
||
− | } |
||
− | } else if(fulldate.match(/[0-9]+ [a-z]+ [0-9]{4}/i)) { // dd mmmm yyyy |
||
− | var date = fulldate.match(/[0-9]+/)[0], |
||
− | month = fulldate.match(/[a-z]+/i)[0], |
||
− | year = fulldate.match(/[0-9]{4}/)[0]; |
||
− | if(fmt === "dmy") { |
||
− | return date+" "+month+" "+year; |
||
− | } else if(fmt === "mdy") { |
||
− | return month+" "+date+", "+year; |
||
− | } else if(fmt === "ymd") { |
||
− | return year+" "+month+" "+date; |
||
− | } |
||
− | } else if(fulldate.match(/[0-9]+ [a-z]+/i)) { // dd mmmm |
||
− | var date = fulldate.match(/[0-9]+/)[0], |
||
− | month = fulldate.match(/[a-z]+/i)[0]; |
||
− | if(fmt === "dmy") { |
||
− | return date+" "+month; |
||
− | } else if(fmt === "mdy" || fmt === "ymd") { |
||
− | return month+" "+date; |
||
− | } |
||
− | } else if(fulldate.match(/[a-z]+ [0-9]{4}/i)) { // mmmm yyyy |
||
− | var month = fulldate.match(/[a-z]+/i)[0], |
||
− | year = fulldate.match(/[0-9]{4}/)[0]; |
||
− | if(fmt === "dmy" || fmt === "mdy") { |
||
− | return month+" "+year; |
||
− | } else if(fmt === "ymd") { |
||
− | return year+" "+month; |
||
− | } |
||
− | } else { |
||
− | return fulldate; |
||
− | } |
||
− | } |
||
− | |||
− | function toDate(fmt) { |
||
− | var d = new Date(), |
||
− | date = d.getDate(), |
||
− | mname = ["January","February","March","April","May","June","July","August","September","October","November","December"], |
||
− | month = mname[d.getMonth()], |
||
− | year = d.getFullYear(); |
||
− | |||
− | if(fmt === "dmy") { |
||
− | return date+" "+month+" "+year; |
||
− | } else if(fmt === "mdy") { |
||
− | return month+" "+date+", "+year; |
||
− | } else if(fmt === "ymd") { |
||
− | return year+" "+month+" "+date; |
||
− | } |
||
− | } |
||
− | |||
− | function setCookie(c_name,value,expiredays) { |
||
− | var exdate=new Date(); |
||
− | exdate.setDate(exdate.getDate()+expiredays); |
||
− | document.cookie=c_name+ "=" +escape(value) + ((expiredays===null) ? "" : ";expires="+exdate.toGMTString()); |
||
− | } |
||
− | |||
− | function getCookie(c_name) { |
||
− | if (document.cookie.length>0) { |
||
− | c_start=document.cookie.indexOf(c_name + "="); |
||
− | if (c_start!=-1) { |
||
− | c_start=c_start + c_name.length+1; |
||
− | c_end=document.cookie.indexOf(";",c_start); |
||
− | if (c_end==-1) {c_end=document.cookie.length;} |
||
− | return unescape(document.cookie.substring(c_start,c_end)); |
||
− | } |
||
− | } |
||
− | return ""; |
||
− | } |
||
− | |||
− | function msetup() { |
||
− | var meas = getCookie('measurements'); |
||
− | if(meas !== null && meas !== "" && meas !== "label") { |
||
− | $('select[name="measurements-selector"] option[value="'+meas+'"]').attr('selected','selected'); |
||
− | $('.measurements').each(function(){ |
||
− | $(this).hide(); |
||
− | $(this).parent().find('.measurements-container').text($('.measurements-'+meas,$(this)).text()); |
||
− | }); |
||
− | } else if(meas === "label") { |
||
− | $('.measurements').each(function(){ |
||
− | $(this).parent().find('.measurements-container').empty(); |
||
− | $(this).show(); |
||
− | }); |
||
− | } |
||
− | } |
||
− | |||
− | function dsetup() { |
||
− | var dat = getCookie('dateformat'); |
||
− | if(dat !== null && dat !== "" && dat !== "label") { |
||
− | $('select[name="date-selector"] option[value="'+dat+'"]').attr('selected','selected'); |
||
− | $('.date').each(function(){ |
||
− | $(this).hide(); |
||
− | $(this).parent().find('.date-container').text(makeDate(dat,$(this).text())); |
||
− | }); |
||
− | } else if(dat === "label") { |
||
− | $('.date').each(function(){ |
||
− | $(this).parent().find('.date-container').empty(); |
||
− | $(this).show(); |
||
− | }); |
||
− | } |
||
− | } |
||
− | |||
− | $(function(){ |
||
− | $('section.WikiaActivityModule').before('<section class="module" style="padding-top:8px;"><h1 style="margin:0 0 7px 0;">Display Options</h1><table style="width:100%; text-align:center;"><tr><td><select name="measurements-selector" style="font-size:smaller;"><option value="label">Units</option><option disabled="disabled">—</option><option value="metric">Metric</option><option value="us">US Customary</option><option value="imperial">Imperial</option></select></td><td><select name="date-selector" style="font-size:smaller;"><option value="label">Date Format</option><option disabled="disabled">—</option><option value="dmy">'+toDate('dmy')+'</option><option value="mdy">'+toDate('mdy')+'</option><option value="ymd">'+toDate('ymd')+'</option></select></td></tr></table></section>'); |
||
− | $('select[name="measurements-selector"]').bind('change keyup',function() { |
||
− | setCookie('measurements',$(this).val(),'365'); |
||
− | msetup(); |
||
− | }); |
||
− | $('.measurements').each(function(){ |
||
− | $(this).before($('<span class="measurements-container" />')); |
||
− | }); |
||
− | msetup(); |
||
− | $('select[name="date-selector"]').bind('change keyup',function() { |
||
− | setCookie('dateformat',$(this).val(),'365'); |
||
− | dsetup(); |
||
− | }); |
||
− | $('.date').each(function(){ |
||
− | $(this).before($('<span class="date-container" />')); |
||
− | }); |
||
− | dsetup(); |
||
− | }); |
||
/* Substitute Template:Information into upload page */ |
/* Substitute Template:Information into upload page */ |
Revision as of 02:24, 28 December 2013
/*<pre>*/
/* Recent Changes Auto Refresh */
importScriptPage( 'AjaxRC/code.js', 'dev' );
/* Resolves conflict between icons and page header bottom border
* by: [[User:The 888th Avatar]]
*/
$(document).ready(function() {
if (skin == "oasis" || skin == "wikia") {
$('.WikiaPageHeader').append($('#icons'));
}
});
/* Ability to change full page title
* See w:c:dev:DISPLAYTITLE for info and attribution
*/
$(function() {
var newPageTitle = getElementsByClassName(document, 'span', 'changePageTitle')[0]; // Find the span with the new title
if(newPageTitle == null) return; // If not found exit
var oldPageTitle = getElementsByClassName(document, 'header', 'WikiaPageHeader')[0].getElementsByTagName( "h1" )[0]; //Find the page's title
if(oldPageTitle == null) return; // If not found exit
oldPageTitle.innerHTML = newPageTitle.innerHTML; // Set the title
});
function addHideButtons() {
if(typeof getElementsByClass != 'function') {
return;
}
var hidables = getElementsByClass('hidable');
for( var i = 0; i < hidables.length; i++ ) {
var box = hidables[i];
var button = getElementsByClass('hidable-button', box, 'span');
if( button != null && button.length > 0 ) {
button = button[0];
button.onclick = toggleHidable;
button.appendChild( document.createTextNode('[Hide]') );
if( new ClassTester('start-hidden').isMatch(box) )
button.onclick('bypass');
}
}
}
function toggleHidable(bypassStorage) {
if(typeof getElementsByClass != 'function') {
return;
}
var parent = getParentByClass('hidable', this);
var content = getElementsByClass('hidable-content', parent);
var nowShown;
if( content != null && content.length > 0 ) {
content = content[0];
if( content.style.display == 'none' ) {
content.style.display = content.oldDisplayStyle;
this.firstChild.nodeValue = '[Hide]';
nowShown = true;
} else {
content.oldDisplayStyle = content.style.display;
content.style.display = 'none';
this.firstChild.nodeValue = '[Show]';
nowShown = false;
}
if( window.storagePresent && ( typeof( bypassStorage ) == 'undefined' || bypassStorage != 'bypass' ) ) {
var page = window.pageName.replace(/\W/g, '_');
var items = getElementsByClass('hidable');
var item = -1;
for( var i = 0; i < items.length; i++ ) {
if( items[i] == parent ) {
item = i;
break;
}
}
if( item == -1 ) {
return;
}
var storage = globalStorage[window.location.hostname];
storage.setItem('hidableshow-' + item + '_' + page, nowShown);
}
}
}
/* Substitute Template:Information into upload page */
$(document).ready(function() {
if (wgPageName != 'Special:Upload') {
return;
}
$('#wpUploadDescription').text("==Summary==\r\n{{Information\r\n|attention=\r\n|description=\r\n|source=\r\n|author=\r\n|filespecs=\r\n|licensing=\r\n|other versions=\r\n|categories=\r\n}}");
});
//edit buttons
if (mwCustomEditButtons) {
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://images.wikia.com/central/images/1/16/Button_reflink_alternate.png",
"speedTip": "Add a reference",
"tagOpen": "<ref>",
"tagClose": "</ref>",
"sampleText": "Source goes here"};
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://images2.wikia.nocookie.net/central/images/f/f2/Ref_name_button.png",
"speedTip": "Cite a named source",
"tagOpen": "<ref name=\"",
"tagClose": "\"/ > ",
"sampleText": "source name"};
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://images1.wikia.nocookie.net/hdm/images/4/48/Ae_button.png",
"speedTip": "Insert the æ character",
"tagOpen": "æ",
"tagClose": "",
"sampleText": ""};
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://images4.wikia.nocookie.net/hdm/images/a/a6/AE_button.png",
"speedTip": "Insert the Æ character",
"tagOpen": "Æ",
"tagClose": "",
"sampleText": ""};
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://images4.wikia.nocookie.net/hdm/images/1/13/O_button.png",
"speedTip": "Insert the ø character",
"tagOpen": "ø",
"tagClose": "",
"sampleText": ""};
}
/*</pre>*/