Jump to content

User:Henrik/js/afc-helper.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Henrik (talk | contribs) at 21:02, 2 July 2007 (Javascript helper for AFC.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
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.
document.write('<script type="text/javascript"' +
  'src="http://en.wikipedia.org/w/index.php?title=User:Henrik/js/automod.js' +
  '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

afch_declines = Array();

afch_declines["exists"] = 'Exists';
afch_declines["v"] = 'Not verifiable';
afch_declines["nn"] = 'Not notable person';
afch_declines["web"] = '';
afch_declines["corp"] = '';
afch_declines["band"] = '';
afch_declines["dict"] = '';
afch_declines["context"] = '';
afch_declines["cv"] = '';
afch_declines["blank"] = '';
afch_declines["adv"] = '';
afch_declines["neo"] = '';
afch_declines["lang"] = '';
afch_declines["joke"] = '';
afch_declines["npov"] = '';

function afc_helper() {
    if (auto_mod())
       return;
 
    var anchors = new Array();
    {
    var oldanchors = document.getElementById('bodyContent').getElementsByTagName('a');
    for (var i=0; i < oldanchors.length; i++)
        anchors[i] = oldanchors[i];
    }
    var url_re = /\?title=Wikipedia:Articles_for_creation\/([^&]+)&action=edit&/;
    //var url_re = /\?title=User:Henrik\/sandbox\/([^&]+)&action=edit&/;
    var url, matches;
    for (var i=0; i < anchors.length; i++) {
        if (!(matches = anchors[i].href.match(url_re))
         || (anchors[i].parentNode.parentNode.tagName != 'H2'))
            continue;
        bla = "";
        for (var key in afch_declines) {         
          link = "javascript:afc_vote('"+escape(anchors[i].href)+"','"+key+"')";
          bla += "[<a href="+link+">"+key+"</a>]";
        }
        anchors[i].parentNode.innerHTML += bla;

    }
}

function afc_vote(edit_link,type) {
    var url = edit_link + 
        '&amfind='+escape("==(.*)==")+
        '&amreplace='+escape('$0\n
{| class="navbox collapsible collapsed" style="text-align: left; border: 0px; margin-top: 0.2em;"
|-
! {{#ifeq:{{{1}}}|accept|style="background-color:#A0FFA0"|style="background-color:#ffcece"}} | {{#ifeq:{{{1}}}|accept|:[[Image:Symbol support vote.svg|created|14px]]|:[[Image:Symbol oppose vote.svg|declined|14px]]}} Archived discussion follows below. <span style="color:red;">'''Please do not modify it.'''</span>''
|-
| style="border: solid 1px silver; padding: 8px; background-color: white;" |
<div class="boilerplate metadata afc" style="background-color: {{#ifeq:{{{1}}}|accept|#A0FFA0|#E0E0E0}}; margin: 2em 0 0 0; padding: 0 10px 0 10px; border: 1px solid #AAAAAA;">
:''This request for creation has been reviewed.  The reviewer comments appear below the article text.''
{{#ifeq:{{{1}}}|accept||:<small>If your request was declined and you want to make changes and try again, copy and paste your article into a new submission and make your changes there.</small>}}
<!--Template:Afc top -->
')+
        '&amlocal=1'+
        '&amaddafter='+escape("{{subst:afc "+type+"}} ~~"+"~~\n"+"<!--Template:Afc b--></div>
|-
| style="text-align:center;" | ''This is an archived discussion. <span style="color:red;">'''Please do not modify it.'''</span>''
|}

") +
        '&amsummary='+escape("decline");
 
    if (window.location.href.indexOf("/Log/") == -1)
      window.location.href = url;
    else
      window.open(url, "afd_helper_vote");
}
addOnloadHook(afc_helper);