Skip to content
This repository
Browse code

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

  • Loading branch information...
commit 6acb64fae4b7f68189c93e25edfba48932d4511a 1 parent 42c86a2
theopolisme theopolisme authored

Showing 2 changed files with 25 additions and 14 deletions. Show diff stats Hide diff stats

  1. +0 14 src/afch.js
  2. +25 0 src/core.js
14 src/afch.js
@@ -6,21 +6,7 @@
6 6 ////////////////////////////////////////////
7 7 //<nowiki>
8 8 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)) {
9   - importScript('User:Timotheus Canens/displaymessage.js');
10 9 var afchelper_baseurl = mw.config.get('wgServer') + '/w/index.php?action=raw&ctype=text/javascript&title=MediaWiki:Gadget-afchelper.js';
11 10 importScriptURI(afchelper_baseurl + '/core.js');
12   - var afcHelper_advert = ' ([[WP:AFCH|AFCH]])';
13   - var pagetext = '';
14   - var usertalkpage = '';
15   -
16   - if (wgPageName.indexOf('Wikipedia:Articles_for_creation/Redirects') !== -1) {
17   - importScriptURI(afchelper_baseurl + '/redirects.js');
18   - } else if ((wgPageName.indexOf('Wikipedia:Articles_for_creation/') !== -1)
19   - || (wgPageName.indexOf('Wikipedia_talk:Articles_for_creation/') !== -1)
20   - || (wgPageName.indexOf('User:') !== -1)
21   - || (wgPageName.indexOf('User_talk:') !== -1)
22   - ){
23   - importScriptURI(afchelper_baseurl + '/submissions.js');
24   - }
25 11 }
26 12 //</nowiki>
25 src/core.js
... ... @@ -1,5 +1,29 @@
1 1 //<nowiki>
2 2 // Script should be located at [[MediaWiki:Gadget-afchelper.js/core.js]]
  3 +
  4 +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)) {
  5 + importScript('User:Timotheus Canens/displaymessage.js');
  6 + var afchelper_baseurl = mw.config.get('wgServer') + '/w/index.php?action=raw&ctype=text/javascript&title=MediaWiki:Gadget-afchelper.js';
  7 +
  8 + var afcHelper_advert = ' ([[WP:AFCH|AFCH]])';
  9 + var pagetext = '';
  10 + var usertalkpage = '';
  11 +
  12 + if (wgPageName.indexOf('Wikipedia:Articles_for_creation/Redirects') !== -1) {
  13 + importScriptURI(afchelper_baseurl + '/redirects.js');
  14 + } else if (wgPageName.indexOf('Wikipedia:Files_for_upload') !== -1) {
  15 + importScriptURI(afchelper_baseurl + '/ffu.js');
  16 + } else if ((wgPageName.indexOf('Wikipedia:Articles_for_creation/') !== -1)
  17 + || (wgPageName.indexOf('Wikipedia_talk:Articles_for_creation/') !== -1)
  18 + || (wgPageName.indexOf('User:') !== -1)
  19 + || (wgPageName.indexOf('User_talk:') !== -1)
  20 + ){
  21 + importScriptURI(afchelper_baseurl + '/submissions.js');
  22 + }
  23 +} else {
  24 + throw "Stopped AFCH from loading on a non-AFC page."; // stop the rest of the script from loading
  25 +}
  26 +
3 27 function afcHelper_generateSelect(title, options, onchange) {
4 28 var text = '<select name="' + title + '" id="' + title + '" ';
5 29 if (onchange !== null) text += 'onchange = "' + onchange + '" ';
@@ -8,6 +32,7 @@ function afcHelper_generateSelect(title, options, onchange) {
8 32 var o = options[i];
9 33 text += '<option value="' + afcHelper_escapeHtmlChars(o.value) + '" ';
10 34 if (o.selected) text += 'selected="selected" ';
  35 + if (o.disabled) text += 'disabled ';
11 36 text += '>' + o.label + '</option>';
12 37 }
13 38 text += "</select>";

0 comments on commit 6acb64f

Please sign in to comment.
Something went wrong with that request. Please try again.