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CAAiBT,GACpB,IAAK,IAAIiB,EAAI,EAAGA,EAAI1C,EAAU2C,SAAUD,EAAG,CACvC,MAAMT,EAAOjC,EAAU0C,GACvB,GAAIjB,GAAQQ,EAAKhC,UAAYwB,GAAQQ,EAAK/B,UACtC,OAAO+B,CAEf,CACA,OAAOjC,EAAU,EACrB,G","sources":["webpack://AJN/webpack/bootstrap","webpack://AJN/webpack/runtime/define property getters","webpack://AJN/webpack/runtime/hasOwnProperty shorthand","webpack://AJN/webpack/runtime/make namespace object","webpack://AJN/external var \"jQuery\"","webpack://AJN/./src/js/books/bookprice.ts","webpack://AJN/./src/js/books/utility.ts","webpack://AJN/./src/js/books/cart.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = jQuery;","export interface BookPrice {\r\n lowcount: number;\r\n highcount: number;\r\n discounttext: string;\r\n name: string;\r\n price: number;\r\n}\r\n\r\nexport const priceList: Array = [\r\n {\r\n lowcount: 1,\r\n highcount: 5,\r\n discounttext: \"No discount\",\r\n name: \"1 - 5 books\",\r\n price: 30.0\r\n },\r\n {\r\n lowcount: 6,\r\n highcount: 15,\r\n name: \"6 - 15 books\",\r\n discounttext: \"10% discount\",\r\n price: 27.0\r\n },\r\n {\r\n lowcount: 16,\r\n highcount: 50,\r\n name: \"16 - 50 books\",\r\n discounttext: \"15% discount\",\r\n price: 25.5\r\n },\r\n {\r\n lowcount: 51,\r\n highcount: 99,\r\n name: \"51 - 99 books\",\r\n discounttext: \"25% discount\",\r\n price: 22.5\r\n },\r\n {\r\n lowcount: 100,\r\n highcount: 10000,\r\n name: \"100 or more books\",\r\n discounttext: \"30% discount\",\r\n price: 21\r\n }\r\n];","\r\n\r\nexport function formatCurrency(amount: number): string {\r\n let USDollar = new Intl.NumberFormat('en-US', {\r\n style: 'currency',\r\n currency: 'USD',\r\n });\r\n return USDollar.format(amount);\r\n}","import * as $ from 'jquery';\r\n\r\nimport { BookPrice, priceList } from \"./bookprice\";\r\nimport { formatCurrency } from \"./utility\";\r\n\r\nconst SALESTAXRATE = 0.09;\r\nconst SHIPPERBOOK = 1.0;\r\nconst MINSHIPPING = 5.0;\r\n\r\n\r\nexport class Cart {\r\n showPurchase: boolean;\r\n $ddQuantity: JQuery;\r\n $priceTable: JQuery;\r\n $cart: JQuery;\r\n quantity: number;\r\n bookeach: number;\r\n booktotal: number;\r\n shipping: number;\r\n salestax: number;\r\n grandtotal: number;\r\n discounttext: string;\r\n\r\n constructor() {\r\n this.showPurchase = false;\r\n this.$ddQuantity = $('#ddquantity');\r\n this.$priceTable = $('#pricetable');\r\n this.$cart = $(\"#cart\");\r\n }\r\n\r\n setup() {\r\n this.fillQuantity();\r\n this.showPriceTable();\r\n }\r\n\r\n fillQuantity() {\r\n const self = this;\r\n let html = \"\";\r\n for (var quan = 1; quan <= 500; ++quan) {\r\n html += ``;\r\n }\r\n this.$ddQuantity.html(html);\r\n\r\n this.$ddQuantity.on(\"change\", () => self.update());\r\n }\r\n\r\n update() {\r\n const sQuan = this.$ddQuantity.val();\r\n if (!sQuan) {\r\n this.$cart.hide();\r\n return;\r\n }\r\n this.quantity = parseInt(sQuan);\r\n const book = Cart.getSelectedPrice(this.quantity);\r\n\r\n this.bookeach = book.price;\r\n this.discounttext = book.discounttext;\r\n this.booktotal = this.bookeach * this.quantity;\r\n this.shipping = SHIPPERBOOK * this.quantity;\r\n if (this.shipping < MINSHIPPING) {\r\n this.shipping = MINSHIPPING;\r\n }\r\n\r\n this.grandtotal = this.booktotal + this.shipping;\r\n\r\n this.showCart();\r\n }\r\n\r\n showCart() {\r\n let html = '';\r\n html += '';\r\n html += ``;\r\n html += ``;\r\n html += ``;\r\n\r\n html += ``;\r\n html += ``;\r\n\r\n html += \"
QuantityUnit Price Total
${this.quantity}${formatCurrency(this.bookeach)} (${this.discounttext})${formatCurrency(this.booktotal)}
Shipping${formatCurrency(this.shipping)}
Total${formatCurrency(this.grandtotal)}
\";\r\n\r\n html += ``;\r\n html += `

.

`\r\n this.$cart.html(html).show();\r\n }\r\n\r\n showPriceTable() {\r\n let html = \"\";\r\n html += \"\";\r\n html += \"\";\r\n for (var row of priceList) {\r\n html += \"\"\r\n html += \"\";\r\n }\r\n\r\n html += \"\";\r\n\r\n html += \"
Number of booksPrice Each
\";\r\n html += \"\" + row.name + \"\";\r\n html += \" (\" + row.discounttext + \")\" + formatCurrency(row.price) + \"
\";\r\n this.$priceTable.html(html);\r\n }\r\n\r\n static getSelectedPrice(quan: number): BookPrice {\r\n for (var i = 0; i < priceList.length; ++i) {\r\n const book = priceList[i];\r\n if (quan >= book.lowcount && quan <= book.highcount) {\r\n return book;\r\n }\r\n }\r\n return priceList[0];\r\n }\r\n}"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","jQuery","priceList","lowcount","highcount","discounttext","name","price","formatCurrency","amount","Intl","NumberFormat","style","currency","format","Cart","constructor","this","showPurchase","$ddQuantity","$priceTable","$cart","setup","fillQuantity","showPriceTable","self","html","quan","on","update","sQuan","val","hide","quantity","parseInt","book","getSelectedPrice","bookeach","booktotal","shipping","grandtotal","showCart","show","row","i","length"],"sourceRoot":""}