User:Cvolton/common.js

/*	based on the CPA newspaper uploader because I'm lazy http://archives.clubpenguinwiki.info/wiki/User:Michaelbrabec/common.js	this is still in a state where it doesn't make any sense whatsoever

$("#p-tb ul").prepend('New Windows 10 Build (beta) '); if (mw.config.get("wgTitle") == "NewWindows10" && mw.config.get("wgNamespaceNumber") == -1) { $("#firstHeading span").html("NewWindows10"); $buildpage = {}; $buildpage.fn = {}; $buildpage.data = {}; $buildpage.errors = [];

/* functions */

// get current build information $buildpage.fn.create = function (a) { var buildnumber = a.buildtag.split(".")[2]; var date = a.buildtag.split(".")[5].split("-")[0]; var finaldate = ["20", date.slice(0, 2), "-", date.slice(2,4), "-", date.slice(4,6)].join(''); var releasedate = [a.link.split("/")[4], "-", a.link.split("/")[5], "-", a.link.split("/")[6]].join(''); var pageContent = "\n"+ "\n"+ "Windows 10 build "+buildnumber+" was released on "+releasedate+" to Insiders in the "+a.ring+" Ring.\n"+ "\n"+ "==Gallery==\n"+ "\n"+ "== External Links ==\n"+ "* ["+a.link+" Official announcement]\n"; var epic = {}; epic.token = mw.user.tokens.get("editToken"); $.ajax({           //url: mw.util.wikiScript("api") + "?action=edit&format=json&title=User:"+mw.config.get("wgUserName")+"/sandbox/a1&text=" + encodeURIComponent(pageContent) + "&summary=" + encodeURIComponent("test"),            type: "POST",            data: epic,            success: function(data) {                console.log(data);                console.log("Success!");            },            error: function(data) {                if (data.status == 756) {                    console.error("The request was too long. Please copy the content in the textarea and use it for creating the page");                } else {                    console.error("An error occured while attempting to publish the page");                }            }        }).always(function {            $("#buildupload-result").val(pageContent);            //$("#buildupload dt").html('' + a.buildtag + ''); $("#buildupload dt").html('' + a.buildtag + ''); });   }

// main execution $buildpage.fn.exe = function { // data from a different page var version = $("#b-version").val, buildtag = $("#b-buildtag").val, link = $("#b-link").val, tcb = $("#b-tcb").val, ring = $("#b-ring").val, timebomb = $("#b-timebomb").val; $buildpage.fn.create({               version: version,                buildtag: buildtag,                timebomb: timebomb,            ring: ring,            tcb: tcb,            link: link

});   }

/* interface */

$("#mw-content-text").html(       ' \n' +        '\t New Windows 10 Build (beta) \n' +        '\tVersion:  \n' +        '\tBuildtag:  \n' +        '\tTimebomb:  \n' +        '\Ring:  \n' +        '\tAnnouncement link:  \n' +        '\tTCB link:  \n' +        '\t\n' +        '\t Output \n' +        '\tIt is likely that the page\'s content will be too long. If that\'s the case, once loading is done, copy the following content to the page:\n' + '\t<dt></dt></dl>\n' + '\t<textarea rows="20" id="buildupload-result"> \n' + ' '   );

$("#buildupload-start").click(function {       $buildpage.fn.exe;    });

/* interface css */

mw.util.addCSS(       '#buildupload {\n' +        '\tbackground: #fafafa;\n' +        '\tborder: 1px solid #ccc;\n' +        '\tpadding: 4px;\n' +        '\tborder-radius: 10px;\n' +        '}\n' +        'section#buildupload h3 {\n' +        '\tmargin-top: 0;\n' +        '}\n' +        '#buildupload textarea {\n' +        '\tresize: none;\n' +        '}\n' +        '#buildupload dl, #buildupload dt {\n' +        '\tmargin: 0;\n' +        '\tpadding-left: 5;\n' +        '}\n' +        '#buildupload dt:not(:empty) {\n' +        '\tmargin: 3px 0;\n' +        '}\n'    ); }