Permalink
Browse files

RELEASE: 25 September 2013

The 25 September release brings with it a brand new interface to add
WikiProject templates to talk pages, widespread CSD logging, integrated
[[User:Ohconfucius/script/formatgeneral.js|formatgeneral.js]] cleanup,
automatic deletion of redirects in the way of acceptance (admins only),
bug fixes, speed improvements, and unicorns.
  • Loading branch information...
1 parent b4cb0f3 commit 344930aeb4953b6ea417cf1ffb3ce4098d3ec52a @theopolisme theopolisme committed Sep 25, 2013
Showing with 519 additions and 290 deletions.
  1. +5 −0 README.md
  2. +5 −1 STYLE_GUIDE.md
  3. +43 −29 src/MediaWiki:Gadget-afchelper.css
  4. +87 −13 src/core.js
  5. +33 −32 src/ffu.js
  6. +30 −30 src/redirects.js
  7. +316 −185 src/submissions.js
View
@@ -20,5 +20,10 @@ To import a script, add it to [your common.js page](http://en.wikipedia.org/wiki
The only exception to this is for the `master` script: to use it, you just need to check the box next to "Yet Another AFC Helper Script" in [your preferences](http://en.wikipedia.org/wiki/Special:Preferences#mw-prefsection-gadgets).
+If the script isn't showing up (for `beta` and `develop`), try clearing your cache first.
+
## License
The script is licensed under the [Creative Commons Attribution-ShareAlike 3.0 Unported License](http://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License) and the [GNU Free Documentation License](http://en.wikipedia.org/wiki/Wikipedia:Text_of_the_GNU_Free_Documentation_License).
+
+## Chat
+If you need help or want to discuss something directly, we have a IRC located at freenode.net #wikipedia-en-afc (Webchat: https://webchat.freenode.net/?channels=wikipedia-en-afc ).
View
@@ -4,5 +4,9 @@ Style Guide
## CSS
If vendor specific CSS rules are added, please add as many as possible.
-### Other stuff
+## Variables
+Variables containing a regular expression should contain at the end of the variable name a "_re".
+
+
+## Other stuff
Buttons and links prompting the user for more information should include ellipsis (HTML code `…`).
@@ -12,42 +12,46 @@ div#afcHelper_betanotice {
font-style: italic;
}
+input[type=text]:hover { /* Small shadow on textarea hover */
+ box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.3) inset;
+}
+
.afcHelper_button {
- background-repeat: repeat-x;
- border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
- display: inline-block;
- padding: 2px 5px;
- font-size: 13px;
- line-height: 18px;
- text-align: center;
- vertical-align: middle;
- cursor: pointer;
- border-width: 1px;
- border-style: solid;
- -moz-border-top-colors: none;
- -moz-border-right-colors: none;
- -moz-border-bottom-colors: none;
- -moz-border-left-colors: none;
- border-image: none;
- border-radius: 4px 4px 4px 4px;
- box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.2) inset, 0px 1px 2px rgba(0, 0, 0, 0.05);
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
- font-weight: normal;
- margin: 0px;
- margin-right: 2px;
+ background-repeat: repeat-x;
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
+ display: inline-block;
+ padding: 2px 5px;
+ font-size: 13px;
+ line-height: 18px;
+ text-align: center;
+ vertical-align: middle;
+ cursor: pointer;
+ border-width: 1px;
+ border-style: solid;
+ -moz-border-top-colors: none;
+ -moz-border-right-colors: none;
+ -moz-border-bottom-colors: none;
+ -moz-border-left-colors: none;
+ border-image: none;
+ border-radius: 4px 4px 4px 4px;
+ box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.2) inset, 0px 1px 2px rgba(0, 0, 0, 0.05);
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+ font-weight: normal;
+ margin: 0px;
+ margin-right: 2px;
}
.afcHelper_button:active {
- border: 1px solid #aaa;
- border-bottom: 1px solid #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;
+ border: 1px solid #aaa;
+ border-bottom: 1px solid #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 {
- background-color: #adfcad;
- background-image: -moz-linear-gradient(center top, #B8FFB8, #A7F3A7);
+ background-color: #adfcad;
+ background-image: -moz-linear-gradient(center top, #B8FFB8, #A7F3A7);
}
#afcHelper_decline_button, .afcHelper_button.decline {
@@ -77,3 +81,13 @@ div#afcHelper_betanotice {
#afcHelper_g13_button {
background-color: #ff3333;
}
+
+.afcHelper_expand {
+ height: 1em;
+ width: 50%;
+ padding: 3px;
+}
+
+#afcHelper_extra select {
+ vertical-align: middle;
+}
View
@@ -1,6 +1,10 @@
//<nowiki>
// Script should be located at [[MediaWiki:Gadget-afchelper.js/core.js]]
+function jqEsc(expression) {
+ return expression.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~]/g, '\\$&');
+}
+
importScript('User:Timotheus Canens/displaymessage.js');
var afchelper_baseurl = mw.config.get('wgServer') + '/w/index.php?action=raw&ctype=text/javascript&title=MediaWiki:Gadget-afchelper.js';
@@ -28,8 +32,13 @@ if (afchelper_baseurl.indexOf('MediaWiki:'+'Gadget-afchelper.js' /* hack to stop
else
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');
+if (BETA) {
+ // Manually load mw.api() and chosen only if we're not using the gadget...with the gadget, they are already dependencies
+ mw.loader.load('mediawiki.api');
+ mw.loader.load('jquery.chosen');
+ // Set the summary to denote that we're using a "beta" version of the script
+ var afcHelper_advert = ' ([[WP:AFCH|AFCH]] beta)';
+}
function afcHelper_generateSelect(title, options, onchange) {
var text = '<select name="' + title + '" id="' + title + '" ';
@@ -46,14 +55,24 @@ function afcHelper_generateSelect(title, options, onchange) {
return text;
}
+function afcHelper_generateChzn(title,placeholder,optionsdict) {
+ // given a dictionary of "title","value"
+ var text = '<select data-placeholder="' + placeholder + '" id="' + title + '" style="width:350px;" class="chzn-select" multiple>';
+ $.each(optionsdict, function(k, v){
+ text += '<option value="' + afcHelper_escapeHtmlChars(v) + '" >' + k + '</option>';
+ });
+ text += "</select>";
+ return text;
+}
+
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, 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>';
+ if (show) $('#afcHelper_status').html($('#afcHelper_status').html() + '<li id="afcHelper_get' + jqEsc(title) + '">Getting <a href="' + wgArticlePath.replace("$1", encodeURI(title)) + '" title="' + title + '">' + title + '</a></li>');
- request = {
+ var request = {
'action': 'query',
'prop': 'revisions',
'rvprop': 'content',
@@ -75,7 +94,7 @@ function afcHelper_getPageText(title, show, redirectcheck, timestamp) {
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';
+ if (show) $('#afcHelper_get' +jqEsc(title)).html('The page <a class="new" href="' + wgArticlePath.replace("$1", encodeURI(title)) + '" title="' + title + '">' + title + '</a> does not exist');
return '';
}
var newtext = response['query']['pages'][pageid]['revisions'][0]['*'];
@@ -85,27 +104,82 @@ function afcHelper_getPageText(title, show, redirectcheck, timestamp) {
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>';
+ $('#afcHelper_status').html($('#afcHelper_status').html() + '<li id="afcHelper_get' + jqEsc(title) + '">Got <a href="' + wgArticlePath.replace("$1", encodeURI(title)) + '" title="' + newusername + '">' + newusername + '</a> (page was renamed from ' + oldusername + ')</li>');
}
} 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>';
+ if (show && !redirectcheck) $('#afcHelper_status').html($('#afcHelper_status').html() + '<li id="afcHelper_get' + jqEsc(title) + '">Got <a href="' + wgArticlePath.replace("$1", encodeURI(title)) + '" title="' + title + '">' + title + '</a></li>');
if (!timestamp) return newtext;
else return {'pagetext':newtext,'timestamp':response['query']['pages'][pageid]['revisions'][0]['timestamp']}
}
+function afcHelper_deletePage(title,reason) {
+ // First set up the status log
+ $("#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_delete' + escape(title) + '">Deleting <a href="' + wgArticlePath.replace("$1", encodeURI(title)) + '" title="' + title + '">' + title + '</a></li>';
+
+ // Then get the deletion token
+ var tokenrequest = {
+ 'action': 'query',
+ 'prop': 'info',
+ 'format': 'json',
+ 'intoken': 'delete',
+ 'indexpageids': true,
+ 'titles' : title
+ };
+ var tokenresponse = JSON.parse(
+ $.ajax({
+ url: mw.util.wikiScript('api'),
+ data: tokenrequest,
+ async: false
+ })
+ .responseText
+ );
+
+ pageid = tokenresponse['query']['pageids'][0];
+ token = tokenresponse['query']['pages'][pageid]['deletetoken'];
+
+ // And finally delete the page
+ var delrequest = {
+ 'action': 'delete',
+ 'reason': reason + afcHelper_advert,
+ 'format': 'json',
+ 'token': token,
+ 'title' : title
+ }
+ var delresponse = JSON.parse(
+ $.ajax({
+ type: "POST",
+ url: mw.util.wikiScript('api'),
+ data: delrequest,
+ async: false
+ })
+ .responseText
+ );
+
+ if (delresponse && delresponse.delete) {
+ document.getElementById('afcHelper_delete' + escape(title)).innerHTML = 'Deleted <a href="' + wgArticlePath.replace("$1", encodeURI(title)) + '" title="' + title + '">' + title + '</a>';
+ return true;
+ } else {
+ document.getElementById('afcHelper_delete' + escape(title)).innerHTML = '<div style="color:red"><b>Deletion failed on <a href="' + wgArticlePath.replace("$1", encodeURI(title)) + '" title="' + title + '">' + title + '</a></b></div>. Error info:' + error;
+ return false;
+ }
+}
+
function afcHelper_editPage(title, newtext, summary, createonly) {
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>';
- request = {
+ $('#afcHelper_status').html($('#afcHelper_status').html() + '<li id="afcHelper_edit' + jqEsc(title) + '">Editing <a href="' + wgArticlePath.replace("$1", encodeURI(title)) + '" title="' + title + '">' + title + '</a></li>');
+ var request = {
'action': 'edit',
'title': title,
'text': newtext,
@@ -118,16 +192,16 @@ function afcHelper_editPage(title, newtext, summary, createonly) {
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>';
+ $('#afcHelper_edit' + jqEsc(title)).html('Saved <a href="' + wgArticlePath.replace("$1", encodeURI(title)) + '" title="' + title + '">' + title + '</a>');
} 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;
+ $('#afcHelper_edit' + jqEsc(title)).html('<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']);
}
} )
.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!';
+ $('#afcHelper_edit' + jqEsc(title)).html('<div class="notice"><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;
+ $('#afcHelper_edit' + jqEsc(title)).html('<div class="notice"><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", '');
Oops, something went wrong.

0 comments on commit 344930a

Please sign in to comment.