User:Cyrius/myskin.js

From Wikipedia, the free encyclopedia

If a message on your talk page led you here, please be wary of who left it. Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. If this is a .js page, the code will be executed when previewing the page.
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
//<pre>
function morelinks() {
  var tabs = document.getElementById('p-cactions').cloneNode(true);
  tabs.id = 'mytabs';
  var listitems = tabs.getElementsByTagName('LI');
  for (i=0;i<listitems.length;i++) {
    if(listitems[i].id) listitems[i].id = 'mytabs-' + listitems[i].id;
  }
  document.getElementById('column-content').appendChild(tabs);
}
addOnloadHook(morelinks);
 
function LinkFA() 
{
   // iterate over all <span>-elements
   for(var i=0; a = document.getElementsByTagName("span")[i]; i++) {
      // if found a FA span
      if(a.className == "FA") {
         // iterate over all <li>-elements
         for(var j=0; b = document.getElementsByTagName("li")[j]; j++) {
            // if found a FA link
            if(b.className == "interwiki-" + a.id) {
               b.style.padding = "0 0 0 16px";
               b.style.backgroundImage = "url('http://upload.wikimedia.org/wikipedia/en/6/60/LinkFA-star.png')";
               b.style.backgroundRepeat = "no-repeat";
               b.title = "This article has gained featured status";
            }
         }
      }
   }
}
 
addOnloadHook(LinkFA);
 
// [[User:Zocky/PicturePopups.js]] - please include this line 
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Zocky/PicturePopups.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
// [[Wikipedia:WikiProject User scripts/Scripts/Talk page section tabs]]
function talkpageplus()
{
    var talkpagelink = document.getElementById('ca-talk');
    if (talkpagelink.className == 'new')
        talkpagelink.firstChild.href += '&section=new';
 
    var talkpagelink = document.getElementById('mytabs-ca-talk');
    if (talkpagelink.className == 'new')
        talkpagelink.firstChild.href += '&section=new';
}
 
addOnloadHook(talkpageplus);
 
function SwapColumns()
{
	this.shown = ['p-navigation', 'p-personal', 'p-search', 'p-tb', ];
	this.hidden = ['replacementPortlets', ];
	this.opacityToggleState = 0;
	this.duration = 500;
	this.timer = 0;
	this.startTime = 0;
	var me = this;	// trickery to pass a function pointer to a method of this object
 
	this.install = function()
	{
		col_one = document.getElementById('column-one');
		col_one.innerHTML = col_one.innerHTML
			+ '<div id="replacementPortlets" style="position:absolute; top:155px; left:0; opacity:0; visibility:hidden;">'
			+ '	<div class="portlet">'
			+ '		<h5>Test</h5>'
			+ '		<div class="pBody">'
			+ '			<ul>'
			+ '				<li><a href="/wiki/Wikipedia:WikiProject_User_scripts">WikiProject User scripts</a></li>'
			+ '			</ul>'
			+ '		</div>'
			+ '	</div>'
			+ '</div>';
 
		a = document.getElementById('p-logo').getElementsByTagName('a').item(0);
		a.href = '#';
		a.title = 'Toggle sidebar';
 
		a.onclick = function() {me.toggle();}
	}
 
	this.toggle = function()
	{
		this.startTime = (new Date).getTime();
		this.timer = setInterval(function() {me.opacityStep();}, 15);
 
		for(i=0; i<this.shown.length; i++) document.getElementById(this.shown[i]).style.visibility = "visible";
		for(i=0; i<this.hidden.length; i++) document.getElementById(this.hidden[i]).style.visibility = "visible";
	}
 
	this.opacityStep = function()
	{
		var time = (new Date).getTime();
		var timePosition = (time - this.startTime) / this.duration;
		var done = false;
 
		if(time >= this.duration + this.startTime)
		{
			clearInterval(this.timer);
			timePosition = 1.0;
		}
 
		shownOpacity  = this.opacityToggleState ? timePosition : 1.0 - timePosition;
		hiddenOpacity = this.opacityToggleState ? 1.0 - timePosition : timePosition;
 
		for(i=0; i<this.shown.length; i++)
		{
			document.getElementById(this.shown[i]).style.opacity = shownOpacity;
 
			if(shownOpacity == 0) document.getElementById(this.shown[i]).style.visibility = "hidden";
		}
 
		for(i=0; i<this.hidden.length; i++)
		{
			document.getElementById(this.hidden[i]).style.opacity = hiddenOpacity;
 
			if(hiddenOpacity == 0) document.getElementById(this.hidden[i]).style.visibility = "hidden";
		}
 
		if(time >= this.duration + this.startTime)
			this.opacityToggleState = this.opacityToggleState ? 0 : 1;
	}
}
 
var toggle = new SwapColumns();
 
addOnloadHook(function(){toggle.install();});
 
 
//</pre>