1$.fn.is_on_screen = function(){ 2 var win = $(window); 3 var viewport = { 4 top : win.scrollTop(), 5 left : win.scrollLeft() 6 }; 7 viewport.right = viewport.left + win.width(); 8 viewport.bottom = viewport.top + win.height(); 9 10 var bounds = this.offset(); 11 bounds.right = bounds.left + this.outerWidth(); 12 bounds.bottom = bounds.top + this.outerHeight(); 13 14 return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom)); 15}; 16 17$.urlParam = function (name) { 18 var results = new RegExp('[\?&]' + name + '=([^&#]*)') 19 .exec(window.location.href); 20 if (results == null) { 21 return 0; 22 } 23 return results[1] || 0; 24} 25 26//console.log($.urlParam('saved')); //edit 27 28var search_query_string = ''; 29var current_page = 1; 30var is_search_loading = false; 31var $container = $('.masonry-container'); 32var isMasonryActive = false; 33var saved_search_active = $.urlParam('saved'); 34 35$(document).ready(function () { 36 if ($('ul#refine-filters').length > 0 && $(document).width() >= 768) 37 { 38 $('ul#refine-filters > li[role="presentation"]').first().click(); 39 $('a[href="#tab_refine-search"]').click(); 40 } 41 if ($(".vt-list").length > 0) //theme-builder 42 { 43 doMasonry(); 44 $(".vt-list").click(function (e) { 45 $('#view-type', $('#frm_search')).val($(this).attr('view-type')); 46 doMasonry(); 47 }); 48 } 49 if ($("#mobile-sort").length > 0) 50 { 51 $("#mobile-sort").change(function (e) { 52 $('#sort').val($(this).val()); 53 reset_page(1); 54 }); 55 } 56 if ($("#sort").length > 0) 57 { 58 $("#sort").change(function (e) { 59 reset_page(1); 60 }); 61 } 62 update_search_filters(); 63 expand_search_filters(); 64 current_page = parseInt($('#page').val()); 65 66 67 68 if($('#unit_infinite_scroll').val() == 1 ) //if disalbed from inventory setting page 69 { 70 $(window).on('resize scroll', function () { 71 if(saved_search_active) return; 72 73 if ($(this).scrollTop() > 220) { 74 $('.back-to-top').fadeIn(500); 75 } else { 76 $('.back-to-top').fadeOut(500); 77 } 78 // refine_search_pos($(this).scrollTop()); 79 80 if (parseInt($("#total_records").val()) == 0) return; 81 if (is_search_loading) return; 82 83 if( $('#scroll_position').length > 0 && $('#scroll_position').is_on_screen() ){ 84 current_page++; 85 do_search(current_page); 86 } 87 }); 88 } 89 $('.back-to-top').click(function (event) { 90 event.preventDefault(); 91 $('html, body').animate({scrollTop: 0}, 500); 92 return false; 93 }); 94 95 96 $('.search-filter, .adv-filter').change(function () { 97 reset_page(1); 98 }); 99 set_button_triggers(); 100 $(document).on('click', 'a[target="_popup"]', function () { 101 $('h4.modal-title', $('#modal_contact_form')).html($(this).text()); 102 //fetch form details 103 var form_url = $(this).attr('href') + "&form-type=inline&r=" + Math.random(); 104 $("#div_contact_form").load(form_url, function () { 105// $('.g-recaptcha').each(function (key, val) { 106// var widgetId = grecaptcha.render('g-recaptcha_' + $(this).data('id'), { 107// 'sitekey': $(this).data('sitekey'), 108// 'theme': 'dark' 109// }); 110// $(this).data('widgetId', widgetId); 111// }); 112 $('form.contact-form').submit(function (e) { 113 e.preventDefault; 114 var form_data = $(this).serializeArray(); 115 save_form(form_data, $(this)); 116 }); 117 $('#modal_contact_form').modal('show'); 118 }); 119 return false;
120 }); 121 122// if($.cookie(location.host) != 'undefined') 123// $(".js-saved-list").show(); 124// 125 show_my_save_link(); 126 127 $(".js-saved-list").click(function () { 128 do_saved_search(); 129 }); 130}); 131 132function doMasonry() 133{ 134 $('.widget-unit_listing').removeClass('unit-grid').removeClass('unit-list').addClass($('#view-type', $('#frm_search')).val()); 135 $('ul.pagination li a').each(function (index, element) { 136 var pagination_url = $(this).attr('href').replace('view-type=unit-list', '').replace('view-type=unit-grid', '').replace('?&', '?'); 137 pagination_url += '&view-type=' + $('#view-type', $('#frm_search')).val(); 138 $(this).attr('href', pagination_url.replace('&&', '&')); 139 }); 140 if ($('#view-type', $('#frm_search')).val() == 'unit-grid') 141 { 142 // $container.imagesLoaded(function () { 143 // $container.masonry({ 144 // columnWidth: '.unit-box', 145 // itemSelector: '.unit-box' 146 // }); 147 // }); 148 isMasonryActive = true; 149 } else if ($('#view-type', $('#frm_search')).val() == 'unit-list' && isMasonryActive == true) 150 { 151 $container.masonry('destroy'); 152 isMasonryActive = false; 153 $('div.unit-box').removeAttr('style'); 154 $('div.masonry-container').removeAttr('style'); 155 } 156} 157 158function refine_search_pos(win_top) 159{ 160 if (win_top > 430) 161 $("#refine-search").removeClass('ref-srch-reset').addClass('ref-srch-up'); 162 else 163 $("#refine-search").removeClass('ref-srch-up').addClass('ref-srch-reset'); 164} 165 166function post_search() 167{ 168 reset_page(1); 169 return false; 170} 171 172function reset_page(page) 173{ 174 is_search_loading = false; 175 current_page = parseInt(page); 176 $('#page').val(page); 177 search_query_string = built_search_query_string(); 178 //console.log(search_query_string); 179 //window.location.href = WS_PATH+"inventory/?"+search_query_string; 180 181 var current_path = window.location.pathname; 182 window.location.href = current_path + "?" + search_query_string; 183 184 // window.location.href = $('#JS_VLP_URL_ID').val() + "/?" + search_query_string; 185} 186 187function built_search_query_string() 188{ 189 //console.clear(); 190 var filter_string = ""; 191 var arr_search_filters = []; 192 var arr_adv_filters = []; 193 arr_search_filters = $(".search-filter:checked").map(function () { 194 return $(this).attr('fld'); 195 }).get(); 196 arr_adv_filters = $(".adv-filter:checked").map(function () { 197 return $(this).attr('fld'); 198 }).get(); 199 arr_search_filters = $.unique(arr_search_filters); 200 arr_adv_filters = $.unique(arr_adv_filters); 201 $.each(arr_search_filters, function (i, val) { 202 var list = $("input[name='" + val + "[]']:checked").map(function () { 203 return $(this).val(); 204 }).get().join('|'); 205 if (list != '') 206 { 207 list = list.replace(/\s/g, "+"); 208 list = list.replace('&', '%26'); 209 filter_string += "&" + val + "=" + list; 210 } 211 }); 212 $.each(arr_adv_filters, function (i, val) { 213 var list = $("input[name='" + val + "[]']:checked").map(function () { 214 return $(this).val(); 215 }).get().join('|'); 216 if (list != '') 217 { 218 list = list.replace(/\s/g, "+"); 219 list = list.replace('&', '%26'); 220 filter_string += "&" + val + "=" + list; 221 } 222 }); 223 var query_string = ""; 224 if ($.trim($("#q").val()) != '') 225 query_string = "q=" + $("#q").val(); 226 if( $.trim($("#q-max_weight").val()) != '' && !isNaN($.trim($("#q-max_weight").val())) ) 227 query_string += "&q-max_weight="+$("#q-max_weight").val(); 228 if ($.trim($("#sort").val()) != '') 229 query_string += "&sort=" + $("#sort").val(); 230 if ($.trim($("#view-type", $('#frm_search')).val()) != '') //theme-builder 231 query_string += "&view-type=" + $("#view-type", $('#frm_search')).val(); 232 233 query_string += filter_string; 234 if (query_string.charAt(0) == '&') 235 return query_string.substring(1); 236 else 237 return query_string; 238} 239 240function set_button_triggers() 241{ 242 $(".call-for-quoate").click(function () { 243 $("#unit_id").val($(this).attr('unit_id')); 244 $("#unit_name").val($(this).attr('unit_name')); 245 $("#unit_code").val($(this).attr('unit_code')); 246 $("#unit_url").val($(this).attr('unit_url')); 247 }); 248} 249 250function update_search_filters() 251{ 252 var search_query_string = built_search_query_string(); 253 var filtervars = { 254 do_what: 'update_search_filters', 255 lang: function () { //set for multilinugal site
256 if (CLIENTS_LOCALE != '') { 257 return _THEME_LANG; 258 } else { 259 return ''; 260 } 261 }, 262 sold_listing:$('#sold_listing').val() 263 }; 264 $.ajax({ 265 type: "POST", 266 url: WS_PATH + "inventory/includes/search_ajax.php?r=" + Math.random() + "&" + search_query_string, 267 data: filtervars, 268 dataType: "html", 269 success: function (html) { 270 var updated_search_filters = $.parseJSON(html); 271 if (typeof (updated_search_filters) == 'object') 272 { 273 $(".search-filter").each(function () { 274 var s = $('span', $(this).parents('label')).html().replace(/\(.*?\)/g, "(0)"); 275 $('span', $(this).parents('label')).html(s); 276 }); 277 $(".adv-filter").each(function () { 278 var s = $('span', $(this).parents('label')).html().replace(/\(.*?\)/g, "(0)"); 279 $('span', $(this).parents('label')).html(s); 280 }); 281 $.each(updated_search_filters, function (fldName, arrFilters) { 282 $.each(arrFilters.opt, function (fldValue, fldData) { 283 set_filter_counter(fldName, fldValue, fldData.CNT); 284 }); 285 }); 286 } 287 } 288 }); 289} 290function set_filter_counter(fldName, fldValue, CNT) { 291 // Handle numeric and string values differently 292 var objFilter; 293 if ($.isNumeric(fldValue)) { 294 objFilter = $("input:checkbox[name='" + fldName + "[]'][value='" + fldValue + "']"); 295 } else { 296 // For string values, try to find exact match first 297 var strFldVal = fldValue.replace(/\\/g, "\\\\").replace(/'/g, "\\'"); 298 objFilter = $("input:checkbox[name='" + fldName + "[]'][value='" + strFldVal + "']"); 299 300 // If no exact match, try case-insensitive 301 if (objFilter.length === 0) { 302 objFilter = $("input:checkbox[name='" + fldName + "[]']").filter(function() { 303 return $(this).val().toLowerCase() === strFldVal.toLowerCase(); 304 }); 305 } 306 307 // If still no match, try with contains as a fallback 308 if (objFilter.length === 0) { 309 objFilter = $("input:checkbox[name='" + fldName + "[]'][value*='" + strFldVal + "']"); 310 } 311 } 312 313 // Update the count if elements were found 314 if (objFilter.length > 0 && $('span', objFilter.parents('label')).length > 0) { 315 var spanElement = $('span', objFilter.parents('label'));
316 var currentHTML = spanElement.html(); 317 318 var updatedHTML = currentHTML.replace(/\(\d+\)/g, "(" + CNT + ")"); 319 320 spanElement.html(updatedHTML); 321 } 322} 323 324function expand_search_filters() 325{ 326 $('a[role="button"]', $(".search-filter:checked").parents('.panel')).click(); 327 $('a[role="button"]', $(".adv-filter:checked").parents('.panel')).click(); 328} 329 330function ChangeUrl(title, url) { 331 if (typeof (history.pushState) != "undefined") { 332 var obj = {Title: title, Url: url}; 333 history.pushState(obj, obj.Title, obj.Url.replace('&&', '&').replace("?&", "?")); 334 } else { 335 //alert("Browser does not support HTML5."); 336 } 337} 338function do_search(page) { 339 var last_page = (page - 1); 340 var current_url = window.location.href; 341 current_url = current_url.replace("page=" + page, "").replace("page=" + last_page, "").replace("page=" + (page + 1), "").replace("&&", "&").replace("?&", "?"); 342 $('#page').val(page); 343 search_query_string = built_search_query_string(); 344 is_search_loading = true; 345 //window.location.href = WS_PATH+"inventory/?page="+page+"&"+search_query_string; 346// window.location.href = $('#JS_VLP_URL_ID').val() + "/?page=" + page + "&" + search_query_string; 347 $('#followingBallsG').removeClass("hide"); 348 var filtervars = { 349 do_what: 'do_search', 350 page: page, 351 sold_listing:$('#sold_listing').val() 352 }; 353 $.ajax({ 354 type: "POST", 355 url: WS_PATH + "inventory/includes/search_ajax.php?r=" + Math.random() + "&page=" + page + "&" + search_query_string, 356// url: $('#JS_VLP_URL_ID').val() + "/?page=" + page + "&" + search_query_string, 357// url: $('#JS_VLP_URL_ID').val() + "/?r=" + Math.random() + "&page=" + page + "&" + search_query_string, 358 data: filtervars, 359 dataType: "html", 360 success: function (html) { 361// var arr_html = html.split('|'); 362// console.log(html); 363 if (html != 'EOF') 364 { 365 if (current_url.indexOf("?") > -1) 366 ChangeUrl(document.title, current_url + "&page=" + page); 367 else 368 ChangeUrl(document.title, current_url + "?page=" + page); 369 370 $("#inventory-listing").append(html); 371 $("#page-" + page).nextAll().hide().slideDown("slow"); 372 $('#followingBallsG').addClass("hide"); 373 is_search_loading = false; 374// tb_init($("#page-"+page).nextAll().find('a.thickbox')); 375 update_search_filters(); 376 set_button_triggers(); 377 } else 378 { 379 $("#inventory-listing").append('<p class="lead text-muted text-center m-t-30">End of Results</p>'); 380 $('#followingBallsG').addClass("hide"); 381 } 382 } 383 }); 384 385 386 387} 388 389function do_saved_search() { 390 saved_search_active = true; 391 392 var unit_list = ''; 393 unit_list = $.cookie(location.host); 394 395 if (unit_list.substring(0, 1) == '|') { 396 unit_list = unit_list.substring(1); 397 } 398 399 if (unit_list != '') 400 window.location.href = $('#JS_VLP_URL_ID').val() + "/?saved=" + unit_list; 401 else 402 window.location.href = $('#JS_VLP_URL_ID').val() + "/?saved=0"; 403} 404 405function show_my_save_link() { 406 var saved_list = $.cookie(location.host) 407 var arr_unit_list = []; 408 409 if (typeof saved_list != 'undefined' && saved_list.length > 0) 410 { 411 saved_list = saved_list.trim(); 412 413 if (saved_list.substring(0, 1) == '|') { 414 saved_list = saved_list.substring(1); 415 } 416 417 arr_unit_list = saved_list.split('|'); 418 } 419// console.log(arr_unit_list.length); 420 421 if (arr_unit_list.length > 0) 422 { 423 $(".js-saved-list").removeClass('hide'); 424 } 425} 426 427$('.vlp-filter-clear').click( function(){ 428 var id = $(this).data('key'); 429 if(id == 'q' || id == 'q-max_weight'){ 430 $('#'+id).val(''); 431 $('#frm_search').submit(); 432 }else{ 433 $('#'+id).trigger('click'); 434 } 435 $(this).parent().remove(); 436}); 437 438$('.vlp-filter-clear-span').click( function(){ 439 $('#vlp-filter-labels').html(''); 440 441 var current_path = window.location.pathname; 442 window.location.href = current_path; 443 444 // window.location.href = $('#JS_VLP_URL_ID').val(); 445}); 446 447$('input[name=q]').autocomplete({ 448 html: true, 449 source: function(request, response) { 450 $.ajax({ 451 type: "POST", 452 url: WS_PATH + "inventory/includes/search_ajax.php?r=" + Math.random(), 453 dataType: "json", 454 data: {do_what: 'do_keyword_search',q: request.term,sold_listing:$('#sold_listing').val()}, 455 success: function(data) { 456 response(data); 457 } 458 }); 459 }, 460 minLength: 3, 461 classes: { 462 "ui-autocomplete" : "suggested-search-ul" 463 }, 464 select: function(event, ui) { 465 if (ui.item.ext != '') { 466 window.location = ui.item.ext; 467 } else if ( 468 ui.item.value == 'error') { 469 return $(this).val(''); 470 } else { 471 $(this).val(ui.item.value); 472 $(this).closest("form").submit(); 473 } 474 } 475}); 476$[ "ui" ][ "autocomplete" ].prototype["_renderItem"] = function( ul, item) { 477 return $( "<li></li>" ) 478 .data( "item.autocomplete", item ) 479 .append( $( "<a></a>" ).html( item.label ) ) 480 .appendTo( ul ); 481};
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.