1const posGlobal = (function() { 2 "use strict"; 3 4 const _this = { 5 user: "Trackside.point_of_sale.user", 6 items: "Trackside.point_of_sale.items", 7 total: "Trackside.point_of_sale.total", 8 tab: "Trackside.point_of_sale.tab", 9 tabDirtyFlag: "Trackside.point_of_sale.tab_dirty_flag", 10 11 initialize() { 12 _this.setUser(null); 13 _this.setItems([]); 14 _this.setTotal(0.00); 15 16 // We set this last so the "dirty tab" flag gets (and stays) set properly 17 _this.setTab(null); 18 }, 19 20 getValue(index, shouldParse = true) { 21 const stringValue = localStorage.getItem(index); 22 return shouldParse ? JSON.parse(stringValue) : stringValue; 23 }, 24 getUser(shouldParse = true) { 25 return _this.getValue(_this.user, shouldParse); 26 }, 27 getItems(shouldParse = true) { 28 return _this.getValue(_this.items, shouldParse); 29 }, 30 getTotal(shouldParse = true) { 31 return _this.getValue(_this.total, shouldParse); 32 }, 33 getTab(shouldParse = true) { 34 return _this.getValue(_this.tab, shouldParse); 35 }, 36 37 isTabDirty() { 38 return _this.getValue(_this.tabDirtyFlag, true); 39 }, 40 41 setValue(index, newValue) { 42 localStorage.setItem(index, typeof newValue !== "string" ? JSON.stringify(newValue) : newValue); 43 44 if (index !== _this.tab && index !== _this.tabDirtyFlag && !_this.isTabDirty() && _this.getTab() !== null) 45 { 46 // Since we have a current tab and we've changed some of our cart data, mark the tab as dirty 47 _this.setValue(_this.tabDirtyFlag, true); 48 } 49 }, 50 setUser(newValue) { 51 _this.setValue(_this.user, newValue); 52 }, 53 setItems(newValue) { 54 _this.setValue(_this.items, newValue); 55 }, 56 setTotal(newValue) { 57 _this.setValue(_this.total, newValue); 58 }, 59 setTab(newValue) { 60 _this.setValue(_this.tab, newValue); 61 62 // Reset our tracking of whether the tab is dirty 63 _this.setValue(_this.tabDirtyFlag, false); 64 }, 65 }; 66 67 return _this; 68})();
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.