8901pureValueA = pureValueA8902.toString()8903.replace(/^(от|from)\s+/i, '')8904.replace(',', '.')8905.trim();8906pureValueB = pureValueB8907.toString()8908.replace(/^(от|from)\s+/i, '')8909.replace(',', '.')8910.trim();89118912var dimensionsPattern = /(\d+)\s?(x|х|×)\s?(\d+)/gi; // 500x700 < 500x1000
var pureValueAMatched = pureValueA.match(dimensionsPattern); var pureValueBMatched = pureValueB.match(dimensionsPattern); if (pureValueAMatched && pureValueBMatched) { pureValueA = pureValueAMatched[2]; pureValueB = pureValueBMatched[2]; } /* instead of localeCompare() */ if (pureValueA > pureValueB) { return 1; } if (pureValueB > pureValueA) { return -1; } return 0; } return parsedValueA - parsedValueB; } else { if (filterValues) { return filterValues.indexOf(valueA) - filterValues.indexOf(valueB); } return 0; } }); } catch (e) { console.error(e); } try { for (var unit in units) { // TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015) // @ts-expect-error ST-2949_2 var unitValues = units[unit]; var isUnit = t_catalog_product_hasMeasureUnit(unitValues, firstTestValue) && t_catalog_product_hasMeasureUnit(unitValues, secondTestValue); var re = new RegExp(/^\d*,?\.?\d+\s*/, 'gi'); if (isUnit) { // TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015) // @ts-expect-error ST-2949_2 result = result.sort(function (a, b) { var valueA = type === 'filter' ? a.value : a; var valueB = type === 'filter' ? b.value : b; valueA = valueA.toString().replace(re, '').trim(); valueB = valueB.toString().replace(re, '').trim(); return unitValues.indexOf(valueA) - unitValues.indexOf(valueB); }); return result; } } } catch (e) { console.error(e); } } return result;}/** * Tests if a value contains a measure unit. * * @param {Array<*>} values - An array of measure units to test against. * @param {string} testValue - The value to test. * @return {boolean} `true` if the value contains a measure unit, `false` otherwise. */function t_catalog_product_hasMeasureUnit(values, testValue) { var clearedTestValue = testValue.replace(/\s/g, ''); return values.some(function (value) { var test = '^[\\d.,]+(' + value + '){1}$'; var re = new RegExp(test, 'i'); return re.test(clearedTestValue); });}// TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015)// @ts-expect-error ST-2949_2function t_catalog_product_getEditionOptionsArr_getParams(p, product, optionsData) { // Глобальный tCatalogOptionsList может отставать от product.json_options после // первого сохранения params.view. UI должен брать view из продукта const globalParams = optionsData?.[p]?.params || {}; let productParams = {};