Permalink
Browse files

New release 11 September 2013

This new release includes a brand new API framework that makes saving
edits up to 5 times faster! Your CSD nominations will now automatically
be logged to your Twinkle log; additionally, you can use a new button
to postpone G13 speedy deletion via AFCH. Plus, CSD tagging
improvements, logs of bug fixes, styling wizardry, and a loading
screen.
  • Loading branch information...
theopolisme committed Sep 11, 2013
2 parents cd26d7c + ebb202f commit b4ff542f24bff86a0af4f5c4b3087283b09848f0
Showing with 296 additions and 206 deletions.
  1. +3 −3 src/MediaWiki:Gadget-afchelper.css
  2. +70 −55 src/core.js
  3. +3 −2 src/ffu.js
  4. +220 −146 src/submissions.js
@@ -40,9 +40,9 @@ div#afcHelper_betanotice {
.afcHelper_button:active {
border: 1px solid #aaa;
border-bottom: 1px solid #888;
-moz-box-shadow: inset 0 0 3px 3px #888;
-webkit-box-shadow: inset 0 0 3px 3px#888;
box-shadow: inset 0 0 3px 3px #888;
-moz-box-shadow: inset 0 0 2px 2px #888;
-webkit-box-shadow: inset 0 0 2px 2px #888;
box-shadow: inset 0 0 2px 2px #888;
}
#afcHelper_accept_button {
View
@@ -9,7 +9,7 @@ var pagetext = '';
var usertalkpage = '';
// CSS stylesheet
importStylesheetURI( mw.config.get( 'wgServer' ) + '/w/index.php?action=raw&ctype=text/css&title=MediaWiki:Gadget-afchelper.css');
importStylesheetURI(mw.config.get('wgServer') + '/w/index.php?action=raw&ctype=text/css&title=MediaWiki:Gadget-afchelper.css');
if (wgPageName.indexOf('Wikipedia:Articles_for_creation/Redirects') !== -1) {
importScriptURI(afchelper_baseurl + '/redirects.js');
@@ -23,10 +23,13 @@ if (wgPageName.indexOf('Wikipedia:Articles_for_creation/Redirects') !== -1) {
}
// This enables the beta notice for all uses except the official gadget
if (afchelper_baseurl.indexOf('MediaWiki:Gadget-afchelper.js') == -1)
BETA = true;
if (afchelper_baseurl.indexOf('MediaWiki:'+'Gadget-afchelper.js' /* hack to stop upload scripts from find+replacing this */) == -1)
var BETA = true;
else
BETA = false;
var BETA = false;
// Manually load mw.api() only if we're not using the gadget...with the gadget, it's already a dependency
if (BETA) mw.loader.load('mediawiki.api');
function afcHelper_generateSelect(title, options, onchange) {
var text = '<select name="' + title + '" id="' + title + '" ';
@@ -47,75 +50,87 @@ function afcHelper_escapeHtmlChars(original) {
return original.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
}
function afcHelper_getPageText(title, show, redirectcheck) {
function afcHelper_getPageText(title, show, redirectcheck, timestamp) {
if (show) document.getElementById('afcHelper_status').innerHTML += '<li id="afcHelper_get' + escape(title) + '">Getting <a href="' + wgArticlePath.replace("$1", encodeURI(title)) + '" title="' + title + '">' + title + '</a></li>';
var req = sajax_init_object();
var params = "action=query&prop=revisions&rvprop=content&format=json&indexpageids=1&titles=" + encodeURIComponent(title);
if(redirectcheck)
params += "&redirects=";
req.open("POST", wgScriptPath + "/api.php", false);
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
req.setRequestHeader("Content-length", params.length);
req.setRequestHeader("Connection", "close");
req.send(params);
var response = eval('(' + req.responseText + ')');
request = {
'action': 'query',
'prop': 'revisions',
'rvprop': 'content',
'format': 'json',
'indexpageids': true,
'titles' : title
};
if (redirectcheck) request.redirects = true;
if (timestamp) request.rvprop = 'content|timestamp';
var response = JSON.parse(
$.ajax({
url: mw.util.wikiScript('api'),
data: request,
async: false
})
.responseText
);
pageid = response['query']['pageids'][0];
if (pageid === "-1") {
if (show) document.getElementById('afcHelper_get' + escape(title)).innerHTML = 'The page <a class="new" href="' + wgArticlePath.replace("$1", encodeURI(title)) + '" title="' + title + '">' + title + '</a> does not exist';
delete req;
return '';
}
var newtext = response['query']['pages'][pageid]['revisions'][0]['*'];
if(redirectcheck && response['query']['redirects'] /* If &redirects if specified but there is no redirect, this stops us from getting an error */){
var oldusername = response['query']['redirects'][0]['from'];
var newusername = response['query']['redirects'][0]['to'];
if ((typeof(oldusername) !== 'undefined') && (typeof(newusername) !== 'undefined') && (oldusername != newusername)){
usertalkpage = newusername;
if (show){
document.getElementById('afcHelper_status').innerHTML += '<li id="afcHelper_get' + escape(title) + '">Got <a href="' + wgArticlePath.replace("$1", encodeURI(title)) + '" title="' + newusername + '">' + newusername + '</a> (page was renamed from ' + oldusername + ')</li>';
}
}else{
redirectcheck = false;
if (redirectcheck && response['query']['redirects'] /* If &redirects if specified but there is no redirect, this stops us from getting an error */){
var oldusername = response['query']['redirects'][0]['from'];
var newusername = response['query']['redirects'][0]['to'];
if ((typeof(oldusername) !== 'undefined') && (typeof(newusername) !== 'undefined') && (oldusername != newusername)){
usertalkpage = newusername;
if (show) {
document.getElementById('afcHelper_status').innerHTML += '<li id="afcHelper_get' + escape(title) + '">Got <a href="' + wgArticlePath.replace("$1", encodeURI(title)) + '" title="' + newusername + '">' + newusername + '</a> (page was renamed from ' + oldusername + ')</li>';
}
}else{
redirectcheck = false;
}
delete req;
} else {
redirectcheck = false;
}
} else {
redirectcheck = false;
}
if (show && !redirectcheck) document.getElementById('afcHelper_status').innerHTML += '<li id="afcHelper_get' + escape(title) + '">Got <a href="' + wgArticlePath.replace("$1", encodeURI(title)) + '" title="' + title + '">' + title + '</a></li>';
return newtext;
if (!timestamp) return newtext;
else return {'pagetext':newtext,'timestamp':response['query']['pages'][pageid]['revisions'][0]['timestamp']}
}
function afcHelper_editPage(title, newtext, summary, createonly) {
var token = mw.user.tokens.get('editToken');
var edittoken = mw.user.tokens.get('editToken');
summary += afcHelper_advert;
$("#afcHelper_finished_wrapper").html('<span id="afcHelper_AJAX_finished_' + afcHelper_AJAXnumber + '" style="display:none">' + $("#afcHelper_finished_wrapper").html() + '</span>');
var func_id = afcHelper_AJAXnumber;
afcHelper_AJAXnumber++;
document.getElementById('afcHelper_status').innerHTML += '<li id="afcHelper_edit' + escape(title) + '">Editing <a href="' + wgArticlePath.replace("$1", encodeURI(title)) + '" title="' + title + '">' + title + '</a></li>';
var req = sajax_init_object();
var params = "action=edit&format=json&token=" + encodeURIComponent(token) + "&title=" + encodeURIComponent(title) + "&text=" + encodeURIComponent(newtext) + "&notminor=1&summary=" + encodeURIComponent(summary);
if (createonly) params += "&createonly=1";
url = wgScriptPath + "/api.php";
req.open("POST", url, true);
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
req.setRequestHeader("Content-length", params.length);
req.setRequestHeader("Connection", "close");
req.onreadystatechange = function() {
if (req.readyState === 4 && req.status === 200) {
response = eval('(' + req.responseText + ')');
try {
if (response['edit']['result'] === "Success") {
request = {
'action': 'edit',
'title': title,
'text': newtext,
'summary': summary,
'token': edittoken
}
if (createonly) request.createonly = true;
var api = new mw.Api();
api.post(request)
.done(function ( data ) {
if ( data && data.edit && data.edit.result && data.edit.result == 'Success' ) {
document.getElementById('afcHelper_edit' + escape(title)).innerHTML = 'Saved <a href="' + wgArticlePath.replace("$1", encodeURI(title)) + '" title="' + title + '">' + title + '</a>';
} else {
document.getElementById('afcHelper_edit' + escape(title)).innerHTML = '<div class="notice"><b>Edit failed on <a href="' + wgArticlePath.replace("$1", encodeURI(title)) + '" title="' + title + '">' + title + '</a></b></div>. Error info:' + response['error']['code'] + ' : ' + response['error']['info'];
document.getElementById('afcHelper_edit' + escape(title)).innerHTML = '<div style="color:red"><b>Edit failed on <a href="' + wgArticlePath.replace("$1", encodeURI(title)) + '" title="' + title + '">' + title + '</a></b></div>. Error info:' + error;
}
} catch (err) {
document.getElementById('afcHelper_edit' + escape(title)).innerHTML = '<div class="notice"><b>Edit failed on <a href="' + wgArticlePath.replace("$1", encodeURI(title)) + '" title="' + title + '">' + title + '</a></b></div>';
}
$("#afcHelper_AJAX_finished_" + func_id).css("display", '');
delete req;
}
};
req.send(params);
}
} )
.fail( function ( error ) {
if (createonly && error == "articleexists")
document.getElementById('afcHelper_edit' + escape(title)).innerHTML = '<div style="color:red"><b>Edit failed on <a href="' + wgArticlePath.replace("$1", encodeURI(title)) + '" title="' + title + '">' + title + '</a></b></div>. Error info: The article already exists!';
else
document.getElementById('afcHelper_edit' + escape(title)).innerHTML = '<div style="color:red"><b>Edit failed on <a href="' + wgArticlePath.replace("$1", encodeURI(title)) + '" title="' + title + '">' + title + '</a></b></div>. Error info:' + error;
})
.always( function () {
$("#afcHelper_AJAX_finished_" + func_id).css("display", '');
});
}
//</nowiki>
View
@@ -96,13 +96,14 @@ function afcHelper_ffu_init() {
value: 'decline'
}, {
label: 'Set on hold',
selected: true,
selected: ((afcHelper_ffuSections[k].indexOf('on hold') == -1) ? true : false),
value: 'hold'
}, {
label: 'Comment',
value: 'comment'
}, {
label: 'None/ignore this URL',
selected: ((afcHelper_ffuSections[k].indexOf('on hold') == -1) ? false : true),
value: 'none'
}];
} else {
@@ -319,7 +320,7 @@ function afcHelper_ffu_performActions() {
// update [[Wikipedia:Files for upload/recent]]
if (sub_m.recent == true) {
recentpagetext = afcHelper_getPageText('Wikipedia:Files_for_upload/recent', true)
var newentry = "\|File:" + sub_m.to + " | " + (typeof sub_m.recenttext !== "undefined" ? sub_m.recenttext : "") + "\n";
var newentry = "\| File:" + sub_m.to + " | " + (typeof sub_m.recenttext !== "undefined" ? sub_m.recenttext : "") + "\n";
var lastentry = recentpagetext.toLowerCase().lastIndexOf("| file:");
var firstentry = recentpagetext.toLowerCase().indexOf("| file:");
recentpagetext = recentpagetext.substring(0, lastentry);
Oops, something went wrong.

0 comments on commit b4ff542

Please sign in to comment.