Dev: Json viewer lazy evaluation

This commit is contained in:
surunzi
2016-10-19 13:18:55 +08:00
parent 9ddba16db9
commit 1ff830a185
4 changed files with 44 additions and 36 deletions

View File

@@ -350,15 +350,13 @@ var {hostname, pathname} = window.location;
function delCookie(key)
{
util.cookie.remove(key);
let hostNames = hostname.split('.'),
pathNames = pathname.split('/'),
domain = '',
pathLen = pathNames.length,
path;
let deleted = () => !util.cookie.get(key);
if (del()) return;
for (let i = hostNames.length - 1; i >= 0; i--)
{
@@ -367,26 +365,27 @@ function delCookie(key)
domain = (domain === '') ? hostName : hostName + '.' + domain ;
path = '/';
util.cookie.remove(key, {domain, path});
if (deleted()) return;
util.cookie.remove(key, {domain});
if (deleted()) return;
if (del({domain, path}) || del({domain})) return;
for (let j = 0; j < pathLen; j++)
{
let pathName = pathNames[j];
if (pathName === '') continue;
path += pathName;
util.cookie.remove(key, {domain, path});
if (deleted()) return;
util.cookie.remove(key, {path});
if (deleted()) return;
if (del({domain, path}) || del({path})) return;
path += '/';
util.cookie.remove(key, {domain, path});
if (deleted()) return;
util.cookie.remove(key, {path});
if (deleted()) return;
if (del({domain, path}) || del({path})) return;
}
}
function del(options = {})
{
util.cookie.remove(key, options);
return !util.cookie.get(key);
}
}
var sliceStr = (str, len) => str.length < len ? str : str.slice(0, len) + '...';