/* Cached on Sat, 27 Apr 2024 17:41:27 */ (function(CB) { function Notepad() { if (CB.get("notepad") == undefined) { this.n = { vac: { r: [], v: [] }, cv: [] }; this.save(); } else { this.n = JSON.parse(CB.get("notepad")); } var self = this; //window.addEventListener('focus', function() { self.checkUpdates.apply(self) }); $(window).on('focus', function() { self.checkUpdates.apply(self) }); } Notepad.prototype.getCountVac = function() { return this.n.vac.r.length + this.n.vac.v.length; }; Notepad.prototype.getCountCv = function() { return this.n.cv.length; }; Notepad.prototype.hasVac = function(type, id) { return !(this.n.vac[type].indexOf(id) == -1); }; Notepad.prototype.hasCv = function(id) { return !(this.n.cv.indexOf(id) == -1); }; Notepad.prototype.addVac = function(type, id) { if (id != undefined) id = parseInt(id); if (id !== undefined && !this.hasVac(type, id)) { this.n.vac[type].push(id); this.save(); } return this; }; Notepad.prototype.addCv = function(id) { if (id != undefined) id = parseInt(id); if (id !== undefined && !this.hasCv(id)) { this.n.cv.push(id); this.save(); } return this; }; Notepad.prototype.removeVac = function(type, id) { if (id != undefined) id = parseInt(id); if (id !== undefined) { var index = this.n.vac[type].indexOf(id); if (index != -1) { this.n.vac[type].splice(index, 1); this.save(); } } return this; }; Notepad.prototype.removeCv = function(id) { if (id != undefined) id = parseInt(id); if (id !== undefined) { var index = this.n.cv.indexOf(id); if (index != -1) { this.n.cv.splice(index, 1); this.save(); } } return this; }; Notepad.prototype.save = function() { CB.set("notepad", JSON.stringify(this.n), {expires: 3600 * 34 * 30}); $(this).trigger({type: "change", fromOtherPage: false }); return this; }; Notepad.prototype.update = function() { this.n = JSON.parse(CB.get("notepad")); return this; }; Notepad.prototype.checkUpdates = function() { if (JSON.stringify(this.n) != CB.get("notepad")) { this.update(); $(this).trigger({type: "change", fromOtherPage: true }); } }; window.Notepad = new Notepad(); })(CookiesBag);