MediaWiki:Gadget-pikan-inkipedia.js

//

function init_pikan {

pikan.wiki_url = "http://splatoonwiki.org/"; pikan.help_link = "http://splatoonwiki.org/wiki/User:Espyo/Pikan"; pikan.module_name = "Inkipedia"; pikan.module_version = "1.3.0";

pikan.types["Problem"] = { color:      "#600", background: "rgba(255, 128, 128, 0.8)", description: "General MediaWiki source or general article problems." }; pikan.types["Policy"] = { color:      "#400", background: "rgba(192, 128, 128, 0.8)", description: "Issues that break a policy, specific or implied." }; pikan.types["Style"] = { color:      "#206", background: "rgba(160, 128, 255, 0.8)", description: "Problems that do not affect the page, but when fixed, make the source easier to use." }; pikan.types["Question"] = { color:      "#420", background: "rgba(255, 192, 128, 0.8)", description: "Results that the analyzer cannot decide whether they're real problems or false-positives." };

pikan.find_problems = function{ var reg; //Find "Wikia" -- we aren't involved with Wikia, so get rid of leftovers. reg = /wikia/igm; pikan.regex_check(reg, "Problem", "\"Wikia\" found. We moved from Wikia, so make sure this isn't a leftover."); //Find "gamepad" reg = /[Gg]amepad/gm; pikan.regex_check(reg, "Problem", "\"Gamepad\" found. The correct spelling for the Wii U's controller is \"GamePad\"."); //Find "Nunchuck" reg = /Nunchuck/igm; pikan.regex_check(reg, "Problem", "\"Nunchuck\" found. The correct spelling of the Wii peripheral is \"Nunchuk\"."); //Find game names without italicization. reg = /(Splatoon 3|Splatoon 2|Splatoon)/igm; pikan.regex_check(   reg, "Policy", "Game and series names should be in italics.", null,    function(r){      if(pikan.is_common_exception(r)) return false;      if( pikan.before(r, 2) == "''" && pikan.after(r, 2) == "''" ){       return false;      }      //Check if the name is a link caption.      //Let's cheat a bit and assume that      //a) the link's text only contains the game name //(otherwise the editor would need the bold inside the link) //b) the italics are placed correctly before the link.     if(pikan.after(r, 4)  == "]]''") return false;      //Special cases: if it's part of "Squidbeak Splatoon", "Splatoon Global Testfire",      //"Splatoon Testfire", then ignore.      if(pikan.before(r, 10) == "Squidbeak ") return false;      if(pikan.after(r, 16) == " Global Testfire") return false;      if(pikan.after(r, 9) == " Testfire") return false;      return true;    }  ); //Find lowercase game name. reg = /(splatoon 3|splatoon 2|splatoon)/gm; pikan.regex_check(   reg, "Policy", "Game name with lowercase 's' found. The official spelling is always with an uppercase 'S'.", null,    function(r){      return !pikan.is_common_exception(r);    }  ); //Find lowercase "Inkling", "Octoling", "Octarian", etc. reg = /(inkling|octoling|octarian|octotrooper)/gm; pikan.regex_check(   reg, "Policy", "Species name starting with a lowercase letter found. It should start with an uppercase letter.", null,    function(r){      return !pikan.is_common_exception(r);    }  ); //Find button names that aren't using the button template. reg = /\b([Pp]ress(ing)? (the)? (A|B|X|Y|L|R|ZL|ZR)|(A|B|X|Y|L|R|ZL|ZR) [Bb]uttons?)\b/gm; pikan.regex_check(   reg, "Policy", "Button being referred to by name. It should be displayed using  instead.", null,    function(r){      return !pikan.is_common_exception(r);    }  ); //Suggest ❌ and instead of manually-written tags. reg = /\((NA|US|EU\/OC|EU\\OC|EUOC|EUAU|EU\/AU|EU\\AU|Europe|North America)\)/igm; pikan.regex_check(   reg, "Question", "Region in parenthesis found. If possible, use ❌,  or  instead."  ); //"You" outside of guide sections. reg = /\b(you|your|you're)\b/igm; pikan.regex_check(   reg, "Question", "The player/reader is referred to as \"you\". This is only okay on guide sections, and this doesn't look like one. If it is, ignore this, otherwise use the third person.", "Inkipedia:Policy#Perspective",    function(r){      if(pikan.is_common_exception(r)) return false;      if(pikan.in_area(r, "<ref", "/ref", false)) return false;      var walkthrough_sec_reg = /^=+ *Walkthrough/igm;      var walkthrough_sec_match = null;      var you_section_nr = pikan.get_section_nr(r);      while(walkthrough_sec_match = walkthrough_sec_reg.exec(pikan.text)){        if(pikan.section_in_section(          you_section_nr,          pikan.get_section_nr(walkthrough_sec_match)        )){          return false;        }      }      return true;    }  ); //Find "font-family", as it is likely a Wikia visual editor leftover. reg = /font\-family/igm; pikan.regex_check(reg, "Question", "Font family tampering found. Possibly a Wikia visual editor leftover. Remove it if so."); //Find tags, which are possible Wikia leftovers. reg = /]/igm; pikan.regex_check(reg, "Question", "&lt;p&gt; tag found. There is normally no reason to use them, meaning this could be a Wikia visual editor leftover. Remove it if so."); //Find black text colors, which are possible Wikia leftovers. reg = /[ ;"]color: ?(black|#000[000]?)/igm; pikan.regex_check(reg, "Question", "Black text color style found. Because it is normally useless to force the text to be black, this is likely a Wikia visual editor leftover. Remove it if so.");  //Find gendered nouns; players should be "they".  reg = /\b(his|him|her|he|she)\b/igm;  pikan.regex_check(    reg, "Question", "Gendered noun found. If this is the player, treat them as \"they\". Otherwise, ignore this.", "Inkipedia:Policy#Pronouns",    function(r){      return !pikan.is_common_exception(r);    }  );  //Find "image:" (it should be "file:").  reg = /\[\[Image\:/igm;  pikan.regex_check(reg, "Style", "Image being called with \"Image:\" found. \"File:\" is better.");  reg = /Image:/igm;  pikan.regex_check(reg, "Style", "Image being called with \"Image:\" found. \"File:\" is better.", null,    function(r){      return pikan.in_area(r, ""); } );  //Find two empty lines in a row.  reg = /(\n\n\n|\r\r\r|\r\n\r\n\r\n)/igm;  pikan.regex_check(reg, "Style", "Double empty lines found. Just one is enough. If you want to add vertical spacing, try the  template. (If you can't see the selection, just press a letter key.)");  //Find redundant "Template:".  reg = /\{\{Template\:/igm;  pikan.regex_check(reg, "Style", "\"\" and \"\" are the same, so use the latter form, which is simpler.");  //Find trailing spaces.  reg = /(^ .+$|^.+ $)/igm;  pikan.regex_check(reg, "Style", "Trailing space found.");  //Find double spaces.  reg = /  /igm;  pikan.regex_check( reg, "Style", "Double spaces found. Just one is enough.", null, function(r){ return !pikan.in_area(r, "|", "="); //Template parameter -- not illegible. } );  //Empty line at the start.  if(pikan.text.length > 2){    if(pikan.text[0] == "\n" || pikan.text[0] == "\r"){      pikan.save_problem(0, 1, "Style", "Empty line at the start found. There's no reason for it to exist, so remove it.");    }  }  //Missing empty line before section.  reg = /([^\n=]\n|[^\r=]\r|[^(\r\n)=]\r\n)=.+=/gm;  pikan.regex_check(reg, "Style", "Add an empty line before section headers, to make it easier to read.");

//Files share their line with other text. reg = /((\[\[File.+\]\][^\n\r\[\]]+$)|(^[^\n\r\[\]]+\[\[File.+\]\]))/igm; pikan.regex_check(reg, "Style", "Image has more than just its code on its line; add a line break between it and the text, to make it easier to read.");

//Underscores in file names. reg = /\File:.+_.+/igm; pikan.regex_check(reg, "Style", "File name with underscores found; spaces are more human-readable."); //Underscores in gallery file names. reg = /.+_.+\|/gm; pikan.regex_check(   reg, "Style", "File name with underscores found; spaces are more human-readable.", "",    function(r){      return pikan.in_area(r, "<gallery", "/gallery");    }  ); //Underscores in links. reg = /\[\^|\*_[^|\]]*(\||\]\])/gm; pikan.regex_check(reg, "Style", "Link with underscores found; spaces are more human-readable."); //Underscores in template names. reg = /\{\{[^\|\}]+_.+(\r|\n|\|\}\})/gm; pikan.regex_check(reg, "Style", "Template name with underscores found; spaces are more human-readable."); //Links like A|A. reg = /\[\[([^\|\]]+)\|\1\]\]/gm; pikan.regex_check(reg, "Style", "Link with the same page and name found. Just simplify it like this: Apple &rarr; Apple."); //Links like A|AB. reg = /\[\[([^\|\]]+)\|\1[^ ]+\]\]/gm; pikan.regex_check(reg, "Style", "Link with a name that contains the page name found. Simplify it like this: Apples &rarr; Apples."); }

/* * * * * * * * * * * * * * * * * * * * * * * * * * Is common exception * * * * * * * * * * * * * * * * * * * * * * * * * * Returns whether a regex match belongs to a * "common exception". Use this to ignore capitalization, * spelling, etc. problems on things like template * parameter names. * reg: regex match. */ pikan.is_common_exception = function(reg){ //Is it in a template? if(pikan.in_area(reg, "")) return true; //Is it in a comment? if(pikan.in_area(reg, "")) return true; //Is it a page link or image? var in_internal_link = (pikan.in_area(reg, "", "")); if(in_internal_link){ var in_left_half = pikan.in_area(reg, "", ""); //A|B format. if(in_left_half) return true; } //Is it a categorization? if(pikan.in_area(reg, "")) return true; if(pikan.in_area(reg, "")) return true; //Is it a file name in a gallery? if(pikan.in_area(reg, "<gallery", "/gallery")){ if(pikan.in_area(reg, "\n", "|")) return true; } //Is it in an external link? if(!in_internal_link){ if(     (pikan.in_area(reg, "[http", "]") || pikan.in_area(reg, "[www", "]")) &&     pikan.in_area(reg, "[", " ")    ){ return true; } }  return false; }

}

if(typeof(pikan) != "undefined") { init_pikan; pikan.setup; }

//