User:Cvolton/common.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/*
based on the CPA newspaper uploader because I'm lazy
http://archives.clubpenguinwiki.info/wiki/User:Misabr/common.js
this is still in a state where it doesn't make any sense whatsoever
*/
$("#p-tb ul").prepend('<li id="t-buildupload"><a href="/wiki/Special:NewWindows10" title="New Windows 10 Build (beta)">New Windows 10 Build <span style="font-size: 80%; color: #08afbd; font-weight: bold;">(beta)</span></a></li>');
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 = "{{Infobox Windows build\n"+
"|version = 10 "+a.version+"\n"+
"|buildtag = "+ a.buildtag + "\n"+
"|arch = x86, x64, ARM64\n"+
"|sku = Education<br>Education N<br>Enterprise<br>Enterprise N<br>Enterprise for Remote Sessions<br>Home<br>Home N<br>Home China<br>Home Single Language<br>Pro<br>Pro N<br>Pro Education<br>Pro Education N<br>Pro for Workstations<br>Pro N for Workstations<br>Pro Single Language<br>IoT Enterprise\n"+
"|compiled = "+finaldate+"\n"+
"|timebomb = "+a.timebomb+"\n"+
"|rivals = {{Rivals|TCB="+a.tcb+"}}\n"+
"|winver = "+buildnumber+"-Winver.png\n"+
"|image = "+buildnumber+"-Desktop.png\n"+
"}}\n"+
"\n"+
"'''Windows 10 build "+buildnumber+"''' was released on "+releasedate+" to Insiders in the "+a.ring+" Ring.\n"+
"\n"+
"==Gallery==\n"+
"<gallery>\n"+
"Win8boot.png|Boot Screen\n"+
"18342-Login1.png|Login screen\n"+
"18342-Login2.png|Login screen\n"+
buildnumber+"-Start.png|Start Menu\n"+
"10159-ShuttingDown.png|Shutdown Screen\n"+
"</gallery>\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 href="'+location.origin+'/wiki/User:'+mw.config.get("wgUserName")+'/sandbox/a1">' + a.buildtag + '</a>');
$("#buildupload dt").html('<a href="'+location.origin+'/index.php?title=Windows 10 build '+buildnumber+'&action=edit">' + a.buildtag + '</a>');
});
}
// 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(
'<section id="buildupload">\n' +
'\t<h3>New Windows 10 Build (beta)</h3>\n' +
'\tVersion: <input type="text" id="b-version" value="version 1903" /><br />\n' +
'\tBuildtag: <input type="text" id="b-buildtag" value="10.0.18348.1.19h1_release.190226-1407" /><br />\n' +
'\tTimebomb: <input type="text" id="b-timebomb" value="2019-07-05"/><br />\n' +
'\Ring: <input type="text" id="b-ring" value="Fast"/><br />\n' +
'\tAnnouncement link: <input type="text" id="b-link" value="https://blogs.windows.com/windowsexperience/2019/03/01/announcing-windows-10-insider-preview-build-18348/"/><br />\n' +
'\tTCB link: <input type="text" id="b-tcb" value="https://thecollectionbook.info/builds/windows/build/4366"/><br />\n' +
'\t<input type="button" id="buildupload-start" value="start" />\n' +
'\t<h3>Output</h3>\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<dl><dt></dt></dl>\n' +
'\t<textarea rows="20" id="buildupload-result"></textarea>\n' +
'</section>'
);
$("#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'
);
}