Thiemo Mättig (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/392854 )

Change subject: Avoid poluting the browsers address bar with irrelevant options
......................................................................

Avoid poluting the browsers address bar with irrelevant options

I noticed that, when I do nothing but just clicking the "Search" button,
the URL that shows up in my browsers address bar is "poluted" with all
options, even the ones I did not even used.

…&advancedSearch-current={
    "options":{
        "filew":[">",""],
        "fileh":[">",""],
        "intitle":"",
        "or":[],
        "filetype":"",
        "phrase":[],
        "not":""
    },
    "namespaces":["6"]
}

The code change in this patch is untested and might be incomplete. It
just tries to reduce the amount of not needed information. Please feel
welcome to continue working on this patch.

Change-Id: I82c13101c555e0b8bc4ced08be955d275e148e92
---
M modules/dm/ext.advancedSearch.SearchModel.js
1 file changed, 9 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AdvancedSearch 
refs/changes/54/392854/1

diff --git a/modules/dm/ext.advancedSearch.SearchModel.js 
b/modules/dm/ext.advancedSearch.SearchModel.js
index a7af335..32197e6 100644
--- a/modules/dm/ext.advancedSearch.SearchModel.js
+++ b/modules/dm/ext.advancedSearch.SearchModel.js
@@ -69,6 +69,11 @@
                        return;
                }
 
+               if ( value === '' || ( Array.isArray( value ) && value.length 
=== 0 ) ) {
+                       this.removeOption( optionId );
+                       return;
+               }
+
                this.searchOptions[ optionId ] = value;
 
                if ( optionId === 'filetype' && 
!this.filetypeSupportsDimensions() ) {
@@ -100,7 +105,6 @@
         * @param {string} optionId
         */
        mw.libs.advancedSearch.dm.SearchModel.prototype.removeOption = function 
( optionId ) {
-
                if ( this.searchOptions[ optionId ] === undefined ) {
                        return;
                }
@@ -116,10 +120,12 @@
 
        /**
         * Reset the file dimension search options
+        *
+        * @private
         */
        
mw.libs.advancedSearch.dm.SearchModel.prototype.resetFileDimensionOptions = 
function () {
-               this.searchOptions.filew = [ '>', '' ];
-               this.searchOptions.fileh = [ '>', '' ];
+               this.removeOption( 'filew' );
+               this.removeOption( 'fileh' );
        };
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/392854
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I82c13101c555e0b8bc4ced08be955d275e148e92
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/AdvancedSearch
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.kr...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to