mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-05 06:22:52 +08:00
e7180a86ce
This also allowed to remove all webpack 'externals' overhead.
7 lines
988 B
JavaScript
7 lines
988 B
JavaScript
/*!
|
|
* Hasher <http://github.com/millermedeiros/hasher>
|
|
* @author Miller Medeiros
|
|
* @version 1.1.2 (2012/10/31 03:19 PM)
|
|
* Released under the MIT License
|
|
*/
|
|
(e=>{var i,a,n=signals.Signal,s=/#(.*)$/,t=/^#/;const r=e=>{if(!e)return"";var i=new RegExp("^\\/|\\$","g");return e.replace(i,"")},h=()=>{var i=s.exec(e.location.href);return i&&i[1]?decodeURIComponent(i[1]):""},o=e=>{if(i!==e){var a=i;i=e,l.changed.dispatch(r(e),r(a))}},c=()=>{var e=h();e!==i&&o(e)},d=e=>(e=e.join("/"))?"/"+e.replace(t,""):e,l={changed:new n,initialized:new n,init:()=>{a||(i=h(),e.addEventListener("hashchange",c),a=!0,l.initialized.dispatch(r(i)))},stop:()=>{a&&(e.removeEventListener("hashchange",c),a=!1)},setHash:(...a)=>{(a=d(a))!==i&&(o(a),a===i&&(e.location.hash="#"+encodeURI(a)))},replaceHash:(...a)=>{(a=d(a))!==i&&(o(a),a===i&&e.location.replace("#"+encodeURI(a)))},dispose:()=>{l.stop(),l.initialized.dispose(),l.changed.dispose(),e.hasher=null}};l.initialized.memorize=!0,e.hasher=l})(this);
|