diff --git a/README.md b/README.md index e07e2ce..665dd06 100644 --- a/README.md +++ b/README.md @@ -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 ). diff --git a/STYLE_GUIDE.md b/STYLE_GUIDE.md index 9b0f2ea..8d3e261 100644 --- a/STYLE_GUIDE.md +++ b/STYLE_GUIDE.md @@ -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 `…`). diff --git a/src/MediaWiki:Gadget-afchelper.css b/src/MediaWiki:Gadget-afchelper.css index 3204d05..1779047 100644 --- a/src/MediaWiki:Gadget-afchelper.css +++ b/src/MediaWiki:Gadget-afchelper.css @@ -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; +} diff --git a/src/core.js b/src/core.js index 639e56c..774ed85 100644 --- a/src/core.js +++ b/src/core.js @@ -1,6 +1,10 @@ // // 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 = '"; + return text; +} + function afcHelper_escapeHtmlChars(original) { return original.replace(/&/g, "&").replace(//g, ">").replace(/"/g, """).replace(/'/g, "'"); } function afcHelper_getPageText(title, show, redirectcheck, timestamp) { - if (show) document.getElementById('afcHelper_status').innerHTML += '
  • Getting ' + title + '
  • '; + if (show) $('#afcHelper_status').html($('#afcHelper_status').html() + '
  • Getting ' + title + '
  • '); - 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 ' + title + ' does not exist'; + if (show) $('#afcHelper_get' +jqEsc(title)).html('The page ' + title + ' does not exist'); return ''; } var newtext = response['query']['pages'][pageid]['revisions'][0]['*']; @@ -85,7 +104,7 @@ 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 += '
  • Got ' + newusername + ' (page was renamed from ' + oldusername + ')
  • '; + $('#afcHelper_status').html($('#afcHelper_status').html() + '
  • Got ' + newusername + ' (page was renamed from ' + oldusername + ')
  • '); } } else { redirectcheck = false; @@ -93,19 +112,74 @@ function afcHelper_getPageText(title, show, redirectcheck, timestamp) { } else { redirectcheck = false; } - if (show && !redirectcheck) document.getElementById('afcHelper_status').innerHTML += '
  • Got ' + title + '
  • '; + if (show && !redirectcheck) $('#afcHelper_status').html($('#afcHelper_status').html() + '
  • Got ' + title + '
  • '); 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(''); + var func_id = afcHelper_AJAXnumber; + afcHelper_AJAXnumber++; + document.getElementById('afcHelper_status').innerHTML += '
  • Deleting ' + title + '
  • '; + + // 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 ' + title + ''; + return true; + } else { + document.getElementById('afcHelper_delete' + escape(title)).innerHTML = '
    Deletion failed on ' + title + '
    . 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(''); var func_id = afcHelper_AJAXnumber; afcHelper_AJAXnumber++; - document.getElementById('afcHelper_status').innerHTML += '
  • Editing ' + title + '
  • '; - request = { + $('#afcHelper_status').html($('#afcHelper_status').html() + '
  • Editing ' + title + '
  • '); + 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 ' + title + ''; + $('#afcHelper_edit' + jqEsc(title)).html('Saved ' + title + ''); } else { - document.getElementById('afcHelper_edit' + escape(title)).innerHTML = '
    Edit failed on ' + title + '
    . Error info:' + error; + $('#afcHelper_edit' + jqEsc(title)).html('
    Edit failed on ' + title + '
    . Error info:' + response['error']['code'] + ' : ' + response['error']['info']); } } ) .fail( function ( error ) { if (createonly && error == "articleexists") - document.getElementById('afcHelper_edit' + escape(title)).innerHTML = '
    Edit failed on ' + title + '
    . Error info: The article already exists!'; + $('#afcHelper_edit' + jqEsc(title)).html('
    Edit failed on ' + title + '
    . Error info: The article already exists!'); else - document.getElementById('afcHelper_edit' + escape(title)).innerHTML = '
    Edit failed on ' + title + '
    . Error info:' + error; + $('#afcHelper_edit' + jqEsc(title)).html('
    Edit failed on ' + title + '
    . Error info: ' + error); }) .always( function () { $("#afcHelper_AJAX_finished_" + func_id).css("display", ''); diff --git a/src/ffu.js b/src/ffu.js index 3ad4f0e..c991b80 100644 --- a/src/ffu.js +++ b/src/ffu.js @@ -1,6 +1,5 @@ // // Script should be located at [[MediaWiki:Gadget-afchelper.js/ffu.js]] -// WARNING: dysfunctional and in development var afcHelper_ffuPageName = wgPageName.replace(/_/g, ' '); var afcHelper_ffuSubmissions = new Array(); var afcHelper_ffuSections = new Array(); @@ -142,20 +141,20 @@ function afcHelper_ffu_init() { } function afcHelper_ffu_onActionChange(id) { - var extra = document.getElementById("afcHelper_ffu_extra_" + id); - var selectValue = document.getElementById("afcHelper_ffu_action_" + id).value; - if (selectValue == 'none') extra.innerHTML = ''; + var extra = $("#afcHelper_ffu_extra_" + id); + var selectValue = $("#afcHelper_ffu_action_" + id).val(); + if (selectValue == 'none') extra.html(''); else if (selectValue == 'accept') { - extra.innerHTML = '' + + extra.html('' + '
    ' + '' + '
    ' + '
    ' + '
    ' + '
    ' + - '
    ' + ''; + '
    ' + ''); // !todo Only show the recenttext option if `recent` is checked } else if (selectValue == 'decline') { - extra.innerHTML = '' + afcHelper_generateSelect('afcHelper_ffu_decline_' + id, [{ + extra.html('' + afcHelper_generateSelect('afcHelper_ffu_decline_' + id, [{ label: 'Not a FFU request', value: 'notffu' }, { @@ -201,20 +200,23 @@ function afcHelper_ffu_onActionChange(id) { label: 'Custom - reason below', selected: true, value: 'custom' - }]) + '
    ' + '' + '
    ' + ''; + }]) + '
    ' + '' + '
    ' + ''); } else if (selectValue == 'hold') { - extra.innerHTML = '' + afcHelper_generateSelect('afcHelper_ffu_hold_' + id, [{ + extra.html('' + afcHelper_generateSelect('afcHelper_ffu_hold_' + id, [{ label: 'On hold (generic)', value: 'h' }, { label: 'Article is at AfD', value: 'afd' + }, { + label: 'Non-free file for use in still-pending AfC submission', + value: 'afc' }, { label: 'No URL', value: 'nourl' - }]) + '
    ' + '' + '
    ' + ''; + }]) + '
    ' + '' + '
    ' + ''); } else if (selectValue == 'comment') { - extra.innerHTML = '' + afcHelper_generateSelect('afcHelper_ffu_prefmtcomment_' + id, [{ + extra.html('' + afcHelper_generateSelect('afcHelper_ffu_prefmtcomment_' + id, [{ label: 'No license', value: 'license' }, { @@ -230,9 +232,9 @@ function afcHelper_ffu_onActionChange(id) { label: 'Custom - comment below', selected: true, value: 'custom' - }]); - extra.innerHTML += '
    ' + ''; - extra.innerHTML += '
    ' + ''; + }])); + extra.html(extra.html() + '
    ' + ''); + extra.html(extra.html() + '
    ' + ''); } } @@ -240,24 +242,23 @@ function afcHelper_ffu_performActions() { // Load all of the data. for (var i = 0; i < afcHelper_Submissions.length; i++) { if (afcHelper_Submissions[i].type == 'ffu') { - var action = document.getElementById("afcHelper_ffu_action_" + i).value; + var action = $("#afcHelper_ffu_action_" + i).val(); afcHelper_Submissions[i].action = action; if (action == 'none') continue; if (action == 'accept') { - afcHelper_Submissions[i].to = document.getElementById("afcHelper_ffu_to_" + i).value; - afcHelper_Submissions[i].talkpage = document.getElementById("afcHelper_ffu_filetalkpage_" + i).checked; - afcHelper_Submissions[i].append = document.getElementById("afcHelper_ffu_append_" + i).value; - afcHelper_Submissions[i].recent = document.getElementById("afcHelper_ffu_recent_" + i).checked; - afcHelper_Submissions[i].recenttext = document.getElementById("afcHelper_ffu_recenttext_" + i).value; + afcHelper_Submissions[i].to = $("#afcHelper_ffu_to_" + i).val(); + afcHelper_Submissions[i].talkpage = $("#afcHelper_ffu_filetalkpage_" + i).attr("checked"); afcHelper_Submissions[i].append = $("#afcHelper_ffu_append_" + i).val(); + afcHelper_Submissions[i].recent = $("#afcHelper_ffu_recent_" + i).attr("checked"); + afcHelper_Submissions[i].recenttext = $("#afcHelper_ffu_recenttext_" + i).val(); } else if (action == 'decline') { - afcHelper_Submissions[i].reason = document.getElementById('afcHelper_ffu_decline_' + i).value; + afcHelper_Submissions[i].reason = $('#afcHelper_ffu_decline_' + i).val(); } else if (action == 'hold') { - afcHelper_Submissions[i].holdrat = document.getElementById('afcHelper_ffu_hold_' + i).value; + afcHelper_Submissions[i].holdrat = $('#afcHelper_ffu_hold_' + i).val(); } else if (action == 'comment') { - afcHelper_Submissions[i].prefmtcomment = document.getElementById("afcHelper_ffu_prefmtcomment_" + i).value; + afcHelper_Submissions[i].prefmtcomment = $("#afcHelper_ffu_prefmtcomment_" + i).val(); } - afcHelper_Submissions[i].comment = document.getElementById("afcHelper_ffu_comment_" + i).value; - afcHelper_Submissions[i].notify = document.getElementById("afcHelper_ffu_notify_" + i).checked; + afcHelper_Submissions[i].comment = $("#afcHelper_ffu_comment_" + i).val(); + afcHelper_Submissions[i].notify = $("#afcHelper_ffu_notify_" + i).attr("checked"); } } // Data loaded. Show progress screen and get WP:FFU page text. @@ -265,7 +266,7 @@ function afcHelper_ffu_performActions() { $("html, body").animate({ scrollTop: 0 }, "slow"); // Takes up back up to the top for the displayMessage() dialog, __slowly__ - document.getElementById('afcHelper_finish').innerHTML += ''; + $('afcHelper_finish').innerHTML += ''; pagetext = afcHelper_getPageText(afcHelper_ffuPageName, true); var totalaccept = 0; var totaldecline = 0; @@ -275,7 +276,7 @@ function afcHelper_ffu_performActions() { var sub = afcHelper_ffuSubmissions[i]; if (pagetext.indexOf(afcHelper_ffuSections[sub.section]) == -1) { // Someone has modified the section in the mean time. Skip. - document.getElementById('afcHelper_status').innerHTML += '
  • Skipping ' + sub.title + ': Cannot find section. Perhaps it was modified in the mean time?
  • '; + $('#afcHelper_status').html($('#afcHelper_status').html() + '
  • Skipping ' + sub.title + ': Cannot find section. Perhaps it was modified in the mean time?
  • '); continue; } var origtext = afcHelper_ffuSections[sub.section]; @@ -302,7 +303,7 @@ function afcHelper_ffu_performActions() { else userpagetext += '\n== Your request at \[\[WP:FFU|Files for upload\]\] ==\n\{\{subst:ffu talk|file=' + sub_m.to + '\}\} \~\~\~\~\n'; afcHelper_editPage('User talk:' + requestinguser, userpagetext, 'Notifying user about [[WP:FFU|FFU]] request', false); } else { - document.getElementById('afcHelper_status').innerHTML += '
  • Unable to notify user for ' + sub.title + ': Could not find a username to notify!
  • '; + $('#afcHelper_status').html($('#afcHelper_status').html() += '
  • Unable to notify user for ' + sub.title + ': Could not find a username to notify!
  • '); } } if (sub_m.action == 'accept') { @@ -330,7 +331,7 @@ function afcHelper_ffu_performActions() { } else if (sub_m.action == 'decline') { var header = text.match(/==[^=]*==/)[0]; if (sub_m.reason == 'custom' && sub_m.comment == '') { - document.getElementById('afcHelper_status').innerHTML += '
  • Skipping ' + sub_m.title + ': No decline reason specified.
  • '; + $('#afcHelper_status').html($('#afcHelper_status').html() + '
  • Skipping ' + sub_m.title + ': No decline reason specified.
  • '); continue; } text = header + "\n\{\{subst:ffu d\}\}\n" + text.substring(header.length); @@ -374,7 +375,7 @@ function afcHelper_ffu_performActions() { // And now finally update the WP:FFU page afcHelper_editPage(afcHelper_ffuPageName, pagetext, summary, false); - document.getElementById('afcHelper_finished_main').style.display = ''; + $('#afcHelper_finished_main').css("display", ""); } function add_review_links() { @@ -398,7 +399,7 @@ function add_review_links() { editSectionLink.appendChild(reviewlink); editSectionLink.innerHTML = editSectionLink.innerHTML + "] " + editSectionContents; reviewlink.onclick = (function() { - reviewlink.innerHTML = "Reviewing requests..."; + $(reviewlink).html("Reviewing requests..."); afcHelper_ffu_init(); }); } else { @@ -407,7 +408,7 @@ function add_review_links() { }); $("#bodyContent [sectionIndex]").click((function() { $("#bodyContent [sectionIndex]").each(function(i) { - this.innerHTML = "Reviewing requests..."; + $(reviewlink).html("Reviewing requests..."); }); afcHelper_ffu_init(); })); diff --git a/src/redirects.js b/src/redirects.js index 271a135..27e09d6 100644 --- a/src/redirects.js +++ b/src/redirects.js @@ -166,14 +166,14 @@ function afcHelper_redirect_init() { } function afcHelper_redirect_onActionChange(id) { - var extra = document.getElementById("afcHelper_redirect_extra_" + id); - var selectValue = document.getElementById("afcHelper_redirect_action_" + id).value; - if (selectValue === 'none') extra.innerHTML = ''; + var extra = $("#afcHelper_redirect_extra_" + id); + var selectValue = $("#afcHelper_redirect_action_" + id).val(); + if (selectValue === 'none') extra.html(''); else if (selectValue === 'accept') { if (afcHelper_Submissions[id].type === 'redirect') { - extra.innerHTML = ''; - extra.innerHTML += ' '; - extra.innerHTML += '' + afcHelper_generateSelect('afcHelper_redirect_append_' + id, [{ + extra.html(extra.html() + ''); + extra.html(extra.html() + ' '); + extra.html(extra.html() + '' + afcHelper_generateSelect('afcHelper_redirect_append_' + id, [{ label: 'R from alternative name', value: 'R from alternative name' }, { @@ -198,16 +198,15 @@ function afcHelper_redirect_onActionChange(id) { label: 'None', selected: true, value: 'none' - }]); + }])); } else { - extra.innerHTML = ''; - extra.innerHTML += '' + ''; + extra.html(''); + extra.html(extra.html() + '' + ''); } - extra.innerHTML += '' + ''; + extra.html(extra.html() + '' + ''); } else if (selectValue === 'decline') { if (afcHelper_Submissions[id].type === 'redirect') { - extra.innerHTML = '' + afcHelper_generateSelect('afcHelper_redirect_decline_' + id, [{ - label: 'Already exists', + extra.html('' + afcHelper_generateSelect('afcHelper_redirect_decline_' + id, [{ label: 'Already exists', value: 'exists' }, { label: 'Blank request', @@ -225,9 +224,9 @@ function afcHelper_redirect_onActionChange(id) { label: 'Custom - reason below', selected: true, value: 'custom' - }]); + }])); } else { - extra.innerHTML = '' + afcHelper_generateSelect('afcHelper_redirect_decline_' + id, [{ + extra.html('' + afcHelper_generateSelect('afcHelper_redirect_decline_' + id, [{ label: 'Already exists', value: 'exists' }, { @@ -243,42 +242,43 @@ function afcHelper_redirect_onActionChange(id) { label: 'Custom - reason below', selected: true, value: 'custom' - }]); + }])); } - extra.innerHTML += '' + ''; + extra.html(extra.html() + '' + ''); + } } else { - extra.innerHTML = '' + ''; + extra.html(extra.html() + '' + ''); } } function afcHelper_redirect_performActions() { // Load all of the data. for (var i = 0; i < afcHelper_Submissions.length; i++) { - var action = document.getElementById("afcHelper_redirect_action_" + i).value; + var action = $("#afcHelper_redirect_action_" + i).val(); afcHelper_Submissions[i].action = action; if (action === 'none') continue; if (action === 'accept') { if (afcHelper_Submissions[i].type === 'redirect') { - afcHelper_Submissions[i].title = document.getElementById("afcHelper_redirect_from_" + i).value; - afcHelper_Submissions[i].to = document.getElementById("afcHelper_redirect_to_" + i).value; - afcHelper_Submissions[i].append = document.getElementById("afcHelper_redirect_append_" + i).value; + afcHelper_Submissions[i].title = $("#afcHelper_redirect_from_" + i).val(); + afcHelper_Submissions[i].to = $("#afcHelper_redirect_to_" + i).val(); + afcHelper_Submissions[i].append = $("#afcHelper_redirect_append_" + i).val(); if (afcHelper_Submissions[i].append === 'custom') { afcHelper_Submissions[i].append = prompt("Please enter the template to append for " + afcHelper_Submissions[i].title + ". Do not include the curly brackets."); } if (afcHelper_Submissions[i].append === 'none' || afcHelper_Submissions[i].append === null) afcHelper_Submissions[i].append = ''; else afcHelper_Submissions[i].append = '\{\{' + afcHelper_Submissions[i].append + '\}\}'; } else { - afcHelper_Submissions[i].title = document.getElementById("afcHelper_redirect_name_" + i).value; - afcHelper_Submissions[i].parent = document.getElementById("afcHelper_redirect_parent_" + i).value; + afcHelper_Submissions[i].title = $("#afcHelper_redirect_name_" + i).val(); + afcHelper_Submissions[i].parent = $("#afcHelper_redirect_parent_" + i).val(); } } else if (action === 'decline') { - afcHelper_Submissions[i].reason = document.getElementById('afcHelper_redirect_decline_' + i).value; + afcHelper_Submissions[i].reason = $('#afcHelper_redirect_decline_' + i).val(); } - afcHelper_Submissions[i].comment = document.getElementById("afcHelper_redirect_comment_" + i).value; + afcHelper_Submissions[i].comment = $("#afcHelper_redirect_comment_" + i).val(); } // Data loaded. Show progress screen and get WP:AFC/R page text. displayMessage(''); - document.getElementById('afcHelper_finish').innerHTML += ''; + $('#afcHelper_finish').html($('#afcHelper_finish').html() + ''); pagetext = afcHelper_getPageText(afcHelper_RedirectPageName, true); var totalaccept = 0; var totaldecline = 0; @@ -288,7 +288,7 @@ function afcHelper_redirect_performActions() { var sub = afcHelper_RedirectSubmissions[i]; if (pagetext.indexOf(afcHelper_RedirectSections[sub.section]) === -1) { // Someone has modified the section in the mean time. Skip. - document.getElementById('afcHelper_status').innerHTML += '
  • Skipping ' + sub.title + ': Cannot find section. Perhaps it was modified in the mean time?
  • '; + $('#afcHelper_status').html($('#afcHelper_status').html() + '
  • Skipping ' + sub.title + ': Cannot find section. Perhaps it was modified in the mean time?
  • '); continue; } var text = afcHelper_RedirectSections[sub.section]; @@ -316,7 +316,7 @@ function afcHelper_redirect_performActions() { if (reason === '') reason = sub.comment; else if (sub.comment !== '') reason = reason + ': ' + sub.comment; if (reason === '') { - document.getElementById('afcHelper_status').innerHTML += '
  • Skipping ' + sub.title + ': No decline reason specified.
  • '; + $('afcHelper_status').html($('#afcHelper_status').html() + '
  • Skipping ' + sub.title + ': No decline reason specified.
  • '); continue; } text = header + "\n\{\{AfC-c|d\}\}\n" + text.substring(header.length); @@ -356,7 +356,7 @@ function afcHelper_redirect_performActions() { if (reason === '') reason = redirect.comment; else if (redirect.comment !== '') reason = reason + ': ' + redirect.comment; if (reason === '') { - document.getElementById('afcHelper_status').innerHTML += '
  • Skipping ' + redirect.title + ': No decline reason specified.
  • '; + $('#afcHelper_status').html($('#afcHelper_status').html() + '
  • Skipping ' + redirect.title + ': No decline reason specified.
  • '); continue; } declinecomment += redirect.title + " → " + redirect.to + ": " + reason + "; "; @@ -405,7 +405,7 @@ function afcHelper_redirect_performActions() { } afcHelper_editPage(afcHelper_RedirectPageName, pagetext, summary, false); - document.getElementById('afcHelper_finished_main').style.display = ''; + $('afcHelper_finished_main').css("display", ''); } // Create portlet link diff --git a/src/submissions.js b/src/submissions.js index 82b9fac..ec2290c 100644 --- a/src/submissions.js +++ b/src/submissions.js @@ -4,7 +4,7 @@ var afcHelper_PageName = wgPageName.replace(/_/g, ' '); var afcHelper_AJAXnumber = 0; var afcHelper_submissionTitle = wgTitle.replace(/Articles for creation\//g, ''); var afcHelper_cache = {}; -var disambig_re = /Disambig|Mil-unit-dis|Hndis|Geodis|Numberdis/gi; +var disambig_re = /Disambig|Mil-unit-dis|Hndis|Geodis|Numberdis/i; var typetemplate_re = /\{\{\s*documentation\s*(?:\{\{[^\{\}]*\}\}|[^\}\{])*\}\}/gi; var afcHelper_reasonhash = [{ label: 'Duplicate articles', @@ -221,7 +221,7 @@ function afcHelper_init() { if (template_statuses === false || $.inArray("", template_statuses) != -1 || $.inArray("r", template_statuses) != -1 || $.inArray("d", template_statuses) != -1 || $.inArray("t", template_statuses) != -1) form += ''; - if (afcHelper_g13_eligible(afcHelper_PageName)) form += ' '; + if (afcHelper_g13_eligible(afcHelper_PageName)) form += ' '; form += '
    '; @@ -247,7 +247,7 @@ function afcHelper_prompt(type) { value: 'list' }]; // checking for ANY submission template (doesn't matter if declined) for the type parameter - // TODO: use boolean variables and add the disambiguation check to the accept stuff deepeer + // TODO: use boolean variables and add the disambiguation check to the accept stuff deeper var afcdab_re = /\{\{\s*afc submission\s*\|(?:\{\{[^\{\}]*\}\}|[^\}\{])*\|\s*type\s*=\s*dab\s*(?:\{\{[^\{\}]*\}\}|[^\}\{])*\}\}/i; var afctemplate_re = /\{\{\s*afc submission\s*\|(?:\{\{[^\{\}]*\}\}|[^\}\{])*\|\s*type\s*=\s*template\s*(?:\{\{[^\{\}]*\}\}|[^\}\{])*\}\}/i; if ((afcdab_re.test(pagetext)) || (disambig_re.test(pagetext))) { @@ -314,18 +314,29 @@ function afcHelper_prompt(type) { '
    '; var assessmentSelect = afcHelper_generateSelect("afcHelper_assessment", afcHelper_assessment, null); text += assessmentSelect; - text += '
    ' + - '
    ' + - '
    ' + - '
    ' + - '
    ' + + + // First load the list of wikiprojects and store it to afcHelper_wikiprojectindex + $.ajax({ + url: "//en.wikipedia.org/w/index.php?title=User:Theo%27s_Little_Bot/afchwikiproject.js&action=raw&ctype=text/javascript", + dataType: "json", + success: function (data) { afcHelper_wikiprojectindex = data; }, + async: false + }); + // Then generate a dynamic menu for them + var wikiprojectSelect = afcHelper_generateChzn("afcHelper_wikiproject_selection",'Start typing to filter the list of WikiProjects...',afcHelper_wikiprojectindex); + text += '

    ' + wikiprojectSelect; + text += '

    ' + + '

    ' + + '

    ' + + '
    ' + + '
    ' + '
    ' + - '