Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Hotfix: Enable support for gadget-based initialization (#88)

  • Loading branch information...
commit 6acb64fae4b7f68189c93e25edfba48932d4511a 1 parent 42c86a2
Theo Patt theopolisme authored
Showing with 25 additions and 14 deletions.
  1. +0 −14 src/afch.js
  2. +25 −0 src/core.js
14 src/afch.js
View
@@ -6,21 +6,7 @@
////////////////////////////////////////////
//<nowiki>
if ((wgPageName.indexOf('Wikipedia:Articles_for_creation') !== -1) || (wgPageName.indexOf('Wikipedia_talk:Articles_for_creation') !== -1) || (wgPageName.indexOf('Wikipedia:Files_for_upload') !== -1) || (wgPageName.indexOf('User:*') !== -1)) {
- 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';
importScriptURI(afchelper_baseurl + '/core.js');
- var afcHelper_advert = ' ([[WP:AFCH|AFCH]])';
- var pagetext = '';
- var usertalkpage = '';
-
- if (wgPageName.indexOf('Wikipedia:Articles_for_creation/Redirects') !== -1) {
- importScriptURI(afchelper_baseurl + '/redirects.js');
- } else if ((wgPageName.indexOf('Wikipedia:Articles_for_creation/') !== -1)
- || (wgPageName.indexOf('Wikipedia_talk:Articles_for_creation/') !== -1)
- || (wgPageName.indexOf('User:') !== -1)
- || (wgPageName.indexOf('User_talk:') !== -1)
- ){
- importScriptURI(afchelper_baseurl + '/submissions.js');
- }
}
//</nowiki>
25 src/core.js
View
@@ -1,5 +1,29 @@
//<nowiki>
// Script should be located at [[MediaWiki:Gadget-afchelper.js/core.js]]
+
+if ((wgPageName.indexOf('Wikipedia:Articles_for_creation') !== -1) || (wgPageName.indexOf('Wikipedia_talk:Articles_for_creation') !== -1) || (wgPageName.indexOf('Wikipedia:Files_for_upload') !== -1) || (wgPageName.indexOf('User:*') !== -1)) {
+ 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';
+
+ var afcHelper_advert = ' ([[WP:AFCH|AFCH]])';
+ var pagetext = '';
+ var usertalkpage = '';
+
+ if (wgPageName.indexOf('Wikipedia:Articles_for_creation/Redirects') !== -1) {
+ importScriptURI(afchelper_baseurl + '/redirects.js');
+ } else if (wgPageName.indexOf('Wikipedia:Files_for_upload') !== -1) {
+ importScriptURI(afchelper_baseurl + '/ffu.js');
+ } else if ((wgPageName.indexOf('Wikipedia:Articles_for_creation/') !== -1)
+ || (wgPageName.indexOf('Wikipedia_talk:Articles_for_creation/') !== -1)
+ || (wgPageName.indexOf('User:') !== -1)
+ || (wgPageName.indexOf('User_talk:') !== -1)
+ ){
+ importScriptURI(afchelper_baseurl + '/submissions.js');
+ }
+} else {
+ throw "Stopped AFCH from loading on a non-AFC page."; // stop the rest of the script from loading
+}
+
function afcHelper_generateSelect(title, options, onchange) {
var text = '<select name="' + title + '" id="' + title + '" ';
if (onchange !== null) text += 'onchange = "' + onchange + '" ';
@@ -8,6 +32,7 @@ function afcHelper_generateSelect(title, options, onchange) {
var o = options[i];
text += '<option value="' + afcHelper_escapeHtmlChars(o.value) + '" ';
if (o.selected) text += 'selected="selected" ';
+ if (o.disabled) text += 'disabled ';
text += '>' + o.label + '</option>';
}
text += "</select>";
Please sign in to comment.
Something went wrong with that request. Please try again.