AndyRussG has uploaded a new change for review.
https://gerrit.wikimedia.org/r/230192
Change subject: Get URL params via mw.Uri() instead of ad-hoc methods
......................................................................
Get URL params via mw.Uri() instead of ad-hoc methods
Change-Id: Idee6c32d06afbc946aa0a03d632b63630af95240
---
M resources/subscribing/ext.centralNotice.display.state.js
1 file changed, 1 insertion(+), 31 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralNotice
refs/changes/92/230192/1
diff --git a/resources/subscribing/ext.centralNotice.display.state.js
b/resources/subscribing/ext.centralNotice.display.state.js
index 1f6890b..96f43f5 100644
--- a/resources/subscribing/ext.centralNotice.display.state.js
+++ b/resources/subscribing/ext.centralNotice.display.state.js
@@ -40,34 +40,6 @@
};
/**
- * Return an object with URL query string parameters.
- * TODO Taken from legacy code. Is this the right way to do this?
- * @returns {Object}
- */
- function setURLParams() {
-
- document.location.search.replace( /\??(?:([^=]+)=([^&]*)&?)/g,
- function ( str, p1, p2 ) {
- state.urlParams[decode( p1 )] = decode( p2 );
- } );
- }
-
- /**
- * '+'-replacer and try-catch wrapper for decodeURIComponent
- * TODO Taken from legacy code. Is this the right way to do this?
- * @param {string} s
- * @returns {string}
- */
- function decode( s ) {
- try {
- // decodeURIComponent can throw an exception for
unknown char encodings.
- return decodeURIComponent( s.replace( rPlus, ' ' ) );
- } catch ( e ) {
- return '';
- }
- }
-
- /**
* Get a code for the general category the user's device is in.
*/
function getDeviceCode() {
@@ -102,7 +74,7 @@
*/
function setInitialData() {
- var urlParams = state.urlParams;
+ var urlParams = state.urlParams = $.extend( {}, ( new mw.Uri()
).query );
data.anonymous = ( mw.config.get( 'wgUserName' ) === null );
data.project = mw.config.get( 'wgNoticeProject' );
@@ -165,13 +137,11 @@
},
setUp: function() {
- setURLParams();
setInitialData();
data.status = STATUSES.CAMPAIGN_NOT_CHOSEN;
},
setUpForTestingBanner: function() {
- setURLParams();
setInitialData();
// Load banner and campaign URL params into data
--
To view, visit https://gerrit.wikimedia.org/r/230192
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idee6c32d06afbc946aa0a03d632b63630af95240
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: campaign_mixins
Gerrit-Owner: AndyRussG <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits