PageSourceSearch

https://coweasy.com/Scripts/fea/cart2.js?0009

js coweasy.com collected 2026-09-24 09:52:32 UTC 21,486 bytes, 559 lines download raw bytes

1var prices = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];
2var formPriceInd = [3, 4, 5, '3', '4', '5'];
3var formPriceInd2 = [4, 5, '4', '5'];
4var cbPriceInd = [6, 7, '6', '7'];
5
6function getUserText() {
7    var lang = getLanguage();
8    if (lang == 'en-gb') return "User";
9    if (lang == 'th') return "ผู้ใช้";
10    return "用戶";
11}
12
13function getEUserText() {
14    var lang = getLanguage();
15    if (lang == 'en-gb') return "Extra User";
16    if (lang == 'th') return "ผู้ใช้พิเศษ";
17    return "額外用戶";
18}
19
20dicountedText = () => getLanguage() == "en-gb" ? "Discounted" : "已折扣";
21
22function getLanguage() {
23    if (WA_Language) return WA_Language;
24    return getCookie('WA_Language') || $('body').attr('lang');
25}
26
27function getCookie(name) {
28    var value = "; " + document.cookie;
29    var parts = value.split("; " + name + "=");
30    if (parts.length == 2) return parts.pop().split(";").shift();
31}
32
33function dayInd(_period) {
34    return _period < _daylength ? 1 : 0;
35}
36
37function exuserPeriod(event, _this) {
38    const _t = $(_this);
39    const opt = $(':selected', _t);
40    setPeriodPrice(opt.attr('data-period'), _this);
41    SumTotal();
42}
43
44function setPeriodPrice(_period, _this) {
45    const $this = $(_this);
46    $("#" + $this.attr("hidid")).val(_period);
47    $("#" + $this.attr("data-mth")).val(0);
48
49    if (isNaN(_period)) return 0;
50    var priceind = $this.attr("priceind");
51    var ind = dayInd(_period);
52
53    setTexts(_this, priceind, _period, ind);
54    var amount_ = getAmount(_this, priceind, _period);
55    var _amtid = $this.attr("amtid");
56    $('#' + _amtid).val(FloatNum(amount_, 2));
57
58    if (GiftUserEnable && _amtid == 'txtUserAmount') {
59        if (amount_ > 0)
60            $("#discounted-user-gift").text("(" + dicountedText() + " " + $("#txtUserAmount").val() + ")");
61        else
62            $("#discounted-user-gift").html("&nbsp;");
63    }
64
65    return amount_;
66}
67function setCBPrice(_this) {
68    const $this = $(_this);
69    const val = $(':checked', _this).val();
70    $("#" + $this.data("slider")).val(val);
71    if (isNaN(val)) return 0;
72    const priceind = $this.data("price");
73
74    const amount_ = getAmount(_this, priceind, val);
75    $('#' + $this.data("amount")).val(FloatNum(amount_, 2));
76
77    return amount_;
78}
79function DiscountText(lang) {
80    return lang == "en-gb" ? "Disc. Start" : lang == "th" ? "ลดราคาเริ่ม" : lang == "zh-cn" ? "折扣开始" : "折扣開始";
81}
82function setSliders() {
83    const lang = getLanguage();
84    const discountText = DiscountText(lang);
85    const _max = 30;
86    $(".slider-user").slider({
87        min: 0,
88        max: _max,
89        create: function () {
90            var ticks = $('<div class="ticks">');
91            for (i = 1; i <= _max; i++) {
92                var tick = $(tickSpan(i));
93                tick.css({ 'left': 100 * i / _max + '%' });
94                ticks.append(tick);
95            }
96            $(this).append(ticks);
97        },
98        slide: function (event, ui) {
99            var _period = getperiod(ui.value);
100            $(this).attr("indid", _period);
101            const hid = $("#" + $(this).attr("hidid"));
102            if (hid.length > 0) {
103                hid.val(_period);
104                if (typeof hid[0].onchange == 'function') hid[0].onchange();
105            }
106
107            if (_period == 0) {
108                $('#' + $(this).attr("spanid")).html("&nbsp;");
109            } else {
110                $('#' + $(this).attr("spanid")).text(_period + " " + getEUserText());
111            }
112            setSliderVal($("#slider-user-gif"), _period);
113
114            SumTotal();
115        }
116    });
117    $(".slider-period").slider({
118        min: 0,
119        max: (periods.length - 1),
120        create: function () {
121            var ticks = $('<div class="ticks">');
122            for (i = 0; i <= (periods.length - 1); i++) {
123                /*if (i != 1
124                 && i != (_daylength)
125                 //&& i != (_daylength + 6) - 1
126                 && i != (_daylength + 12) - 1
127                 && i != (_daylength + 24) - 1) continue;*/
128                var ind = dayInd(i);
129                var tick = $(tickSpan(periods[i] + perioddur(ind) + (periods[i] != 12 || ind != 0 ? '' : '<span style="color:red;margin-left:6px;">
129(' + discountText + ')</span>')));
130                tick.css({ 'left': 100 * i / (periods.length - 1) + '%' });
131                ticks.append(tick);
132            }
133            $(this).append(ticks);
134        },
135        slide: function (event, ui) {
136            var _period = getperiod(ui.value);
137            $(this).attr("indid", _period);
138            const hid = $("#" + $(this).attr("hidid"));
139            if (hid.length > 0) {
140                hid.val(_period);
141                if (typeof hid[0].onchange == 'function') hid[0].onchange();
142            }
143
144            if ($('#' + $(this).attr("spanid3")).length > 0) {
145                $('#' + $(this).attr("spanid3")).css({ display: _period == 0 ? 'none' : '' });
146            }
147            if ($(this).attr('idsync')) {
148                var $slider = $("#" + $(this).attr('idsync'));
149                setSliderVal($slider, _period);
150            }
151            SumTotal();
152        }
153    });
154
155    $(".slider-forms").each(function (i, v) {
156        let maxperiod = $(v).attr('period');
157        const dticks = DataImportTicks(lang, maxperiod);
158        maxperiod = dticks.length;
159        if (PricingRegion != 'HK') {
160            $(this).attr("spanid", '');
161        }
162        $(v).slider({
163            min: 0,
164            max: maxperiod,
165            create: function () {
166                var ticks = $('<div class="ticks">');
167                for (i = 1; i <= maxperiod; i++) {
168                    var tick = $(tickSpan(dticks[i - 1]));
169                    tick.css({ 'left': 100 * i / maxperiod + '%' });
170                    ticks.append(tick);
171                }
172                $(this).append(ticks);
173            },
174            slide: function (event, ui) {
175                var _period = ui.value;
176                $(this).attr("indid", _period);
177                $("#" + $(this).attr("hidid")).val(_period);
178
179                if (_period == 0) {
180                    $('#' + $(this).attr("spanid")).html("&nbsp;");
181                } else {
182                    $('#' + $(this).attr("spanid")).text(_period + " " + $(v).attr('quantifier'));
183                }
184                SumTotal();
185            }
186        });
187    });
188}
189
190function setTexts(_this, priceind, _period, ind) {
191    if (!_this) return;
192    const $this = $(_this);
193    const showDate = typeof datesText == "function";
194    let _spanid2 = $('#' + $this.attr("spanid2")), _spanid = $('#' + $this.attr("spanid"));
195    if (!_spanid) _spanid = $('#' + $this.data("text-span"));
196    const _extoraddu = $("#extoraddu").val() == 1;
197    if (_extoraddu) {
198        if ($this.attr("id2")) {
199            var $id2 = $("#" + $this.attr("id2"));
200            if ($id2.attr("indid") > 0) {
201                _spanid.text($("#" + $id2.attr("spanid")).text() + " X " + priceText(priceind));
202                if (showDate) _spanid2.text(datesText());
203            } else {
204                _spanid.html("&nbsp;");
205                _spanid2.html("&nbsp;");
206            }
207        } else {
208            _spanid.html("&nbsp;");
209            _spanid2.html("&nbsp;");
210        }
211    } else {
212        if (_period == 0) {
213            _spanid.html("&nbsp;");
214            _spanid2.html("&nbsp;").attr('date2', '');
215        } else {
216            if ($this.attr("id2")) {
217                var $id2 = $("#" + $this.attr("id2"));
218                if ($id2.attr("indid") > 0) {
219                    _spanid.text($("#" + $id2.attr("spanid")).text() + " X " + priceText(priceind, _period, ind));
220                    if (showDate) {
221                        var date2 = getDate2(_period, ind, getDate1(_period, ind));
222                        _spanid2.text(datesText(_period, ind)).attr('date2', date2.valueOf());
223                    }
224                } else {
225                    _spanid.html("&nbsp;");
226                    _spanid2.html("&nbsp;").attr('date2', '');
227                }
228            } else {
229                if ($this.attr("id") == 'slider-subperiod')
230                    _spanid.text(priceText(priceind, _period, ind));//"1 " + getUserText() + " X " + 
231                else if (formPriceInd.indexOf(priceind) >= 0)
232                    _spanid.text(priceText(priceind, _period, ind, $this.attr("quantifier"), $this.attr("pradio"), $this.attr("period")));
233                else
234                    _spanid.text(priceText(priceind, _period, ind));
235
236                if ($this.attr("id") == 'slider-suppperiod') {
237                    if (showDate) {
238                        var date2 = getDate2(_period, ind, getDate1(_period, ind, supportEnd));
239                        _spanid2.text(datesText(_period, ind, supportEnd)).attr('date2', date2.valueOf());
240                    }
241                } else if (formPriceInd.indexOf(priceind) >= 0) {
242                    _spanid2.text("&nbsp;").attr('date2', '');
243                } else if (showDate) {
244                    var date2 = getDate2(_period, ind, getDate1(_period, ind));
245                    _spanid2.text(datesText(_period, ind)).attr('date2', date2.valueOf());
246                }
247            }
248        }
249    }
250    if (_spanid2.attr('id') == 'slider-value-user-dates' || _spanid2.attr('id') == 'slider-value-sub-dates') {
251        var _text = $('#slider-value-sub-dates').text().trim() ? $('#slider-value-sub-dates').text() : $('#slider-value-user-dates').text();
252        $('.slider-value-sub-dates').text(_text);
253        var _subperiod = $("#slider-hidden-subperiod-text").val();
254        //if (_subperiod) $('.slider-value-sub-dates2').css('opacity', 1);
255        //.text($("#slider-hidden-today-text").val() + " + " + _subperiod + " = " + $("#slider-hidden-subperiod-end-text").val());
256        //else $('.slider-value-sub-dates2').css('opacity', 0);
257        var _div = $("#all-user-count");
258        if (!_text.trim()) {
259            _div.css('display', 'none');
260            return false;
261        }
262        _div.css('display', '');
263        _div.find('.currentUser').css('display', _extoraddu ? 'inline-block' : 'none');
264        _div.find('.adminUser').css('display', !_extoraddu ? 'inline-block' : 'none');
265
266        var _total = _extoraddu ? CurrentUsers : 1;
267        var _user = parseInt($('#slider-hidden-user').val());
268        if (!_extoraddu) {
269            const freeadd = parseInt($("#free-add-user").val());
270            if (!isNaN(freeadd)) _user += freeadd;
271        }
272
273        _total += _user;
274
275        $('#all-user-count .extraUser .user-count').text(_user);
276        if (GiftUserEnable) {
277            _total += _user;
278            $('#all-user-count .giftUser .user-count').text(_user);
279            $('.giftUser2 .user-count').text(_user);
280        }
281        $('#all-user-count .totalUser .user-count').text(_total);
282    }
283    if (typeof updateGift == "function") updateGift();
284}
285
286function perioddur(ind) {
287    var lang = getLanguage();
288    if (lang == 'en-gb') return ind == 0 ? " Mth" : " Day";
289    if (lang == 'zh-cn') return ind == 0 ? " 个月" : " 日";
290    if (lang == 'th') return ind == 0 ? " เดือน" : " วัน";
291    return ind == 0 ? " 個月" : " 日";
292}
293
294function getAmount(_this, priceind, _period, _period2) {
295    const $this = $(_this);
296    var amount_ = 0;
297    if ($("#extoraddu").val() == 0) {
298        _period = parseInt(_period);
299        var period = formPriceInd.indexOf(priceind) >= 0 ? _period : _period2 && !isNaN(_period2) ? periods[_period2] : periods[_period];
300        if ($this.attr("pradio") && (formPriceInd2.indexOf(priceind) >= 0)) {
301            if ($("input[type='radio'][name='" + $this.attr("pradio") + "']:checked").val() == 1)
302                _period += parseInt($this.attr("period"));
303        }
304        const price_ = getPrice(priceind, _period);
305        $this.attr("data-price", price_);
306        if (cbPriceInd.indexOf(priceind) >= 0 || (formPriceInd2.indexOf(priceind) >= 0 && PricingRegion != 'HK'))
307            amount_ = round2(price_);
308        else
309            amount_ = round2(price_ * period);
310    } else {
311        const adduserdays = $("#adduser-hidden-userperiod option:selected");
312        const days = adduserdays.attr("data-days"), tmonth = adduserdays.attr("data-tmonth");
313        if ($this.attr("id") != 'slider-userperiod' && $this.attr("id2") != 'slider-user')
314            amount_ = 0;
315        else {
316            const price_ = price(priceind, priceind4());
317            $this.attr("data-price", price_);
318            if (tmonth >= 1.0000)
319                amount_ = round2(price_ * tmonth);
320            else
321                amount_ = round2(price_ * days);
322        }
323    }
324    if ($this.attr("ucount")) amount_ = $("#" + $this.attr("ucount")).attr("indid") * amount_;
325    if (isNaN(amount_)) return 0;
326    return amount_;
327}
328
329function changeCurr() {
330    //var rate = 1;
331    var _curr = getCurrency();
332    checkCurrs(_curr);
333
334    _CurrCode = CurrencyName(getLanguage(), _curr);
335
336    //set pricing
337    prices = getPricingTable(_curr, systype);
338
339    SumTotal();
340
341    var eqwidth1 = 0, eqwidth2 = 0, eqwidth3 = 0;
342    $(".eqwidth2,.eqwidth3").css({ "width": "auto" });//.eqwidth1,
343    //        $(".eqwidth1").each(function(key, val) {
344    //            if ($(val).width() > eqwidth1) eqwidth1 = $(val).width();
345    //        });
346    //        $(".eqwidth1").width(eqwidth1);
347    $(".eqwidth2").each(function (key, val) {
348        if ($(val).width() > eqwidth2) eqwidth2 = $(val).width();
349    });
350    $(".eqwidth2").width(eqwidth2 + 5);
351    $(".eqwidth3").each(function (key, val) {
352        if ($(val).width() > eqwidth3) eqwidth3 = $(val).width();
353    });
354    $(".eqwidth3").width(eqwidth3);
355
356}
357
358
359
360function getDiscounted(_period, _this) {
361    let discounted_ = 0, discounted0 = 0;
362    let spandisid = $(_this).attr("spandisid");
363    if (!spandisid) spandisid = $(_this).data("discount");
364    var _discountSpan = $("#" + spandisid);
365    if (_discountSpan.length > 0) {
366        _discountSpan.text('');
367    }
368    if (GiftUserEnable && spandisid == 'discounted-user') {
369        if ($("#txtUserAmount").val().replace(/,/g, '') > 0)
370            discounted0 += round2($("#txtUserAmount").val().replace(/,/g, ''));
371    }
372    if (isNaN(_period)) return discounted0;
373    var priceind = $(_this).attr("priceind");
374    if (formPriceInd.indexOf(priceind) >= 0) {
375        var a = getAmount(_this, priceind, 1) * _period, b = getAmount(_this, priceind, _period);
376        discounted_ = a - b;
377        if (_discountSpan.length > 0 && discounted_ > 0)
378            _discountSpan.text("(" + dicountedText() + " " + discounted_.toFixed(2) + ")");
379        return discounted_;
380    }
381    if (_daylength > _period) return discounted0;
382
383    var a = getAmount(_this, priceind, _daylength, _period), b = getAmount(_this, priceind, _period);
384    discounted_ = a - b;
385    if (_discountSpan.length > 0 && discounted_ > 0)
386        _discountSpan.text("(" + dicountedText() + " " + discounted_.toFixed(2) + ")");
387
388    return discounted_ + discounted0;
389}
390
391var total = 0.00, discounted = 0;
392function SumTotal() {
393    total = 0.00, discounted = 0;
394    let CPADiscount = 0, SBPDiscount = 0;
395
396    $(".slider-period").each(function (i, v) {
397        const _amount = setPeriodPrice($(v).attr("indid"), v);
398        if ($("#txtCPAOff").val()) {
399            if ($(v).attr("id") == 'slider-subperiod' || $(v).attr("id") == 'slider-userperiod') {
400                CPADiscount += _amount * $("#txtCPAOff").val();
401            }
402        }
403        total += _amount;
404    });
405
406    $('.cb-amount-items').each(function (i, v) {
407        const _amount = setCBPrice(v);
408        total += _amount;
409        //discounted += getDiscounted($(':checked', v).val(), v);;
410    });
411
412    if (typeof changeAddon == 'function') {
413        const _addon = changeAddon(null);
414        if (_addon) {
415            total += _addon.total;
416            discounted += _addon.discount;
417        }
418    }
419
420    $(".slider-period").each(function (i, v) {
421        discounted += getDiscounted($(v).attr("indid"), v);
422    });
423
424    if ($("#txtSBPOff").val()) {
425        SBPDiscount = total * $("#txtSBPOff").val();
426    }
427
428    $(".slider-forms").each(function (i, v) {
429        total += setPeriodPrice($(v).attr("indid"), v);
430        discounted += getDiscounted($(v).attr("indid"), v);
431    });
432
433    // _FIRST_SET_UP_FEE_
434    if (typeof oneTimeFee != 'undefined' && oneTimeFee)
435        total += setupfee;
436
437    total -= CPADiscount;
438    discounted += CPADiscount;
439
440    total -= SBPDiscount;
441    discounted += SBPDiscount;
442
443    if (typeof codeDiscount != 'undefined' && codeDiscount != null) {
444        const limiteddisc = codeDiscount.update();
445        if (limiteddisc > 0) {
446            total -= limiteddisc;
447            discounted += limiteddisc;
448        }
449    }
450    if (typeof limitedDiscount != 'undefined' && limitedDiscount != null) {
451        const limiteddisc = limitedDiscount.update();
452        if (limiteddisc > 0) {
453            total -= limiteddisc;
454            discounted += limiteddisc;
455        }
456    }
457
458    $("#txtTotal").val((FloatNum(total, 2)));
459    $("#txtCPADiscount").val((FloatNum(-CPADiscount, 2)));
460    $("#txtSBPDiscount").val((FloatNum(-SBPDiscount, 2)));
461    $("#txtSubscribeTotalShow").val($("#txtTotal").val());
462    if (discounted > 0) {
463        $(".discounted-total").css("display", "");
464        $("#txtDiscounted").text(FloatNum(discounted, 2));
465    } else {
466        $(".discounted-total").css("display", "none");
467    }
468}
469
470function getTotal(id) {
471    let _total = 0.00;
472    if ($("#" + id).attr("checked")) {
473        _total = FloatNum(parseFloat($("#" + id).val()) * parseFloat($("#" + id).attr("tag")), 2);
474        _total = FloatStr(_total);
475    }
476    return _total;
477}
478
479function priceind4() {
480    const adduserdays = $("#adduser-hidden-userperiod option:selected");
481    const months = adduserdays.attr("data-months"), days = adduserdays.attr("data-days");
482    if (_monD.length > 0 && months >= _monD[0]) return 6;
483    if (_monC.length > 0 && months >= _monC[0]) return 5;
484    if (_monB.length > 0 && months >= _monB[0]) return 4;
485    if (_monA.length > 0 && months >= 1) return 3;// _monA[0]
486    if (_dayC.length > 0 && days >= _dayC[0]) return 2;
487    if (_dayB.length > 0 && days >= _dayB[0]) return 1;
488    if (_dayA.length > 0 && days >= _dayA[0]) return 0;
489    return 3;
490}
491
492function price(priceind, ind) {
493    if (priceind < 0 || priceind >= prices.length) return 0;
494    const _prices = prices[priceind];
495    if (ind < 0 || ind >= _prices.length) return 0;
496    return _prices[ind];
497}
498
499function getPrice(priceind, _period) {
500    const index = formPriceInd.indexOf(priceind) >= 0 || cbPriceInd.indexOf(priceind) >= 0 ? _period - 1 : priceind2(_period);
501    return price(priceind, index);
502}
503
504function getDays() {
505    const adduserdays = $("#adduser-hidden-userperiod option:selected");
506    const months = adduserdays.attr("data-months"), days = adduserdays.attr("data-days");
507    const durs = [];
508    if (months > 0) durs.push(months + " " + perioddur(0));
509    if (days > 0) durs.push(days + " " + perioddur(1));
510    return durs.join(" ");
511}
512
513function priceind2(_period) {
514    if (_period < _dayA.length)
515        return 0;//0-5 day
516    if (_period < _dayA.length + _dayB.length)
517        return 1;//6-15 day
518    if (_period < _daylength)
519        return 2;//16-30 day
520    if (_period < _daylength + _monA.length)
521        return 3;//1-11
522    if (_period < _daylength + _monA.length + _monB.length)
523        return 4;//12-23
524    if (_period < _daylength + _monA.length + _monB.length + _monC.length)
525        return 5;//24
526    //if (_period < _daylength + _monA.length + _monB.length + _monC.length)
527    return 6;//36 or more
528}
529
530function priceind3(priceind2) {
531    if (priceind2 == 0)
532        return 0;//0-5 day
533    if (priceind2 == 1)
534        return 1;//6-15 day
535    if (priceind2 == 3)
536        return 2;//16-30 day
537    if (priceind2 == 3)
538        return 6;//1-6 mon
539    if (priceind2 == 4)
540        return 12;//7-12 mon
541    if (priceind2 == 5)
542        return 24;//24 mon
543    //if (priceind2 == 5)
544    return 36;//36 mon or more
545}
546
547function priceText(priceind, _period, ind, _quantifier, _pradio, __period) {
548    _period = parseInt(_period);
549    if (formPriceInd.indexOf(priceind) >= 0) {
550        let period = _period;
551
552        if (formPriceInd2.indexOf(priceind) >= 0 && _pradio && $("input[type='radio'][name='" + _pradio + "']:checked").val() == 1 && __period)
553            period = _period + parseInt(__period);
554        return _CurrCode + " " + getPrice(priceind, period) + " X " + _period + " " + _quantifier;
555    } else if (_period != null && ind != null) {
556        return _CurrCode + " " + getPrice(priceind, _period) + " X " + periods[_period] + " " + perioddur(ind);
557    }
558    return _CurrCode + " " + price(priceind, priceind4()) + " X " + getDays();
559}

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.