JAVASCRIPT 40
Filtersearch.js Guest on 7th July 2020 01:58:33 PM
  1. $(document).off('click', '.disable-opt').on('click', '.disable-opt', function (e) {
  2. // e.preventDefault();
  3. //alert('aa');
  4. $('input[name="searchFormContentString"]').val("");
  5. $(document).find('input.set-checkbox').removeClass('set-checkbox');
  6. $(this).find('input[type=checkbox]:first').addClass('set-checkbox');
  7. //        alert('ccccc');
  8. $('#selectionUnavailableModal').css("display", "block");
  9. });
  10. var alertMessage = '<div id="selectionUnavailableModal" class="modal">  <div class="GC24 modal-content"> <span id="closemodal" class="close">&times;</span> <p><span id="LD.LD_SEARCH_SELECTIONUNAVAILABLE" name="LD.LD_SEARCH_SELECTIONUNAVAILABLE">This selection is not available with your other choices. Should we reset the other choices so you can pick this one?</span></p> <div class="btn_grup"><div class="btn_inner"> <button id="cancel" type="button"><span id="LD.LD_CANCEL" name="LD.LD_CANCEL">Cancel</span></button> </div> <div class="btn_inner"> <button id="ok" type="button"><span id="LD.LD_OK" name="LD.LD_OK">OK</span></button> </div><div> </div></div>';
  11. if ($('body').find('#selectionUnavailableModal').length == 0) {
  12. $('body').prepend(alertMessage);
  13. }
  14. var loaderDiv = '<div id="searching-progress" style="text-align: center; padding: 10px 0px; display: block;position: fixed;display: block;width: 100%;height: 100%;top: 0;left: 0;right: 0;bottom: 0;background-color: rgba(0, 0, 0, 0.5);z-index: 9999999;cursor: pointer;padding: 0 !important;margin: 0;"><div class="searching-progress_wrapper" style="position: relative;width: 100%;height: 100%;"><div class="searching-progress_inner" style="position: absolute;top: 50%;left: 50%;transform: translate(-50%, -50%);display: inline-block;"><h2><span id="LD.LD_SEARCHINGHEAD" name="LD.LD_SEARCHINGHEAD">Searching...</span></h2><div class="icon-spinner2 icon-fa-spin" style="margin:auto auto;font-size:2em;"></div><p><span id="LD.LD_SEARCHing" name="LD.LD_SEARCHING">Searching for phrase</span></p><p id="search-phrase-waiting"></p></div></div></div>';
  15. if ($('body').find('#searching-progress').length == 0) {
  16. $('body').prepend(loaderDiv);
  17. }
  18. /*
  19. * Author: Sl
  20. * Created: 05 April 2018
  21. * Description:   creating  function for form reset
  22. */
  23. function refresh_page() {
  24. $(document).find('#searching-progress').css("display", "block");
  25. if(history.replaceState)history.replaceState(null,null,document.location.href.replace(/searchphrase=[^&=]*&?/,''));
  26. setTimeout(function(){document.location.reload()}, 200);
  27. }
  28. function resetSelections() {
  29. $("#checkbox_brands").val("");
  30. $('#specifications_feature').val("");
  31. $('#optionschoice').val("");
  32. $('#get_special').val("0");
  33. $('#selectkeywords').val("");
  34. $('#dept').val("");
  35. var min = $("#slider-range").slider("option", "min"), max = $("#slider-range").slider("option", "max");
  36. price_filter_init(min, max);
  37. $("#amountL").html(tf.core.dPrc(min, true));
  38. $("#amountR").html(tf.core.dPrc(max, true));
  39. $("#minValue").val(min);
  40. $("#maxValue").val(max);
  41. $("#ignore_websitecontent").val('0');
  42. $('#frmfilter').find('.disable-opt').removeClass('disable-opt');
  43. }
  44. /*
  45. * Author: Sl
  46. * Created: 05 April 2018
  47. * Description:   creating  function for form submit
  48. */
  49. function submit() {
  50. $("#pagereset").val('1');
  51. var pgid = $('#pgid').val();
  52. var lastsearchvalue = $('#lastsearchvalue').val();
  53. var newserachval = $('#searchFormContentString').val();
  54. /****if($.trim(newserachval) == ""){
  55. return;
  56. }*/
  57. if (lastsearchvalue != newserachval) {
  58. if (pgid == '') {
  59. filterSearchAcquire({
  60. 'filterproc': 'filteracquire',
  61. 'fmt': 'html',
  62. 'pgid': '',
  63. 'sub': '',
  64. 'searchFormContentString': newserachval,
  65. 'disp': tf.sfFilters['dispFilterTypes']
  66. });
  67. }
  68. updateURL(newserachval);
  69. }
  70. $('[name=start_page]').val(1);
  71. $('#dept').val('');
  72. filter_Timer();
  73. }
  74. /*
  75. * Author: Sl
  76. * Created: 05 April 2018
  77. * Description:   creating time function for form submit
  78. */
  79. var filter_Timer_id;
  80. function filter_Timer(eventChecked) {
  81. $('#search-phrase-waiting').html($("#searchFormContentString").val()); // update loader search text
  82. clearInterval(filter_Timer_id);
  83. filter_Timer_id = setInterval(function () {
  84. /*check if not any other option is checked if yes then need to disable brands otherwise not */
  85. var isSpecSelected = $('#specifications_feature').val();
  86. var isOptionSelected = $('#optionschoice').val();
  87. var isKeywordSelected = $('#selectkeywords').val();
  88. var isSpecialSelected = $('#get_special').is(':checked');
  89. $('#lastEventChecked').val("");
  90. if (!isSpecSelected && !isOptionSelected && !isSpecialSelected && !isKeywordSelected) {
  91. $('#lastEventChecked').val("brands"); // if set to brands then it will not disable brands checkboxes
  92. }
  93. clearInterval(filter_Timer_id);
  94. $(document).find('#searching-progress').css("display", "block");
  95. if (eventChecked == "reset") {
  96. var minPrice = $('input[name="searchFormPriceMin"]').val();
  97. var maxPrice = $('input[name="searchFormPriceMax"]').val();
  98. $('input[name="searchFormPriceMax"]').val("");
  99. $('input[name="searchFormPriceMin"]').val("");
  100. $('input[name="resetform"]').val("yes");
  101. $('#pagereset').val(1);
  102. $(document.frmfilter).append('<input type="hidden" name="loaddefault" value="yes" />')
  103. }
  104. $('#frmfilter').submit();
  105. if (eventChecked == "reset") {
  106. $(document.frmfilter).find('[name=loaddefault]').remove();
  107. setTimeout(function () {
  108. $('input[name="searchFormPriceMax"]').val(maxPrice);
  109. $('input[name="searchFormPriceMin"]').val(minPrice);
  110. }, 1000);
  111. }
  112. $('.rest-btn.rest-arrow-wrapper, .new_search_icon').toggleClass('highlight', false);
  113. }, 0);
  114. }
  115. function getOrLoadRightSide(rightside, data, searchURL, q) {
  116. var needRefresh = (data.indexOf('<!-- SF PHPSearch results') == -1 || data.indexOf('design=' + parm['design']) == -1);
  117. if (!needRefresh) {
  118. needRefresh = (data.match(/<!-- SF PHPSearch lmd=([0-9.]+)/) ? parseFloat(tf.lmd['searchcsv']) > parseFloat(RegExp.$1) : false);
  119. }
  120. if (needRefresh) {
  121. if (searchURL && q) var netSearch = new net.ContentLoader(searchURL + '?' + q, net.ContentLoader.onloadSearchResult, null, null, parm['find'] ? 'GET' : 'POST', q);
  122. else filterSearch(document.frmfilter);
  123. loadhistory = 0;
  124. }
  125. else {
  126. loadrightside(rightside, data);
  127. }
  128. }
  129. /*
  130. * Author: Sl
  131. * Created: 06 Feb 2018
  132. * Description:   getting  display order for  sorting list
  133. * Exactly the same function in search.js and filtersearch.js
  134. */
  135. function price_filter_init(minVal, maxVal) {
  136. var maxValNew = parseFloat(maxVal);
  137. $('#initialmin').val(minVal);
  138. $('#initialmax').val(maxValNew);
  139. $("#slider-range").slider({
  140. range: true,
  141. min: parseFloat(minVal),
  142. //min: parseFloat('13.00'),
  143. max: parseFloat(maxValNew),
  144. values: [0.00, maxValNew],
  145. step: 0.01,
  146. slide: function (event, ui) {
  147. //alert(ui.values[1]);
  148. var gotmin;
  149. if (ui.values[0] == 0) {
  150. var gotmin = '0.00';
  151. } else {
  152. var gotmin = parseFloat(ui.values[0]);
  153. }
  154. $("#amountL").html(tf.core.dPrc(gotmin, true));
  155. $("#amountR").html(tf.core.dPrc(ui.values[1], true));
  156. $("#minValue").val(gotmin);
  157. $("#maxValue").val(ui.values[1]);
  158. },
  159. change: function (event, ui) {
  160. $('.price_box .rest-btn.rest-arrow-wrapper, .price_box .new_search_icon').toggleClass('highlight', true);
  161. /*add flag ignore_webcontent 0 or 1 according to condition*/
  162. filterchange_status();
  163. }
  164. });
  165. }
  166. function decodeHtml(str) {
  167. return str.replace(/&#(\d+);/g, function(match, dec) {
  168. return String.fromCharCode(dec);
  169. });
  170. }
  171. function decodeEntities(encodedString) {
  172. var div = document.createElement('div');
  173. div.innerHTML = encodedString.replace(/\&\#34\;/g,'&=#34;');
  174. return div.textContent.replace(/\&\=\#34\;/g,'&#34;').trim().replace(/(?:\&\#58\;|\&\#44\;|\.,)*$/g,'');
  175. }
  176. $('#frmfilter #searchFormContentString')
  177. .off('keypress blur')
  178. .on('keypress blur', function () {
  179. $('.searchbox .rest-btn.rest-arrow-wrapper, .searchbox .new_search_icon').toggleClass('highlight', $(this).val() ? true : false);
  180. });
  181. var fsDispArray = fsDispArray || ['specialorder', 'prices', 'brandorder', 'specifications_featurelist', 'optionchoice'];
  182. function init_advance_filter() {
  183. //$(document).find('#searching-progress').css("display", "none");
  184. //$('#searching-progress').remove();
  185. var minVal = 0;
  186. var maxVal = 0;
  187. var elArray = [];
  188. $(document).find(".styleclass").each(function () {
  189. elArray[$(this).attr("data-id")] = $(this).html();
  190. });
  191. var sortfilter_html = "";
  192. $.each(fsDispArray, function (index, value) {
  193. if (value == "prices") {
  194. var priceHtml = $($.parseHTML(elArray[value]));
  195. minVal = priceHtml.find('#minValue').val();
  196. maxVal = priceHtml.find('#maxValue').val();
  197. }
  198. if (elArray[value]) {
  199. sortfilter_html += "<div class='outer_section styleclass' data-id='" + value + "'>";
  200. sortfilter_html += elArray[value];
  201. sortfilter_html += "</div>";
  202. }
  203. });
  204. // adding to  .sidbar  class
  205. if (sortfilter_html) $(document).find(".sidebar_filter").html(sortfilter_html);
  206. /*
  207. * Author: Sl
  208. * Created: 06 Feb 2018
  209. * Description:   adding price slider code here
  210. */
  211. setTimeout((function (minVal, maxVal) {
  212. price_filter_init(minVal, maxVal);
  213. $("#amountL").html(tf.core.dPrc($("#slider-range").slider("values", 0), true));
  214. $("#amountR").html(tf.core.dPrc($("#slider-range").slider("values", 1), true));
  215. })(minVal, maxVal), 1000);
  216. $(".newtoggle").click(function () {
  217. $(this).parents(".panel").find("input:checkbox").prop("checked", false);
  218. $(this).parents(".panel").find("input:radio").prop("checked", false);
  219. });
  220. /*
  221. * Author: Sl
  222. * Created: 06 Feb 2018
  223. * Description:  filter loggle code for hide and show
  224. */
  225. $(".showAllCheckbocx").click(function () {
  226. $(".allCheckbox").toggle(600);
  227. $(".showAllCheckbocx").hide();
  228. });
  229. $(".showAllCheckbocx_brand").click(function () {
  230. $(".allCheckbox_brand").toggle(600);
  231. $(".showAllCheckbocx_brand").hide();
  232. });
  233. $(".showAllCheckbocx_features").click(function () {
  234. $(".allCheckbox_features").toggle(600);
  235. $(".showAllCheckbocx_features").hide();
  236. });
  237. $(".showAllCheckbocx_features_less").click(function () {
  238. $(this).parents(".allCheckbox_features").toggle(600);
  239. $(this).parents(".allCheckbox_features").prev('.showAllCheckbocx_features').show();
  240. //$(this).hide();
  241. });
  242. $(".showAllCheckbocx_options").click(function () {
  243. $(this).next(".allCheckbox_options").toggle(600);
  244. $(this).hide();
  245. });
  246. $(".showAllCheckbocx_options_less").click(function () {
  247. $(this).parents(".allCheckbox_options").toggle(600);
  248. $(this).parents(".allCheckbox_options").prev('.showAllCheckbocx_options').show();
  249. //$(this).hide();
  250. });
  251. $(".showAllCheckbocx_brand_less").click(function () {
  252. $(this).parents(".allCheckbox_brand").toggle(600);
  253. $(this).parents(".allCheckbox_brand").prev('.showAllCheckbocx_brand').show();
  254. //$(this).hide();
  255. });
  256. $(".showAllCheckbocx_keywords").click(function () {
  257. $(".allCheckbox_keywords").toggle(600);
  258. $(".showAllCheckbocx_keywords").hide();
  259. });
  260. // Add minus icon for collapse element which is open by default
  261. $(".collapse.in").each(function () {
  262. $(this).siblings().find(".panel-heading .find_class").addClass("sm_addclass").removeClass("sm_removeclass");
  263. });
  264. // Toggle plus minus icon on show hide of collapse element
  265. $(".collapse").off("show.bs.collapse").on("show.bs.collapse", function () {
  266. $(this).siblings().find(".panel-heading .find_class").removeClass("sm_removeclass").addClass("sm_addclass");
  267. $(window).trigger('resize');
  268. if (tf.equalHeight) tf.equalHeight();
  269. })
  270. .off("hide.bs.collapse").on("hide.bs.collapse", function () {
  271. $(this).siblings().find(".panel-heading .find_class").removeClass("sm_addclass").addClass("sm_removeclass");
  272. $(window).trigger('resize');
  273. if (tf.equalHeight) tf.equalHeight();
  274. });
  275. /*
  276. * Author: Sl
  277. * Created: 06 Feb 2018
  278. * Description:checking if  special is clicked
  279. */
  280. $('.getspecial').click(function () {
  281. $("#pagereset").val('1');
  282. $(this).attr("checked", "checked");
  283. if (!$(this).is(":checked")) {
  284. $(this).attr('checked', false);
  285. }
  286. $('[name=searchFormPriceMin]').val(0);
  287. $('[name=searchFormPriceMax]').val(0);
  288. /*add flag ignore_webcontent 0 or 1 according to condition*/
  289. filterchange_status();
  290. filter_Timer();
  291. });
  292. /*
  293. * Author: Sl
  294. * Created: 06 Feb 2018
  295. * Description: checking if keywords checkbox clicked
  296. */
  297. $('.keyword_btn').click(function () {
  298. $("#pagereset").val('1');
  299. $('[name=searchFormPriceMin]').val(0);
  300. $('[name=searchFormPriceMax]').val(0);
  301. $('#dept').val('');
  302. var favorite = [];
  303. if (!$(this).is(":checked")) {
  304. $(this).attr('checked', false);
  305. }
  306. $.each($(".keyword_btn:checked"), function () {
  307. favorite.push($(this).val());
  308. });
  309. $('#selectkeywords').val(favorite);
  310. /*add flag ignore_webcontent 0 or 1 according to condition*/
  311. filterchange_status();
  312. filter_Timer();
  313. });
  314. /*
  315. * Author: Sl
  316. * Created: 06 Feb 2018
  317. * Description:checking if brnad checkbox clicked
  318. */
  319. $('.brand_btn').click(function () {
  320. $("#pagereset").val('1');
  321. $('[name=searchFormPriceMin]').val(0);
  322. $('[name=searchFormPriceMax]').val(0);
  323. $('[name=initialmin]').val(0);
  324. $('[name=initialmax]').val(0);
  325. $('#searching-progress').css("display", "block");
  326. var searchfor = ($('#searchFormContentString').val() || '');
  327. var get_special = ($('#get_special').val() || '0');
  328. var specifications_feature = ($('#specifications_feature').val() || '');
  329. var optionschoice = ($('#optionschoice').val() || '');
  330. var checkbox_brands = ($('#checkbox_brands').val() || '');
  331. var numberOfChecked = $('.brand_btn:checkbox:checked').length;
  332. var numberOfCheckedspecification = $('.specification_btn:checkbox:checked').length;
  333. var numberOfCheckedoptions = $('.options_btn:checkbox:checked').length;
  334. if (!$(this).is(":checked")) {
  335. $(this).attr('checked', false);
  336. $('[name=searchFormPriceMin]').val(0);
  337. $('[name=searchFormPriceMax]').val(0);
  338. }
  339. if (numberOfCheckedoptions == '0' && numberOfCheckedspecification == '0' && get_special == '0' && searchfor == '' && numberOfChecked == '0') {
  340. refresh_page();
  341. // var default_brand = 'all_search_filter';
  342. // var default_brandright = 'all_search_filter_results';
  343. // loadleftside(default_brand);
  344. // loadrightside(default_brandright);
  345. return;
  346. }
  347. var favorite = [];
  348. $.each($(".brand_btn:checked"), function () {
  349. favorite.push(encodeURI($(this).val()));
  350. });
  351. $('#checkbox_brands').val(favorite);
  352. if (numberOfCheckedoptions == '0' && numberOfCheckedspecification == '0' && get_special == '0' && searchfor == '' && numberOfChecked == '1') {
  353. //alert(' i m here');
  354. var brand_str = $(document).find('.brand_btn:checked').val();
  355. brand_str = brand_str.replace(" ", "_");
  356. var brands = 'leftside_' + brand_str;
  357. brands = decodeHtml(decodeEntities(brands))
  358. var brandright = decodeHtml(decodeEntities(brand_str))+'-'+tf.parm['searchFormDisplayStyle'];
  359. if (numberOfChecked == 1) {
  360. var searchURLALL = unescape(tf.wm.hostbaseurl) + "contents/phpsearch/htmlfiles/" + brandright + ".html";
  361. //alert('url for search '+ searchURLALL);
  362. $.ajax({
  363. url: searchURLALL,
  364. error: function () {
  365. //alert('on error ==>>'+ brand+'==='+ brandright);
  366. $('#dept').val('');
  367. $('[name=start_page]').val(1);
  368. $('#searching-progress').css("display", "block");
  369. filter_Timer();
  370. },
  371. success: function (data) {
  372. getOrLoadRightSide(brandright, data);
  373. }
  374. });
  375. }
  376. } else {
  377. $('#dept').val('');
  378. $('[name=start_page]').val(1);
  379. $('#searching-progress').css("display", "block");
  380. filter_Timer();
  381. }
  382. /*add flag ignore_webcontent 0 or 1 according to condition*/
  383. filterchange_status();
  384. });
  385. /*
  386. * Author: Sl
  387. * Created: 06 Feb 2018
  388. * Description:option and choice filter script  for getting the data from checkbox and add to hidden field
  389. */
  390. $(document).off('change', 'input[name=specials]').on('change', 'input[name=specials]', function () {
  391. $('#dept').val('');
  392. $('[name=start_page]').val(1);
  393. $(this).val(this.checked ? 1 : 0);
  394. if (!$(this).is(":checked")) {
  395. $(this).attr('checked', false);
  396. $('[name=searchFormPriceMin]').val(0);
  397. $('[name=searchFormPriceMax]').val(0);
  398. }
  399. /*add flag ignore_webcontent 0 or 1 according to condition*/
  400. filterchange_status();
  401. });
  402. $(document).off('change', '.options_btn').on('change', '.options_btn', function () {
  403. $('[name=searchFormPriceMin]').val(0);
  404. $('[name=searchFormPriceMax]').val(0);
  405. $('#dept').val('');
  406. $('[name=start_page]').val(1);
  407. var data = {},
  408. dataCnt = 0;
  409. var opts;
  410. if ($(this).attr('type') == 'radio') {
  411. $('.optradio').not(this).prop('checked', false);
  412. }
  413. $(".option_checked").each(function () {
  414. $('#dept').val('');
  415. opts = $(this).attr('id');
  416. var typecheck = $(this).attr('data-type');
  417. var choice = []; // <-- Main array
  418. if (typecheck == "check") {
  419. $(this).find("input:checked").each(function () {
  420. $(this).attr("checked", "checked");
  421. choice.push($(this).val());
  422. });
  423. } else if (typecheck == "select") {
  424. $(this).find("input:checked").each(function () {
  425. $(this).attr("checked", "checked");
  426. choice.push($(this).val());
  427. });
  428. } else if (typecheck == "radio") {
  429. $(this).find("input:checked").each(function () {
  430. $(this).attr("checked", "checked");
  431. choice.push($(this).val());
  432. });
  433. }
  434. if (choice.length > 0) {
  435. data[opts] = choice;
  436. dataCnt++;
  437. }
  438. });
  439. var jsonString = dataCnt > 0 ? JSON.stringify(data) : '';
  440. //console.log(jsonString);
  441. $('#optionschoice').val(jsonString);
  442. /*add flag ignore_webcontent 0 or 1 according to condition*/
  443. filterchange_status();
  444. filter_Timer();
  445. });
  446. /*
  447. * Author: Sl
  448. * Created: 06 Feb 2018
  449. * Description:specifiaction filter script  get data from  checkbox and  add to hidden field
  450. */
  451. $(document).off('change', '.specification_btn').on('change', '.specification_btn', function () {
  452. $('[name=searchFormPriceMin]').val(0);
  453. $('[name=searchFormPriceMax]').val(0);
  454. //$(this).attr("checked", "checked");
  455. $("#ignore_websitecontent").val('1');
  456. $('#dept').val('');
  457. $('[name=start_page]').val(1);
  458. var data = {},
  459. dataCnt = 0;
  460. var opts;
  461. $(".specification_checked").each(function () {
  462. opts = $(this).attr('data-id');
  463. var choice = []; // <-- Main array
  464. $(this).find("input:checked").each(function () {
  465. choice.push($(this).val());
  466. });
  467. if (choice.length > 0) {
  468. data[opts] = choice;
  469. dataCnt++;
  470. }
  471. });
  472. var jsonString = dataCnt > 0 ? JSON.stringify(data) : '';
  473. //console.log(jsonString);
  474. $('#specifications_feature').val(jsonString);
  475. /*add flag ignore_webcontent 0 or 1 according to condition*/
  476. filterchange_status();
  477. filter_Timer();
  478. });
  479. }
  480. var timer_ok;
  481. $("#ok").off('click').on("click", function (e) {
  482. e.preventDefault();
  483. e.stopPropagation();
  484. clearInterval(timer_ok);
  485. timer_ok = setInterval(function () {
  486. clearInterval(timer_ok);
  487. okClick();
  488. }, 0);
  489. });
  490. function okClick() {
  491. $(document).find('.tag').removeClass('disable-opt');
  492. $(document).find('input[type=checkbox]:not(.allproductcheck)').removeAttr('checked');
  493. $("#searchFormContentString").val("");
  494. $('#dept').val("");
  495. resetSelections();
  496. $("#minValue").val(0);
  497. $("#maxValue").val(0);
  498. $('#searching-progress').css("display", "block");
  499. $('#selectionUnavailableModal').css("display", "none");
  500. $(document).find('.set-checkbox').trigger('click');
  501. //$('#frmfilter').submit();
  502. }
  503. $("#cancel").click(function () {
  504. $(document).find('.set-checkbox').removeClass('set-checkbox');
  505. $('#selectionUnavailableModal').css("display", "none");
  506. });
  507. $("#closemodal").click(function () {
  508. $(document).find('.set-checkbox').removeClass('set-checkbox');
  509. $('#selectionUnavailableModal').css("display", "none");
  510. });
  511. /* Copy Link */
  512. $('.copy-icon').off('click').on('click', function (e) {
  513. e.preventDefault();
  514. var url = $(this).attr('data-link');
  515. //var lastval = url.slice(-12);
  516. var lastword = url.split("&").pop();
  517. var lastvals = lastword.split("=");
  518. var lastval = lastvals[0];
  519. if (url !== undefined && lastval == 'start_page' || lastval == 'lang') {
  520. var langs = tf.lang;
  521. url += "&langs=" + langs + "&copylink=yes";
  522. }
  523. if (url !== undefined) {
  524. var temp = '<input  class="sr-only" type="text" id="txt_copy" value="' + url + '">';
  525. $("body").append(temp);
  526. document.getElementById("txt_copy").select();
  527. document.execCommand('copy');
  528. $("#txt_copy").remove();
  529. $("#copymsg").fadeIn();
  530. $("#copymsg").fadeOut(2500);
  531. $("#copymsg").hide();
  532. }
  533. });
  534. $(document).off('change', '.department').on('change', '.department', function () {
  535. var dept = $(this).val();
  536. var searchstring = $('#searchContentString').val();
  537. var currentval = $('#searchFormContentString').val();
  538. $('#dept').val(dept);
  539. $('#searchFormContentString').val(searchstring || currentval);
  540. $('[name=start_page]').val(1);
  541. // return false;
  542. filter_Timer();
  543. });
  544. $(document).off('click', '.allproductcheck').on('click', '.allproductcheck', function () {
  545. var product = 0;
  546. var content = 0;
  547. var checked;
  548. if ($("#allproductcheck").prop('checked') == true) {
  549. product = 1;
  550. checked = 'P';
  551. $('#frmfilter').show();
  552. } else {
  553. var min = $("#slider-range").slider("option", "min"),
  554. max = $("#slider-range").slider("option", "max");
  555. price_filter_init(min, max);
  556. $("#amountL").html(tf.core.dPrc(min, true));
  557. $("#amountR").html(tf.core.dPrc(max, true));
  558. $("#minValue").val(min);
  559. $("#maxValue").val(max);
  560. }
  561. if ($("#searchwithincontent").prop('checked') == true) {
  562. content = 1;
  563. checked = 'W';
  564. $('#frmfilter').hide();
  565. }
  566. if (content == '1' && product == '1') {
  567. $('#frmfilter').show();
  568. checked = 'A';
  569. }
  570. if (content == '0' && product == '0') {
  571. $('#frmfilter').hide();
  572. checked = 'A';
  573. }
  574. if (content == '1' && product == '0') {
  575. $('#frmfilter').hide();
  576. $('#dept').val('');
  577. $('#checkbox_brands').val('');
  578. $('#minValue').val('');
  579. $('#maxValue').val('');
  580. $('#specifications_feature').val('');
  581. $('#optionschoice').val('');
  582. $("#ignore_websitecontent").val('0');
  583. checked = 'W';
  584. }
  585. $('#searchFormRootUse').val(checked);
  586. $('[name=start_page]').val(1);
  587. // return false;
  588. filter_Timer();
  589. });
  590. $(document).ready(function () {
  591. setTimeout(function () {
  592. var getminval = $('#minValue').val();
  593. if (getminval == '') {
  594. getminval = 0;
  595. }
  596. $("#amountL").html(tf.core.dPrc(getminval, true));
  597. }, 2000);
  598. });
  599. function updateURL(newserachval) {
  600. if (history.pushState) {
  601. var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?searchphrase=' + newserachval;
  602. window.history.pushState({
  603. path: newurl
  604. }, '', newurl);
  605. }
  606. }
  607. function filterchange_status() {
  608. var pgid = $('#pgid').val();
  609. if (pgid === '') {
  610. var searchstring = $('#searchContentString').val();
  611. $('#searchFormContentString').val(searchstring);
  612. var Checkedspecial = $('.getspecial:checkbox:checked').length;
  613. var numberOfChecked = $('.brand_btn:checkbox:checked').length;
  614. var numberOfCheckedspecification = $('.specification_btn:checkbox:checked').length;
  615. var numberOfCheckedoptions = $('.options_btn:checkbox:checked').length;
  616. var minprices = $('#minValue').val();
  617. var maxprices = $('#maxValue').val();
  618. var nmin = $("#slider-range").slider("option", "min");
  619. var nmax = $("#slider-range").slider("option", "max");
  620. if (Checkedspecial == 0 && numberOfChecked == 0 && numberOfCheckedspecification == 0 && numberOfCheckedoptions == 0) {
  621. if (maxprices == nmax && minprices == nmin) {;
  622. $("#ignore_websitecontent").val('0');
  623. } else {
  624. $("#ignore_websitecontent").val('1');
  625. }
  626. } else {
  627. $("#ignore_websitecontent").val('1');
  628. $("#pagereset").val('1');
  629. }
  630. }
  631. }
  632. $(document).off('click', '.rest-arrow-wrapper').on('click', '.rest-arrow-wrapper', function () {
  633. var searchstring = $('#searchContentString').val();
  634. if (searchstring !== undefined) {
  635. $('#searchFormContentString').val(searchstring);
  636. }
  637. });
  638. $(document).off('click', '.new_search_icon').on('click', '.new_search_icon', function () {
  639. if ($('#minValue').val() == 0 && $('#maxValue').val() == 0) {
  640. $('#minValue').val($('#initialmin').val());
  641. $('#maxValue').val($('#initialmax').val());
  642. }
  643. $('#pricebuttonclick').val(1);
  644. });
  645. $(document).ready(function () {
  646. var numberOfChecked = $('.brand_btn:checkbox:checked').length;
  647. if (numberOfChecked == 0) {
  648. }
  649. });
  650. //========================
  651. function updateremoveURL() {
  652. var onlyUrl = window.location.href.replace(window.location.search, '');
  653. window.history.pushState({
  654. path: onlyUrl
  655. }, '', onlyUrl);
  656. }

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.