UNPKG

a-multilayout-splitter

Version:

A React package designed to facilitate the division of your views into distinct sections, offering effortless resizing and support for intricate layouts.

1 lines 1.57 kB
class SplitSessionStorage{constructor(){this.sessionKeyIdentifier="@a-multilayout-splitter",this.splitterLocalIdentifierPrefix="alphaFact",this.openPrefix="open",this.closePrefix="close",this.horizontalPrefix="horizontal",this.verticalPrefix="vertical",this.encodeBase64=e=>Buffer.from(e).toString("base64"),this.decodeBase64=e=>Buffer.from(e,"base64").toString("ascii")}setItem(e,t){return localStorage.setItem(e,JSON.stringify(t))}getItem(e){var t=localStorage.getItem(this.sessionKeyIdentifier);let i=null;return{allItem:i=t?JSON.parse(t):i,item:i&&i[e]||null}}removeItem(e){localStorage.removeItem(e)}removeStoredSession(e){this.removeItem(this.sessionKeyIdentifier)}SetSession(e,t,i=!1){var s=function(e,t){var i=null==(i=this.getItem(btoa(this.splitterLocalIdentifierPrefix+e)))?void 0:i.allItem;i?this.setItem(this.sessionKeyIdentifier,Object.assign(Object.assign({},i),{[btoa(this.splitterLocalIdentifierPrefix+e)]:t})):this.setItem(this.sessionKeyIdentifier,{[btoa(this.splitterLocalIdentifierPrefix+e)]:t})}.bind(this),o=window.location,o=o.host+o.pathname;s(i?o+t+this.closePrefix:o+t,e)}GetSession(e,t=!1){var i=function(e,t,i=""){var e=this.splitterLocalIdentifierPrefix+e+t+i,s=null==(s=this.getItem(btoa(e)))?void 0:s.item,o=window.location;return atob(btoa(e))===this.splitterLocalIdentifierPrefix+o.host+o.pathname+t+i&&s?s:[]}.bind(this),s=window.location,s=s.host+s.pathname;return t?(t=i(window.location.href,e,this.closePrefix),this.removeItem(btoa(this.splitterLocalIdentifierPrefix+s+e+this.closePrefix)),t):i(s,e)}}export default SplitSessionStorage;