1var _rangeSeparator = '-'; 2var _valueDataSeparator = '^'; 3var _rangeSuffix = '_range'; 4var _pageChangeUrl = ''; 5var _pageSizeChangeUrl = ''; 6var _sortChangeUrl = ''; 7var _createDateChangeUrl = ''; 8var _changeCache = []; 9var _autosuggestCache = []; 10 11function toggleRefineBox(headerElement, boxId) { 12 var button = jQuery(headerElement).find('.openclose'); 13 if (button.hasClass('minus')) { 14 button.removeClass('minus'); 15 button.addClass('plus'); 16 button.html('+'); 17 jQuery('#' + boxId).hide(); 18 jQuery('#' + boxId + ' input').attr('disabled', 'disabled'); 19 } else { 20 button.removeClass('plus'); 21 button.addClass('minus'); 22 button.html('-'); 23 jQuery('#' + boxId + ' input').prop('disabled', false); 24 jQuery('#' + boxId).show(); 25 } 26} 27 28function addFilter(paramType, name, value, displayText) { 29 if (displayText && displayText != value) 30 value += _valueDataSeparator + displayText; 31 var url = getFilterQuery('a' + paramType, name + '=' + encodeURIComponent(value)); 32 //alert(url); 33 window.location = url; 34} 35 36function updateFilter(paramType, name, value, displayText) { 37 if (displayText && displayText != value) 38 value += _valueDataSeparator + displayText; 39 var url = getFilterQuery('u' + paramType, name + '=' + encodeURIComponent(value)); 40 //alert(url); 41 window.location = url; 42} 43 44function updateFilters(btnParamType, btnName, btnValue) { 45 var searchParams = ''; 46 var refineParams = ''; 47 48 if (btnParamType && btnName && btnValue) { 49 if (jQuery.isArray(btnValue) && btnName.indexOf(_rangeSuffix) == -1) 50 btnName += _rangeSuffix; 51 if (getCachedFilterIndex(btnName) == -1) { 52 if (jQuery.isArray(btnValue)) 53 cacheFilterChange(btnParamType, btnName, btnValue[0] + _rangeSeparator + btnValue[1], null); 54 else 55 cacheFilterChange(btnParamType, btnName, btnValue, null); 56 } 57 } 58 59 for (var i = 0; i < _changeCache.length; i++) { 60 var param = _changeCache[i].name + '=' + _changeCache[i].value; 61 if (_changeCache[i].paramType == 's') { 62 if (searchParams.length != 0) 63 searchParams += '&'; 64 searchParams += param; 65 } 66 else if (_changeCache[i].paramType == 'r') { 67 if (refineParams.length != 0) 68 refineParams += '&'; 69 refineParams += param; 70 } 71 } 72 73 var url = getFilterPage(); 74 if (searchParams) 75 url = addToQuery('us', searchParams, url); 76 if (refineParams) 77 url = addToQuery('ur', refineParams, url); 78 //alert(url); 79 window.location = url; 80} 81 82function removeFilter(paramType, name, value) { 83 if (!value) 84 value = '*' 85 var url = getFilterQuery('r' + paramType, name + '=' + encodeURIComponent(value)); 86 //alert(url); 87 window.location = url; 88} 89 90function cacheFilterChange(paramType, name, value, displayText) { 91 var idx = getCachedFilterIndex(name); 92 if (idx >= 0) { 93 _changeCache[idx].value = value; 94 _changeCache[idx].displayText = displayText; 95 } 96 else 97 _changeCache.push({ 'paramType': paramType, 'name': name, 'value': value, 'displayText': displayText }); 98} 99 100function getCachedFilterIndex(name) { 101 var idx = -1; 102 for (var i = 0; i < _changeCache.length; i++) { 103 if (_changeCache[i].name == name) { 104 idx = i; 105 break; 106 } 107 } 108 return idx; 109} 110 111function GetQueryString(sParam) { 112 var url = window.location.search.substring(1); 113 var urlVar = url.split('&'); 114 for (var i = 0; i < urlVar.length; i++) { 115 var sName = urlVar[i].split('='); 116 if (sName[0] == sParam) { 117 return sName[1]; 118 } 119 } 120} 121 122 123function changeSort(sortBy) { 124 var url = _sortChangeUrl.replace(/\{0\}/, sortBy); 125 if (GetQueryString("PageSize") != null) 126 window.location = url + "&PageSize=" + GetQueryString("PageSize"); 127 else 128 window.location = url; 129} 130 131function changePageSize(pageSize) { 132 var url = _pageSizeChangeUrl.replace(/\{0\}/, pageSize); 133 if (GetQueryString("SortBy") != null)
134 window.location = url + "&SortBy=" + GetQueryString("SortBy"); 135 else 136 window.location = url; 137} 138 139function changeCreateDates(createDate) { 140 var url = _createDateChangeUrl.replace(/\{0\}/, createDate); 141 //alert(url); 142 window.location = url; 143} 144 145function getFilterPage() { 146 var url = _pageChangeUrl.replace(/\{0\}/, '1'); 147 return url; 148} 149 150function getFilterQuery(name, value) { 151 var url = getFilterPage(); 152 return addToQuery(name, value, url); 153} 154 155function addToQuery(name, value, url) { 156 if (!url) 157 url = currentContext.url; 158 if (url.indexOf('?') == -1) 159 url += '?'; 160 else 161 url += '&'; 162 url += name + '=' + encodeURIComponent(value); 163 return url; 164} 165 166function createSlider(containerId, name, inputValues, sliderValues, sliderLimits, stepAmount, thousandsSeparator) { 167 var minInput = jQuery("#" + containerId + " .sf_" + name + "_min"); 168 var maxInput = jQuery("#" + containerId + " .sf_" + name + "_max"); 169 170 jQuery("#" + containerId + " ." + name + "_slider").slider({ 171 range: true, 172 min: sliderLimits[0], 173 max: sliderLimits[1], 174 values: sliderValues, 175 step: stepAmount, 176 slide: function (event, ui) { 177 minInput.val(addThousandsSeparator(ui.values[0], thousandsSeparator)); 178 maxInput.val(addThousandsSeparator(ui.values[1], thousandsSeparator)); 179 }, 180 stop: function (event, ui) { 181 cacheFilterChange('s', name + _rangeSuffix, ui.values[0] + _rangeSeparator + ui.values[1], null); 182 }, 183 change: function (event, ui) { 184 jQuery("#" + containerId + " ." + name + "_button").slideDown('fast'); 185 } 186 }); 187 188 minInput.on("focus", function (event) { 189 jQuery("#" + containerId + " ." + name + "_button").slideDown('fast'); 190 }); 191 maxInput.on("focus", function (event) { 192 jQuery("#" + containerId + " ." + name + "_button").slideDown('fast'); 193 }); 194 195 var manualChangeCallback = function (containerId, name, inputValues, sliderLimits, inputElem, oppositeElem, isMinInput, thousandsSeparator) { 196 var inputValue = inputElem.val().replace(/\D/g, ""); 197 if (inputValue == "") 198 inputValue = "0"; 199 var newValue = parseInt(inputValue); 200 if (newValue < 0) 201 newValue = 0; 202 inputElem.val(addThousandsSeparator(newValue, thousandsSeparator)); 203 204 var slider = jQuery("#" + containerId + " ." + name + "_slider"); 205 var values = slider.slider("option", "values"); 206 if (newValue < sliderLimits[0]) { 207 sliderLimits[0] = newValue; 208 slider.slider("option", "min", newValue); 209 } 210 if (newValue > sliderLimits[1]) { 211 sliderLimits[1] = newValue; 212 slider.slider("option", "max", newValue); 213 } 214 215 if (isMinInput) { 216 inputValues[0] = newValue; 217 values[0] = newValue; 218 if (newValue > values[1]) { 219 values[1] = sliderLimits[1]; 220 oppositeElem.val(addThousandsSeparator(values[1], thousandsSeparator)); 221 } 222 } 223 else { 224 inputValues[1] = newValue; 225 values[1] = newValue; 226 if (newValue < values[0]) { 227 values[0] = sliderLimits[0]; 228 oppositeElem.val(addThousandsSeparator(values[0], thousandsSeparator)); 229 } 230 } 231 //alert(inputValues[0] + '-' + inputValues[1] + ' / ' + values[0] + '-' + values[1]); 232 cacheFilterChange('s', name + _rangeSuffix, inputValues[0] + _rangeSeparator + inputValues[1], null); 233 slider.slider("option", "values", values); 234 } 235 236 minInput.on("change", function (event) { 237 manualChangeCallback(containerId, name, inputValues, sliderLimits, minInput, maxInput, true, thousandsSeparator); 238 }); 239 maxInput.on("change", function (event) { 240 manualChangeCallback(containerId, name, inputValues, sliderLimits, maxInput, minInput, false, thousandsSeparator); 241 });
242} 243 244function addThousandsSeparator(num, separator) { 245 var val = num + ''; 246 if (!separator || !num) 247 return val; 248 249 var re = new RegExp('(-?[0-9]+)([0-9]{3})'); 250 while (re.test(val)) { 251 val = val.replace(re, '$1' + separator + '$2'); 252 } 253 return val; 254} 255 256function getSearchSuggestions(fieldName, typedText, callbackFunc) { 257 jQuery.getJSON(currentContext.homeFolder + "/js/GetSuggestions.ashx?action=searchform&fieldname=" + encodeURIComponent(fieldName) + "&typedtext=" + encodeURIComponent(typedText), null, callbackFunc); 258} 259 260function performStructuredSearch() { 261 if (g_objCatSel.selectedCategory) { 262 setFieldValue('sf_category', g_objCatSel.selectedCategory); 263 } else { 264 setFieldValue('sf_category', g_objCatSel.selectedCatalog); 265 } 266 //alert(g_objCatSel.selectedCatalog + ', ' + g_objCatSel.selectedCategory); 267 submitForm('search', 'http://dealers.mascus.com/volvona/Search.aspx') 268} 269 270function loadSearchSuggestions(inputElement, typedText, callbackFunc) { 271 var fieldName = inputElement.name; 272 if (!fieldName) 273 fieldName = inputElement.id; 274 275 fieldName = fieldName.toLowerCase(); 276 if (fieldName.indexOf("sf_") == 0 || fieldName.indexOf("rf_") == 0) 277 fieldName = fieldName.substring(3); 278 279 var items = null; 280 for (var i = 0; i < _autosuggestCache.length; i++) { 281 if (_autosuggestCache[i].fieldName == fieldName) { 282 items = _autosuggestCache[i].items; 283 break; 284 } 285 } 286 287 if (items != null) { 288 callbackFunc(items); 289 } 290 else { 291 getSearchSuggestions(fieldName, typedText, function (data, textStatus, jqXHR) { 292 _autosuggestCache.push({ 293 "fieldName": fieldName, 294 "items": data.items 295 }); 296 callbackFunc(data.items); 297 }); 298 } 299} 300 301 302/*----------------- update search script for category selector---------------------*/ 303var glCatalog = ""; 304var glMainCategory = ""; 305var glSubCategory = ""; 306 307function OnCatalogClick(autoSearch) { 308 var catalog = jQuery("#Catalogs option").filter(":selected").val(); 309 if (catalog == "All") { 310 eraseCookie("catalogSelector"); 311 eraseCookie("maincategorySelector"); 312 eraseCookie("subcategorySelector"); 313 } 314 else if (readCookie("catalogSelector") == "") { 315 if (readCookie("maincategorySelector") != "") { 316 jQuery(".SubCategory." + readCookie("maincategorySelector")).css("display", "none"); 317 } 318 eraseCookie("catalogSelector"); 319 eraseCookie("maincategorySelector"); 320 eraseCookie("subcategorySelector"); 321 createCookie("catalogSelector", catalog, 1); 322 } 323 else { 324 if (readCookie("maincategorySelector") != "") { 325 jQuery(".SubCategory." + readCookie("maincategorySelector")).css("display", "none"); 326 } 327 jQuery(".MainCategory." + readCookie("catalogSelector")).css("display", "none"); 328 eraseCookie("catalogSelector"); 329 eraseCookie("maincategorySelector"); 330 eraseCookie("subcategorySelector"); 331 createCookie("catalogSelector", catalog, 1); 332 } 333 jQuery(".MainCategory." + catalog).css("display", "block"); 334 jQuery('.catalogChange').attr('value', catalog); 335 if (autoSearch == "true") 336 SearchCategorySelector(); 337} 338 339function OnMainCategoryClick(autoSearch) { 340 var category = jQuery(".MainCategory." + jQuery("#Catalogs option").filter(":selected").val() + " option").filter(":selected").val(); 341 if (category == "undefined" || category == "All") { 342 eraseCookie("maincategorySelector"); 343 eraseCookie("subcategorySelector"); 344 } 345 else if (readCookie("maincategorySelector") == "") { 346 eraseCookie("maincategorySelector"); 347 eraseCookie("subcategorySelector"); 348 createCookie("maincategorySelector", category, 1); 349 } 350 else { 351 jQuery(".SubCategory." + readCookie("maincategorySelector")).css("display", "none"); 352 eraseCookie("maincategorySelector"); 353 eraseCookie("subcategorySelector"); 354 createCookie("maincategorySelector", category, 1); 355 } 356 jQuery(".SubCategory." + category).css("display", "block"); 357 jQuery('.catChange').attr('value', category); 358 if (autoSearch == "true") 359 SearchCategorySelector(); 360} 361 362function OnSubCategoryClick(autoSearch) { 363 subcategory = jQuery(".SubCategory." + jQuery(".MainCategory." + jQuery("#Catalogs option").filter(":selected").val() + " option").filter(":selected").val() + " option").filter(":selected").val(); 364 if (subcategory == "undefined" || subcategory == "All") { 365 eraseCookie("subcategorySelector"); 366 } else { 367 eraseCookie("subcategorySelector"); 368 createCookie("subcategorySelector", subcategory, 1); 369 } 370 jQuery('.catChange').attr('value', readCookie("subcategorySelector"));
371 if (autoSearch == "true") 372 SearchCategorySelector(); 373} 374 375 376 377 378function eraseCookie(cookiename) { 379 createCookie(cookiename, "", -1); 380} 381 382function createCookie(cookiename, value, days) { 383 if (days) { 384 var date = new Date(); 385 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); 386 var expires = "; expires=" + date.toGMTString(); 387 } 388 else var expires = ""; 389 document.cookie = cookiename + "=" + value + expires + ";"; 390} 391 392function readCookie(cookiename) { 393 var name = cookiename + "="; 394 var ca = document.cookie.split(';'); 395 for (var i = 0; i < ca.length; i++) { 396 var c = ca[i]; 397 while (c.charAt(0) == ' ') c = c.substring(1); 398 if (c.indexOf(name) == 0) return c.substring(name.length, c.length); 399 } 400 return ""; 401} 402 403function SearchCategorySelector() { 404 glCatalog = readCookie("catalogSelector"); 405 glMainCategory = readCookie("maincategorySelector"); 406 glSubCategory = readCookie("subcategorySelector"); 407 if (window.location.href.indexOf("?") > -1) { 408 var parameter = ""; 409 410 if (glCatalog != "" && glCatalog != "All") { 411 parameter = glCatalog; 412 if (glMainCategory != "" && glMainCategory != "All") { 413 parameter += '/' + glMainCategory; 414 if (glSubCategory != "" && glSubCategory != "All") { 415 parameter += '/' + glSubCategory; 416 newParameter(parameter); 417 } 418 else { 419 newParameter(parameter); 420 } 421 } 422 else { 423 newParameter(parameter); 424 } 425 } 426 else { 427 newParameter(parameter); 428 } 429 430 } 431 else { 432 var catalog = jQuery("#Catalogs option").filter(":selected").val(); 433 var maincategory = ""; 434 var subcategory = ""; 435 var pathn = window.location.pathname.split('/'); 436 var linksearch = "search.aspx?sf_categorypath="; 437 if (catalog != "All") { 438 maincategory = jQuery(".MainCategory." + catalog + " option").filter(":selected").val(); 439 if (maincategory != "undefined" && maincategory != "All") { 440 subcategory = jQuery(".SubCategory." + maincategory + " option").filter(":selected").val(); 441 if (subcategory == "undefined" && subcategory == "All") { 442 subcategory = ""; 443 } 444 } else { 445 maincategory = ""; 446 } 447 } 448 else { 449 catalog = ""; 450 } 451 eraseCookie("catalogSelector"); 452 eraseCookie("maincategorySelector"); 453 eraseCookie("subcategorySelector"); 454 if (catalog != "" && catalog != "All") { 455 linksearch += catalog; 456 createCookie("catalogSelector", catalog, 1); 457 if (maincategory != "" && maincategory != "All") { 458 linksearch += "%2f" + maincategory; 459 createCookie("maincategorySelector", maincategory, 1); 460 if (subcategory != "" && subcategory != "All") { 461 linksearch += "%2f" + subcategory; 462 createCookie("subcategorySelector", subcategory, 1); 463 } 464 } 465 } 466 467 if (document.querySelector('[name="q"]') != null) 468 linksearch += "&q=" + document.querySelector('[name="q"]').value; 469 470 if (window.location.hostname == "localhost") { 471 window.location.replace(window.location.protocol + "//" + window.location.hostname + ":85/" + pathn[1] + "/" + linksearch); 472 } else { 473 window.location.replace(window.location.protocol + "//" + window.location.hostname + "/" + pathn[1] + "/" + linksearch); 474 } 475 } 476} 477 478function categoryPathBuilder() { 479 var path = "sf_categorypath="; 480 if (readCookie("catalogSelector") != "") { 481 path += readCookie("catalogSelector"); 482 if (readCookie("maincategorySelector") != "") { 483 path += "%2f" + readCookie("maincategorySelector"); 484 if (readCookie("subcategorySelector") != "") { 485 path += "%2f" + readCookie("subcategorySelector"); 486 } 487 } 488 } 489 return path; 490} 491 492function newParameter(parameter) { 493 var sf = queryString.parse(window.location.search); 494 495 if (sf['Page'] != null) { 496 sf['Page'] = 1; 497 } 498 if (sf['rs'] != null) { 499 sf['rs'] = ''; 500 } 501 502 sf.sf_categorypath = parameter; 503 if (document.querySelector('[name="q"]') != null && document.querySelector('[name="q"]').value != "") 504 sf.q = document.querySelector('[name="q"]').value; 505 window.location.replace("search.aspx?" + queryString.stringify(sf)); 506} 507 508function getURLParameter(name) { 509 var url = window.location.href; 510 if (url.indexOf(name) != -1) 511 return true; 512 return false; 513} 514 515(function () { 516 'use strict'; 517 var queryString = {}; 518 519 queryString.parse = function (str) { 520 if (typeof str !== 'string') { 521 return {}; 522 } 523 524 str = str.trim().replace(/^(\?|#)/, ''); 525 526 if (!str) { 527 return {}; 528 } 529 530 return str.trim().split('&').reduce(function (ret, param) { 531 var parts = param.replace(/\+/g, ' ').split('='); 532 var key = parts[0]; 533 var val = parts[1]; 534 535 key = decodeURIComponent(key); 536 val = val === undefined ? null : decodeURIComponent(val); 537 538 if (!ret.hasOwnProperty(key)) { 539 ret[key] = val; 540 } else if (Array.isArray(ret[key])) { 541 ret[key].push(val); 542 } else { 543 ret[key] = [ret[key], val]; 544 } 545 546 return ret; 547 }, {}); 548 }; 549 550 queryString.stringify = function (obj) { 551 return obj ? Object.keys(obj).map(function (key) { 552 var val = obj[key]; 553 554 if (Array.isArray(val)) { 555 return val.map(function (val2) { 556 return encodeURIComponent(key) + '=' + encodeURIComponent(val2); 557 }).join('&'); 558 } 559 560 return encodeURIComponent(key) + '=' + encodeURIComponent(val); 561 }).join('&') : ''; 562 }; 563 564 if (typeof define === 'function' && define.amd) { 565 define(function () { return queryString; }); 566 } else if (typeof module !== 'undefined' && module.exports) { 567 module.exports = queryString; 568 } else { 569 window.queryString = queryString; 570 } 571})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.