User:C886553/global.js

importScriptPage('User:Ajraddatz/VDA.js', 'community') /*** Followed by 100 zeroes is amazing. ***/ /*

VDA-full beta

Notes to developers: VDA.enable.log("I am a jelly doughnut");
 * Use "return VDA;" or "return VDA.LIBRARY_NAME;" at the end of non-utility functions to chain VDA functions, like so:
 * JSLint (jslint.org) should be run here regularly

Known issues:
 * When viewing a page OTHER than the newest history, rollback will not work

If you notice that this tool is breaking in a disruptive manner, add ?vdadisable=1 or &vdadisable=1 (shouldn't be hard to decide) to your URL to disable VDA and contact us at vda.wikia.com immediately.

Also remember: VDA may not be accepted on all wikis. If the community on a particular wiki decides that VDA should not be used, by all means disable it. If you're unsure, ask another user.



jQuery.extend({URLEncode:function(c){var o=;var x=0;c=c.toString;var r=/(^[a-zA-Z0-9_.]*)/; while(x1 && m[1]!=){o+=m[1];x+=m[1].length;    }else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16);    o+='%'+(h.length<2?'0':)+h.toUpperCase;}x++;}}return o;}, URLDecode:function(s){var o=s;var binVal,t;var r=/(%[^%]{2})/;  while((m=r.exec(o))!=null && m.length>1 && m[1]!=){b=parseInt(m[1].substr(1),16);  t=String.fromCharCode(b);o=o.replace(m[1],t);}return o;} });

importScriptURI("http://trentrichardson.com/Impromptu/scripts/jquery-impromptu.3.0.min.js");

var VDA = { colors: { light: "yellow", dark: "black" },   personalize: function (settings) { VDA.colors = settings; },   util: { // Trim string as in PHP trim: function (str) { return str.replace(/^\s+|\s+$/g, ""); },       // Convert CSV to array csv: function (input) { if ((typeof input) === "string") { input = input.split(","); for (var i = 0; i < input.length; i++) { input[i] = VDA.util.trim(input[i]); }           } else if ((typeof input) !== "array") { input = [input]; }           return input; },       // URL GET as associative array getUrlVars: function { var vars = {}; location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {               vars[$.URLDecode(key)] = $.URLDecode(value);            }); return vars; },       // A quick wikilinking function for usernames userLink: function (name) { return "" + name + ""; },       // Prevent IE caching results randomString: function { var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; var rstring = ''; // We can increase the 10, but at a cost of performance for (var i = 0; i < 10; i++) { var rnum = Math.floor(Math.random * chars.length); rstring += chars.charAt(rnum); }           return rstring; },       // Make an array of users from the history page; useful for revert scripts hist2array: function { if (wgAction !== "history") { return VDA.error("VDA.util.hist2array called on non-history page"); }           var arr = []; $("ul#pagehistory li").each(function {                var oldid = $(this).find("input + a").attr("href");                oldid = oldid.substring(oldid.lastIndexOf("=") + 1);                var username = $(this).find("span.history-user > a").html;                arr.push({ username: username, oldid: oldid });           });            return arr; },       // Get some info necessary for performing a rollback rollback_info: function (histarr) { var username = ""; for (var i = 0; i < histarr.length; i++) { if (i === 0) { username = histarr[i].username; } else if (histarr[i].username !== username) { return {old: histarr[i], username: username}; }           }            return false; // This will only be reached when all the edits were made by the same user }   },    // Logging function entries: [], log: function (str) { if (!!str) { var d = new Date; VDA.entries.push(d + " Log entry: " + str); }       return VDA; },   warn: function (str) { if (!!str) { var d = new Date; VDA.entries.push(d + " Warning: " + str); }       return VDA; },   error: function (str) { if (!!str) { var d = new Date; VDA.entries.push(d + " Error: " + str); }       return VDA; },   show_entries: function  { $.prompt('' + VDA.entries.join("\n") + ' ', { buttons: { OK: true } }); },   // Functions to enable/disable VDA enabled: true, enable: function { VDA.enabled = true; return VDA.log("VDA enabled"); },   disable: function  { VDA.enabled = false; return VDA.log("VDA disabled"); },   // Libraries libraries: { // VDA RV ///////////////////////////////////////////////////////////////// RV: { rollback: function { var histarr = VDA.util.hist2array; var rv = VDA.util.rollback_info(histarr); $.prompt({                   state0: {                        html: "What best describes the edits which you are reverting?",                        buttons: {                            "Vandalism": "v",                            "Good faith": "gf",                            "Other": "g"                        },                        submit: function (v, m, f) {                            switch (v) {                                case "v":                                    VDA.RV.revert(rv.old.oldid, "Reverted vandalism by " + VDA.util.userLink(rv.username) + " back to revision " + rv.old.oldid + " by " + VDA.util.userLink(rv.old.username) + ") (VDA");                                    $.prompt.close;                                    break;                                case "gf":                                    $.prompt.goToState("state1");                                    break; case "g": $.prompt.goToState("state2"); break; }                           return false; }                   },                    state1: { html: 'You are reverting good faith edits. Briefly summarize why you reverted the edits in the box below. Your entry will be used in the VDA edit summary. ', buttons: { Done: true },                       submit: function (v, m, f) { if (f.message) { return VDA.RV.revert(rv.old.oldid, "Reverted good faith edits by " + VDA.util.userLink(rv.username) + " back to revision " + rv.old.oldid + " by " + VDA.util.userLink(rv.old.username) + ": " + f.message + ") (VDA"); }                           return false; }                   },                    state2: { html: 'You are reverting edits. Briefly summarize why you reverted the edits in the box below. Your entry will be used in the VDA edit summary. ', buttons: { Done: true },                       submit: function (v, m, f) { if (f.message) { return VDA.RV.revert(rv.old.oldid, "Reverted edits by " + VDA.util.userLink(rv.username) + " back to revision " + rv.old.oldid + " by " + VDA.util.userLink(rv.old.username) + ": " + f.message + ") (VDA"); }                           return false; }                   }                });            },            revertTo: function (i) {                var histarr = VDA.util.hist2array;                var rv = histarr[i];                $.prompt({ state0: { html: "What best describes the edits which you are reverting?", buttons: { "Vandalism": "v", "Good faith": "gf", "Other": "g" },                       submit: function (v, m, f) { switch (v) { case "v": VDA.RV.revert(rv.oldid, "Reverted vandalism back to revision " + rv.oldid + " by " + VDA.util.userLink(rv.username) + ") (VDA"); $.prompt.close; break; case "gf": $.prompt.goToState("state1"); break; case "g": $.prompt.goToState("state2"); break; }                           return false; }                   },                    state1: { html: 'You are reverting good faith edits. Briefly summarize why you reverted the edits in the box below. Your entry will be used in the VDA edit summary. ', buttons: { Done: true },                       submit: function (v, m, f) { if (f.message) { return VDA.RV.revert(rv.oldid, "Reverted good faith edits back to revision " + rv.oldid + " by " + VDA.util.userLink(rv.username) + ": " + f.message + ") (VDA"); }                           return false; }                   },                    state2: { html: 'You are reverting edits. Briefly summarize why you reverted the edits in the box below. Your entry will be used in the VDA edit summary. ', buttons: { Done: true },                       submit: function (v, m, f) { if (f.message) { return VDA.RV.revert(rv.oldid, "Reverted edits back to revision " + rv.oldid + " by " + VDA.util.userLink(rv.username) + ": " + f.message + ") (VDA"); }                           return false; }                   }                });            },            revert: function (oldid, msg) {                $("body").append($(' Loading, please wait... ')).fadeIn(100);                location.href = wgScript + "?title=" + $.URLEncode(wgTitle) + "&action=edit&oldid=" + oldid + "&vdarv=1&vdamsg=" + $.URLEncode(msg);            },            init: function  {                if (wgAction === "history") {                    var content = ' Hover over a revision below and press Revert to revert back to that revision.';                    if (!$_GET.offset) {                        content += '

Rollback'; }                   content += " "; $(content).insertAfter("#mw-history-searchform"); $("ul#pagehistory > li").each(function (i) {                       var content = ' (none) ';                        if (i !== 0) {                            content = 'Revert';                        }                        $(this).append($(' ' + content + ' '));                    }); } else if ($_GET.vdarv) { $("body").append($(' Loading, please wait... '));                   $("#wpSummary").val($.URLDecode($_GET.vdamsg).replace(/\+/g," ")); $("#editform").submit; }               return VDA.RV; }       },        // END VDA RV ///////////////////////////////////////////////////////////////// // VDA JFF ///////////////////////////////////////////////////////////////// JFF: { tips: [ // Developers: Go ahead, have some fun, add some stuffs "Listen up, everyone! I am a very shy and introverted person.", "I'm so humble, I'm the humblest person in the world.", "I never make misteaks.", "Ajraddatz is a noob. There, I said it!", "I am very proud to have lost the habit of the use of unnecessary words in my speech.", "The cool thing about this sentence is that you never really know that it's useless until it's already too late.", "My grammer and splelling is impeckable!", "I lost the game.", "100% of the population thinks that this sentence is useless", 'Read the following sentence out loud: "This for is as how do you off keep were an as idiot has busy that for the twenty good five not seconds how." Now read every other word, starting at "this."', "CATS: All your base are belong to us. You have no chance to survive make your time.", "The lack of money is the root of all evil. -- Mark Twain", "Camping is nature's way of promoting the motel business. -- Dave Barry", "We believe that electricity exists, because the electric company keeps sending us bills for it, but we cannot figure out how it travels inside wires. -- Dave Barry" ],           counter: 0, init: function { var totd = VDA.JFF.tips[Math.floor(Math.random * (VDA.JFF.tips.length + 1))]; $(document).click(function {                    if (++VDA.JFF.counter === 10) {                        $.prompt("Tip of the day: " + totd, { buttons: { OK: true } });                        VDA.log("VDA JFF has just revealed a pearl of wisdom (!)");                    }                }); return VDA.JFF; }       }        // END VDA JFF ///////////////////////////////////////////////////////////////// },   loaded_libs: [], load: function (str) { if (VDA.libraries[str]) { VDA[str] = VDA.libraries[str]; VDA.loaded_libs.push(str); return VDA.log("VDA library '" + str + "' loaded successfully"); } else { return VDA.warn("Unknown library '" + str + "' not loaded"); }   },    // Run VDA init: function { for (var i = 0; i < VDA.loaded_libs.length; i++) { if (typeof VDA[VDA.loaded_libs[i]].init === "function") { VDA[VDA.loaded_libs[i]].init; } else { VDA.warn("No init function found for library '" + VDA.loaded_libs[i] + "'."); }       }        // These variables aren't needed any more; they only make sense before the initializing call delete VDA.libraries; delete VDA.loaded_libs; delete VDA.load; return VDA.log("VDA.init called"); } };

var $_GET = VDA.util.getUrlVars;

// This uses jQuery's $(document).ready function; if jQuery is not installed, use addOnloadHook $(function {    if (VDA.enabled && (!(VDA.util.getUrlVars.vdadisable))) {        VDA.init;    } else {        VDA.log("VDA.init not called (VDA has been manually disabled)");    } });

VDA.load("RV"); VDA.load("JFF");