Jump to content

User:Themeparkgc/vector.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Themeparkgc (talk | contribs) at 09:08, 21 February 2012 (unwatch). 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:Ohconfucius/script/MOSNUM dates.js');  //Dates
importScript("User:GregU/dashes.js"); //Dashes
importScript('User:Ioeth/friendly.js'); //Friendly
importScript('MediaWiki:LinkFixr.js'); //Link fixr
importScript('User:Ohconfucius/script/EngvarB.js');  //ENGVAR
importScript('User:AWeenieMan/furme.js'); //FUR Me
importScript('User:AzaToth/morebits.js');
importScript('User:Shubinator/DYKcheck.js'); //DYKcheck tool
importScript('User:Porchcorpter/rollback.js'); //Rollback extension
importScript('User:Splarka/ajaxfilemove.js');//File mover script

//My article traffic stats script
function start_ats()
{
   var now = new Date();
   var month = now.getMonth() + 1;
   var monthLong;
   if (month < 10) {
      monthLong = "0" + month;
   } else {
      monthLong = month;
   }
   var year = now.getFullYear();
   addPortletLink('p-tb','http://stats.grok.se/en/' + year + monthLong + '/' + encodeURIComponent(wgTitle),'Article Traffic Stats','','Article Traffic Stats');
}
addOnloadHook(start_ats);

//My article contributors script
function start_contrib()
{
   addPortletLink('p-tb','http://toolserver.org/~daniel/WikiSense/Contributors.php?wikilang=en&wikifam=.wikipedia.org&page=' + encodeURIComponent(wgTitle) + '&since=&until=&grouped=on&order=-edit_count&max=100&format=html','Article Contributors','','Article Contributors');
}
addOnloadHook(start_contrib);

//My Commons Helper script
function start_mtc()
{
  if(wgCanonicalNamespace == 'Image' || wgCanonicalNamespace == 'File')
   {
    addPortletLink('p-tb','http://toolserver.org/~magnus/commonshelper.php?interface=en&image=' + encodeURIComponent(wgTitle) + '&reallydirectupload=1&remove_categories=1&commonsense=0&lang=en&username=' + encodeURIComponent(wgUserName) + '&tusc_user=' + encodeURIComponent(wgUserName),'Move to Commons','','Move to Commons');
  }
}
addOnloadHook(start_mtc);

//RefToolbar - custom dialogs
$j('head').one('reftoolbarbase', function() {
CiteTB.UserOptions['autodate fields'] = ['date', 'accessdate', 'archivedate'];

new citeTemplate('RCDB', 'RCDB',
[ // Basic fields
{"field": "coaster_name", "label":"Coaster name"},
{"field": "location", "label":"Park name"}, 
{"field": "metric", "tooltip":"Optional"},
{"field": "rcdb_number", "label":"RCDB Number"},
{"field": "accessdate", "label":"Access date"},
{"field": "url", "label":"URL"}
],
[ // Expanded fields
]);

new citeTemplate('Parkz', 'Parkz',
[ // Basic fields
{"field": "ride_name"},
{"field": "location"}, 
{"field": "parkz_number", "label":"Parkz Number"},
{"field": "accessdate", "label":"Access date"}
],
[ // Expanded fields
]);

new citeTemplate('TV Tonight', 'TV Tonight',
[ // Basic fields
{"field": "title", "label":"Title"},
{"field": "url", "label":"URL"}, 
{"field": "date", "label":"Date"},
{"field": "accessdate", "label":"Access date"}
],
[ // Expanded fields
{"field": "archivedate", "label":"Archive date"},
{"field": "archiveurl", "label":"Archive URL"}
]);

new citeTemplate('Cite press release', 'Cite press release',
[ // Basic fields
{"field": "title", "label":"Title"},
{"field": "url", "label":"URL"}, 
{"field": "accessdate", "label":"Access date"},
{"field": "date", "label":"Date"},
{"field": "publisher", "label":"Publisher"}
],
[ // Expanded fields
{"field": "archivedate", "label":"Archive date"},
{"field": "archiveurl", "label":"Archive URL"},
{"field": "quote", "label":"Quote"},
{"field": "ref", "label":"Anchor"},
{"field": "language", "label":"Language"},
{"field": "trans_title", "label":"Translated title"},
{"field": "format", "label":"Format"}
]);

});

// Add [[WP:Reflinks]] launcher in the toolbox on left
addOnloadHook(function () {
 addPortletLink(
  "p-tb",     // toolbox portlet
  "http://toolserver.org/~dispenser/cgi-bin/webreflinks.py/" + wgPageName 
   + "?client=script&citeweb=on&overwrite=&limit=20&lang=" + wgContentLanguage,
  "Reflinks"  // link label
)});


//AUTOTAG SCRIPT
addOnloadHook(function() {
    if (wgNamespaceNumber == 1) {//Talk
        addPortletLink("p-tb", "javascript:projectsTag()", 'Project Tagging');
    } else if (wgNamespaceNumber == 14) {//Category
        addPortletLink("p-tb", "javascript:catmainTag()", '{' + '{Catmain}}');
    } else if (wgNamespaceNumber == 0) {//Article
        addPortletLink("p-tb", "javascript:hatnoteTag()", 'Add hatnote');
        addPortletLink("p-tb", "javascript:toolbox()", 'Article toolbox');
    } else if (wgNamespaceNumber == 6) {//File
        addPortletLink("p-tb", "javascript:thumbnailImage()", 'Load thumbnail');
    } else if (wgNamespaceNumber == 10) {//Template
        addPortletLink("p-tb", "javascript:hlistConvert()", 'Convert to hlist');
    }
    if(location.href.indexOf("&autotag=")!=-1&&document.getElementById('wpTextbox1')!=null) {
        var x=decodeURIComponent(location.href.split("&autotag=")[1]);
        document.getElementById('wpTextbox1').value = x + "\n" + document.getElementById('wpTextbox1').value;
        document.getElementById('wpSummary').value = "Adding " + x + " using [[User:Themeparkgc/vector.js|script]]";
        document.getElementById('wpSave').click();
    } else if(location.href.indexOf("&hlist=")!=-1&&document.getElementById('wpTextbox1')!=null) {
        var content = document.getElementById('wpTextbox1').value;
        content = replaceAll(content, "  ", " ");
        content = replaceAll(content, "   ", " ");
        content = replaceAll(content, "{{·}}", "\n*");
        content = replaceAll(content, "{{•}}", "\n*");
        content = replaceAll(content, "{{·w}}", "\n*");
        content = replaceAll(content, "{{!}}", "\n*");
        content = replaceAll(content, "{" + "{Navbox","{" + "{Navbox\n|listclass=hlist\n|belowclass=hlist");
        content = replaceAll(content, "{" + "{navbox","{" + "{Navbox\n|listclass=hlist\n|belowclass=hlist");
        for(i=0;i<20;i++) {
            content = content.replace("list" + i + " =", "list" + i + " =\n*");
            content = content.replace("list" + i + "=", "list" + i + "=\n*");
        }
        content = content.replace("below =", "below =\n*");
        content = content.replace("below=", "below=\n*");
        document.getElementById('wpTextbox1').value = content;
        document.getElementById('wpSummary').value = "convert to [[WP:HLIST|hlist]] using [[User:Themeparkgc/vector.js|script]]";
        document.getElementById('wpPreview').click();
        //document.getElementById('wpSave').click();
    } else if(location.href.indexOf("&toolbox=true")!=-1) {
        //document.getElementById('bodyContent').innerHTML = '<div style="background-color:#F9F9F9;border:1px solid #AAAAAA;padding:5px;width:220px;border-radius:10px;"><ul><li><a target="_blank" href="http://toolserver.org/%7Edispenser/cgi-bin/altviewer.py/' + encodeURIComponent(wgPageName) + '">Alt Text</a></li><li><a target="_blank" href="http://toolserver.org/%7Edispenser/cgi-bin/webreflinks.py/' + encodeURIComponent(wgPageName) + '?client=script&citeweb=on&overwrite=&limit=20&lang=en">Reflinks</a></li><li><a target="_blank" href="http://toolserver.org/~daniel/WikiSense/Contributors.php?wikilang=en&wikifam=.wikipedia.org&page=' + encodeURIComponent(wgPageName) + '&since=&until=&grouped=on&order=-edit_count&max=100&format=html">Article Contributors</a></li><li><a target="_blank" href="http://toolserver.org/%7Edispenser/cgi-bin/webchecklinks.py/' + encodeURIComponent(wgPageName) + '">Check Links</a></li><li><a target="_blank" href="http://toolserver.org/%7Edispenser/cgi-bin/dablinks.py/' + encodeURIComponent(wgPageName) + '">DAB links</a></li><li><a target="_blank" href="http://toolserver.org/%7Edispenser/view/Peer_reviewer#page:' + encodeURIComponent(wgPageName) + '">Peer Reviewer</a></li><li><a target="_blank" href="http://toolserver.org/%7Edispenser/cgi-bin/rdcheck.py/' + encodeURIComponent(wgPageName) + '">Redirects</a></li></ul></div>' + document.getElementById('bodyContent').innerHTML;
    }
});

function replaceAll(txt, replace, with_this) {
  return txt.replace(new RegExp(replace, 'g'),with_this);
}

function catmainTag() {
    var x=prompt("Tagging for {" + "{Catmain}}. Main article: ", wgTitle);
    if (x==null) return;
    x = "{" + "{Catmain|" + x + "}}";
    location.href=wgServer+wgScript+"?title=" + encodeURIComponent(wgPageName) + "&action=edit&autotag=" + encodeURIComponent(x);
}

function hatnoteTag() {
    var str;
    var x=prompt("Add hatnote. Template name (without braces): ", "");
    if (x==""|x==null) return;
    var y=prompt("{" + "{" + x + "}} parameter (leave blank for no parameter): ", "");
    if (y==""|y==null) str = "{" + "{" + x + "}}";
    else str = "{" + "{" + x + "|" + y + "}}";
    location.href=wgServer+wgScript+"?title=" + encodeURIComponent(wgPageName) + "&action=edit&autotag=" + encodeURIComponent(str);
}

function hlistConvert() {
    location.href=wgServer+wgScript+"?title=" + encodeURIComponent(wgPageName) + "&action=edit&hlist=true";
}

function projectsTag() {
    var aparksClass=prompt("Tagging for {" + "{WikiProject Amusement Parks}}. Class: ");
    var aparksImportance;
    var rcClass;
    var rcImportance;
    var rcInc = true;
    if (aparksClass==null) {
        return;
    } else {
        aparksImportance=prompt("Tagging for {" + "{WikiProject Amusement Parks}}. Importance: ");
        if (aparksImportance==null) {
            return;
        } else {
            rcClass=prompt("Tagging for {" + "{WikiProject Roller Coasters}}. Class: ");
            if (rcClass==null) {
                rcInc = false;
            } else {
                rcImportance=prompt("Tagging for {" + "{WikiProject Roller Coasters}}. Importance: ");
                if (rcImportance==null) {
                    rcInc = false;
                }
            }
        }
    }
    var x = "{" + "{Talk header}}\n";
    if (rcInc == true) {
        x += "{" + "{WikiProjectBannerShell|1=\n"
    }
    x += "{" + "{WikiProject Amusement Parks|class=" + aparksClass + "|importance=" + aparksImportance + "}}\n"
    if (rcInc == true) {
        x += "{" + "{WikiProject Roller Coasters|class=" + rcClass + "|importance=" + rcImportance + "}}\n}}\n"
    }
    location.href=wgServer+wgScript+"?title=" + encodeURIComponent(wgPageName) + "&action=edit&autotag=" + encodeURIComponent(x);
}

function toolbox() {
    //location.href=wgServer+wgScript+"?title=" + encodeURIComponent(wgPageName) + "&toolbox=true";
    document.getElementById('bodyContent').innerHTML = '<div style="background-color:#F9F9F9;border:1px solid #AAAAAA;padding:5px;width:220px;border-radius:10px;"><ul><li><a target="_blank" href="http://toolserver.org/%7Edispenser/cgi-bin/altviewer.py/' + encodeURIComponent(wgPageName) + '">Alt Text</a></li><li><a target="_blank" href="http://toolserver.org/%7Edispenser/cgi-bin/webreflinks.py/' + encodeURIComponent(wgPageName) + '?client=script&citeweb=on&overwrite=&limit=20&lang=en">Reflinks</a></li><li><a target="_blank" href="http://toolserver.org/~daniel/WikiSense/Contributors.php?wikilang=en&wikifam=.wikipedia.org&page=' + encodeURIComponent(wgPageName) + '&since=&until=&grouped=on&order=-edit_count&max=100&format=html">Article Contributors</a></li><li><a target="_blank" href="http://toolserver.org/%7Edispenser/cgi-bin/webchecklinks.py/' + encodeURIComponent(wgPageName) + '">Check Links</a></li><li><a target="_blank" href="http://toolserver.org/%7Edispenser/cgi-bin/dablinks.py/' + encodeURIComponent(wgPageName) + '">DAB links</a></li><li><a target="_blank" href="http://toolserver.org/%7Edispenser/view/Peer_reviewer#page:' + encodeURIComponent(wgPageName) + '">Peer Reviewer</a></li><li><a target="_blank" href="http://toolserver.org/%7Edispenser/cgi-bin/rdcheck.py/' + encodeURIComponent(wgPageName) + '">Redirects</a></li></ul></div>' + document.getElementById('bodyContent').innerHTML;
}

function thumbnailImage() {
    var size = prompt("Please enter a size for the thumbnail: ", "250px");
    if (size==null) return;
    var title = wgTitle;
    title.replace(" ", "+");
    location.href="/media/wikipedia/en/thumb/5/50/" + title + "/" + size + "-" + title;
}

addOnloadHook(function () {

    // Check if we're on the watchlist
    if (!wgCanonicalSpecialPageName || wgCanonicalSpecialPageName != "Watchlist") return;
    if (!document.forms[0] || !document.forms[0].namespace) return;

    // Unwatch links go back to watchlist with "Removing requested items from watchlist..." message
    var query_prefix = "title="+encodeURIComponent(wgPageName)+"&action=submit&remove=1&id[]=";

    // ...or...
    // Unwatch links go to "Removed from watchlist" page
    //var query_prefix = "action=unwatch&title=";

    // get list of all links in content:
    var links = document.getElementById('content').getElementsByTagName('a');

    // make a static copy of the nodelist and lose the original for speed
    // while we're at it, prune the uninteresting links from the list
    var linksCopy = new Array ();
    for (var i = 0; i < links.length; i++) {
        if (/[?&]action=history([&#]|$)/.test(links[i].href)) linksCopy.push(links[i]);
    }
    links = linksCopy;

    for (var i = 0; i < links.length; i++) {
        // create unwatch link and append it after history link
        var unwatch = document.createElement('a');
        unwatch.href = wgServer + wgScriptPath + "/index.php?" + query_prefix + encodeURIComponent(links[i].title);
        unwatch.title = "Unwatch "+links[i].title;
        unwatch.appendChild(document.createTextNode("unwatch"));
        links[i].parentNode.insertBefore(unwatch, links[i].nextSibling);

        // insert a delimiter between the two links
        var delim = links[i].previousSibling;
        delimText = (delim.nodeType == 3 ? delim.nodeValue : ""); // kluge to handle case where "diff" is unlinked
        delim = document.createTextNode(delimText.replace(/^.*diff/, ""));
        links[i].parentNode.insertBefore(delim, unwatch);
    }
});