Difference between revisions of "User:Edward.81/vector.js"

From Team Fortress Wiki
Jump to: navigation, search
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
document.write('<script type="text/javascript" src="http://en.wikipedia.org/w/index.php?title=User:Pilaf/instaview.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');
+
var intcodes =["ru","fr","de","pl","pt-br","fi","es","nl","zh-hans","zh-hant","ar","cs","da","hu","it","ja","ko","no","pt","ro","sv","tr"];
InstaView.conf.user.name = 'User Name';
+
if (!Array.prototype.indexOf) {
/* This is to keep track of who is using InstaView: [[User:Pilaf/instaview.js]] */
+
  Array.prototype.indexOf = function(elt /*, from*/) {
 +
    var len = this.length;
 +
 
 +
    var from = Number(arguments[1]) || 0;
 +
    from = (from < 0)
 +
        ? Math.ceil(from)
 +
        : Math.floor(from);
 +
    if (from < 0){
 +
      from += len;
 +
    }
 +
    for (; from < len; from++) {
 +
      if (from in this && this[from] === elt){
 +
        return from;
 +
      }
 +
    }
 +
    return -1;
 +
  };
 +
}
 +
 
 +
if (document.addEventListener)
 +
  document.addEventListener("DOMContentLoaded", onReady, false)
 +
 
 +
 
 +
//location.href.lastIndexOf("/");
 +
//location.href.length
 +
// http://wiki.teamfortress.com/wiki/Special:RecentChangesLinked/Category:it
 +
function onReady()
 +
{
 +
    var loc = location.href.substring(location.href.lastIndexOf("/")+1,location.href.length);
 +
    var index = intcodes.indexOf(loc);
 +
    if (index > -1){
 +
        var x = document.getElementById('n-mainpage-description').children[0];
 +
        x.href = x.href + "/" + intcodes[index];
 +
        x = document.getElementById('p-logo').children[0];
 +
        x.href = x.href + "/" + intcodes[index];
 +
    }
 +
}

Latest revision as of 12:38, 9 July 2011

var intcodes =["ru","fr","de","pl","pt-br","fi","es","nl","zh-hans","zh-hant","ar","cs","da","hu","it","ja","ko","no","pt","ro","sv","tr"];
if (!Array.prototype.indexOf) {
  Array.prototype.indexOf = function(elt /*, from*/) {
    var len = this.length;

    var from = Number(arguments[1]) || 0;
    from = (from < 0)
         ? Math.ceil(from)
         : Math.floor(from);
    if (from < 0){
      from += len;
    }
    for (; from < len; from++) {
      if (from in this && this[from] === elt){
        return from;
      }
    }
    return -1;
  };
}

if (document.addEventListener)
  document.addEventListener("DOMContentLoaded", onReady, false)


//location.href.lastIndexOf("/");
//location.href.length
// http://wiki.teamfortress.com/wiki/Special:RecentChangesLinked/Category:it
function onReady()
{
    var loc = location.href.substring(location.href.lastIndexOf("/")+1,location.href.length);
    var index = intcodes.indexOf(loc);
    if (index > -1){
        var x = document.getElementById('n-mainpage-description').children[0];
        x.href = x.href + "/" + intcodes[index];
        x = document.getElementById('p-logo').children[0];
        x.href = x.href + "/" + intcodes[index];
    }
}