User:ReyBrujo/Tools/phs.js

/*

*

*

* __DESCRIPTION__

* phs (short for Pretty Helpful Summaries) is a personal project to help less experienced users with

* suggestions. Summaries are extremely useful for newbies, especially when reverting their modifications.

* A novice who had had his edition reverted with a "rv", "reverted to xxx using popups", "reverted due

* vandalism", or similar aren't useful for them. They don't learn why their edits were deleted.

*

* With phs I try to solve that. When using it, a combo appears near the summary box, with a list of the

* different valid Wikipedia reasons. In example, guidelines from WP:NOT, WP:DATE, WP:EL, etc. When you

* have reverted or deleted something, you just need to choose the guideline that applies. In example, if

* you have deleted an external link to a blog, you can choose "WP:EL Blogs and forums" in the phs combo,

* which would automatically add "Clean up: blogs, social networking sites and forums are not good

* external links per 10th guideline." to your summary box. This way,

* the user who has added the forum link will read a valid reason, and by clicking on the wikilink, he

* will be able to confirm about what has been said.

*

* phs tries to determine if you are editing the latest version of the page, or a previous one. If you

* are editing a previous version, the heading text will state that you are reverting. In the previous

* forum link, it would look like "Reverted to version as of 23:44, 26 May 2006, blogs, social networking

* sites and forums are not good external links per 10th guideline."

*

* __USAGE__

* Just include the following code somewhere into your monobook.js. If you want, you can copy the contents

* directly into your monobook.js, as I will be updating it with new Wikipedia guidelines.

*

* document.write('');

*

* __GLITCHES__

* 1. The revert text is too long, taking around up to 50 characters. That forces explanations to be under

* 160 or so characters, otherwise they will be truncated.

* 2. When editing certain pages, a message box may popup saying it was not possible to find a node. This

* just informs the script could not detect a few things, and won't be accessed in the page. Protected

* pages do this.

* 3. The combo appears below the summary textbox. Later I will align it to a side, or exactly below the

* summary textbox.

* 4. Haven't checked in many browsers, just Firefox and Explorer, and seems to work fine enough.

* 5. Code is experimental. Hopefully it won't crash a browser, but if it does, disable javascript and

* remove the link from your monobook.js.

*/

var arrSummaryRevert = [

"",

// "avoid overlinking dates per date formatting guidelines.",

"a page title that is just a positive whole number is always a year per date format guidelines.",

"'18th century', not '18th Century', per date format guidelines.",

"'1830s', not '1830's', per date format guidelines.",

"<500BC redirects to decades, <1700BC redirects to centuries, <4000BC redirects to millenniums per date guidelines.",

"there was no year 0 per date format guidelines.",

"when only approximate date is available the abbreviation 'c.' can be used per date format guidelines.",

"when a date is uncertain it should be noted and referenced per date format guidelines.",

"if a date includes month and day, it should be wikilinked per date format guidelines.",

"day and month should be linked together, and the year separately per date format guidelines.",

"in article titles, dates will not be converted, per date format guidelines.",

"month and day names should not be linked unless there is a specific reason per date format guidelines.",

"don't link months or years numbers alone, per date format guidelines.",

"topic concerning a specific country may use the date format of that country, per date format guidelines.",

"UK, Australia and New Zealand date format is 'dd mm yyyy' without th nor comma per date format guidelines.",

"US and Canada date format is 'mm dd, yyyy' per date format guidelines.",

"ISO date formats should generally not be used in normal prose per date format guidelines.",

"ISO date formats are useful for lists, tables and ease of comparison per date format guidelines.",

"do not use numbers to express a month except in full ISO 8601 format per date format guidelines.",

"do not abbreviate months like 'Feb' unless space is precious in tables, infoboxes, etc, per date format guidelines.",

"do not use two digits for years unless at the end of range or when not ambiguous per date format guidelines.",

"use consistent date formatting throughout an article per date format guidelines.",

"do not use ordinal suffixes ('February 14th' or '14th February') per date format guidelines.",

"do not use articles ('the 14th of February') instead per date format guidelines.",

"do not put a comma or the word 'of' between a month and year, per date format guidelines.",

"direct quotations should not be altered, per date format guidelines.",

"birth location should be included in the article, not in the birth information, per date format guidelines.",

"do not use a dash after the birthday for living persons, per date format guidelines.",

"use 'c.' rather than 'circa', 'ca.' or question mark per date format guidelines.",

"do not use seasons unless absolutely necessary or quoting per date format guidelines.",

"both BCE/CE and BC/AD are acceptable, but must be consistent within the article per date format guidelines.",

"in articles about prehistory, expand BP and MYA when first used per date format guidelines.",

"when two styles are acceptable, it is inappropriate for an editor to change from a style to another, per date format guidelines.",

"current events should be given in the Gregorian calendar per date format guidelines.",

"dates before October 15, 1582 should be given in Julian calendar per date format guidelines.",

"Julian dates can be kept, converted or explained per date format guidelines.",

"other types of dates should include a conversion to the Gregorian calendar per date format guidelines.",

"in 12-hour clock use '12:04:38 a.m.' instead of '12:04:38pm', '12:04:38 PM' or '12.04 38' per time format guidelines.",

"in 24-hour clock use '14:34' instead of '14.34' or '1434', per time format guidelines.",

"include the UTC date and time of the event in the article if possible, per time format guidelines.",

"for numbers between minus one and plus one, include the leading 0 ('0.02', not '.02') per number format guidelines.",

"use hyphen-minus '-' or '−' for negative numbers per number format guidelines.",

"'percent' or 'per cent' are acceptable, but be consistent per number format guidelines.",

"use the symbol % with a numeral for percentage in a table, infobox or the like per number format guidelines.",

"whole numbers from zero to ten should be spelled in the body of an article; use numbers in tables per number format guidelines.",

"whole numbers above ten may be written out if expressed in two words or less except in tables per number format guidelines.",

"within a context or a list, style should be consistent per number format guidelines.",

"do not start sentences with a number, recast it or spell the number out per number format guidelines.",

"fractions standing alone should be spelt out unless in percentage or mixed with whole numbers per number format guidelines.",

"do not use billion (ambiguous), use numerals or combinations with the 'million' word per number format guidelines.",

"do not say 'natural number', use either 'positive integer' or 'non-negative integer' per number format guidelines.",

"ranges should be spell out as '4 to 7' or 'four through seven' per number format guidelines.",

"ranges should be separated with –, but do not change hyphens to en dashes per number format guidelines.",

"in computer-related articles, use C prefixes, 0x for hexa, 0 for octal, and 0b for binary, per number format guidelines.",

"use subscript notation for numbers not in base ten, with letters in uppercase per number format guidelines.",

"conversions should generally not be removed per measurement guidelines.",

"if editors can't agree, put the source value first and the converted value second per measurement guidelines.",

"spell out source units in text, digits and unit symbols for converted values and tables per measurement guidelines.",

"if the choice of units is arbitrary, choose SI units, unless US centric subject, per measurement guidelines.",

"digit and unit symbols for values in parentheses and tables, per measurement guidelines.",

"converted values should use a similar level of precision as the source value, per measurement guidelines.",

"use standard measurement abbreviations, like 'kg' for kilogram and 'in' for inch, per measurement guidelines.",

"do not append an 's' for plurals of unit abbreviations per measurement guidelines.",

"specify unit when necessary, like US gallon or imperial gallon rather than 'gallon' per measurement guidelines.",

"reader should see a space between the value and the unit; use   for the space per measurement guidelines.",

"use prefixes kibi-, mebi-, gibi-, etc, and Ki, Mi, Gi to specify binary multiples per magnitude guidelines.",

"do not change all SI prefixes to IEC prefixes in computing contexts per magnitude guidelines.",

"geographical coordinates should be entered with the {{tl|coord}} template, per coordinate guidelines.",

"in countries where euro is used, do not place 'EU' or similar prefix before the € sign per conversion guidelines.",

"conversions should be in parentheses after original currency, with year given as rough reference per conversion guidelines.",

"use 'US$100' instead of '$100', '$100', '100$', '$100 (US)' or '$US100', per conversion guidelines.",

"non-official factually inaccurate or unverified original research are not good external links per 1st guideline.",

"sites that do not provide a unique resource are not good external links per 2nd guideline.",

"links added to promote a site are not good external links per 3rd guideline.",

"sites primarily existing to sell products or services are not good external links per WP:EL.",

"sites with objectionable amounts of advertising are not good external links per 5th guideline.",

"paid sites are not good external links per 6th guideline.",

"non official sites requiring Flash, Java, etc, are not good external links per 7th guideline.",

"bookstores are not good external links, use ISBN linking per 8th guideline.",

"owned sites unless official ones are not good external links per 9th guideline.",

"blogs, social networking sites and forums are not good external links per 10th guideline.",

"free alternatives must be used instead of Fair use ones per 1st Fair use criteria policy.",

"the material should not replace the original role per 2nd Fair use criteria policy.",

"the amount of copyrighted work should be as little as possible per 3rd Fair use criteria policy.",

"use low-resolution images instead of high-resolution ones per 3rd Fair use criteria policy.",

"do not use multiple images if one serves the purpose adequately per 3rd Fair use criteria policy.",

"the material must have previously been published per 4th Fair use criteria policy.",

"the material must be encyclopedic and meet Wikipedia requirements per 5th Fair use criteria policy.",

"the material must meet the media-specific policy requirements per 6th Fair use criteria policy.",

"the material must be used in at least one article per 7th Fair use criteria policy.",

"the material must contribute significantly and not serve a purely decorative purpose per 8th Fair use criteria policy.",

"Fair use images should be used only in article namespace, not in templates, user or talk pages per 9th Fair use criteria policy.",

"Fair use images needs source, fair use tag and rationale per 10th Fair use criteria policy.",

"the subject of the article should be mentioned in bold at the first natural place per lead section guidelines.",

"the subject of the article should be mentioned in the first paragraph per lead section guidelines.",

"the introduction must establish the context of the article per lead section guidelines.",

"the introduction must provide a clear overview of the article per introduction guidelines.",

"the introduction should be of appropiate length depending on article size per introduction guidelines.",

"no specialized terminology (if used, terms must be defined) in the lead section per introduction guidelines.",

"'the', 'a' and 'an' should be omitted from the beginning of heading titles per heading wording guideline.",

"do not restate the subject of the article in heading titles per heading wording guideline.",

"do not repeat section titles per heading wording guideline.",

"use 'See also', 'Notes', 'References' and 'External links' titles per standard heading guidelines.",

"ordered 'See also', 'Notes', 'References' and 'External links' per standard heading order guidelines.",

"capitalise the first letter of the first word and proper nouns only, per heading capitalisation guidelines.",

"avoid linking headers, per heading linking guidelines.",

"avoid special characters as ampersand, plus sign, curly or square braces, per special characters guidelines.",

"use two equal signs, not triple apostrophes, per heading markup guidelines.",

"nest headings correctly per heading nesting guidelines.",

"spaces between the equal signs and after the heading are optional, per heading spacing guidelines.",

"floating the TOC is not always a good idea, per table of contents guidelines.",

"there is no practical limit to the number of topics, per Wikipedia is not a paper encyclopedia.",

"do not create an entry merely to define a term, per Wikipedia is not a dictionary, 1st guideline.",

"list of dictionary definitions do not fit Wikipedia, per Wikipedia is not a dictionary, 2nd guideline.",

"do not tell others how words, idioms, etc, should be used, per Wikipedia is not a dictionary, 3rd guideline.",

"no original research, proposing theories and solutions, per 1st publishing guideline.",

"no original inventions, new words, dances, etc, per 2nd publishing guideline.",

"no critical reviews unless referenced, per 3rd publishing guideline.",

"do not state personal opinions in articles per 4st publishing guideline.",

"do not express opinion on current affairs per 5th publishing guideline.",

"do not take discussions into articles as if it were a fourm per 6th publishing guideline.",

"do not insert propaganda or advocacy of any kind per 1st propaganda policy.",

"avoid contributing to articles about you, your family or personally involved subjects per 2nd propaganda policy.",

"articles about companies or products must not be biased and verifiable by third parties, per 3rd propaganda policy.",

"do not abuse external linking per repository policy.",

"upload only files that to be used per host policy.",

"format FAQs as neutral prose within articles per 1st information policy.",

"list of quotes or aphorisms go to Wikiquote per 2nd information policy.",

"local landmark contact information go to Wikitravel per 3rd information policy.",

"this is not place to honour deceased non notable people per 4th information policy.",

"breaking news go to Wikinews or current events per 5th information policy.",

"biographies only for people with some notoriety per 6th information policy.",

"no upcoming events, promotions, phone numbers per 7th information policy.",

"no advice, suggestions, tutorials, guides, manuals per 8th information policy.",

"scheduled events should be included if the event is notable and almost certain only per 1st speculation policy.",

"no items from lists or systematic pattern of names preassigned to future events per 2nd speculation policy.",

"extrapolation, speculation and future history are original research unless referenced per 3rd speculation policy.",

"Wikipedia is not censored according to the Wikipedia:Content disclaimer per censorship policy.",

"no personal attacks, stay civil, state your point per interaction policy.",

"Wikipedia restrics freedom and openness if they interfere with its main purpose per anarchy policy.",

"Wikipedia is not ruled by voting but consensus per democracy policy.",

"Wikipedia is not a legal system, follow the spirit, not the letter of rules per bureaucracy policy.",

"do not include the song's entire lyrics unless it is public domain per song guidelines.",

"formatted chart table per Music charts guidelines.",

"formatted single infobox per infobox guidelines.",

"weasel words make sentences longer and less informative-dense, per problems with weasel words.",

"weasel words usually abuse passive voice, which is not recommended per problems with weasel words.",

"weasel words require convoluted syntax to get a point across, per problems with weasel words.",

"'clearly' is often used to state that an arguement or discussion is clear when it is not per problems with weasel words.",

"Argumentum ad populum should be avoided as a general means of providing support per problems with weasel words.",

"there are only so many times in one paragraph you can use weasel words per problems with weasel words."

];

var arrSummaryRevertCombo = [

"",

//"WP:DATE Avoid overlinking dates",

"WP:DATE Page title is always year",

"WP:DATE 18th century, not 18th Century",

"WP:DATE 1830s, not 1830's",

"WP:DATE Redirections for years before 500 BC",

"WP:DATE There was no year 0",

"WP:DATE Circa abbreviation",

"WP:DATE Specify when date is uncertain",

"WP:DATE Linking day and month",

"WP:DATE Linking day, month and year",

"WP:DATE Article titles",

"WP:DATE No link for month and day names",

"WP:DATE Don't link month or year only",

"WP:DATE Topic can set date format",

"WP:DATE UK, AUS and NZ date format",

"WP:DATE US and Canada date format",

"WP:DATE No ISO formats in prose",

"WP:DATE ISO format for lists and tables",

"WP:DATE No numbers as month",

"WP:DATE No abbreviations per month",

"WP:DATE No two-digits years",

"WP:DATE Consistent date format",

"WP:DATE No ordinal suffixes",

"WP:DATE No articles in dates",

"WP:DATE No separation between month and year",

"WP:DATE Direct quotations",

"WP:DATE Separate location from birth information",

"WP:DATE No ending dash for birthdays",

"WP:DATE Circa",

"WP:DATE No seasons",

"WP:DATE BCE/CE and BC/AD are valid",

"WP:DATE Prehistory format",

"WP:DATE Clashing formats",

"WP:DATE Gregorian calendars",

"WP:DATE Julian calendar",

"WP:DATE Julian to Gregorian conversion",

"WP:DATE Convert other calendars in Gregorian",

"WP:DATE 12-hour format",

"WP:DATE 24-hour format",

"WP:DATE UTC date",

"WP:DATE Numbers between -1 and +1",

"WP:DATE Negative numbers",

"WP:DATE Percentage consistence",

"WP:DATE Percentage symbol in tables",

"WP:DATE Whole numbers from 0 to 10",

"WP:DATE Whole numbers above 10",

"WP:DATE Consistent style in a context",

"WP:DATE Numeral as first word of sentence",

"WP:DATE Fractions and whole numbers",

"WP:DATE Billion",

"WP:DATE Do not say natural number",

"WP:DATE Ranges",

"WP:DATE Ranges separation",

"WP:DATE Non-base-ten computer-related articles",

"WP:DATE Use base for non-decimal numbers",

"WP:DATE Do not remove measurement conversion",

"WP:DATE First source, then converted",

"WP:DATE Spell out source units in text",

"WP:DATE SI units are preferred",

"WP:DATE Digits and unit symbols",

"WP:DATE Level of measurement precision",

"WP:DATE Standard measurement abbreviations",

"WP:DATE Use singular for unit abbreviations",

"WP:DATE Specify unit when necessary",

"WP:DATE Space between value and unit symbol",

"WP:DATE Use kibi-, mebi-, gibi-, etc.",

"WP:DATE Do not change SI to IEC prefixes",

"WP:DATE Geographical coordinates",

"WP:DATE Do not place EU before €",

"WP:DATE Currency conversions",

"WP:DATE Currency abbreviature style",

"WP:EL Inaccurate or original research",

"WP:EL Non unique resource",

"WP:EL External spam",

"WP:EL Shop",

"WP:EL Advertisment abuse",

"WP:EL Paid sites",

"WP:EL External applications",

"WP:EL Bookstores",

"WP:EL Vanity",

"WP:EL Blogs and forums",

"WP:FUC Free equivalent available",

"WP:FUC Must not replace the original",

"WP:FUC As little copyrighted work as possible",

"WP:FUC Use low-resolution images",

"WP:FUC Use one instead of multiple images",

"WP:FUC Material must have been published",

"WP:FUC Material must be encyclopedic",

"WP:FUC Material must meet WP requirements",

"WP:FUC Material must be used in an article",

"WP:FUC Material must not be decorative",

"WP:FUC Images only in article namespace",

"WP:FUC Images requirements",

"WP:LEAD Bold title",

"WP:LEAD Title at the beginning of the article",

"WP:LEAD Establish context",

"WP:LEAD Provide overview",

"WP:LEAD Appropiate length",

"WP:LEAD Accessibility at the introduction",

'WP:MOSHEAD "the", "a" and "and"',

"WP:MOSHEAD Do not restate the subject",

"WP:MOSHEAD Do not repeat section titles",

'WP:MOSHEAD "See also", "Notes" title format',

'WP:MOSHEAD "See also", "Notes" ordering',

"WP:MOSHEAD Capitalisation",

"WP:MOSHEAD Linking",

"WP:MOSHEAD Special characters",

"WP:MOSHEAD Equal sings instead of apostrophes",

"WP:MOSHEAD Nest headings correctly",

"WP:MOSHEAD Spaces",

"WP:MOSHEAD Floating the TOC",

"WP:NOT Paper encyclopedia",

"WP:NOT Dictionary definitions",

"WP:NOT List of dictionary definitions",

"WP:NOT Usage, slang or idiom guide",

"WP:NOT Original research",

"WP:NOT Original inventions",

"WP:NOT Critical reviews",

"WP:NOT Personal essays or blogs",

"WP:NOT Opinions on current affairs",

"WP:NOT Discussion forum",

"WP:NOT Propaganda or advocacy",

"WP:NOT Self-promotion",

"WP:NOT Advertising",

"WP:NOT Collection of external links",

"WP:NOT File storage areas",

"WP:NOT FAQ",

"WP:NOT Quotes",

"WP:NOT Travel guide",

"WP:NOT Memorials",

"WP:NOT News reports",

"WP:NOT Genealogical or phonebook entries",

"WP:NOT Contact information",

"WP:NOT Instruction manuals",

"WP:NOT Scheduled or future events",

"WP:NOT Systematic pattern of names",

"WP:NOT Speculation and future history",

"WP:NOT Censorship",

"WP:NOT ...A battleground",

"WP:NOT ...An experiment in anarchy",

"WP:NOT ...An experiment in democracy",

"WP:NOT ...A bureaucracy",

"WP:SONG Lyrics",

"WP:SONG Chart tables",

"WP:SONG Single format",

"WP:WEASEL Sentence stuffing",

"WP:WEASEL Passive voice abuse",

"WP:WEASEL Convoluted syntax",

"WP:WEASEL Use of clearly",

"WP:WEASEL Ad populum arguments",

"WP:WEASEL Repetition"

];

function UpdateSummaryCombo(strValue) {

if (strValue) {

var nodeSummary = document.getElementById("wpSummary");

if (nodeSummary) {

nodeSummary.value=strValue;

}

}

else {

alert("Empty summary combo!");

}

}

function CreateSummaryCombo(strRevision) {

var nodeCombo;

var strCombo = "";

var strHeading = "";

var strCurrentGuideline = "";

if (strRevision == "") {

strHeading = "Clean up: ";

}

else {

strHeading = "Reverted to version as of " + strRevision + ", ";

}

nodeCombo = document.createElement("div");

strCombo = '';

nodeCombo.innerHTML += strCombo;

return (nodeCombo);

};

function AddExtras() {

var nodeContentSub = document.getElementById('contentSub');

if (nodeContentSub) {

var nodeRevision = document.getElementById('mw-revision-date');

if (nodeRevision) {

var strRevision = nodeRevision.innerHTML;

var nodeOptions = document.getElementById('wpSummary');

if (nodeOptions) {

var nodeSummaryCombo = CreateSummaryCombo(strRevision);

nodeOptions.parentNode.insertBefore(nodeSummaryCombo, nodeOptions.nextSibling);

}

}

}

};

if (window.location.href.indexOf("action=edit") != -1 ||

window.location.href.indexOf("action=submit") != -1) {

addOnloadHook(AddExtras);

}

/*

*

*/