MediaWiki:CRT Search.js: Difference between revisions
No edit summary |
No edit summary |
||
| Line 1,412: | Line 1,412: | ||
/** | /** | ||
* Update URL with current filters | * Update URL with current filters | ||
* Preserves the 'title' parameter if present (for index.php?title=... URLs) | |||
*/ | */ | ||
function updateURL() { | function updateURL() { | ||
var filters = collectFilters(); | var filters = collectFilters(); | ||
var params = new URLSearchParams(); | var params = new URLSearchParams(window.location.search); | ||
// Preserve the 'title' parameter if it exists | |||
var titleParam = params.get('title'); | |||
// Clear all params except 'title' | |||
params = new URLSearchParams(); | |||
if (titleParam) { | |||
params.set('title', titleParam); | |||
} | |||
for (var key in filters) { | for (var key in filters) { | ||
| Line 1,454: | Line 1,464: | ||
var params = new URLSearchParams(window.location.search); | var params = new URLSearchParams(window.location.search); | ||
// No URL params to process | // No URL params to process (other than possibly 'title') | ||
var hasFilterParams = false; | |||
params.forEach(function(value, key) { | |||
if (key !== 'title') { | |||
hasFilterParams = true; | |||
} | |||
}); | |||
if (!hasFilterParams) { | |||
return; | return; | ||
} | } | ||
params.forEach(function(value, key) { | params.forEach(function(value, key) { | ||
// Skip the 'title' parameter - it's just for page routing | |||
if (key === 'title') { | |||
return; | |||
} | |||
if (key === 'sort') { | if (key === 'sort') { | ||
document.getElementById('sort-by').value = value; | document.getElementById('sort-by').value = value; | ||