Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

morebits: remove Morebits.queryString #725

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions modules/friendlywelcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/

Twinkle.welcome = function friendlywelcome() {
if (Morebits.queryString.exists('friendlywelcome')) {
if (Morebits.queryString.get('friendlywelcome') === 'auto') {
if (mw.util.getParamValue('friendlywelcome')) {
if (mw.util.getParamValue('friendlywelcome') === 'auto') {
Twinkle.welcome.auto();
} else {
Twinkle.welcome.semiauto();
Expand All @@ -27,7 +27,7 @@ Twinkle.welcome = function friendlywelcome() {
};

Twinkle.welcome.auto = function() {
if (Morebits.queryString.get('action') !== 'edit') {
if (mw.util.getParamValue('action') !== 'edit') {
// userpage not empty, aborting auto-welcome
return;
}
Expand All @@ -40,7 +40,7 @@ Twinkle.welcome.semiauto = function() {
};

Twinkle.welcome.normal = function() {
if (Morebits.queryString.exists('diff')) {
if (mw.util.getParamValue('diff')) {
// check whether the contributors' talk pages exist yet
var $oList = $('#mw-diff-otitle2').find('span.mw-usertoollinks a.new:contains(talk)').first();
var $nList = $('#mw-diff-ntitle2').find('span.mw-usertoollinks a.new:contains(talk)').first();
Expand All @@ -64,7 +64,7 @@ Twinkle.welcome.normal = function() {
var oHref = $oList.attr('href');

var oWelcomeNode = welcomeNode.cloneNode(true);
oWelcomeNode.firstChild.setAttribute('href', oHref + '&' + Morebits.queryString.create({
oWelcomeNode.firstChild.setAttribute('href', oHref + '&' + $.param({
'friendlywelcome': Twinkle.getFriendlyPref('quickWelcomeMode') === 'auto' ? 'auto' : 'norm',
'vanarticle': Morebits.pageNameNorm
}));
Expand All @@ -76,7 +76,7 @@ Twinkle.welcome.normal = function() {
var nHref = $nList.attr('href');

var nWelcomeNode = welcomeNode.cloneNode(true);
nWelcomeNode.firstChild.setAttribute('href', nHref + '&' + Morebits.queryString.create({
nWelcomeNode.firstChild.setAttribute('href', nHref + '&' + $.param({
'friendlywelcome': Twinkle.getFriendlyPref('quickWelcomeMode') === 'auto' ? 'auto' : 'norm',
'vanarticle': Morebits.pageNameNorm
}));
Expand All @@ -98,7 +98,7 @@ Twinkle.welcome.welcomeUser = function welcomeUser() {

var params = {
value: Twinkle.getFriendlyPref('quickWelcomeTemplate'),
article: Morebits.queryString.exists('vanarticle') ? Morebits.queryString.get('vanarticle') : '',
article: mw.util.getParamValue('vanarticle') || '',
mode: 'auto'
};

Expand Down Expand Up @@ -148,7 +148,7 @@ Twinkle.welcome.callback = function friendlywelcomeCallback(uid) {
type: 'input',
name: 'article',
label: '* Linked article (if supported by template):',
value: Morebits.queryString.exists('vanarticle') ? Morebits.queryString.get('vanarticle') : '',
value: mw.util.getParamValue('vanarticle') || '',
tooltip: 'An article might be linked from within the welcome if the template supports it. Leave empty for no article to be linked. Templates that support a linked article are marked with an asterisk.'
});

Expand Down
10 changes: 5 additions & 5 deletions modules/twinklearv.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Twinkle.arv.callback.changeCategory = function (e) {
name: 'page',
label: 'Primary linked page: ',
tooltip: 'Leave blank to not link to the page in the report',
value: Morebits.queryString.exists('vanarticle') ? Morebits.queryString.get('vanarticle') : '',
value: mw.util.getParamValue('vanarticle') || '',
event: function(e) {
var value = e.target.value;
var root = e.target.form;
Expand All @@ -126,8 +126,8 @@ Twinkle.arv.callback.changeCategory = function (e) {
name: 'badid',
label: 'Revision ID for target page when vandalised: ',
tooltip: 'Leave blank for no diff link',
value: Morebits.queryString.exists('vanarticlerevid') ? Morebits.queryString.get('vanarticlerevid') : '',
disabled: !Morebits.queryString.exists('vanarticle'),
value: mw.util.getParamValue('vanarticlerevid') || '',
disabled: !mw.util.getParamValue('vanarticle'),
event: function(e) {
var value = e.target.value;
var root = e.target.form;
Expand All @@ -139,8 +139,8 @@ Twinkle.arv.callback.changeCategory = function (e) {
name: 'goodid',
label: 'Last good revision ID before vandalism of target page: ',
tooltip: 'Leave blank for diff link to previous revision',
value: Morebits.queryString.exists('vanarticlegoodrevid') ? Morebits.queryString.get('vanarticlegoodrevid') : '',
disabled: !Morebits.queryString.exists('vanarticle') || Morebits.queryString.exists('vanarticlerevid')
value: mw.util.getParamValue('vanarticlegoodrevid') || '',
disabled: !mw.util.getParamValue('vanarticle') || mw.util.getParamValue('vanarticlerevid')
});
work_area.append({
type: 'checkbox',
Expand Down
6 changes: 3 additions & 3 deletions modules/twinklebatchdelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ Twinkle.batchdelete.callback = function twinklebatchdeleteCallback() {

query.generator = 'allpages';
query.gaplimit = Twinkle.getPref('batchMax'); // the max for sysops
if (Morebits.queryString.exists('prefix')) {
query.gapnamespace = Morebits.queryString.get('namespace');
query.gapprefix = Morebits.string.toUpperCaseFirstChar(Morebits.queryString.get('prefix'));
if (mw.util.getParamValue('prefix')) {
query.gapnamespace = mw.util.getParamValue('namespace');
query.gapprefix = mw.util.getParamValue('prefix');
} else {
var pathSplit = decodeURIComponent(location.pathname).split('/');
if (pathSplit.length < 3 || pathSplit[2] !== 'Special:PrefixIndex') {
Expand Down
5 changes: 2 additions & 3 deletions modules/twinklebatchprotect.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,8 @@ Twinkle.batchprotect.callback = function twinklebatchprotectCallback() {
query.gcmlimit = Twinkle.getPref('batchMax'); // the max for sysops
} else if (mw.config.get('wgCanonicalSpecialPageName') === 'Prefixindex') {
query.generator = 'allpages';
query.gapnamespace = Morebits.queryString.exists('namespace') ? Morebits.queryString.get('namespace') : $('select[name=namespace]').val();
query.gapprefix = Morebits.queryString.exists('from') ? Morebits.string.toUpperCaseFirstChar(Morebits.queryString.get('from').replace('+', ' ')) :
Morebits.string.toUpperCaseFirstChar($('input[name=prefix]').val());
query.gapnamespace = mw.util.getParamValue('namespace') || $('select[name=namespace]').val();
query.gapprefix = mw.util.getParamValue('prefix') || $('input[name=prefix]').val();
Copy link
Collaborator

@Amorymeltzer Amorymeltzer Jan 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow! from is used to paginate, while prefix is the actual prefix. That is, prefix defines the list (e.g. prefix=A) while from defines what is shown on the user's screen (e.g. prefix=A&from=Amory_Lovins). batchprotect has been busted on non-first-page results for a decade, very lame!

query.gaplimit = Twinkle.getPref('batchMax'); // the max for sysops
} else {
query.generator = 'links';
Expand Down
28 changes: 7 additions & 21 deletions modules/twinklediff.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,10 @@ Twinkle.diff = function twinklediff() {
if (mw.config.get('wgNamespaceNumber') < 0 || !mw.config.get('wgArticleId')) {
return;
}

var query = {
'title': mw.config.get('wgPageName'),
'diff': 'cur',
'oldid': 'prev'
};

Twinkle.addPortletLink(mw.util.wikiScript('index') + '?' + $.param(query), 'Last', 'tw-lastdiff', 'Show most recent diff');
Twinkle.addPortletLink(mw.util.getUrl(mw.config.get('wgPageName'), {diff: 'cur', oldid: 'prev'}), 'Last', 'tw-lastdiff', 'Show most recent diff');

// Show additional tabs only on diff pages
if (Morebits.queryString.exists('diff')) {
if (mw.util.getParamValue('diff')) {
Twinkle.addPortletLink(function() {
Twinkle.diff.evaluate(false);
}, 'Since', 'tw-since', 'Show difference between last diff and the revision made by previous user');
Expand All @@ -36,12 +29,7 @@ Twinkle.diff = function twinklediff() {
}, 'Since mine', 'tw-sincemine', 'Show difference between last diff and my last revision');

var oldid = /oldid=(.+)/.exec($('#mw-diff-ntitle1').find('strong a').first().attr('href'))[1];
query = {
'title': mw.config.get('wgPageName'),
'diff': 'cur',
'oldid': oldid
};
Twinkle.addPortletLink(mw.util.wikiScript('index') + '?' + $.param(query), 'Current', 'tw-curdiff', 'Show difference to current revision');
Twinkle.addPortletLink(mw.util.getUrl(mw.config.get('wgPageName'), {diff: 'cur', oldid: oldid}), 'Current', 'tw-curdiff', 'Show difference to current revision');
}
};

Expand Down Expand Up @@ -82,12 +70,10 @@ Twinkle.diff.callbacks = {
self.statelem.error('no suitable earlier revision found, or ' + self.params.user + ' is the only contributor. Aborting.');
return;
}
var query = {
'title': mw.config.get('wgPageName'),
'oldid': revid,
'diff': mw.config.get('wgCurRevisionId')
};
window.location = mw.util.wikiScript('index') + '?' + Morebits.queryString.create(query);
window.location = mw.util.getUrl(mw.config.get('wgPageName'), {
diff: mw.config.get('wgCurRevisionId'),
oldid: revid
});
}
};
})(jQuery);
Expand Down
14 changes: 7 additions & 7 deletions modules/twinklefluff.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Twinkle.fluff = {

var vandal = $('#mw-diff-ntitle2').find('a.mw-userlink').text();

Twinkle.fluff.revert(Morebits.queryString.get('twinklerevert'), vandal, true);
Twinkle.fluff.revert(mw.util.getParamValue('twinklerevert'), vandal, true);
},

contributions: function() {
Expand All @@ -69,11 +69,11 @@ Twinkle.fluff = {
var href = $(current).find('.mw-changeslist-diff').attr('href');
current.appendChild(document.createTextNode(' '));
var tmpNode = revNode.cloneNode(true);
tmpNode.firstChild.setAttribute('href', href + '&' + Morebits.queryString.create({ 'twinklerevert': 'norm' }));
tmpNode.firstChild.setAttribute('href', href + '&twinklerevert=norm');
current.appendChild(tmpNode);
current.appendChild(document.createTextNode(' '));
tmpNode = revVandNode.cloneNode(true);
tmpNode.firstChild.setAttribute('href', href + '&' + Morebits.queryString.create({ 'twinklerevert': 'vand' }));
tmpNode.firstChild.setAttribute('href', href + '&twinklerevert=vand');
current.appendChild(tmpNode);
});
}
Expand Down Expand Up @@ -443,16 +443,16 @@ Twinkle.fluff.callbacks = {

switch (Twinkle.getPref('userTalkPageMode')) {
case 'tab':
window.open(mw.util.wikiScript('index') + '?' + Morebits.queryString.create(query), '_blank');
window.open(mw.util.getUrl('', query), '_blank');
break;
case 'blank':
window.open(mw.util.wikiScript('index') + '?' + Morebits.queryString.create(query), '_blank',
window.open(mw.util.getUrl('', query), '_blank',
'location=no,toolbar=no,status=no,directories=no,scrollbars=yes,width=1200,height=800');
break;
case 'window':
/* falls through */
default:
window.open(mw.util.wikiScript('index') + '?' + Morebits.queryString.create(query),
window.open(mw.util.getUrl('', query),
window.name === 'twinklewarnwindow' ? '_blank' : 'twinklewarnwindow',
'location=no,toolbar=no,status=no,directories=no,scrollbars=yes,width=1200,height=800');
break;
Expand Down Expand Up @@ -560,7 +560,7 @@ Twinkle.fluff.init = function twinklefluffinit() {
'SineBot'
];

if (Morebits.queryString.exists('twinklerevert')) {
if (mw.util.getParamValue('twinklerevert')) {
// Return if the user can't edit the page in question
if (!mw.config.get('wgIsProbablyEditable')) {
alert("Unable to edit the page, it's probably protected.");
Expand Down
2 changes: 1 addition & 1 deletion modules/twinklewarn.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Twinkle.warn.callback = function twinklewarnCallback() {
type: 'input',
name: 'article',
label: 'Linked page',
value: Morebits.queryString.exists('vanarticle') ? Morebits.queryString.get('vanarticle') : '',
value: mw.util.getParamValue('vanarticle') || '',
tooltip: 'A page can be linked within the notice, perhaps because it was a revert to said page that dispatched this notice. Leave empty for no page to be linked.'
});

Expand Down
Loading