PageSourceSearch

https://scooterdynasty.com/scripts/storefront.js

js scooterdynasty.com collected 2026-10-04 03:01:41 UTC 15,719 bytes, 449 lines download raw bytes

1/* ----------------------- jQuery No Conflict Namespace & Ready ------------------------ */
2
3//In order to avoid breaking any code that customers may insert, we use our own unobtrusive selector (ns$).
4if (window.jQuery) {
5    var ns$ = jQuery.noConflict();
6
7    if ($ == null || $ == undefined) {
8        $ = ns$;
9    }
10
11    (function ($) {
12        var __load = jQuery.fn.load;
13        $.fn.load = function (selector, data, handler) {
14            if (typeof selector === "string" && __load) {
15                return __load.apply(this, arguments);
16            } else {
17                this.on("load", selector, data, handler);
18            }
19        };
20        $.fn.unload = function (selector, data, handler) {
21            this.on("unload", selector, data, handler);
22            return this;
23        };
24    })(jQuery);
25}
26
27/* ------------------------------------------------------------------------------------- */
28/* -------------------- MC JavaScript Namespace and globlal methods -------------------- */
29
30var MC = function () {
31    var _currentRating = 0;
32    return {
33
34        addLoadEvent: function (func) {
35            var currentOnLoad = window.onload;
36            if (typeof window.onload != 'function') {
37                window.onload = func;
38            } else {
39                window.onload = function () {
40                    currentOnLoad();
41                    func();
42                }
43            }
44        },
45
46        getElementById: function (elementId) {
47            if (document.getElementById) {
48                return document.getElementById(elementId);
49            } else if (document.all) {
50                return document.all[elementId];
51            } else {
52                return null;
53            }
54        },
55
56        formatCurrency: function (num) {
57            num = num.toString().replace(/\$|\,/g, '');
58
59            if (isNaN(num)) { num = "0" }
60
61            sign = (num == (num = Math.abs(num)));
62            num = Math.floor(num * 100 + 0.50000000001);
63            cents = num % 100;
64            num = Math.floor(num / 100).toString();
65
66            if (cents < 10) { cents = "0" + cents; }
67
68            for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3) ; i++) {
69                num = num.substring(0, num.length - (4 * i + 3)) + ',' + num.substring(num.length - (4 * i + 3));
70            }
71
72            return (((sign) ? '' : '-') + '$' + num + '.' + cents);
73        },
74
75        swapRatingImage: function (imageId, index, themePath) {
76            var noneImageUrl = '/' + themePath + '/images/layout/rating-none.gif';
77            var fullImageUrl = '/' + themePath + '/images/layout/rating-full.gif';
78
79            for (var x = 1; x <= 5; x++) {
80                var item = MC.getElementById(imageId.substring(0, imageId.length - 1) + x);
81
82                if (item.nodeName == 'A') {
83                    item = item.firstChild;
84                }
85
86                if (x <= index) {
87                    item.src = fullImageUrl;
88                } else {
89                    item.src = noneImageUrl;
90                }
91            }
92        },
93
94        resetRating: function (imageId, themePath) {
95            MC.swapRatingImage(imageId, _currentRating, themePath);
96        },
97
98        getCurrentRating: function () {
99            return _currentRating;
100        },
101
102        setCurrentRating: function (imageId, hiddenId, rating) {
103            _currentRating = rating;
104            MC.getElementById(hiddenId).value = rating;
105        },
106
107        limitInputLength: function (textarea, limit, counter) {
108            var text = MC.fixNewline(textarea.value);
109
110            if (text.length > limit) {
111                text = text.substring(0, limit);
112                textarea.value = text;
113            }
114            var hasInnerText = (document.getElementsByTagName("body")[0].innerText != undefined) ? true : false;
115            var counterText = (limit - text.length) + " characters remaining.";
116
117            if (hasInnerText) {
118                document.getElementById(counter).innerHTML = counterText;
119            } else {
120                document.getElementById(counter).textContent = counterText;
121            }
122        },
123
124        fixNewline: function (val) {
125            if (val.indexOf('\r\n') != -1) {
126                ; // this is IE on windows. Puts both characters for a newline, no need to alter
127            } else if (val.indexOf('\r') != -1) {
128                val = val.replace(/\r/g, "\r\n");        // this is IE on a Mac. Need to add the line feed
129            } else if (val.indexOf('\n') != -1) {
130                val = val.replace(/\n/g, "\r\n");        // this is Firefox on any platform. Need to add carriage return
131            } else {
132                ; // no newlines in the textarea  
133            }
134
135            return val;
136        },
137
138        toggle: function (toggle, item) {
139            var element = MC.getElementById(item);
140
141            if (element.style.display == "none") {
142                element.style.display = "";
143                toggle.innerHTML = 'collapse';
144            } else {
145                element.style.display = "none";
146                toggle.innerHTML = 'expand';
147            }
148        },
149
150        toggleChecked: function (rel, check) {
151            if (!document.getElementsByTagName) return;
152
153            var inputs = document.getElementsByTagName("input");
154
155            for (var i = 0; i < inputs.length; i++) {
156                var input = inputs[i];
157                if (input.getAttribute("type") == "checkbox" && input.getAttribute("rel") == rel) {
158                    input.checked = check;
159                }
160            }
161        },
162
163        setupAspect: function (aspect, count, threshold) {
164            var node;
165
166            if (aspect.getElementsByClassName) {
167                var nodes = aspect.getElementsByClassName("ref-current");
168
169                if (nodes.length != 0) {
170                    node = nodes[0];
171                }
172            } else {
173                var candidates = aspect.getElementsByTagName("li");
174
175                for (var i = 0; i < candidates.length; ++i) {
176                    if (candidates[i].className = "ref-current") {
177                        node = candidates[i];
178                        break;
179                    }
180                }
181            }
182
183            if (!node) return;
184
185            var innerLists = node.getElementsByTagName("ul");
186            if (innerLists == null || innerLists.length == 0) return;
187
188            var innerList = innerLists[0];
189            var items = innerList.getElementsByTagName("li");
190            if (items.length <= threshold) return;
191
192            var visible = true;
193
194            var toggleAspect = function (anchor) {
195                visible = !visible;
196
197                for (var i = count; i < items.length - 1; ++i) {
198                    var item = items[i];
199
200                    if (visible) {
201                        item.style.display = "";
202                    } else {
203                        item.style.display = "none";
204                    }
205                }
206
207                anchor.innerHTML = visible ? "Show fewer&hellip;" : "Show more&hellip;";
208            };
209
210            var toggleItem = document.createElement("li")
211            var toggleAnchor = document.createElement("a");
212
213            toggleItem.setAttribute("class", "ref-toggle");
214            toggleAnchor.setAttribute("href", "#");
215
216            toggleAnchor.onclick = function () {
217                toggleAspect(this);
218                return false;
219            };
220
221            toggleItem.appendChild(toggleAnchor);
222            innerList.appendChild(toggleItem);
223
224            toggleAspect(toggleAnchor);
225        }
226    };
227}();
228
229var Confirm = function () {
230    return {
231
232        addToCart: function (name, quantity) {
233            alert(quantity + ' - ' + name + ' has been added to your cart.');
234        },
235
236        addToList: function (name, quantity) {
237            alert(quantity + ' - ' + name + ' has been added to your shopping list.');
238        },
239
240        updateQuantity: function (name, quantity) {
241            alert(name + ' quantity has been updated.');
242        },
243
244        outOfStock: function (name, quantity) {
245            alert('The quantity you requested (' + quantity + ') is not currently in stock.');
246        },
247
248        unavailable: function (name, quantity) {
249            alert('You are not allowed to purchase ' + name + '.');
250        },
251
252        reqQuestion: function (name, quantity) {
253            alert('You must select options for ' + name + '.');
254        },
255
256        belowMinQty: function (name, quantity) {
257            alert('You are not allowed to purchase fewer than ' + quantity + ' of ' + name + '.');
258        },
259
260        aboveMaxQty: function (name, quantity) {
261            alert('You are not allowed to purchase more than ' + quantity + ' of ' + name + '.');
262        },
263
264        invalidCaptcha: function(name, quantity) {
265            alert(name + ' could not be added to cart. Captcha was invali
265d.');
266        }
267    };
268}();
269
270var Window = function () {
271    var isNetscape = (navigator.appName == "Netscape") ? true : false;
272    return {
273
274        open: function (url, name, width, height, scrollbars, resizable) {
275            var left = (screen.width - width) / 2;
276            var top = (screen.height - height) / 2;
277            resizable = 'yes';
278            var properties = 'height=' + height + ',width=' + width + ',top=' + top + ',left=' + left + ',scrollbars=' + scrollbars + ',resizable=' + resizable + ',toolbar=0,location=0,statusbar=0,menubar=0';
279
280            var win = window.open(url, 'win', properties);
281
282            if (isNetscape) {
283                win.window.focus();
284            } else {
285                win.focus();
286            }
287        },
288
289        close: function (win) {
290            win.close();
291        },
292
293        print: function (win) {
294            win.print();
295        },
296
297        center: function (win) {
298            var width, height;
299            var left, top;
300
301            width = win.outerWidth;
302            height = win.outerHeight;
303
304            if (win.document.layers || (win.document.getElementById && !win.document.all)) {
305                width = win.outerWidth;
306                height = win.outerHeight;
307            } else if (win.document.all) {
308                width = win.document.body.clientWidth;
309                height = win.document.body.clientHeight;
310            }
311
312            left = (screen.width - width) / 2;
313            top = (screen.height - height) / 2;
314
315            if (parseInt(navigator.appVersion) >= 4) {
316                window.moveTo(left, top);
317            }
318        },
319
320        resizeToObject: function (imageId, extraWidth, extraHeight) {
321            var image = MC.getElementById(imageId);
322            var offsetTop = 100;
323            var offsetLeft = 100;
324
325            if (image) {
326                width = (image.width + extraWidth);
327                height = (image.height + extraHeight);
328
329                if (height - offsetTop > screen.availHeight) { height = screen.availHeight - offsetTop; }
330                if (width - offsetLeft > screen.availWidth) { width = screen.availWidth - offsetLeft; }
331
332                window.moveTo(offsetLeft, offsetTop);
333                window.resizeTo(width, height);
334            }
335        }
336    };
337}();
338
339/* ------------------------------------------------------------------------------------- */
340/*------------------------------Checkout Functions--------------------------------------*/
341function detectCCTypeBasedOnCCNumber() {
342    var $this = $('[name*="ccnumber"]');
343    var value = $this.val();
344
345    if (value != null && value.length == 4 && $.isNumeric(value)) {
346
347        if (value.substring(0, 2) == "55") {
348            // "Master Card"
349            $('[name*="cctype"]').val(1).change();
350
351        } else if (parseInt(value.substring(0, 2)) >= 51 && parseInt(value.substring(0, 2)) <= 55) {
352            // "Master Card"
353            $('[name*="cctype"]').val(1).change();
354
355        } else if (parseInt(value.substring(0, 4)) >= 2221 && parseInt(value.substring(0, 4)) < 2721) {
356            //"new mastercard" 
357            $('[name*="cctype"]').val(1).change();
358
359        } else if (value.substring(0, 1) == "4") {
360            // "Visa"
361            $('[name*="cctype"]').val(2).change();
362
363        } else if (value.substring(0, 4) == "6011" || value.substring(0, 2) == "65") {
364            // "Discover" 
365            $('[name*="cctype"]').val(3).change();
366
367        } else if (value.substring(0, 2) == "34" || value.substring(0, 2) == "37") {
368            // "American Express"   
369            $('[name*="cctype"]').val(4).change();
370
371        } else if (value.substring(0, 4) == "2131" || value.substring(0, 4) == "1800" || value.substring(0,2) == "35") {
372            //"JCB"    
373            $('[name*="cctype"]').val(5).change();
374
375        } else if (value.substring(0, 2) == "36" || value.substring(0, 2) == "38") {
376            //"Diner's Club"
377            $('[name*="cctype"]').val(6).change();
378
379        } else if (parseInt(value.substring(0, 3)) >= 300 && parseInt(value.substring(0, 3)) <= 305) {
380            //"Diner's Club" 
381            $('[name*="cctype"]').val(6).change();
382            
383        } else {
384            // "N/A"
385            $('[name*="cctype"]').val(0).change();
386        }
387        
388    }
389}
390
391function chkBillingSameAsShippingChange() {
392    var $self = $("[id$='chkBillingSameAsShipping']:first");
393
394    var chkBoxLabelText = $("label[for='" + $self[0].id + "']").text();
395
396    if (chkBoxLabelText == 'Billing same as shipping') {
397        $(".checkout-billing-address tr.hideRowClass").toggle(!$self[0].checked);
398    } else if (chkBoxLabelText == 'Shipping same as billing') {
399        $(".checkout-shipping-address tr.hideRowClass").toggle(!$self[0].checked);
400    }
401}
402
403function isNumber(event) {
404    var key = window.event ? event.keyCode : event.which;
405
406    
407    var browser = whichBrowser();
408
409    if (browser.indexOf("Firefox") != -1) {
410        // Allow CTRL events, backspace, tab, delete, left arrow , right arrow, dashes, parenthesis 
411        if (event.ctrlKey || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 46
412            || event.keyCode == 37 || event.keyCode == 39 || key == 45
413            || key == 40 || key == 41) {
414            return;
415        }
416    } else {
417        // Allow CTRL events, backspace, tab, delete,  dashes, parenthesis 
418        if (event.ctrlKey || event.keyCode == 8 || event.keyCode == 9 || event.DEL || key == 45
419            || key == 40 || key == 41) {
420            return;
421        }
422    }
423
424    // check if this is a number
425    if (key < 48 || key > 57) {
426        return false;
427    }
428
429    return true;
430}
431
432
433function whichBrowser(){
434    var ua= navigator.userAgent, tem, 
435    M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
436    if(/trident/i.test(M[1])){
437        tem=  /\brv[ :]+(\d+)/g.exec(ua) || [];
438        return 'IE '+(tem[1] || '');
439    }
440    if(M[1]=== 'Chrome'){
441        tem= ua.match(/\bOPR\/(\d+)/)
442        if(tem!= null) return 'Opera '+tem[1];
443    }
444    M= M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
445    if((tem= ua.match(/version\/(\d+)/i))!= null) M.splice(1, 1, tem[1]);
446    return M.join(' ');
447}
448/* ------------------------------------------------------------------------------------- */
449

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.