Jump to content

User:Pythoncoder/Scripts/voteSymbols.js: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Undid revision 886724010 by Pythoncoder (talk)
function
(3 intermediate revisions by the same user not shown)
Line 8: Line 8:
{
{
return s.toLowerCase().split('.').join('').split(',').join('').split(':').join('').split(';').join('').split('+').join('');
return s.toLowerCase().split('.').join('').split(',').join('').split(':').join('').split(';').join('').split('+').join('');
}
function mergeWords(a, b, j, k) {
try {
if(lowerNoPunct(j[k])==a&&lowerNoPunct(j[k+1])==b) {
j.splice(k, 2, a+' '+b);
}
return j;
} catch(e) {
return j;
}
}
}


Line 65: Line 75:
// Note that icon 8 on the list is often used for debate-specific !votes
// Note that icon 8 on the list is often used for debate-specific !votes
la['comment']=9; la['note']=9; la['comments']=9;
la['comment']=9; la['note']=9; la['comments']=9;
la['delist']=10; la['unsupport']=10;
la['delist']=10; la['demote']=10; la['unsupport']=10;
la['question']=11;
la['question']=11;
la['disambiguate']=12; la['dab']=12; la['dabify']=12; la['sia']=12;
la['disambiguate']=12; la['dab']=12; la['dabify']=12; la['sia']=12;
Line 81: Line 91:
la['withdraw']=24; la['withdrawn']=24;
la['withdraw']=24; la['withdrawn']=24;
la['information']=25; la['info']=25;
la['information']=25; la['info']=25;
la['update']=26;
la['update']=26; la['answer']=26;
la['snow']=27; la['snowball']=27;
la['snow']=27; la['snowball']=27;
la['blank']=28;
la['blank']=28;
Line 106: Line 116:
if(lowerNoPunct(j[k])=="don't"||lowerNoPunct(j[k])=='not'
if(lowerNoPunct(j[k])=="don't"||lowerNoPunct(j[k])=='not'
||lowerNoPunct(j[k])=='no'||lowerNoPunct(j[k])=='without') break;
||lowerNoPunct(j[k])=='no'||lowerNoPunct(j[k])=='without') break;

if(lowerNoPunct(j[k])=='speedy'&&lowerNoPunct(j[k+1])=='delete') {
j.splice(k, 2, 'speedy delete');
mergeWords('speedy','delete',j,k);
mergeWords('speedy','keep',j,k);
}
if(lowerNoPunct(j[k])=='speedy'&&lowerNoPunct(j[k+1])=='keep') {
mergeWords('speedy','redirect',j,k);
mergeWords('strong','support',j,k);
j.splice(k, 2, 'speedy keep');
mergeWords('strongly','support',j,k);
}
mergeWords('weak','support',j,k);
if(lowerNoPunct(j[k])=='speedy'&&lowerNoPunct(j[k+1])=='redirect') {
mergeWords('strong','oppose',j,k);
j.splice(k, 2, 'speedy redirect');
mergeWords('strongly','oppose',j,k);
}
mergeWords('weak','oppose',j,k);
if(lowerNoPunct(j[k])=='strong'&&lowerNoPunct(j[k+1])=='support') {
j.splice(k, 2, 'strong support');
mergeWords('partial','support',j,k);
mergeWords('conditional','support',j,k);
}
if(lowerNoPunct(j[k])=='strongly'&&lowerNoPunct(j[k+1])=='support') {
j.splice(k, 2, 'strongly support');
}
if(lowerNoPunct(j[k])=='weak'&&lowerNoPunct(j[k+1])=='support') {
j.splice(k, 2, 'weak support');
}
if(lowerNoPunct(j[k])=='strong'&&lowerNoPunct(j[k+1])=='oppose') {
j.splice(k, 2, 'strong oppose');
}
if(lowerNoPunct(j[k])=='strongly'&&lowerNoPunct(j[k+1])=='oppose') {
j.splice(k, 2, 'strongly oppose');
}
if(lowerNoPunct(j[k])=='weak'&&lowerNoPunct(j[k+1])=='oppose') {
j.splice(k, 2, 'weak oppose');
}
if(lowerNoPunct(j[k])=='partial'&&lowerNoPunct(j[k+1])=='support') {
j.splice(k, 2, 'partial support');
}
if(lowerNoPunct(j[k])=='conditional'&&lowerNoPunct(j[k+1])=='support') {
j.splice(k, 2, 'conditional support');
}
var l=la[lowerNoPunct(j[k])];
var l=la[lowerNoPunct(j[k])];
if(l!==undefined)
if(l!==undefined)

Revision as of 15:56, 8 March 2019

// Revised from [[User:Ais523/votesymbols.js]]
// Code for adding icons to !votes in AfDs, RfAs, etc...
// Doesn't affect the page, just shows the icons when this code is installed.
// Please see [[:Image:Votesymbols.js-enhanced_SfD.png]] and 
// [[c:Category:Norro style 1 icons]] for copyright info on the images that are added.

function lowerNoPunct(s)
{
  return s.toLowerCase().split('.').join('').split(',').join('').split(':').join('').split(';').join('').split('+').join('');
}
function mergeWords(a, b, j, k) {
  try {
    if(lowerNoPunct(j[k])==a&&lowerNoPunct(j[k+1])==b) {
      j.splice(k, 2, a+' '+b);
    }
    return j;
  } catch(e) {
    return j;
  }
}

$(function() {
  if(mw.config.get('wgNamespaceNumber')===0) return; //avoid article space, generally speaking
  if(mw.config.get('wgNamespaceNumber')===118) return; //ditto for drafts
  var vs=
  "//upload.wikimedia.org/wikipedia/commons/thumb/9/94/Symbol_support_vote.svg/60px-Symbol_support_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/d/d0/Symbol_keep_vote.svg/60px-Symbol_keep_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/7/7f/Symbol_oppose_vote.svg/60px-Symbol_oppose_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/8/89/Symbol_delete_vote.svg/60px-Symbol_delete_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/8/89/Symbol_neutral_vote.svg/60px-Symbol_neutral_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Symbol_merge_vote.svg/60px-Symbol_merge_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/5/50/Symbol_move_vote.svg/60px-Symbol_move_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/0/0c/Symbol_redirect_vote.svg/60px-Symbol_redirect_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/b/ba/Symbol_opinion_vote.svg/60px-Symbol_opinion_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/e/e0/Symbol_comment_vote.svg/60px-Symbol_comment_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Symbol_unsupport_vote.svg/60px-Symbol_unsupport_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/e/e0/Symbol_question.svg/60px-Symbol_question.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/2/2a/Symbol_dab_class.svg/60px-Symbol_dab_class.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/5/54/Symbol_wait.svg/60px-Symbol_wait.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/0/0a/Symbol_rename_vote.svg/60px-Symbol_rename_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Symbol_support2_vote.svg/60px-Symbol_support2_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Symbol_no_support_vote.svg/60px-Symbol_no_support_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Symbol_split_vote.svg/60px-Symbol_split_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/6/61/Symbol_abstain_vote.svg/60px-Symbol_abstain_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/0/09/Symbol_draft_class.svg/60px-Symbol_draft_class.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/1/13/Symbol_user_class.svg/60px-Symbol_user_class.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/d/db/Symbol_list_class.svg/60px-Symbol_list_class.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/d/d2/Symbol_reply.svg/60px-Symbol_reply.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/6/66/Symbol_create_protect_vote.svg/60px-Symbol_create_protect_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/8/85/Symbol_unrelated.svg/60px-Symbol_unrelated.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/8/8c/Symbol_information_vote.svg/60px-Symbol_information_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/1/18/Symbol_version_future.svg/60px-Symbol_version_future.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/d/d3/Bouncing_Snowball.png/60px-Bouncing_Snowball.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/1/1b/Symbol_plain_white.svg/60px-Symbol_plain_white.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/6/6d/Symbol_speedy_delete_vote.svg/60px-Symbol_speedy_delete_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/b/bc/Symbol_speedy_keep_vote.svg/60px-Symbol_speedy_keep_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/2/22/Symbol_speedy_redirect_vote.svg/60px-Symbol_speedy_redirect_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/8/84/Symbol_strong_support_vote.svg/60px-Symbol_strong_support_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/5/5e/Symbol_oppose_vote_oversat.svg/60px-Symbol_oppose_vote_oversat.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/8/8c/GA_candidate.svg/60px-GA_candidate.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/f/f5/BA_candidate.svg/60px-BA_candidate.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/b/b2/Symbol_conditional_support.svg/60px-Symbol_conditional_support.svg.png#"+
  "";
  var vt=vs.split("#");
  var la=[];
  la['support']=0; la['endorse']=0; la['accept']=0;
  la['keep']=1; la['allow']=1; la['permit']=1;
  la['oppose']=2; la['overturn']=2; la['object']=2; la['disallow']=2; la['decline']=2;
  la['delete']=3; la['remove']=3;
  la['neutral']=4;
  la['merge']=5; la['upmerge']=5;
  la['move']=6; la['transwiki']=6; la['convert']=6;
  la['redirect']=7; la['retarget']=7;
  la['relist']=8; la['subst']=8; la['change']=8; la['recuse']=8;
  // Note that icon 8 on the list is often used for debate-specific !votes
  la['comment']=9; la['note']=9; la['comments']=9;
  la['delist']=10; la['demote']=10; la['unsupport']=10;
  la['question']=11;
  la['disambiguate']=12; la['dab']=12; la['dabify']=12; la['sia']=12;
  la['wait']=13; la['hold']=13;
  la['rename']=14;
  la['undelete']=15; la['restore']=15;
  la['close']=16;
  la['split']=17;
  la['abstain']=18; la['unnecessary']=18;
  la['draftify']=19; la['incubate']=19;
  la['userfy']=20; 
  la['listify']=21;
  la['reply']=22;
  la['salt']=23;
  la['withdraw']=24; la['withdrawn']=24;
  la['information']=25; la['info']=25;
  la['update']=26; la['answer']=26;
  la['snow']=27; la['snowball']=27;
  la['blank']=28;
  la['speedy']=29; la['speedy delete']=29;
  la['speedy keep']=30;
  la['speedy redirect']=31;
  la['strong support']=32; la['strongly support']=32;
  la['strong oppose']=33; la['strongly oppose']=33;
  la['weak support']=34;
  la['weak oppose']=35;
  la['partial support']=36; la['conditional support']=36;

  var btc=document.body.getElementsByTagName("B");
  i=btc.length;
  while(i--)
  {
    var j,k;
    j=btc[i].textContent
    j=j.split("<").join(" ").split(">").join(" ").split("/").join(" ").split(" ");
    k=0;
    var x="";
    while(k<j.length)
    {
      if(lowerNoPunct(j[k])=="don't"||lowerNoPunct(j[k])=='not'
       ||lowerNoPunct(j[k])=='no'||lowerNoPunct(j[k])=='without') break;

      mergeWords('speedy','delete',j,k);
      mergeWords('speedy','keep',j,k);
      mergeWords('speedy','redirect',j,k);
      mergeWords('strong','support',j,k);
      mergeWords('strongly','support',j,k);
      mergeWords('weak','support',j,k);
      mergeWords('strong','oppose',j,k);
      mergeWords('strongly','oppose',j,k);
      mergeWords('weak','oppose',j,k);
      mergeWords('partial','support',j,k);
      mergeWords('conditional','support',j,k);
      var l=la[lowerNoPunct(j[k])];
      if(l!==undefined)
      {
        x+='<img src="'+vt[l]+'" alt="" style="height:15px" /> '
      }
      k++;
    }
    if(x!=="") btc[i].innerHTML=x+btc[i].innerHTML;
  }
});
//[[Category:Wikipedia scripts]]