1jQuery(function () { 2 /** 3 * Add tag search parameter to all links in the advanced search tools 4 * 5 * This duplicates the solution from the watchcycle plugin, and should also be replaced 6 * with a DokuWiki event, which does not exist yet, but should handle extending search tools. 7 */ 8 const $advancedOptions = jQuery('.search-results-form .advancedOptions'); 9 if (!$advancedOptions.length) { 10 return; 11 } 12 13 /** 14 * Extracts the value of a given parameter from the URL querystring 15 * 16 * taken via watchcycle from https://stackoverflow.com/a/31412050/3293343 17 * @param param 18 * @returns {*} 19 */ 20 function getQueryParam(param) { 21 location.search.substr(1) 22 .split("&") 23 .some(function(item) { // returns first occurence and stops 24 return item.split("=")[0] === param && (param = item.split("=")[1]) 25 }); 26 return param 27 } 28 29 if (getQueryParam('tagging-logic') === 'and') { 30 $advancedOptions.find('a').each(function (index, element) { 31 const $link = jQuery(element); 32 // do not override parameters in our own links 33 if ($link.attr('href').indexOf('tagging-logic') === -1) { 34 $link.attr('href', $link.attr('href') + '&tagging-logic=and'); 35 } 36 }); 37 } 38}); 39