mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-12-05 05:04:20 +00:00
2 lines
1.5 KiB
JavaScript
2 lines
1.5 KiB
JavaScript
/*! Widget: storage - updated 4/18/2017 (v2.28.8) */
|
|
!function(e,t,r){"use strict";var o=e.tablesorter||{};e.extend(!0,o.defaults,{fixedUrl:"",widgetOptions:{storage_fixedUrl:"",storage_group:"",storage_page:"",storage_storageType:"",storage_tableId:"",storage_useSessionStorage:""}}),o.storage=function(o,s,a,i){var g,n,p,l=!1,d={},u=(o=e(o)[0]).config,S=u&&u.widgetOptions,c=(i&&i.storageType||S&&S.storage_storageType).toString().charAt(0).toLowerCase(),_=c?"":i&&i.useSessionStorage||S&&S.storage_useSessionStorage,f=e(o),m=i&&i.id||f.attr(i&&i.group||S&&S.storage_group||"data-table-group")||S&&S.storage_tableId||o.id||e(".tablesorter").index(f),w=i&&i.url||f.attr(i&&i.page||S&&S.storage_page||"data-table-page")||S&&S.storage_fixedUrl||u&&u.fixedUrl||t.location.pathname;if("c"!==c&&(c="s"===c||_?"sessionStorage":"localStorage")in t)try{t[c].setItem("_tmptest","temp"),l=!0,t[c].removeItem("_tmptest")}catch(e){u&&u.debug&&console.warn(c+" is not supported in this browser")}if(u.debug&&console.log("Storage widget using",l?c:"cookies"),e.parseJSON&&(l?d=e.parseJSON(t[c][s]||"null")||{}:(n=r.cookie.split(/[;\s|=]/),d=0!==(g=e.inArray(s,n)+1)?e.parseJSON(n[g]||"null")||{}:{})),void 0===a||!t.JSON||!JSON.hasOwnProperty("stringify"))return d&&d[w]?d[w][m]:"";d[w]||(d[w]={}),d[w][m]=a,l?t[c][s]=JSON.stringify(d):((p=new Date).setTime(p.getTime()+31536e6),r.cookie=s+"="+JSON.stringify(d).replace(/\"/g,'"')+"; expires="+p.toGMTString()+"; path=/")}}(jQuery,window,document); |