User:Holly Cheng/vector.js

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
Script error: No such module "Message box".
Template:Script doc autoNote: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the Script error: No such module "key". key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// <pre>
// [[Wikipedia:WikiProject User scripts/Scripts/addLink]]
 function addLink(where, url, name, id, title, key, after) {
     // addLink() accepts either an id or a DOM node, addPortletLink() only takes a node
     if (after && !after.cloneNode)
         after = document.getElementById(after);
 
     return addPortletLink(where, url, name, id, title, key, after);
 }

function addTab(url, name, id, title, key){
    return addLink('p-cactions', url, name, id, title, key);
}

// [[User:Lupin/popups.js]]      
importScript('User:Lupin/popups.js');
popupAdminLinks=true;
popupFixDabs=true;

/**** afd helper ****/
document.write('<script type="text/javascript"' +
  'src="http://en.wikipedia.org/w/index.php?title=User:Jnothman/afd_helper/' +
  'script.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');

/* This is to keep track of who is using this extension: [[User:Jnothman/afd_helper/script.js]] */

// Live Preview customization,
// edit this to your own liking.

wpUserName   = 'Howcheng';   // User name to display in signatures
wpShowImages = true;      // Enable downloading and displaying of images

// Include Live Preview...
//document.write('<script type="text/javascript"' +
//   'src="http://en.wikipedia.org/w/index.php?title=User:Pilaf/' + 
//   'livepreview.js&action=raw&ctype=text/javascript&dontcountme=s"><\/script>');

// Now set everything up
//window.onload = Main;

function Main()
{
 LivePreviewInstall();
 // You may include here other "extensions"
}


/* This is to keep track of who is using the Live Preview: [[User:Pilaf/livepreview.js]] */

//If you are not editing a page, a tab will appear allowing you to edit the 0th section of a page (the top area usually used as an introduction.

$(function () {
    var x;
    if (!(x = document.getElementById('ca-edit') )) return;
    var url;
    if (!(url = x.getElementsByTagName('a')[0] )) return;
    if (!(url = url.href )) return;
    var y = addLink('p-cactions', url+"&section=0", '0', 'ca-edit-0',
                    'Edit the lead section of this page', '0', x.nextSibling);

    y.className = x.className;  // steal classes from the the edit tab...
    x.className = 'istalk';     // ...and make the edit tab have no right margin

    // exception: don't steal the "selected" class unless actually editing section 0:
    if (/(^| )selected( |$)/.test(y.className)) {
        if (!document.editform || !document.editform.wpSection
            || document.editform.wpSection.value != "0") {
            y.className = y.className.replace(/(^| )selected( |$)/g, "$1");
            x.className += ' selected';
        }
    }
});

function addLastDiff() {
    var l=addTab("http://en.wikipedia.org/w/index.php?title=" + mw.config.get('wgPageName') + "&diff=cur&oldid=prev", 'last', '');
    l.lastChild.title="Show most recent diff";
}

if (mw.config.get('wgCanonicalNamespace') != "Special") {
  if (window.addEventListener) window.addEventListener("load", addLastDiff, false);
  else if (window.attachEvent) window.attachEvent("onload", addLastDiff);
}

function addPurge() {
   var t = addTab("http://en.wikipedia.org/w/index.php?title=" + mw.config.get('wgPageName') + "&action=purge", 'purge', '');
   t.lastChild.title = "Purge the server cache";
}

if (mw.config.get('wgCanonicalNamespace') != "Special") {
  if (window.addEventListener) window.addEventListener("load", addPurge, false);
  else if (window.attachEvent) window.attachEvent("onload", addPurge);
}

// <nowiki>If you are editing a page, click the wikify button on your tab bar to add "{{Wikify-date|{{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}}}" to the top, set "Marked for wikification." as the edit summary, mark it as a minor edit, and submit.</nowiki>

function doQwikify() {
  document.editform.wpTextbox1.value = '{' + '{' + 'Wikify|date=' + '{' + '{' + 'subst:CURRENTMONTHNAME}} ' + '{' + '{' + 'subst:CURRENTYEAR}}}}\n\n' + document.editform.wpTextbox1.value;
  document.editform.wpSummary.value = 'Marked for wikification.';
  document.editform.wpMinoredit.checked = true;
  document.editform.submit();
}

function addQwikify() {
  addTab("javascript:doQwikify()", "wikify", "ca-wikify", "Mark for wikification", "");
  akeytt();
}

$(function() {
  if (document.title.indexOf("User:") != -1 || document.title.indexOf("User talk:") != -1) {
     return;
  }
  if (document.title.indexOf("Editing ") != -1) {
  addOnloadHook(addQwikify);
  }
});

  function add_link2(url, name)
  {
    var na = document.createElement('a');
    na.setAttribute('href', url);
    na.appendChild(document.createTextNode(name));
  
    var li = document.createElement('li');
    li.appendChild(na);
  
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    tabs.appendChild(li);
  }
  
  function strip_namespace(target)
  {
    var colon = target.indexOf(':');
    if (colon != -1)
      {
        var spaces = new Array('User', 'Wikipedia', 'Image', 'MediaWiki', 'Template', 'Help', 'Category');
        var ns = target.substring(0, colon);
        if (ns == '' || ns == 'Talk')
          return target.substring(colon + 1);
        else
          for (var i = 0; i < spaces.length; ++i)
            {
              if (ns == spaces[i]
                  || ns == spaces[i] + '_talk')
                return target.substring(colon + 1);
            }
      }
    return target;
  }
  
// CSD AutoReason
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:^demon/csd.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

/* wpvfdhide */
function hidevfd(){
    var divs = document.getElementsByTagName("div");
    for(var x = 0; x < divs.length; ++x)
        if(divs[x].className.indexOf("vfd") != -1)
            divs[x].style.display = "none";
    document.getElementById('footer').style.display = 'none';
}

function showvfd(){
    var divs = document.getElementsByTagName("div");
    for(var x = 0; x < divs.length; ++x)
        if(divs[x].className.indexOf("vfd") != -1)
            divs[x].style.display = "";
    document.getElementById('footer').style.display = '';
}

function vfdlinks(){
    if(document.title.indexOf("Wikipedia:Articles for deletion") == 0 && location.href.indexOf("Log") > -1){
        addLink('p-cactions', 'javascript:hidevfd()', 'Hide');
        addLink('p-cactions', 'javascript:showvfd()', 'Show');
    }
}

if (window.addEventListener) window.addEventListener("load",vfdlinks,false);
else if (window.attachEvent) window.attachEvent("onload",vfdlinks);

document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Howcheng/quickimgdelete.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

function replace() {
    var s = prompt("Search regexp?");
    if(s) {
        var r = prompt("Replace regexp?");
        if(!r && r != '') return;
        var txt = document.editform.wpTextbox1;
        txt.value = txt.value.replace(new RegExp(s, "g"), r);
    }
}

$(function () {
    if(document.forms.editform) {
        addLink('p-cactions', 'javascript:replace()', 'replace', 'ca-replace', 'Regexp replace for the edit window', '', 'ca-history');
    }
});

importScript("User:Ais523/topcontrib.js");

importScript("User:Rjd0060/PermissionOTRS.js");
// </pre>