User:Quarl/userwarn.js

// User:Quarl/autowarn.js - application for warning bad users.

// Interface for selecting the best warning. Parses a user's contribution // history and presents checkboxes to select which edits to reference in the // warning.

// (Version 1, a more basic implementation, is archived at // User:Quarl/autowarn_basic.js)

// depends: wikipage.js, wikiedit.js, wikitabs.js // enhanced by: advanced_sig.js

// quarl 2006-02-10 version 2 - contribution parsing and such

//

/* TODO

add warn links to history

add warn tab if relevantUser

insert an opening div as with redirector

option for referencing pages vs diffs. default page.

if reqWithPage:  reference first page; then bullets for others if altWithPage and pages: reference first page; then bullets for others

extra parameters

*/

autowarn = new Object;

autowarn.warnings = [ { heading: "Generic testing or vandalism", warnings: [ [ "selftest", "Thanks for reverting your test; use sandbox", {altWithPage:"selftest-n"} ], [ "test1", "Your test worked, and has been reverted", {altWithPage:"test-n"} ], [ "test2", "Stop adding nonsense", {altWithPage:"test2-n"} ], [ "test3", "Stop vandalizing, or face block", {altWithPage:"test3-n"} ], [ "test4", "Last warning, will be blocked", {altWithPage:"test4-n"} ], [ "test4im", "This is your ONLY WARNING, will be blocked" ], [ "test5", "You have been temporarily BLOCKED", {altWithPage:"test5-n"} ], [ "test6", "You have been BLOCKED for repeated vandalism" ], [ "bv", "Blatant vandal" ] ]},   { heading: "Testing - removing content", warnings: [ [ "test1a", "Please don't remove content" ], [ "test2a", "Stop removing content" ] ]},   { heading: "Blanking", warnings: [ [ "blank2", "Don't blank; blanks are harmful" ], [ "blank3", "Stop blanking, or face block" ], [ "blank4", "Last warning, will be blocked" ], [ "blank5", "You have been BLOCKED for blanking" ] ]},   { heading: "Page move vandalism", warnings: [ [ "test2m", "Please do not move to nonsensical" ] ]},   { heading: "Non-notable", warnings: [ [ "nn-test", "Welcome; edits considered non-notable and reverted" ] ]},   { heading: "Bad-faith errors", warnings: [ [ "verror2", "Please stop deliberately introducing errors" ], [ "verror3", "Please stop, or face block" ], [ "verror4", "Last warning, will be blocked" ] ]},   { heading: "Spam", warnings: [ [ "spam1", "Please don't add commercial links" ], [ "spam2", "Please stop spamming" ], [ "spam3", "Last warning, will be blocked" ], [ "spam4", "You have been BLOCKED for spamming" ], ] },   { heading: "3RR", warnings: [ [ "3RR", "Please don't revert more than 3 times in 24 hours" ], [ "3RR2", "Danger of violating 3RR; may be blocked" ], [ "3RR3", "You have been temporarily BLOCKED for violation of 3RR" ] ]},   { heading: "Civility", warnings: [ [ "civil1", "Please be civil; no personal attacks" ], [ "civil2", "Please be civil! No edit wars!" ]         ]},    { heading: "Copyright violation", warnings: [ [ "nothanks", "Please, no copyrighted work", {reqWithPage:"1"} ], [ "nothanks-sd", "Please, no copyright violation of URL - speedy deletion", {reqWithPage:"pg", params:["url"]} ] ]},   { heading: "Miscellaneous", warnings: [ [ "newvoter", "New voter: Your vote may be discounted", {reqWithPage:"1"} ], [ "tilde", "Please sign your posts on Talk pages" ], [ "wr", "Please do not remove warnings" ], ]}   ];

autowarn.run = function {

}

// autowarn.warn = function(template) { //    var pagenames = prompt("Vandalism to which article(s) (separate using &&)?"); //    if (typeof pagenames != 'string') return;

//    wikiPage.getEditorAsync(autowarn._edit, template, pagenames); // }

// autowarn._englishJoin = function(words) { //    if (words.length == 0) { //        return ''; //    } else if (words.length == 1) { //        return words[0]; //    } else if (words.length == 2) { //        return words[0] + ' and ' + words[1]; //    } else { //        words[words.length-1] = 'and ' + words[words.length-1]; //        return words.join(', '); //    } // }

// autowarn._splitPageNames = function(s) { //    var words = s.split('&&'); //    var pages = []; //    for (var i in words) { //        var word = trimspaces(words[i]); //        if (!word) continue; //        word = word.replace(/^\[\[/, ''); //        word = word.replace(/\]\]$/, ''); //        pages.push( + word + ); //    } //     return pages; // }

// autowarn._edit = function(editor, template, pagenames) { //    if (typeof(template) != 'string') { alert("autowarn Internal error 5f95d195-b1c8-4f7e-b751-740230b1926a"); return; }

//    var pagesw = autowarn._splitPageNames(pagenames); //    var pages = autowarn._englishJoin(pagesw);

//    var text = ' ~\n';

//    if (pages) { //        text = ('This message concerns the ' + (pagesw.length==1?'page':'pages') + ' ' + //                 pages + '.  ' + text); //    } //     text = '\n\n' + text;

//    var summary = "Warning "; //    if (pages) { //        summary += ", concerning " + pages; //    }

//    // if (editor.refuseCreate) return; //    editor.wpTextbox1 = trim_lines(editor.wpTextbox1) + text; //    editor.wpSummary = summary; //    editor.submit; // }

autowarn._load = function { if (wikiDoc.relevantUser) { autowarn.tab = wikitabs.addTab('Warn', 'javascript:autowarn.run', 'ca-autowarn', 'Warn a mis-behaving user'); } }

addOnloadHook(autowarn._load);

//

//