/* * storage for jquery collapse * -- * source: http://github.com/danielstocks/jquery-collapse/ * site: http://webcloud.se/jquery-collapse * * @author daniel stocks (http://webcloud.se) * copyright 2013, daniel stocks * released under the mit, bsd, and gpl licenses. */ /* �������������֮�� www.lanrenzhijia.com */ (function($) { var storage_key = "jquery-collapse"; function storage(id) { var db; try { db = window.localstorage || $.fn.collapse.cookiestorage; } catch(e) { db = false; } return db ? new _storage(id, db) : false; } function _storage(id, db) { this.id = id; this.db = db; this.data = []; } _storage.prototype = { write: function(position, state) { var _this = this; _this.data[position] = state ? 1 : 0; // pad out data array with zero values $.each(_this.data, function(i) { if(typeof _this.data[i] == 'undefined') { _this.data[i] = 0; } }); var obj = this.getdataobject(); obj[this.id] = this.data; this.db.setitem(storage_key, json.stringify(obj)); }, read: function() { var obj = this.getdataobject(); return obj[this.id] || []; }, getdataobject: function() { var string = this.db.getitem(storage_key); return string ? json.parse(string) : {}; } }; jquerycollapsestorage = storage; })(jquery); /* �������������֮�� www.lanrenzhijia.com */