Jump to content

User:GetOutFrog/vector.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
importScript('User:Alex Smotrov/histcomb.js')


//<pre>
// Compare link
/*
 
To install Compare link, put:
 
// [[User:Superm401/Compare link.js]]
importScript("User:Superm401/Compare link.js");
 
in your monobook.
 
In addition to the GFDL:
 
This function (compare link) is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
 
This function is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
 
A copy of the GPL is available at http://www.prism.gatech.edu/~mflaschen3/gpl.txt .
 
By modifying "Wikipedia:WikiProject User scripts/Scripts/Compare link":
You agree to dual-license your contributions under both the GFDL (http://en.wikipedia.org/wiki/WP:GFDL)
and version 2 of the GPL (http://www.prism.gatech.edu/~mflaschen3/gpl.txt) or any later version
of the GPL published by the FSF.
 
*/
function fixCompare()
{
  var histForm=document.getElementsByTagName("form")[1];
  var finalButton=document.getElementById("pagehistory").nextSibling;
  if(!finalButton || finalButton == null)
    return;
 
  var firstButton=histForm.getElementsByTagName("input")[1];
  histForm.removeChild(finalButton);
  histForm.removeChild(firstButton);
  var compareLink=document.createElement("a");
  var genLink = mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + histForm.title.value + "&diff=" + histForm.diff[0].value + "&oldid=" + histForm.oldid[1].value;
  compareLink.setAttribute("href", genLink);
  compareLink.appendChild(document.createTextNode("Compare selected versions"));
  histForm.insertBefore(compareLink, document.getElementById("pagehistory"));
  var endLink=compareLink.cloneNode(true);
  histForm.appendChild(endLink);
  var diffList=document.getElementById("pagehistory");
  diffList.setAttribute("onchange", "updateCompare()");
}
function updateCompare()
{
  var histForm=document.getElementsByTagName("form")[1];
  var diffList=document.getElementById("pagehistory");
  var compareLink=diffList.previousSibling;
  var endLink=diffList.nextSibling;
  var oldInd=-1;
  var i=0;
  while(oldInd==-1 & i<histForm.oldid.length)
  {
    if(histForm.oldid[i].checked)
      oldInd=i;
    i++;
  }
  var diffInd=-1;
  var j=0;
  while(diffInd==-1 & j<histForm.diff.length)
  {
    if(histForm.diff[j].checked)
      diffInd=j;
    j++;
  }
var genLink = mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + histForm.title.value + "&diff=" + histForm.diff[diffInd].value + "&oldid=" + histForm.oldid[oldInd].value;
  compareLink.setAttribute("href", genLink);
  endLink.setAttribute("href", genLink);
}
if(window.location.href.indexOf("action=history")!=-1)
$(fixCompare);
//</pre>




if( typeof( TwinkleConfig ) == 'undefined' ) TwinkleConfig = {}; // DO NOT REMOVE THIS LINE - ALL TWINKLE SETTINGS AFTER THIS
TwinkleConfig.showSharedIPNotice			=	false;
TwinkleConfig.userTalkPageMode				=	'tab';
TwinkleConfig.watchRevertedPages			=	[];
TwinkleConfig.watchWarnings				=	false;