1 2window.IsMobile = function () { 3 return window.innerWidth <= 1047; 4}; 5window.IsMobile720 = function () { 6 return window.innerWidth <= 720; 7}; 8window.IsMobileSmall = function () { 9 return window.innerWidth <= 600; 10}; 11window.ForEachBlock = function(callback, selectors, ...args) { 12 selectors.forEach(sel => { 13 const el = typeof sel === 'string' ? document.querySelector(sel) : sel; 14 if (el) callback(el, ...args); 15 }); 16}; 17window.getCurrencySymbol = function(currency) { 18 const map = { 19 RUB: 'Ñ.', 20 USD: '$', 21 EUR: 'â¬' 22 }; 23 24 return map[currency] || currency; 25} 26 27window.formatPrice = function (number, curr = '') { 28 29 var currency = window.RepresentCurrency; 30 31 if (curr != '') { 32 currency = curr; 33 } 34 35 let locale; 36 let symbol; 37 let digits; 38 39 switch (currency) { 40 case "USD": 41 case "$": 42 locale = "en-US"; 43 symbol = "$"; 44 digits = 2; 45 break; 46 47 case "EUR": 48 case "â¬": 49 locale = "de-DE"; 50 symbol = "â¬"; 51 digits = 2; 52 break; 53 54 case "RUB": 55 default: 56 case "Ñ.": 57 locale = "ru-RU"; 58 symbol = "Ñ."; 59 digits = 0; 60 break; 61 } 62 63 return number.toLocaleString(locale, { maximumFractionDigits: digits }) + " " + symbol; 64}; 65 66window.universalEqual = (a, b) => { 67 if (typeof a === 'object' && typeof b === 'object') { 68 return JSON.stringify(a) === JSON.stringify(b); 69 } 70 return a === b; 71}; 72 73 74window.parseAndConvertToRub = (value) => { 75 if (value === null || value === undefined) return null; 76 77 value = String(value).trim(); 78 79 const currencyMap = { 80 'â½': 'RUB', 81 'Ñ': 'RUB', 82 'Ñ.': 'RUB', 83 'RUB': 'RUB', 84 85 '$': 'USD', 86 'ç¾å ': 'USD', 87 'USD': 'USD', 88 89 'â¬': 'EUR', 90 'EUR': 'EUR', 91 }; 92 93 let detectedCurrency = 'RUB'; 94 95 for (const symbol in currencyMap) { 96 if (value.toUpperCase().includes(symbol.toUpperCase())) { 97 detectedCurrency = currencyMap[symbol]; 98 value = value.replace(symbol, ''); 99 break; 100 } 101 } 102 103 value = value.replace(/[\s,]/g, s => s === ',' ? '.' : ''); 104 105 if (isNaN(value)) return null; 106 107 const amount = parseFloat(value); 108 109 if (detectedCurrency === 'RUB') { 110 return amount; 111 } 112 113 if (detectedCurrency) { 114 return amount * window.ConvertFactoryEx ; 115 } 116 117 return amount; 118} 119 120window.ConvertUnit = (valueMm, toUnit = '', getUserUnitFn = null) => { 121 const units = { 122 MM: 1, 123 ÐÐ: 1, 124 CM: 0.1, 125 M: 0.001, 126 INCH: 1 / 25.4, 127 FT: 1 / 304.8, 128 }; 129 130 if (!toUnit || toUnit === '') { 131 if (typeof getUserUnitFn === 'function') { 132 toUnit = getUserUnitFn(); 133 } else { 134 toUnit = 'ÐÐ'; 135 } 136 } 137 138 toUnit = String(toUnit).toUpperCase(); 139 140 if (!units[toUnit]) { 141 throw new Error(`Unknown unit: ${toUnit}`); 142 } 143 144 return valueMm * units[toUnit]; 145} 146window.ConvertUnitBack = (valueWithUnit) => { 147 const units = { 148 MM: 1, 149 ÐÐ: 1, 150 CM: 0.1, 151 M: 0.001, 152 INCH: 1 / 25.4, 153 FT: 1 / 304.8, 154 }; 155 156 if (!valueWithUnit) return 0; 157 let str = String(valueWithUnit).trim().toUpperCase(); 158 159 let detectedUnit = 'ÐÐ'; 160 for (const unit in units) { 161 if (str.endsWith(unit)) { 162 detectedUnit = unit; 163 str = str.slice(0, -unit.length).trim(); 164 break; 165 } 166 } 167 str = str.replace(/\s+/g, ''); 168 169 170 const num = parseFloat(str); 171 if (isNaN(num)) return 0; 172 173 return num / units[detectedUnit]; 174} 175 176 177const REPRESENT_CURRENCY_MAP = { 178 "RUB": "Ñ.", 179 "USD": "$", 180 "EUR": "â¬" 181}; 182 183window.GetActualUserCurrency = () => { 184 return window.ACTUAL_CURRENCY || window.UserCurrency; 185} 186window.GetActualUserUNIT = () => { 187 return window.ACTUAL_UNIT || window.UserUnit; 188} 189window.GetActualRepresentCurrency = () => { 190 return REPRESENT_CURRENCY_MAP[window.ACTUAL_CURRENCY || window.UserCurrency]; 191} 192window.GetActualRepresentUnit = () => { 193 return window.ACTUAL_UNIT || window.UserUnit; 194}
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.