User:AFigureOfBlue/dazzle/report.js

//Still underconstruction // if( typeof( DazzleConfig ) == 'undefined' ) { DazzleConfig = {}; } if( typeof( DazzleConfig.edit_summary ) == 'undefined' ) { DazzleConfig.edit_summary = ") (Dazzle!"; }

$(function{ var wgNamespaceNumber = mw.config.get('wgNamespaceNumber'); var wgCanonicalSpecialPageName = mw.config.get('wgCanonicalSpecialPageName'); if(typeof addDazzleLink === 'undefined') return; if (wgNamespaceNumber == 2 || wgNamespaceNumber == 3 || wgCanonicalSpecialPageName == "Contributions" || wgCanonicalSpecialPageName == "Log") { addDazzleLink('javascript:dazzle_report_start;', 'Report', 'dz-report', 'Report user to administrators'); } });

function dazzle_report_start{ var floatbox = new Floatbox("Report " + userpage_of + " to admins", "Grey"); set_status("Loading..."); var floatform = floatbox.create_form;

var optionslist = floatbox.form_append("select"); optionslist.id = "dazzle_report_options"; var option_aiv = add_child(optionslist, "option", "Vandalism"); option_aiv.selected = "selected"; //var option_ew = add_child(optionslist, "option", "Edit warring"); //var option_ew = add_child(optionslist, "option", "Improper username"); var full_aiv_reason = " Reason for requesting block:  Vandalism after final recent warning  Persistent spamming after warnings  Account belongs to a blocked user who is evading the block (specify the username in the text field below)  Major violation of the biographies of living people policy after warnings  Creation of inappropriate pages after warnings  Attacks against other users  Other/additional reason ";

floatbox.form_append("br");

var presubmit = floatbox.form_append("div"); presubmit.id = "floatbox-presubmit"; presubmit.innerHTML = full_aiv_reason;

optionslist.onchange = function{ var newform = document.createElement("div"); switch (optionslist.selectedIndex) { case 0: //Vandalism newform.innerHTML = full_aiv_reason; break; case 1: //Edit warring break; case 2: //Username break; } id("floatbox-presubmit").parentNode.replaceChild(newform, id("floatbox-presubmit")); newform.id = "floatbox-presubmit"; };

var submitbutton = floatbox.form_input("button", "submit"); submitbutton.value = "Submit"; set_status("Awaiting input..."); submitbutton.onclick = function{ set_status("Editing..."); switch (optionslist.selectedIndex) { case 0: //Vandalism var reportText = "\n* "; if(userpage_of.match(/(\d{1,3}\.){4}/)) { reportText += " - "; } else { reportText += " - "; }   if (id("vand_reason_afterRecent").checked) { reportText += id("vand_reason_afterRecent").value + ". "; }   if (id("vand_reason_spam").checked) { reportText += id("vand_reason_spam").value + ". "; }   if (id("vand_reason_blocked").checked) { reportText += id("vand_reason_blocked").value + ". "; }   if (id("vand_reason_badpages").checked) { reportText += id("vand_reason_badpages").value + ". "; }   if (id("vand_reason_attack").checked) { reportText += id("vand_reason_attack").value + ". "; }   if (id("vand_reason_BLP").checked) { reportText += id("vand_reason_BLP").value + ". "; }   if (id("vand_reason_txt").value) { reportText += id("vand_reason_txt").value + ". "; }   reportText += "~"; floatbox.mainbox.removeChild(floatform); add_child(floatbox.mainbox, "p", "Editing pages... please wait. The page will reload once editing is complete.");

var token = query("action=query&prop=info&intoken=edit&titles=User:Drilnoth/Sanbox_3&format=xml"); token.oncomplete(function{    var edittoken = token.results("TagAttr", "page", "edittoken");     var starttimestamp = token.results("TagAttr", "page", "starttimestamp");     var edit = query("action=edit&title=Wikipedia:Administrator_intervention_against_vandalism&section=2&notminor=notminor&token=" + enc(edittoken) + "&summary=" + enc("Reporting " + userpage_of + "" + DazzleConfig.edit_summary) + "&appendtext=" + enc(reportText) + "&starttimestamp=" + starttimestamp + "&format=xml");     edit.oncomplete(function{ if (edit.results("Error")) { alert("An error occurred and the edit was not made: " + edit.results("Error", "info") + "."); }     dazzle_prod_complete; });   });

break; case 1: //Edit warring break; case 2: //Username break; } }; } function dazzle_report_complete{ set_status("Done!"); location.reload; } //