1var RFPCart = function () { 2 var self = this; 3 4 self._suppliers = []; 5 // Load the cookie into the cart on creation 6 self.loadFromCookie(); 7}; 8 9RFPCart.prototype.loadFromCookie = function() { 10 var self = this; 11 var cookiedata = $.cookie('RFPCart'); 12 if (cookiedata) { 13 var suppliers = JSON.parse(cookiedata); 14 if (suppliers instanceof Array) { 15 self._suppliers = suppliers; 16 } 17 } 18}; 19 20RFPCart.prototype.saveToCookie = function() { 21 var self = this; 22 var cookiedata = JSON.stringify(self._suppliers); 23 // is a year long enough? 24 $.cookie('RFPCart',cookiedata,{ expires: 365, path: '/' }); 25}; 26 27RFPCart.prototype.getSuppliers = function() { 28 var self = this; 29 return self._suppliers; 30}; 31 32RFPCart.prototype.addSupplier = function(supplierId) { 33 var self = this; 34 self._suppliers.push(supplierId); 35 self.saveToCookie(); 36}; 37 38RFPCart.prototype.removeSupplier = function(supplierId) { 39 var self = this; 40 if (self.isSupplierInCart(supplierId)) { 41 self._suppliers = $.grep(self._suppliers,function(id){ 42 return (id !== supplierId); 43 }); 44 self.saveToCookie(); 45 } 46}; 47 48RFPCart.prototype.isSupplierInCart = function(supplierId) { 49 var self = this; 50 if ($.inArray(supplierId,self._suppliers) > -1 ) { 51 return true; 52 } 53 else { 54 return false; 55 } 56}; 57
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.