94019402var regexp = new RegExp(/\[\d.*\]$/, 'gi');9403var match = key.match(regexp);9404var recid = match ? Number(JSON.parse(match[0])) : null;94059406if (!recid) {9407console.error("Can't find recid in URL param");9408return;9409}94109411// If recid is not on the page, don't add it to params9412var isRecOnPage = document.querySelector('#rec' + recid);
if (!isRecOnPage) { return; } var filter = key.replace(regexp, '').replace('tfc_', ''); if (!result[recid]) result[recid] = {}; result[recid][filter] = result[recid][filter] ? result[recid][filter].concat(values) : values; } } catch (e) { console.error(e); } }); } window.tStoreCustomUrlParams = result; t_store_paramsToObj_updateUrl(result); // Check if there are any default sort options var sortByRec = t_store_paramsToObj_getDefaultSort(recid, opts.defaultSort); for (var rec in sortByRec) { var newSort = sortByRec[rec].sort; var newQuantity = sortByRec[rec].quantity; // var isSortChanged = false; if (!newSort && !newQuantity) { continue; } if (result[rec] && result[rec].sort && opts.previewmode) { // Do not set default sorting if it has been already set by URL param } else if (newSort) { if (!result[rec]) { result[rec] = {}; } result[rec].sort = newSort; } if ( result[rec] && result[rec].quantity && typeof result[rec].quantity === 'object' && result[rec].quantity[0] === 'y' && opts.previewmode ) { // If quantity is set to 'y' by URL params, don't change it } else if (newQuantity) { // Otherwise, if default (new) quantity is 'y', update it if (!result[rec]) { result[rec] = {}; } if (!result[recid].quantity) { result[rec].quantity = ['y']; } } } window.tStoreCustomUrlParams = result; return result;}function t_store_paramsToObj_updateUrl(paramsObj) { var newUrl = t_store_customURLParamsToString(paramsObj); if (window.location.hash) { newUrl += window.location.hash; } try { window.history.replaceState(null, null, encodeURI(newUrl)); } catch (error) { console.error(error); }}function t_store_paramsToObj_getDefaultSort(recid, sort) { // Store default sort opts for all recids in window var result = window.tStoreDefaultSort ? window.tStoreDefaultSort : {}; if (!sort) { return result; } if (sort.default) { var mapSort = {