MediaWiki:Monobook.js

From Geofic

(Difference between revisions)
(test)
Line 1: Line 1:
-
/* <pre><nowiki> */
 
-
 
/* tooltips and access keys */
/* tooltips and access keys */
ta = new Object();
ta = new Object();
Line 10: Line 8:
ta['pt-watchlist'] = new Array('l','The list of pages you\'re monitoring for changes.');
ta['pt-watchlist'] = new Array('l','The list of pages you\'re monitoring for changes.');
ta['pt-mycontris'] = new Array('y','List of my contributions');
ta['pt-mycontris'] = new Array('y','List of my contributions');
-
ta['pt-login'] = new Array('o','You are encouraged to log in; however, it is not mandatory.');
+
ta['pt-login'] = new Array('o','You are encouraged to log in, it is not mandatory however.');
-
ta['pt-anonlogin'] = new Array('o','You are encouraged to log in; however, it is not mandatory.');
+
ta['pt-anonlogin'] = new Array('o','You are encouraged to log in, it is not mandatory however.');
ta['pt-logout'] = new Array('o','Log out');
ta['pt-logout'] = new Array('o','Log out');
ta['ca-talk'] = new Array('t','Discussion about the content page');
ta['ca-talk'] = new Array('t','Discussion about the content page');
Line 22: Line 20:
ta['ca-undelete'] = new Array('d','Restore the edits done to this page before it was deleted');
ta['ca-undelete'] = new Array('d','Restore the edits done to this page before it was deleted');
ta['ca-move'] = new Array('m','Move this page');
ta['ca-move'] = new Array('m','Move this page');
 +
ta['ca-nomove'] = new Array('','You don\'t have the permissions to move this page');
ta['ca-watch'] = new Array('w','Add this page to your watchlist');
ta['ca-watch'] = new Array('w','Add this page to your watchlist');
ta['ca-unwatch'] = new Array('w','Remove this page from your watchlist');
ta['ca-unwatch'] = new Array('w','Remove this page from your watchlist');
ta['search'] = new Array('f','Search this wiki');
ta['search'] = new Array('f','Search this wiki');
-
ta['p-logo'] = new Array('','Main Page');
+
ta['p-logo'] = new Array('','WikiFur Furry Central');
-
ta['n-mainpage'] = new Array('z','Visit the Main Page');
+
ta['n-mainpage'] = new Array('z','Visit Furry Central');
ta['n-portal'] = new Array('','About the project, what you can do, where to find things');
ta['n-portal'] = new Array('','About the project, what you can do, where to find things');
-
ta['n-currentevents'] = new Array('','Find background information on current events');
+
ta['n-currentevents'] = new Array('','Discuss WikiFur with others');
-
ta['n-recentchanges'] = new Array('r','The list of recent changes in the wiki.');
+
ta['n-recentchanges'] = new Array('r','The list of recent changes in the wiki');
-
ta['n-translations'] = new Array('','Help with translations');
+
ta['n-randompage'] = new Array('x','Load a random page');
ta['n-randompage'] = new Array('x','Load a random page');
-
ta['n-help'] = new Array('','The place to find out.');
+
ta['n-help'] = new Array('','The place to find out');
-
ta['n-sitesupport'] = new Array('','Support us');
+
ta['n-sitesupport'] = new Array('','Report this broken tooltip to your local administrator!');
-
ta['n-Metapub'] = new Array('','Central forum about the Wikimedia Foundation and its projects');
+
ta['n-mailinglists'] = new Array('','Learn more about editing at WikiFur');
-
ta['n-Babel'] = new Array('','General and policy discussion page for Meta');
+
-
ta['n-planet'] = new Array('','Weblog aggregator of Wikimedia-related posts');
+
ta['t-whatlinkshere'] = new Array('j','List of all wiki pages that link here');
ta['t-whatlinkshere'] = new Array('j','List of all wiki pages that link here');
ta['t-recentchangeslinked'] = new Array('k','Recent changes in pages linked from this page');
ta['t-recentchangeslinked'] = new Array('k','Recent changes in pages linked from this page');
Line 55: Line 51:
ta['ca-nstab-help'] = new Array('c','View the help page');
ta['ca-nstab-help'] = new Array('c','View the help page');
ta['ca-nstab-category'] = new Array('c','View the category page');
ta['ca-nstab-category'] = new Array('c','View the category page');
 +
ta['listfrom'] = new Array('r', 'Show the changes since you loaded this page');
 +
ta['markpatrolled'] = new Array('p', 'Mark this article as patrolled');
-
// ============================================================
+
/*Google Analytics*/
-
// BEGIN pageview counter
+
/*
-
// Please talk to User:LeonWeber before changing anything or
+
document.write('\\<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"\\>\\<'+'\\/script\\>');
-
// if there are any issues with that.
+
document.write('\\<script type="text/javascript"\\>_uacct = "UA-89493-1";urchinTracker();\\<'+'\\/script\\>');
-
// Please do NOT install this on a different site without
+
*/
-
// Talking to him before.
+
-
+
-
// this should be adjusted to a good value.
+
-
// BE CAREFULL, you will break zedler if it's too low!
+
-
// And then DaB. will kill Leon :-(
+
-
var disable_counter = 0;
+
-
var counter_factor = 50;
+
-
+
-
function pgcounter_setup()
+
-
{
+
-
if(disable_counter == 0)
+
-
{
+
-
var url = window.location.href;
+
-
if(Math.floor(Math.random()*counter_factor)==42)  // the probability thing
+
-
  {
+
-
  if(wgIsArticle==true || wgArticleId==0) // do not count history pages etc.
+
-
{
+
-
var pgcountNs = wgCanonicalNamespace;
+
-
if(wgCanonicalNamespace=="")
+
-
{
+
-
pgcountNs = "0";
+
-
}
+
-
  var cnt_url = "http://pgcount.wikimedia.de/index.png?ns=" + pgcountNs + "&title=" + encodeURI(wgTitle) + "&factor=" + counter_factor + "&wiki=metawiki";
+
-
var img = new Image();  
+
-
img.src = cnt_url;
+
-
}
+
-
}
+
-
}
+
-
}
+
-
// Do not use aOnloadFunctions[aOnloadFunctions.length] = pgcounter_setup;
+
-
//  (or other onload functions), some browsers don't like that.
+
-
pgcounter_setup();
+
-
+
-
// END pageview counter
+
-
// ============================================================
+
 +
/*IE7 fixes so we can use a front page header that overlaps the title*/
 +
document.write('<!--[if IE 7]><style type="text/css">/*<![CDATA[*/ #column-content #content { margin-left: 12.2em ; margin-top: 3em ; height: 1% ; position: relative ; } /*]]>*/</style><![endif]-->');
 +
/*Remove h1 on front page*/
 +
if (document.title.indexOf("WikiFur Furry Central - ") == 0) {
 +
document.write('<style type="text/css">/*<![CDATA[*/ #lastmod, #contentSub, h1.firstHeading { display: none !important; } /*]]>*/</style>'); }
-
/**
+
/*Change the search button link*/
-
* Implements language selection for multilingual elements
+
function loadFunc()
-
*
+
{
-
  * In certain environments, it's not feasible to neatly box away each
+
  document.getElementById('searchform').getElementsByTagName('a')[0].href = "http://furry.wikia.com/index.php?title=Special:Search&adv=1";
-
* different language into its own section of the site. By marking elements
+
}
-
* multilingual, you can emulate this behavior by only displaying the
+
addOnloadHook(loadFunc);
-
* message in the user's language. This reduced the "Tower of Babel" effect.
+
-
*
+
-
* @author Edward Z. Yang (Ambush Commander)
+
-
* @version $Id: language_select.js 1358 2007-02-19 15:34:59Z Edward $
+
-
*/
+
-
/* Configuration: */
 
-
// in your monobook.js, set ls_enable = false to stop the javascript
+
/* START Sortable tables */
-
// maybe it should be cookie configurable. However, you can achieve
+
addEvent(window, "load", sortables_init);
-
// something almost to this effect through cookie settings
+
-
var ls_enable = true;
+
-
// the cookie name we use to stash the info.
+
var SORT_COLUMN_INDEX;
-
// change this if you are porting it to another wiki!
+
-
var ls_cookie = 'metawiki_language_js';
+
-
// link to the language select page
+
function sortables_init() {
-
var ls_help_url = 'http://meta.wikimedia.org/wiki/Meta:Language_select';
+
    // Find all tables with class sortable and make them sortable
-
 
+
    if (!document.getElementsByTagName) return;
-
// strings that are part of the widgets
+
    tbls = document.getElementsByTagName("table");
-
var ls_string_help = 'Language select:';
+
    for (ti=0;ti<tbls.length;ti++) {
-
var ls_string_select = 'Select';
+
        thisTbl = tbls[ti];
-
var ls_string_showall = 'Show all';
+
        if (((' '+thisTbl.className+' ').indexOf("sortable") != -1) && (thisTbl.id)) {
-
 
+
            //initTable(thisTbl.id);
-
// define some meta-variables
+
            ts_makeSortable(thisTbl);
-
var ls__first = true; // the first iteration?
+
         }
-
 
+
     }
-
// node compatability fix
+
-
if (!window.Node) {
+
-
    var Node = {
+
-
        ELEMENT_NODE : 1,
+
-
         ATTRIBUTE_NODE: 2,
+
-
        TEXT_NODE: 3,
+
-
        COMMENT_NODE: 8,
+
-
        DOCUMENT_NODE: 9,
+
-
        DOCUMENT_FRAGMENT_NODE: 11
+
-
     };
+
}
}
-
// autodetects a browser language
+
function ts_makeSortable(table) {
-
function ls_getBrowserLanguage() {
+
     if (table.rows && table.rows.length > 0) {
-
    var language;
+
         var firstRow = table.rows[0];
-
    // borrowed from Wikimedia's site error notice
+
-
    // find the language
+
-
     if (navigator.userLanguage) {
+
-
        // use the user's preferred language (non-Gecko)
+
-
        language = navigator.userLanguage;
+
-
    } else if (navigator.appName == 'Netscape') {
+
-
         // use the only language information available to Gecko
+
-
        language = navigator.language;
+
-
    } else {
+
-
        // get the browser language information in non-Gecko browsers
+
-
        // (IE, Opera, Konqueror)
+
-
        language = navigator.browserLanguage;
+
     }
     }
-
     return language;
+
     if (!firstRow) return;
-
}
+
-
 
+
-
// grabs language from cookie
+
-
function ls_getCookieLanguage() {
+
-
    var allcookies = document.cookie;
+
-
    var marker = ls_cookie + '=';
+
-
    var pos = allcookies.indexOf(marker);
+
      
      
-
     // cookie isn't set, so no behavior defined
+
     // We have a first row: assume it's the header, and make its contents clickable links
-
     if (pos === -1) return null;
+
     for (var i=0;i<firstRow.cells.length;i++) {
-
   
+
        var cell = firstRow.cells[i];
-
    // cookie is set
+
        var txt = ts_getInnerText(cell);
-
    var start = pos + marker.length;
+
        cell.innerHTML = '<a href="#" class="sortheader" '+
-
    var end  = allcookies.indexOf(';', start);
+
        'onclick="ts_resortTable(this, '+i+');return false;">' +
-
    if (end == -1) end = allcookies.length;
+
        txt+'<span class="sortarrow">&nbsp;&nbsp;&nbsp;</span></a>';
-
   
+
     }
-
    var raw  = allcookies.substring(start,end);
+
-
    var value = unescape(raw);
+
-
      
+
-
    return value;
+
}
}
-
// sets a new language to the cookie
+
function ts_getInnerText(el) {
-
function ls_setCookieLanguage(language) {
+
if (typeof el == "string") return el;
-
    var today = new Date();
+
if (typeof el == "undefined") { return el };
-
    var expiry = new Date(today.getUTCFullYear() + 30, 1);
+
if (el.innerText) return el.innerText; //Not needed but it is faster
-
    document.cookie = ls_cookie + '=' + escape(language) + '; expires=' + expiry.toGMTString();
+
var str = "";
 +
 +
var cs = el.childNodes;
 +
var l = cs.length;
 +
for (var i = 0; i < l; i++) {
 +
switch (cs[i].nodeType) {
 +
case 1: //ELEMENT_NODE
 +
str += ts_getInnerText(cs[i]);
 +
break;
 +
case 3: //TEXT_NODE
 +
str += cs[i].nodeValue;
 +
break;
 +
}
 +
}
 +
return str;
}
}
-
// deletes the cookie
+
function ts_resortTable(lnk,clid) {
-
function ls_deleteCookieLanguage(language) {
+
     // get the span
-
     document.cookie = ls_cookie + '=; expires=Fri, 02-Jan-1970 00:00:00 GMT';
+
    var span;
-
}
+
    for (var ci=0;ci<lnk.childNodes.length;ci++) {
-
 
+
        if (lnk.childNodes[ci].tagName && lnk.childNodes[ci].tagName.toLowerCase() == 'span') span = lnk.childNodes[ci];
-
// grabs the ISO 639 language code based
+
-
// on either the browser or a supplied cookie
+
-
// return of "mul" will display all available strings
+
-
function ls_getLanguage() {
+
-
    var language = '';
+
-
   
+
-
    // Priority:
+
-
    //  1. Cookie
+
-
    //  2. wgUserLanguage global variable
+
-
    //  3. Browser autodetection
+
-
   
+
-
    // grab according to cookie
+
-
    language = ls_getCookieLanguage();
+
-
   
+
-
    // grab according to wgUserLanguage
+
-
    if (!language && window.wgUserLanguage) {
+
-
        language = wgUserLanguage;
+
     }
     }
 +
    var spantext = ts_getInnerText(span);
 +
    var td = lnk.parentNode;
 +
    var column = clid || td.cellIndex;
 +
    var table = getParent(td,'TABLE');
      
      
-
     // grab according to browser if none defined
+
     // Work out a type for the column
-
     if (!language) {
+
    if (table.rows.length <= 1) return;
-
         language = ls_getBrowserLanguage();
+
    var itm = ts_getInnerText(table.rows[1].cells[column]);
 +
    sortfn = ts_sort_caseinsensitive;
 +
     if (itm.match(/^\\d\\d[\\/-]\\d\\d[\\/-]\\d\\d\\d\\d$/)) sortfn = ts_sort_date;
 +
    if (itm.match(/^\\d\\d[\\/-]\\d\\d[\\/-]\\d\\d$/)) sortfn = ts_sort_date;
 +
    if (itm.match(/^[£$]/)) sortfn = ts_sort_currency;
 +
    if (itm.match(/^[\\d\\.]+$/)) sortfn = ts_sort_numeric;
 +
    SORT_COLUMN_INDEX = column;
 +
    var firstRow = new Array();
 +
    var newRows = new Array();
 +
    for (i=0;i<table.rows[0].length;i++) { firstRow[i] = table.rows[0][i]; }
 +
    for (j=1;j<table.rows.length;j++) { newRows[j-1] = table.rows[j]; }
 +
 
 +
    newRows.sort(sortfn);
 +
 
 +
    if (span.getAttribute("sortdir") == 'down') {
 +
         ARROW = '&nbsp;&nbsp;&uarr;';
 +
        newRows.reverse();
 +
        span.setAttribute('sortdir','up');
 +
    } else {
 +
        ARROW = '&nbsp;&nbsp;&darr;';
 +
        span.setAttribute('sortdir','down');
     }
     }
      
      
-
     // inflexible: can't accept multiple languages
+
     // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones
 +
    // don't do sortbottom rows
 +
    for (i=0;i<newRows.length;i++) { if (!newRows[i].className || (newRows[i].className && (newRows[i].className.indexOf('sortbottom') == -1))) table.tBodies[0].appendChild(newRows[i]);}
 +
    // do sortbottom rows only
 +
    for (i=0;i<newRows.length;i++) { if (newRows[i].className && (newRows[i].className.indexOf('sortbottom') != -1)) table.tBodies[0].appendChild(newRows[i]);}
      
      
-
     // remove dialect/region code, leaving only the ISO 639 code
+
     // Delete any other arrows there may be showing
-
     var length;
+
     var allspans = document.getElementsByTagName("span");
-
     // possible bug: supposedly the language string could be en_US
+
     for (var ci=0;ci<allspans.length;ci++) {
-
    // switch to regexps when we get the chance
+
        if (allspans[ci].className == 'sortarrow') {
-
    if ((length = language.indexOf('-')) !== -1) {
+
            if (getParent(allspans[ci],"table") == getParent(lnk,"table")) { // in the same table as us?
-
        language = language.substr(0, length);
+
                allspans[ci].innerHTML = '&nbsp;&nbsp;&nbsp;';
 +
            }
 +
        }
     }
     }
-
   
+
       
-
     return language;
+
     span.innerHTML = ARROW;
}
}
-
// walks all child elements and finds all elements with multilingual in them
+
function getParent(el, pTagName) {
-
function ls_getAllMultilingualElements(n) {
+
if (el == null) return null;
-
    var elements = new Array();
+
else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase()) // Gecko bug, supposed to be uppercase
-
    // possible bug if we have a classname that includes the word multilingual
+
return el;
-
    //  but it's unlikely
+
else
-
    if (n.className && n.className.indexOf('multilingual') != -1) {
+
return getParent(el.parentNode, pTagName);
-
        elements = elements.concat(n);
+
-
    }
+
-
    var children = n.childNodes;
+
-
    for(var i=0; i < children.length; i++) {
+
-
        if (children[i].nodeType !== Node.ELEMENT_NODE) continue;
+
-
        elements = elements.concat(ls_getAllMultilingualElements(children[i]));
+
-
    }
+
-
    return elements;
+
}
}
-
 
+
function ts_sort_date(a,b) {
-
// walks a hash and hides all non-matching languages
+
    // y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX
-
function ls_hideAllExcept(lang_element_hash, language) {
+
    aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
-
     for (var n in lang_element_hash) {
+
     bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
-
        if (n == language) {
+
    if (aa.length == 10) {
-
            lang_element_hash[n].style.display = '';
+
        dt1 = aa.substr(6,4)+aa.substr(3,2)+aa.substr(0,2);
-
        } else {
+
    } else {
-
            lang_element_hash[n].style.display = 'none';
+
        yr = aa.substr(6,2);
-
         }
+
        if (parseInt(yr) < 50) { yr = '20'+yr; } else { yr = '19'+yr; }
 +
         dt1 = yr+aa.substr(3,2)+aa.substr(0,2);
     }
     }
-
}
+
     if (bb.length == 10) {
-
 
+
         dt2 = bb.substr(6,4)+bb.substr(3,2)+bb.substr(0,2);
-
// walks a hash and shows all languages
+
    } else {
-
function ls_showAll(lang_element_hash) {
+
        yr = bb.substr(6,2);
-
     for (var n in lang_element_hash) {
+
        if (parseInt(yr) < 50) { yr = '20'+yr; } else { yr = '19'+yr; }
-
         if (lang_element_hash[n].style.display) {
+
         dt2 = yr+bb.substr(3,2)+bb.substr(0,2);
-
            lang_element_hash[n].style.display = '';
+
-
         }
+
     }
     }
 +
    if (dt1==dt2) return 0;
 +
    if (dt1<dt2) return -1;
 +
    return 1;
}
}
-
// build widget for changing the language cookie
+
function ts_sort_currency(a,b) {  
-
function ls_buildWidget(language) {
+
     aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,'');
-
 
+
     bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,'');
-
     // set up the floating form
+
     return parseFloat(aa) - parseFloat(bb);
-
    var form = document.createElement('form');
+
-
    form.className = 'lang_info';
+
-
    form.onsubmit = function() {
+
-
        if (this.elements[2].ls_mul_flag) {
+
-
            this.elements[2].ls_mul_flag = false;
+
-
            var language = 'mul';
+
-
            var temporary = true;
+
-
        } else {
+
-
            ls_setCookieLanguage(this.elements[0].value);
+
-
            var language = this.elements[0].value;
+
-
            var temporary = false;
+
-
        }
+
-
        ls_applyLanguageSelect(language, temporary);
+
-
       
+
-
        return false; // don't perform action
+
-
    };
+
-
    form.appendSpace = function() {
+
-
        this.appendChild(document.createTextNode(' '));
+
-
    };
+
-
   
+
-
    // link to language select description page
+
-
    var link = document.createElement('a');
+
-
    link.href = ls_help_url;
+
-
    link.className = 'ls_link';
+
-
    link.appendChild(document.createTextNode(ls_string_help));
+
-
    form.appendChild(link);
+
-
   
+
-
    form.appendSpace();
+
-
   
+
-
    // input box for the language
+
-
    var input = document.createElement('input');
+
-
    input.setAttribute('type', 'text');
+
-
     input.setAttribute('size', '2');
+
-
    input.setAttribute('maxlength', '3');
+
-
    input.onclick = function() { this.select(); };
+
-
    input.className = 'ls_input';
+
-
    input.value = language;
+
-
    form.appendChild(input);
+
-
   
+
-
    form.appendSpace();
+
-
   
+
-
    // save button
+
-
    var submit = document.createElement('input');
+
-
    submit.setAttribute('type', 'submit');
+
-
    submit.value = ls_string_select;
+
-
    submit.className = 'ls_select';
+
-
    form.appendChild(submit);
+
-
   
+
-
    form.appendSpace();
+
-
   
+
-
    // show all button
+
-
    // equivalent to setting input box to "mul" and pressing save
+
-
    var showall = document.createElement('input');
+
-
    showall.setAttribute('type', 'submit');
+
-
     showall.value = ls_string_showall;
+
-
    showall.onclick = function() {
+
-
        this.ls_mul_flag = true;
+
-
    };
+
-
    form.appendChild(showall);
+
-
   
+
-
    return form;
+
-
   
+
}
}
-
// main body of the function
+
function ts_sort_numeric(a,b) {  
-
function ls_applyLanguageSelect(language, temporary) {
+
     aa = parseFloat(ts_getInnerText(a.cells[SORT_COLUMN_INDEX]));
-
      
+
     if (isNaN(aa)) aa = 0;
-
    // possible site for cookie checking to disable language select
+
    bb = parseFloat(ts_getInnerText(b.cells[SORT_COLUMN_INDEX]));  
-
    if (!ls_enable) return;
+
    if (isNaN(bb)) bb = 0;
-
   
+
     return aa-bb;
-
    // if language is blank, delete the cookie and then recalculate
+
-
    if (!language) {
+
-
        ls_deleteCookieLanguage();
+
-
        language = ls_getLanguage();
+
-
    }
+
-
   
+
-
    // grab the body element (only one)
+
-
    var body = document.getElementsByTagName('body')[0];
+
-
   
+
-
    // grab an array of multilingual elements
+
-
    var mls = ls_getAllMultilingualElements(body);
+
-
      
+
-
    // this will get overwritten many times, temporary variable
+
-
    var form, language_element_hash;
+
-
   
+
-
    // iterate through all those elements
+
-
    for (var i = 0; i < mls.length; i++) {
+
-
        var ml  = mls[i];        // the current multilingual container
+
-
        var ml_c = ml.childNodes; // children of the container
+
-
       
+
-
        // if it's the first iteration...
+
-
        if (ls__first) {
+
-
            form = ls_buildWidget(language);
+
-
            ml.appendChild(form, ml_c[0]);
+
-
        } else {
+
-
            // update widget
+
-
            form = ml_c[ml_c.length - 1]; // form is last element
+
-
            if (!temporary) {
+
-
                form.elements[0].value = language;
+
-
                form.elements[0].removeAttribute('disabled');
+
-
                form.elements[2].removeAttribute('disabled');
+
-
            } else {
+
-
                form.elements[0].setAttribute('disabled', 'disabled');
+
-
                form.elements[2].setAttribute('disabled', 'disabled');
+
-
            }
+
-
        }
+
-
       
+
-
        form.elements[0].style.background="#FFF";
+
-
       
+
-
        // tells us whether or not to blindly perform the keep
+
-
        var message_exists  = false;
+
-
       
+
-
        // iterate through all languages and set up a hash
+
-
        //  with references to each of the language nodes
+
-
        lang_element_hash = new Object();
+
-
        for (var j = 0; j < ml_c.length; j++) {
+
-
            var n = ml_c[j];
+
-
            if (n.nodeType != Node.ELEMENT_NODE) continue; // skip non-elements
+
-
            if (!n.lang) continue; // skip non-language specific elements
+
-
            if (n.lang.indexOf(language) === 0) {
+
-
                // it turns out our language is here
+
-
                message_exists  = true;
+
-
            }
+
-
            lang_element_hash[n.lang] = n;
+
-
        }
+
-
       
+
-
        // if a preferred language was kept, do quickest processing
+
-
        if (message_exists) {
+
-
            ls_hideAllExcept(lang_element_hash, language);
+
-
            continue;
+
-
        }
+
-
       
+
-
        // otherwise, nothing happened, this means that it wasn't found
+
-
       
+
-
        // if it's not the first time, repaint all of them
+
-
        if (!ls__first) {
+
-
            ls_showAll(lang_element_hash);
+
-
        }
+
-
       
+
-
        if (language != 'mul') {
+
-
            form.elements[0].style.background="#FCC";
+
-
        }
+
-
       
+
-
     }
+
-
   
+
-
    // we've already processed once
+
-
    ls__first = false;
+
-
   
+
}
}
-
function ls_applyDefaultLanguageSelect() {
+
function ts_sort_caseinsensitive(a,b) {
-
     ls_applyLanguageSelect(ls_getLanguage(), false);
+
     aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase();
 +
    bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase();
 +
    if (aa==bb) return 0;
 +
    if (aa<bb) return -1;
 +
    return 1;
}
}
-
// register as onload function (there must be a better way)
+
function ts_sort_default(a,b) {
-
if (window.addEventListener) {
+
    aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
-
     window.addEventListener("load", ls_applyDefaultLanguageSelect, false);
+
     bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
-
} else if (window.attachEvent) {
+
    if (aa==bb) return 0;
-
     window.attachEvent("onload", ls_applyDefaultLanguageSelect);
+
     if (aa<bb) return -1;
 +
    return 1;
}
}
-
/* </nowiki></pre> */
+
function addEvent(elm, evType, fn, useCapture)
 +
// addEvent and removeEvent
 +
// cross-browser event handling for IE5+,  NS6 and Mozilla
 +
// By Scott Andrew
 +
{
 +
  if (elm.addEventListener){
 +
    elm.addEventListener(evType, fn, useCapture);
 +
    return true;
 +
  } else if (elm.attachEvent){
 +
    var r = elm.attachEvent("on"+evType, fn);
 +
    return r;
 +
  } else {
 +
    alert("Handler could not be removed");
 +
  }
 +
}
 +
/* END Sortable tables */

Revision as of 08:01, 5 April 2007

/* tooltips and access keys */
ta = new Object();
ta['pt-userpage'] = new Array('.','My user page');
ta['pt-anonuserpage'] = new Array('.','The user page for the ip you\'re editing as');
ta['pt-mytalk'] = new Array('n','My talk page');
ta['pt-anontalk'] = new Array('n','Discussion about edits from this ip address');
ta['pt-preferences'] = new Array('','My preferences');
ta['pt-watchlist'] = new Array('l','The list of pages you\'re monitoring for changes.');
ta['pt-mycontris'] = new Array('y','List of my contributions');
ta['pt-login'] = new Array('o','You are encouraged to log in, it is not mandatory however.');
ta['pt-anonlogin'] = new Array('o','You are encouraged to log in, it is not mandatory however.');
ta['pt-logout'] = new Array('o','Log out');
ta['ca-talk'] = new Array('t','Discussion about the content page');
ta['ca-edit'] = new Array('e','You can edit this page. Please use the preview button before saving.');
ta['ca-addsection'] = new Array('+','Add a comment to this discussion.');
ta['ca-viewsource'] = new Array('e','This page is protected. You can view its source.');
ta['ca-history'] = new Array('h','Past versions of this page.');
ta['ca-protect'] = new Array('=','Protect this page');
ta['ca-delete'] = new Array('d','Delete this page');
ta['ca-undelete'] = new Array('d','Restore the edits done to this page before it was deleted');
ta['ca-move'] = new Array('m','Move this page');
ta['ca-nomove'] = new Array('','You don\'t have the permissions to move this page');
ta['ca-watch'] = new Array('w','Add this page to your watchlist');
ta['ca-unwatch'] = new Array('w','Remove this page from your watchlist');
ta['search'] = new Array('f','Search this wiki');
ta['p-logo'] = new Array('','WikiFur Furry Central');
ta['n-mainpage'] = new Array('z','Visit Furry Central');
ta['n-portal'] = new Array('','About the project, what you can do, where to find things');
ta['n-currentevents'] = new Array('','Discuss WikiFur with others');
ta['n-recentchanges'] = new Array('r','The list of recent changes in the wiki');
ta['n-randompage'] = new Array('x','Load a random page');
ta['n-help'] = new Array('','The place to find out');
ta['n-sitesupport'] = new Array('','Report this broken tooltip to your local administrator!');
ta['n-mailinglists'] = new Array('','Learn more about editing at WikiFur');
ta['t-whatlinkshere'] = new Array('j','List of all wiki pages that link here');
ta['t-recentchangeslinked'] = new Array('k','Recent changes in pages linked from this page');
ta['feed-rss'] = new Array('','RSS feed for this page');
ta['feed-atom'] = new Array('','Atom feed for this page');
ta['t-contributions'] = new Array('','View the list of contributions of this user');
ta['t-emailuser'] = new Array('','Send a mail to this user');
ta['t-upload'] = new Array('u','Upload images or media files');
ta['t-specialpages'] = new Array('q','List of all special pages');
ta['ca-nstab-main'] = new Array('c','View the content page');
ta['ca-nstab-user'] = new Array('c','View the user page');
ta['ca-nstab-media'] = new Array('c','View the media page');
ta['ca-nstab-special'] = new Array('','This is a special page, you can\'t edit the page itself.');
ta['ca-nstab-wp'] = new Array('a','View the project page');
ta['ca-nstab-image'] = new Array('c','View the image page');
ta['ca-nstab-mediawiki'] = new Array('c','View the system message');
ta['ca-nstab-template'] = new Array('c','View the template');
ta['ca-nstab-help'] = new Array('c','View the help page');
ta['ca-nstab-category'] = new Array('c','View the category page');
ta['listfrom'] = new Array('r', 'Show the changes since you loaded this page');
ta['markpatrolled'] = new Array('p', 'Mark this article as patrolled');

/*Google Analytics*/
/*
document.write('\\<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"\\>\\<'+'\\/script\\>');
document.write('\\<script type="text/javascript"\\>_uacct = "UA-89493-1";urchinTracker();\\<'+'\\/script\\>');
*/

/*IE7 fixes so we can use a front page header that overlaps the title*/
document.write('<!--[if IE 7]><style type="text/css">/*<![CDATA[*/ #column-content #content { margin-left: 12.2em ; margin-top: 3em ; height: 1% ; position: relative ; } /*]]>*/</style><![endif]-->');
/*Remove h1 on front page*/
if (document.title.indexOf("WikiFur Furry Central - ") == 0) {
document.write('<style type="text/css">/*<![CDATA[*/ #lastmod, #contentSub, h1.firstHeading { display: none !important; } /*]]>*/</style>'); }

/*Change the search button link*/
function loadFunc()
{
 document.getElementById('searchform').getElementsByTagName('a')[0].href = "http://furry.wikia.com/index.php?title=Special:Search&adv=1";
}
addOnloadHook(loadFunc);


/* START Sortable tables */
addEvent(window, "load", sortables_init);

var SORT_COLUMN_INDEX;

function sortables_init() {
    // Find all tables with class sortable and make them sortable
    if (!document.getElementsByTagName) return;
    tbls = document.getElementsByTagName("table");
    for (ti=0;ti<tbls.length;ti++) {
        thisTbl = tbls[ti];
        if (((' '+thisTbl.className+' ').indexOf("sortable") != -1) && (thisTbl.id)) {
            //initTable(thisTbl.id);
            ts_makeSortable(thisTbl);
        }
    }
}

function ts_makeSortable(table) {
    if (table.rows && table.rows.length > 0) {
        var firstRow = table.rows[0];
    }
    if (!firstRow) return;
    
    // We have a first row: assume it's the header, and make its contents clickable links
    for (var i=0;i<firstRow.cells.length;i++) {
        var cell = firstRow.cells[i];
        var txt = ts_getInnerText(cell);
        cell.innerHTML = '<a href="#" class="sortheader" '+ 
        'onclick="ts_resortTable(this, '+i+');return false;">' + 
        txt+'<span class="sortarrow">&nbsp;&nbsp;&nbsp;</span></a>';
    }
}

function ts_getInnerText(el) {
	if (typeof el == "string") return el;
	if (typeof el == "undefined") { return el };
	if (el.innerText) return el.innerText;	//Not needed but it is faster
	var str = "";
	
	var cs = el.childNodes;
	var l = cs.length;
	for (var i = 0; i < l; i++) {
		switch (cs[i].nodeType) {
			case 1: //ELEMENT_NODE
				str += ts_getInnerText(cs[i]);
				break;
			case 3:	//TEXT_NODE
				str += cs[i].nodeValue;
				break;
		}
	}
	return str;
}

function ts_resortTable(lnk,clid) {
    // get the span
    var span;
    for (var ci=0;ci<lnk.childNodes.length;ci++) {
        if (lnk.childNodes[ci].tagName && lnk.childNodes[ci].tagName.toLowerCase() == 'span') span = lnk.childNodes[ci];
    }
    var spantext = ts_getInnerText(span);
    var td = lnk.parentNode;
    var column = clid || td.cellIndex;
    var table = getParent(td,'TABLE');
    
    // Work out a type for the column
    if (table.rows.length <= 1) return;
    var itm = ts_getInnerText(table.rows[1].cells[column]);
    sortfn = ts_sort_caseinsensitive;
    if (itm.match(/^\\d\\d[\\/-]\\d\\d[\\/-]\\d\\d\\d\\d$/)) sortfn = ts_sort_date;
    if (itm.match(/^\\d\\d[\\/-]\\d\\d[\\/-]\\d\\d$/)) sortfn = ts_sort_date;
    if (itm.match(/^[£$]/)) sortfn = ts_sort_currency;
    if (itm.match(/^[\\d\\.]+$/)) sortfn = ts_sort_numeric;
    SORT_COLUMN_INDEX = column;
    var firstRow = new Array();
    var newRows = new Array();
    for (i=0;i<table.rows[0].length;i++) { firstRow[i] = table.rows[0][i]; }
    for (j=1;j<table.rows.length;j++) { newRows[j-1] = table.rows[j]; }

    newRows.sort(sortfn);

    if (span.getAttribute("sortdir") == 'down') {
        ARROW = '&nbsp;&nbsp;&uarr;';
        newRows.reverse();
        span.setAttribute('sortdir','up');
    } else {
        ARROW = '&nbsp;&nbsp;&darr;';
        span.setAttribute('sortdir','down');
    }
    
    // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones
    // don't do sortbottom rows
    for (i=0;i<newRows.length;i++) { if (!newRows[i].className || (newRows[i].className && (newRows[i].className.indexOf('sortbottom') == -1))) table.tBodies[0].appendChild(newRows[i]);}
    // do sortbottom rows only
    for (i=0;i<newRows.length;i++) { if (newRows[i].className && (newRows[i].className.indexOf('sortbottom') != -1)) table.tBodies[0].appendChild(newRows[i]);}
    
    // Delete any other arrows there may be showing
    var allspans = document.getElementsByTagName("span");
    for (var ci=0;ci<allspans.length;ci++) {
        if (allspans[ci].className == 'sortarrow') {
            if (getParent(allspans[ci],"table") == getParent(lnk,"table")) { // in the same table as us?
                allspans[ci].innerHTML = '&nbsp;&nbsp;&nbsp;';
            }
        }
    }
        
    span.innerHTML = ARROW;
}

function getParent(el, pTagName) {
	if (el == null) return null;
	else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase())	// Gecko bug, supposed to be uppercase
		return el;
	else
		return getParent(el.parentNode, pTagName);
}
function ts_sort_date(a,b) {
    // y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX
    aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
    bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
    if (aa.length == 10) {
        dt1 = aa.substr(6,4)+aa.substr(3,2)+aa.substr(0,2);
    } else {
        yr = aa.substr(6,2);
        if (parseInt(yr) < 50) { yr = '20'+yr; } else { yr = '19'+yr; }
        dt1 = yr+aa.substr(3,2)+aa.substr(0,2);
    }
    if (bb.length == 10) {
        dt2 = bb.substr(6,4)+bb.substr(3,2)+bb.substr(0,2);
    } else {
        yr = bb.substr(6,2);
        if (parseInt(yr) < 50) { yr = '20'+yr; } else { yr = '19'+yr; }
        dt2 = yr+bb.substr(3,2)+bb.substr(0,2);
    }
    if (dt1==dt2) return 0;
    if (dt1<dt2) return -1;
    return 1;
}

function ts_sort_currency(a,b) { 
    aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,'');
    bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,'');
    return parseFloat(aa) - parseFloat(bb);
}

function ts_sort_numeric(a,b) { 
    aa = parseFloat(ts_getInnerText(a.cells[SORT_COLUMN_INDEX]));
    if (isNaN(aa)) aa = 0;
    bb = parseFloat(ts_getInnerText(b.cells[SORT_COLUMN_INDEX])); 
    if (isNaN(bb)) bb = 0;
    return aa-bb;
}

function ts_sort_caseinsensitive(a,b) {
    aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase();
    bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase();
    if (aa==bb) return 0;
    if (aa<bb) return -1;
    return 1;
}

function ts_sort_default(a,b) {
    aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
    bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
    if (aa==bb) return 0;
    if (aa<bb) return -1;
    return 1;
}


function addEvent(elm, evType, fn, useCapture)
// addEvent and removeEvent
// cross-browser event handling for IE5+,  NS6 and Mozilla
// By Scott Andrew
{
  if (elm.addEventListener){
    elm.addEventListener(evType, fn, useCapture);
    return true;
  } else if (elm.attachEvent){
    var r = elm.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
} 
/* END Sortable tables */
Personal tools
active geofiction