PageSourceSearch

https://www.altium.com/sites/default/assets/js/js_AANlpwsgV0MUpkoi…xVrdiomunbiuJeimrwV9rUDtKQWMBz1s3Ob4BuPKuwg

js altium.com collected 2026-10-02 02:24:41 UTC 8,548 bytes, 3 lines download raw bytes

1/* @license GPL-2.0-or-later https://www.drupal.org/licensing/faq */
2(function(Drupal,once){'use strict';var STORAGE_ATTRIBUTE='data-altium-dss-attributes';var ENDPOINT='/api/dss/get-markup-values';var REQUEST_TIMEOUT=10000;function fetchWithTimeout(url,options,timeout){return Promise.race([fetch(url,options),new Promise(function(_,reject){setTimeout(function(){reject(new Error('Request timeout'));},timeout||REQUEST_TIMEOUT);})]);}function parseAttributes(element){var rawValue=element.getAttribute(STORAGE_ATTRIBUTE);if(!rawValue)return {};try{var values=JSON.parse(rawValue);return values&&typeof values==='object'?values:{};}catch(error){console.warn('[altium_dss] Failed to parse attributes',error);return {};}}function normalizeValue(attributeKey,value){if(attributeKey==='PaymentTermIndex'){if(value==='Month (0)')return '0';if(value==='Year (1)')return '1';}return value;}function buildQueryString(attributes,extraParams){var parts=[];Object.keys(attributes).forEach(function(attributeKey){if(attributeKey==='PriceProductId')return;var value=normalizeValue(attributeKey,attributes[attributeKey]);if(value===undefined||value===null||value==='')return;parts.push(encodeURIComponent(attributeKey)+'='+encodeURIComponent(value));});if(extraParams)Object.keys(extraParams).forEach(function(key){var value=extraParams[key];if(value!==undefined&&value!==null&&value!=='')parts.push(encodeURIComponent(key)+'='+encodeURIComponent(value));});return parts.join('&');}function applyRetVal(element,attributes,retVal){if(!retVal)return;attributes.RetVal=retVal;element.setAttribute(STORAGE_ATTRIBUTE,JSON.stringify(attributes));element.textContent=retVal;}function extractRetVal(data,attributes){if(!data||!Array.isArray(data.prices))return null;var price=data.prices.find(function(item){return item&&typeof item.RetVal==='string'&&item.RetVal.length;});if(!price)return null;if(attributes&&attributes.RetVal==='price_per_product')return extractPricePerProduct(price.RetVal,attributes.PriceProductId);return reformatCurrencyString(price.RetVal);}function reformatCurrencyString(raw){var match=/^([A-Za-z]{3})\s+(-?\d+(?:\.\d+)?)$/.exec(String(raw).trim());if(!match)return raw;var numeric=Number(match[2]);if(!Number.isFinite(numeric))return raw;return formatCurrency(match[1],numeric);}function formatCurrency(currencyCode,amount){if(!currencyCode)return String(Math.round(amount));try{return new Intl.NumberFormat('en-US',{style:'currency',currency:currencyCode,minimumFractionDigits:0,maximumFractionDigits:0}).format(amount);}catch(error){return (currencyCode+' '+Math.round(amount)).trim();}}function extractPricePerProduct(rawRetVal,priceProductId){var items;try{items=JSON.parse(rawRetVal);}catch(error){return null;}if(!Array.isArray(items)||!items.length)return null;var target=String(priceProductId||'').trim();var match=target?items.find(function(item){return item&&String(item.ProductId)===target;}):null;if(!match){if(target)return null;match=items[0];}var currency=match.CurrencyCode||'';var rawPrice=match.Price;if(rawPrice===undefined||rawPrice===null||rawPrice==='')return null;var numeric=Number(rawPrice);if(!Number.isFinite(numeric))return (currency+' '+rawPrice).trim();return formatCurrency(currency,numeric);}function requestValues(element,attributes,extraParams){var query=buildQueryString(attributes,extraParams);if(!query)return;fetchWithTimeout(ENDPOINT+'?'+query,{credentials:'same-origin'}).then(function(response){if(!response.ok)throw new Error('Request failed with status '+response.status);return response.json().catch(function(){return null;});}).then(function(data){var retVal=extractRetVal(data,attributes);applyRetVal(element,attributes,retVal);}).catch(function(error){console.warn('[altium_dss] Failed to fetch pricing data',error);});}function processElement(element){var attributes=parseAttributes(element);var keys=Object.keys(attributes);if(!keys.length)return;var geoip=Drupal.altiumDssGeoip||null;var extraParams={};if(geoip&&geoip.CountryCode)extraParams.CountryCode=geoip.CountryCode;requestValues(element,attributes,extraParams);}function fetchGeoip(){if(!Drupal.altiumDssGeoipPromise)Drupal.altiumDssGeoipPromise=Drupal.altiumGeoip.get().then(function(geo){Drupal.altiumDssGeoip={CountryCode:(geo&&geo.code)||''};return Drupal.altiumDssGeoip;});return Drupal.altiumDssGeoipPromise;}Drupal.behaviors.altiumDssDataAttributes={attach:function(context){fetchGeoip().finally(function(){once('altium-dss-data','['+STORAGE_ATTRIBUTE+']',context).forEach(function(element){processElement(element);});});}};})(Drupal,once);;
3(function($,Drupal,once){Drupal.behaviors.altiumGlobalSearch={attach(context){once('altium-global-search-form','#altium-global-search-form',context).forEach((form)=>{const $form=$(form);
3initClearFilters($form);initSectionSwitcher($form);initCheckboxes($form);initSubmitButton($form);});}};function initClearFilters($form){const $selectedBlock=$form.find('.aside__selected, ._selected-filters');once('altium-global-search-clear-item','.b-selected__item__close',$form[0]).forEach((element)=>{$(element).on('click',function(){const checkboxName=$(this).closest('.b-selected__item').attr('data-checkbox');if(!checkboxName)return;$form.find(`input[name="${checkboxName}"]`).prop('checked',false);if(checkboxName==='checkbox-Altium-Designer')$form.find('input[name^="checkbox-ad-version"]').prop('checked',false);if(checkboxName==='checkbox-Altium-NEXUS')$form.find('input[name^="checkbox-nexus-version"]').prop('checked',false);$form.trigger('submit');});});once('altium-global-search-clear-all','._clear-filters, .s-search-result__sidebar__btn-clear .btn',$form[0]).forEach((element)=>{$(element).on('click',(event)=>{event.preventDefault();const $button=$(element);if($button.data('isProcessing'))return;$button.data('isProcessing',true);$button.addClass('_is-loading');$selectedBlock.find('.b-selected__item').each(function(){const checkboxName=$(this).attr('data-checkbox');if(checkboxName)$form.find(`input[name="${checkboxName}"]`).prop('checked',false);});const $defaultRadio=$form.find('input[name="radio-nn"]').first();if($defaultRadio.length)$defaultRadio.prop('checked',true);$form.trigger('submit');window.setTimeout(()=>{$button.removeClass('_is-loading');$button.removeData('isProcessing');},2000);});});}function initCheckboxes($form){once('altium-global-search-checkboxes','.form-type-checkbox > label',$form[0]).forEach((element)=>{$(element).on('click',function(event){event.preventDefault();const $label=$(this);const $checkbox=$label.siblings('input[type="checkbox"]');const $children=$label.closest('.form-type-checkbox').find('.b-filter__sub-item input[type="checkbox"]');const isSubItem=$label.hasClass('sub-label');const willCheck=!$checkbox.prop('checked');$checkbox.prop('checked',willCheck);if(willCheck){if(isSubItem)$label.closest('.b-filter__item').children('.form-checkbox').prop('checked',true);}else $children.prop('checked',false);});});}function initSubmitButton($form){once('altium-global-search-submit','.form-actions[type="submit"]',$form[0]).forEach((element)=>{$(element).on('click',()=>{$form.trigger('submit');});});}function initSectionSwitcher($form){const sectionMap={all:[],company:findSections($form,'.b-filter__category.categories'),documentation:findSections($form,'.b-filter__category.product'),hub:findSections($form,'.b-filter__category.hub')};const allSections=collectAllSections(sectionMap);once('altium-global-search-section','.b-categories label',$form[0]).forEach((element)=>{$(element).on('click',function(event){event.preventDefault();const $label=$(this);const $radioBtn=$label.siblings('input[type="radio"]');if(!$radioBtn.length)return;const value=($radioBtn.val()||'').toString().toLowerCase();$radioBtn.prop('checked',true);const activeSections=sectionMap[value]||[];allSections.forEach((section)=>{const isActive=value!=='all'&&activeSections.indexOf(section)!==-1;toggleSection(section,isActive);});});});}function toggleSection(section,isActive){const $section=section&&section.jquery?section:$(section);if(!$section.length)return;$section.toggleClass('_active',isActive);if(!isActive)$section.find('input[type="checkbox"]').prop('checked',false);}function findSections($form,selector){const element=$form.find(selector).get(0);return element?[element]:[];}function collectAllSections(sectionMap){const uniqueSections=[];Object.values(sectionMap).forEach((group)=>{group.forEach((section)=>{if(section&&uniqueSections.indexOf(section)===-1)uniqueSections.push(section);});});return uniqueSections;}}(jQuery,Drupal,once));;

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.