PageSourceSearch

https://www.supermicro.com/sites/default/files/static/frontend/rea…/configurator/configurator-widget.js?v=

js supermicro.com collected 2026-09-24 08:34:42 UTC 8,204 bytes, 183 lines download raw bytes

1(function () {
2    const setting = {
3        summary: null,//configurator assemblyInstructions
4        selectedSummary: null,
5        timmer: null
6    };
7
8    function getSkuFromSpecPage() {
9        var str = window.location.pathname.split('/');
10        str = decodeURIComponent(str[str.length - 1].toUpperCase());
11        str = str.replace('_', '+');
12        str = str.replace('.CFM', '');
13        str = str.replace(/^AS-/, 'AS -');
14        if (str.length >= 30) {
15            return '';
16        }
17        return str;
18    }
19
20    function parseConfigurationSpec(summary, selectedSummary) {
21        //console.log('parseConfigurationSpec');
22        //console.log(summary);
23        //console.log(selectedSummary);
24        const excludeRows = selectedSummary.filter(function (ele) {
25            if (['keyboard', 'monitor', 'accessory', 'warranty', 'os', 'software', 'dvd'].includes(ele.type.toLowerCase())) {
26                return true;
27            }
28            return false;
29            // console.log(ele.sku);
30            // const found = summary.addToCartItems.find(item => item.sku === ele.sku);
31            // if (found) {
32            //     return false;
33            // }else{
34            //     return true;
35            // }
36        });
37
38        //console.log(excludeRows);
39
40        const rows = excludeRows.map(function (ele, index) {
41            let str = '';
42            if ((index === 0) || ((index > 0) && (excludeRows[index].type !== excludeRows[index - 1].type))) {
43                str = ele.type.toUpperCase() + ':\n';
44            }
45            return `${str} ${ele.selectedQty} X ${ele.sku}`;
46            // return (
47            //     <div className="sm-mb-3" key={index}>
48            //         {((index === 0) || ((index > 0) && (selectedSummary[index].type !== selectedSummary[index - 1].type))) &&
49            //             <div className={'sm-inline-block sm-text-white sm-text-sm sm-px-1.5 sm-py-0.5 sm-leading-none ' + (ele.componentType ? ' sm-cursor-pointer hover:sm-shadow hover:sm-shadow-gray-600 ' : '') + componentBg} onClick={() => onLabelClick(ele.componentType)}>{getComponentsTitle(ele.type)}</div>
50            //         }
51            //         <div className="sm-flex sm-px-2 sm-mt-1 sm-leading-none">
52            //             <div className="sm-flex-auto sm-text-sm sm-leading-4"><span className="sm-align-middle">{ele.name}</span><OutOfStock inventory={isOutOfStock ? 0 : 9999} /></div>
53            //             <div className="sm-flex-none sm-w-10 sm-text-center">x</div>
54            //             <div className="sm-flex-none sm-text-center sm-text-xs sm-leading-6 sm-rounded-full sm-bg-gray-500 sm-text-white sm-w-6 sm-h-6 sm--mt-0.5">{ele.selectedQty}</div>
55            //         </div>
56            //     </div>
57            // )
58        });
59
60        let selectedSummaryStr = rows.join('\n');
61
62        let assemblyInstructions = summary.assemblyInstructions;
63        assemblyInstructions = assemblyInstructions.replaceAll('~', '\n');
64        assemblyInstructions = assemblyInstructions.replaceAll('<br>', '\n');
65
66        return assemblyInstructions + '\n' + selectedSummaryStr;
67    }
68
69    function applySmcConfiguratorSepc() {
70        var $message = jQuery('#hsForm_5a951771-1008-40eb-9ee2-6ea9de4b7420 textarea[name=message]');
71        if ($message.length <= 0) {
72            return;
73        }
74        var sku = getSkuFromSpecPage();
75        jQuery('#hsForm_5a951771-1008-40eb-9ee2-6ea9de4b7420 input[name=product_sku]').val(sku);
76        $message.val(parseConfigurationSpec(setting.summary, setting.selectedSummary));
77        setting.summary = null;
78        clearInterval(setting.timmer);
79    }
80
81    function handleOnSmcConfiguratorGetPricing(summary, selectedSummary) {
82        //console.log('handleOnSmcConfiguratorGetPricing');
83        //console.log(summary);
84        //console.log(selectedSummary);
85        setting.summary = summary;
86        setting.selectedSummary = selectedSummary;
87
88        var renderContactForm = function ($link) {
89            $link.addClass('use-ajax');
90            $link.data('dialog-type', 'dialog').data('dialog-renderer', 'off_canvas').data('dialog-options', {
91                width: 500
92            });
93        }
94
95        var generateBtn = function (url, str) {
96            return jQuery('<a id="configuratorGetPricing" class="shop-systems enterprise btn" href="' + url + '" target="_blank">' + str + '</a>');
97        }
98
99        var generateBtnForGetPrice = function () {
100            var $link = generateBtn(Drupal.url('contact/get_pricing'), 'Get Pricing');
101            return $link;
102        }
103
104        var $configuratorGetPricing = jQuery('#configuratorGetPricing');
105        if ($configuratorGetPricing.length <= 0) {
106            $configuratorGetPricing = generateBtnForGetPrice();
107            jQuery('body').append($configuratorGetPricing);
108            renderContactForm($configuratorGetPricing);
109            Drupal.attachBehaviors(document, Drupal.settings); // Reattach all drupal event
110            $configuratorGetPricing.hide();
111        }
112        $configuratorGetPricing.trigger('click');
113    }
114
115    function bindEvent() {
116        window.onSmcConfiguratorGetPricing = handleOnSmcConfiguratorGetPricing;
117        jQuery(window).on('dialog:aftercreate', function () {
118            console.log('trigger - after create');
119            if (setting.summary) {
120                setting.timmer = setInterval(applySmcConfiguratorSepc, 300);
121            }
122        });
123        jQuery('.tab-system-builder-more').on('click', function () {
124            setTimeout(() => {
125                window.dispatchEvent(new Event('resize'))
126            }, 300);
127        });
128    }
129
130    function init() {
131        bindEvent();
132        jQuery('.spec-container').attr('id', 'smc-configurator-spec-container');
133
134        var attributeParams = '';
135        var urlParams = new URLSearchParams(window.location.search);
136        var cid = urlParams.get('cid');
137        if (cid) {//Reconfigure mode, and is now configuration owner
138            attributeParams += ' configID="' + SMC_COMMON.tools.escapeHTML(cid) + '"';
139        }
140
141        var oid = urlParams.get('oid');
142        if (oid) {//Reconfigure mode, and is now configuration owner
143            attributeParams += ' orderID="' + SMC_COMMON.tools.escapeHTML(oid) + '"';
144        }
145
146        if (urlParams.get('isRegenerate')) {
147            attributeParams += ' isRegenerate="true"';
148        }
149
150        var sku = SMC_COMMON.tools.escapeHTML(getSkuFromSpecPage());
151        var el = jQuery("#smc-configurator-widget");
152        if (el.val() === undefined) {
153            return;
154        }
155        //console.log(el.attr('app'));
156        var app = (el.attr('app')) ? el.attr('app').toLowerCase() : 'enterprise';
157        if (app === 'estore') {
158            app = 'enterprise';
159        } else if (app === 'estorebv') {
160            app = 'enterprisebv';
161        }
162        attributeParams += ' app="' + SMC_COMMON.tools.escapeHTML(app) + '"';
163
164        var login = (el.attr('login')) ? el.attr('login') : false;
165        attributeParams += ' login="' + SMC_COMMON.tools.escapeHTML(login) + '"';
166
167        el.replaceWith('<div translate="no" id="smc-configurator-widget" systemSku="' + sku + '" client="enterprise" ' + attributeParams + '></div>');
168        SMC_COMMON.tools.reactAppLoad('/sites/default/files/static/frontend/react-embed/configurator/widget');
169        //SMC_COMMON.tools.reactAppLoad('/frontend' + (((window.location.hostname.indexOf('staging.supermicro.com') === 0) || (window.location.hostname.indexOf('entweb-va.supermicro.com') === 0)) ? '/ss' : '') + '/configurator/widget');
170        if (jQuery('.tab-system-builder-more.active').length <= 0) {
171            jQuery('.row.system-builder').hide();
172        }
173        // if (cid) {
174        //     if (!jQuery('.tab-menu .tab-system-builder-more')[0].classList.contains('active')){
175        //         jQuery('.tab-menu .tab-system-builder-more').trigger('click');
176        //     }
177        // }
178    }
179
180    jQuery(document).ready(function () {
181        init();
182    });
183}())

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.