JavaScript Ali Express Discounted Cart: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
(Created page with "<source lang="js"> var AliExp=AliExp||(function(me){ me.Cart = { TotalUSD : 82.55, TotalMYR : 340.5, Print : function(){ me.Cart...")
 
No edit summary
 
Line 29: Line 29:
             msg += '\nShahed Total Amount: US $' + Math.floor(me.Shahed.Total*100)/100;
             msg += '\nShahed Total Amount: US $' + Math.floor(me.Shahed.Total*100)/100;
             msg += '\nSaikat Total Amount: US $' + Math.floor(me.Saikat.Total*100)/100;
             msg += '\nSaikat Total Amount: US $' + Math.floor(me.Saikat.Total*100)/100;
             console.log(msg)
             console.log(msg);
         }
         }
     }
     }
Line 53: Line 53:
             msg += '\nShahed Total Amount: US $' + Math.floor(me.Shahed.Total()*100)/100;
             msg += '\nShahed Total Amount: US $' + Math.floor(me.Shahed.Total()*100)/100;
             msg += '\nSaikat Total Amount: US $' + Math.floor(me.Saikat.Total()*100)/100;
             msg += '\nSaikat Total Amount: US $' + Math.floor(me.Saikat.Total()*100)/100;
             console.log(msg)
             console.log(msg);
         }
         }
     }
     }
Line 76: Line 76:
             msg += '\nShahed Total Amount: MY ¥' + Math.floor(me.Shahed.Total()*100)/100;
             msg += '\nShahed Total Amount: MY ¥' + Math.floor(me.Shahed.Total()*100)/100;
             msg += '\nSaikat Total Amount: MY ¥' + Math.floor(me.Saikat.Total()*100)/100;
             msg += '\nSaikat Total Amount: MY ¥' + Math.floor(me.Saikat.Total()*100)/100;
             console.log(msg)
             console.log(msg);
         }
         }
     }
     }

Latest revision as of 20:30, 13 November 2019

var AliExp=AliExp||(function(me){
    me.Cart     = {
        TotalUSD : 82.55,
        TotalMYR : 340.5,
        Print    : function(){
            me.CartPrice.Print();
            me.DiscPrice.Print();
            me.ExchPrice.Print();
        }
    };
    me.exchRate = (me.Cart.TotalMYR/me.Cart.TotalUSD);
    return me;
})({});
;AliExp.CartPrice||(function($, me){
    me = {
        Shahed   : {
            Total: (38.84 + 17.59 + 14.15 + 3.49 + 2.75)
        },
        Saikat   : {
            Total: (38.84)
        },
        Total    : function(total){
            total = me.Shahed.Total + me.Saikat.Total;
            return total;
        },
        Print    : function(msg){
            msg  = '\nBefore Discount:';
            msg += '\nShahed Total Amount: US $' + Math.floor(me.Shahed.Total*100)/100;
            msg += '\nSaikat Total Amount: US $' + Math.floor(me.Saikat.Total*100)/100;
            console.log(msg);
        }
    }
    $.CartPrice = me;
})(AliExp);
;AliExp.DiscPrice||(function($, me){
    me = {
        Total    : $.Cart.TotalUSD,
        Shahed   : {
            Total: function(total){
                total = $.CartPrice.Shahed.Total * (me.Total/$.CartPrice.Total());
                return total;
            }
        },
        Saikat   : {
            Total: function(total){
                total = $.CartPrice.Saikat.Total * (me.Total/$.CartPrice.Total());
                return total;
            }
        },
        Print    : function(msg){
            msg  = '\nAfter Discount:';
            msg += '\nShahed Total Amount: US $' + Math.floor(me.Shahed.Total()*100)/100;
            msg += '\nSaikat Total Amount: US $' + Math.floor(me.Saikat.Total()*100)/100;
            console.log(msg);
        }
    }
    $.DiscPrice = me;
})(AliExp);
;AliExp.ExchPrice||(function($, me){
    me = {
        Shahed   : {
            Total: function(total){
                total = $.DiscPrice.Shahed.Total() * $.exchRate;
                return total;
            }
        },
        Saikat   : {
            Total: function(total){
                total = $.DiscPrice.Saikat.Total() * $.exchRate;
                return total;
            }
        },
        Print    : function(msg){
            msg  = '\nDiscounted Exchange Price:';
            msg += '\nShahed Total Amount: MY ¥' + Math.floor(me.Shahed.Total()*100)/100;
            msg += '\nSaikat Total Amount: MY ¥' + Math.floor(me.Saikat.Total()*100)/100;
            console.log(msg);
        }
    }
    $.ExchPrice = me;
})(AliExp);
AliExp.Cart.Print();