Jump to content

User:Thetrick/my helper/script.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.
//<pre><nowiki>
 
/*************** MY Helper **************/
/* see [[User:Thetrick/my_helper]]      */

importScript("User:Thetrick/tfd_helper/automodtfdh.js");

var tfdh_advanced;

/* this function runs at load */
function my_helper() {
    /* call auto mod first, exit if it did processing */
    if (auto_mod_tfdh())
       return;
    if (tfdh_advanced == null)
        tfdh_advanced = false;
    /* add these to the tabs at the top */
    if (tfdh_advanced && wgCanonicalNamespace == 'Template' && wgIsArticle == true) {
        amtfdh_add_li('cactions', 'javascript:add_doc_sub()', 'add doc. sub.', 'myh1', 'Add Template:Documentation subpage to a doc page');
    }
    /* add these to the sidebar if a template */
    if (tfdh_advanced && wgCanonicalNamespace == 'Template' && wgIsArticle == true) {
        amtfdh_add_li('tb', 'javascript:remove_tfd()', 'MYh: remove TfD', 'myh2', 'Remove a TfD tag from a failed TfD if the admin overlooked it');
        amtfdh_add_li('tb', 'javascript:remove_uncat()', 'MYh: remove uncat.', 'myh3', 'Remove an uncategorized tag for a reason');
    }
}

/* myh1 - doc subpage template and place for categories to a doc page */
function add_doc_sub() {
    window.location.href = amtfdh_make_url(wgPageName, '{{Documentation subpage}}\n<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->\n', '\n<includeonly>\n<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->\n\n\n</includeonly>', 'Added Template:Documentation subpage') + "&tfdpreview=true";
}

/* myh2 - remove a tfd tag from a failed tfd */
function remove_tfd() {
    var rmv_rsn = window.prompt("Explain why this TfD should be removed from " + wgPageName + " (e.g. failed Tfd, article created with tag, etc.)", "");
    if (!rmv_rsn)
        return;
    window.location.href = amtfdh_make_url(wgPageName, '', '', 'Removed invalid TfD tag because ' + rmv_rsn) + "&tfdfind={{tfd}}";
}

/* myh3 - remove a uncat tag from a hopelessly munged template */
function remove_uncat() {
    var rmv_rsn = window.prompt("Explain why the uncategorized tag should be removed from " + wgPageName + ":", "");
    if (!rmv_rsn)
        return;
    window.location.href = amtfdh_make_url(wgPageName, '', '', 'Removed uncategorized tag because ' + rmv_rsn) + "&tfdfind={{uncat}}";
}

/* run a register function */
$(my_helper);

//bits of test code sit here
//    var yes_no = window.prompt('Here is the url', am_make_url(here, here, here, here));
//    return;
 
//</nowiki></pre>