1/* 2 * TotalStorage 3 * 4 * Copyright (c) 2012 Jared Novack & Upstatement (upstatement.com) 5 * Dual licensed under the MIT and GPL licenses: 6 * http://www.opensource.org/licenses/mit-license.php 7 * http://www.gnu.org/licenses/gpl.html 8 * 9 * Total Storage is the conceptual the love child of jStorage by Andris Reinman, 10 * and Cookie by Klaus Hartl -- though this is not connected to either project. 11 * 12 * @name $.totalStorage 13 * @cat Plugins/Cookie 14 * @author Jared Novack/[email protected] 15 * @version 1.1.2 16 * @url http://upstatement.com/blog/2012/01/jquery-local-storage-done-right-and-easy/ 17 */ 18(function($){var ls=window.localStorage;var supported;if(typeof ls=='undefined'||typeof window.JSON=='undefined'){supported=false;}else{supported=true;} 19$.totalStorage=function(key,value,options){return $.totalStorage.impl.init(key,value);} 20$.totalStorage.setItem=function(key,value){return $.totalStorage.impl.setItem(key,value);} 21$.totalStorage.getItem=function(key){return $.totalStorage.impl.getItem(key);} 22$.totalStorage.getAll=function(){return $.totalStorage.impl.getAll();} 23$.totalStorage.deleteItem=function(key){return $.totalStorage.impl.deleteItem(key);} 24$.totalStorage.impl={init:function(key,value){if(typeof value!='undefined'){return this.setItem(key,value);}else{return this.getItem(key);}},setItem:function(key,value){if(!supported){try{$.cookie(key,value);return value;}catch(e){console.log('Local Storage not supported by this browser. Install the cookie plugin on your site to take advantage of the same functionality. You can get it at https://github.com/carhartl/jquery-cookie');}} 25var saver=JSON.stringify(value);ls.setItem(key,saver);return this.parseResult(saver);},getItem:function(key){if(!supported){try{return this.parseResult($.cookie(key));}catch(e){return null;}} 26return this.parseResult(ls.getItem(key));},deleteItem:function(key){if(!supported){try{$.cookie(key,null);return true;}catch(e){return false;}} 27ls.removeItem(key);return true;},getAll:function(){var items=new Array();if(!supported){try{var pairs=document.cookie.split(";");for(var i=0;i<pairs.length;i++){var pair=pairs[i].split('=');var key=pair[0];items.push({key:key,value:this.parseResult($.cookie(key))});}}catch(e){return null;}}else{for(var i in ls){if(i.length){items.push({key:i,value:this.parseResult(ls.getItem(i))});}}} 28return items;},parseResult:function(res){var ret;try{ret=JSON.parse(res);if(ret=='true'){ret=true;} 29if(ret=='false'){ret=false;} 30if(parseFloat(ret)==ret&&typeof ret!="object"){ret=parseFloat(ret);}}catch(e){} 31return ret;}}})(jQuery);
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.