Jump to content

User:CBM/vector.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by CBM (talk | contribs) at 14:52, 27 June 2013 (c). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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:Mr.Z-man/rollbackSummary.js');

importScript('User:CBM/patrollinks.js');

/*
importScript('User:CBM/dates.js');  
*/

importScript('User:CBM/quickpreview.js');
 
importScript('User:CBM/csd.js');

importScript("MediaWiki:Gadget-morebits.js");
importScript('User:CBM/ratemath.js');

importScript('User:CBM/stubtagtab.js');
importScript('User:CBM/nostubtagtab.js');

/*
var noUnreferenced = 1;
importScript('User:CBM/shortambox.js');
*/


/* Bypass ISBN page to go straight to amazon */
function externISBN() {
 
  var magicURL = "http://www.amazon.com/s?search-alias=stripbooks&field-isbn=MAGICNUMBER";
 
  var magicRegex = /MAGICNUMBER/ig;
  if(wgPageName != "Special:Booksources"
           && wgPageName != "Wikipedia:Book_sources"){
    for (var i = 0; i < document.links.length; i++) {       
      if( document.links[i].href.match(/Special:BookSources\/(.*)/) ) {
        document.links[i].href=magicURL.replace(magicRegex, RegExp.$1);
      }
    }
  }
 
}
 
addOnloadHook(externISBN);

addOnloadHook(function delete_dropdown() {
  var list = document.getElementById('wpDeleteReasonList');
  if(!list) return;
  list.options[0] = new Option("Blank","");
  list.selectedIndex = 0;
});

addOnloadHook(function() {
    var contentSub = document.getElementById("contentSub");
    if(!contentSub) return;
    var elem = contentSub.nextSibling;
    while(elem.nodeType != 1) elem = elem.nextSibling;
    if(elem.className != 'usermessage') return;
    elem.getElementsByTagName('A')[1].href = elem.getElementsByTagName('A')[1].href.replace("diff=cur","action=history")
    elem.getElementsByTagName('A')[1].textContent = "history";
});


/* This will add an [edit] link for the first section
  * of all pages except preview pages and the main page
  * by User:Pile0nades 
  */
// Add an [edit] link to pages
addOnloadHook(function () {
  // if this is preview page or generated page, stop
  if(
    document.getElementById("wikiPreview") ||
    document.getElementById("histlegend‎") ||
    document.getElementById("difference‎") ||
    document.getElementById("watchdetails") ||
    document.getElementById("ca-viewsource") ||
    window.location.href.indexOf("/wiki/Special:") != -1
  ) {
    if(window.location.href.indexOf("&action=edit&section=0") != -1) {
      document.getElementById("wpSummary").value = "/* [[WP:LEAD|Lede]] */  ";
    }
    return;
  };
 
  // get the page title
  var pageTitle = wgPageName;
 
  // create div and set innerHTML to link
  var divContainer = document.createElement("div");
  divContainer.innerHTML = '<div class="editsection">[<a href="/w/index.php?title='+pageTitle+'&action=edit&section=0" title="Edit section: '+pageTitle+'">edit lede</a>]</div>';
 
  // insert divContainer into the DOM below the h1
  if(window.location.href.indexOf("&action=edit") == -1) {
    document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);
  }
 
});



/* Add LI to a UL */
function addlilink(tabs, url, name, id, title, key){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    tabs.appendChild(li);
   
    // re-render the title and accesskeys from existing code in wikibits.js
    return li;
}

/* Add Personal */
function addPersonal(url, name, id, title, key){
    var tabs = document.getElementById('p-personal').getElementsByTagName('ul')[0];
    return addlilink(tabs, url, name, id, title, key);
}

addOnloadHook(function () {
  addPersonal("https://en.wikipedia.org/w/index.php?title=Special:RecentChangesLinked&days=7&limit=250&target=User%3AVeblenBot%2FList_of_mathematical_logic_articles", "Watched articles", "Tools3", "Tools4", "Tools5");
});



/* recreate Simple skin */
/*
addOnloadHook(function () {
  /* move p-personal to left bar */
  personal = document.getElementById("p-personal");
  parent = personal.parentNode;
  parent.removeChild(personal);
  nav = document.getElementById("mw-panel");
  nav.insertBefore(personal, nav.firstChild);

  /* load CSS */
  filename = 'http://en.wikipedia.org/w/index.php?action=raw&title=User:CBM/vector2.css&ctype=text/css';
  file=document.createElement("link")
  file.rel = "stylesheet";
  file.media = "screen";
  file.type = "text/css";
  file.href = filename;
  document.getElementsByTagName("head")[0].appendChild(file);
});

addOnloadHook(function () {
  /* align right nav box (must be done after CSS loads) */
  rgt = document.getElementById("right-navigation");
  content= document.getElementById("content");
  nav = document.getElementById("mw-panel");
 
  //  should be content.clientWidth but that doesn't work right now 
  width = 800 + nav.clientWidth;

  left = width - rgt.clientWidth;
  pos = left.toString() + 'px';

  rgt.style.left = pos;
});
*/