Skip to content

Instantly share code, notes, and snippets.

@kovkor
Created December 3, 2017 17:28
Show Gist options
  • Select an option

  • Save kovkor/1e8e333bec0051149491649b3900907e to your computer and use it in GitHub Desktop.

Select an option

Save kovkor/1e8e333bec0051149491649b3900907e to your computer and use it in GitHub Desktop.
URL feldolgozása pl. kereséshez. A / jellel elválasztott url-ben megkeresi a kulcsszavakat, majd a mögöttök található keresőszavakat tömbbe rendezi.
var keresoszavak = ['kategoria','helyiseg'];
function prepareSearch() {
let searchwords = [];
let uri = window.location.pathname;
let uritemp = uri.split('/');
let db = uritemp.length;
for (i=1;i<db;i++) {
if (uritemp[i]) {
if ($.inArray(uritemp[i],keresoszavak)>-1) {
actualwords = i;
if (searchwords[uritemp[actualwords]] == undefined) searchwords[uritemp[actualwords]] = '';
}
if ($.inArray(uritemp[i],keresoszavak) == -1) {
searchwords[uritemp[actualwords]] = searchwords[uritemp[actualwords]] + uritemp[i]+',';
}
}
}
return searchwords;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment