puvox-library 1.0.42 → 1.0.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/library_standard.js
CHANGED
@@ -2739,75 +2739,6 @@ const puvox_library =
|
|
2739
2739
|
md5(str){var md5cycle=function(x,k){var a=x[0],b=x[1],c=x[2],d=x[3];a=ff(a,b,c,d,k[0],7,-680876936);d=ff(d,a,b,c,k[1],12,-389564586);c=ff(c,d,a,b,k[2],17,606105819);b=ff(b,c,d,a,k[3],22,-1044525330);a=ff(a,b,c,d,k[4],7,-176418897);d=ff(d,a,b,c,k[5],12,1200080426);c=ff(c,d,a,b,k[6],17,-1473231341);b=ff(b,c,d,a,k[7],22,-45705983);a=ff(a,b,c,d,k[8],7,1770035416);d=ff(d,a,b,c,k[9],12,-1958414417);c=ff(c,d,a,b,k[10],17,-42063);b=ff(b,c,d,a,k[11],22,-1990404162);a=ff(a,b,c,d,k[12],7,1804603682);d=ff(d,a,b,c,k[13],12,-40341101);c=ff(c,d,a,b,k[14],17,-1502002290);b=ff(b,c,d,a,k[15],22,1236535329);a=gg(a,b,c,d,k[1],5,-165796510);d=gg(d,a,b,c,k[6],9,-1069501632);c=gg(c,d,a,b,k[11],14,643717713);b=gg(b,c,d,a,k[0],20,-373897302);a=gg(a,b,c,d,k[5],5,-701558691);d=gg(d,a,b,c,k[10],9,38016083);c=gg(c,d,a,b,k[15],14,-660478335);b=gg(b,c,d,a,k[4],20,-405537848);a=gg(a,b,c,d,k[9],5,568446438);d=gg(d,a,b,c,k[14],9,-1019803690);c=gg(c,d,a,b,k[3],14,-187363961);b=gg(b,c,d,a,k[8],20,1163531501);a=gg(a,b,c,d,k[13],5,-1444681467);d=gg(d,a,b,c,k[2],9,-51403784);c=gg(c,d,a,b,k[7],14,1735328473);b=gg(b,c,d,a,k[12],20,-1926607734);a=hh(a,b,c,d,k[5],4,-378558);d=hh(d,a,b,c,k[8],11,-2022574463);c=hh(c,d,a,b,k[11],16,1839030562);b=hh(b,c,d,a,k[14],23,-35309556);a=hh(a,b,c,d,k[1],4,-1530992060);d=hh(d,a,b,c,k[4],11,1272893353);c=hh(c,d,a,b,k[7],16,-155497632);b=hh(b,c,d,a,k[10],23,-1094730640);a=hh(a,b,c,d,k[13],4,681279174);d=hh(d,a,b,c,k[0],11,-358537222);c=hh(c,d,a,b,k[3],16,-722521979);b=hh(b,c,d,a,k[6],23,76029189);a=hh(a,b,c,d,k[9],4,-640364487);d=hh(d,a,b,c,k[12],11,-421815835);c=hh(c,d,a,b,k[15],16,530742520);b=hh(b,c,d,a,k[2],23,-995338651);a=ii(a,b,c,d,k[0],6,-198630844);d=ii(d,a,b,c,k[7],10,1126891415);c=ii(c,d,a,b,k[14],15,-1416354905);b=ii(b,c,d,a,k[5],21,-57434055);a=ii(a,b,c,d,k[12],6,1700485571);d=ii(d,a,b,c,k[3],10,-1894986606);c=ii(c,d,a,b,k[10],15,-1051523);b=ii(b,c,d,a,k[1],21,-2054922799);a=ii(a,b,c,d,k[8],6,1873313359);d=ii(d,a,b,c,k[15],10,-30611744);c=ii(c,d,a,b,k[6],15,-1560198380);b=ii(b,c,d,a,k[13],21,1309151649);a=ii(a,b,c,d,k[4],6,-145523070);d=ii(d,a,b,c,k[11],10,-1120210379);c=ii(c,d,a,b,k[2],15,718787259);b=ii(b,c,d,a,k[9],21,-343485551);x[0]=add32(a,x[0]);x[1]=add32(b,x[1]);x[2]=add32(c,x[2]);x[3]=add32(d,x[3])};var cmn=function(q,a,b,x,s,t){a=add32(add32(a,q),add32(x,t));return add32(a<<s|a>>>32-s,b)};var ff=function(a,b,c,d,x,s,t){return cmn(b&c|~b&d,a,b,x,s,t)};var gg=function(a,b,c,d,x,s,t){return cmn(b&d|c&~d,a,b,x,s,t)};var hh=function(a,b,c,d,x,s,t){return cmn(b^c^d,a,b,x,s,t)};var ii=function(a,b,c,d,x,s,t){return cmn(c^(b|~d),a,b,x,s,t)};var md51=function(s){var txt="",n=s.length,state=[1732584193,-271733879,-1732584194,271733878],i;for(i=64;i<=s.length;i+=64){md5cycle(state,md5blk(s.substring(i-64,i)))}s=s.substring(i-64);var tail=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(i=0;i<s.length;i++)tail[i>>2]|=s.charCodeAt(i)<<(i%4<<3);tail[i>>2]|=128<<(i%4<<3);if(i>55){md5cycle(state,tail);for(i=0;i<16;i++)tail[i]=0}tail[14]=n*8;md5cycle(state,tail);return state};var md5blk=function(s){var md5blks=[],i;for(i=0;i<64;i+=4){md5blks[i>>2]=s.charCodeAt(i)+(s.charCodeAt(i+1)<<8)+(s.charCodeAt(i+2)<<16)+(s.charCodeAt(i+3)<<24)}return md5blks};var hex_chr="0123456789abcdef".split("");var rhex=function(n){var s="",j=0;for(;j<4;j++)s+=hex_chr[n>>j*8+4&15]+hex_chr[n>>j*8&15];return s};var hex=function(x){for(var i=0;i<x.length;i++)x[i]=rhex(x[i]);return x.join("")};var md5_=function(s){return hex(md51(s))};var add32=function(a,b){return a+b&4294967295};if(md5_("hello")!="5d41402abc4b2a76b9719d911017c592"){var add32=function(x,y){var lsw=(x&65535)+(y&65535),msw=(x>>16)+(y>>16)+(lsw>>16);return msw<<16|lsw&65535}}return md5_(str)},
|
2740
2740
|
|
2741
2741
|
|
2742
|
-
// ######## Cookies: https://github.com/ttodua/useful-javascript/blob/master/cookies-library.js ######## //
|
2743
|
-
Cookies : {
|
2744
|
-
get(a,b) { return this.cookies_instance().get(a,b); },
|
2745
|
-
set(a,b,c) { return this.cookies_instance().set(a,b); },
|
2746
|
-
remove(a, b) {return this.cookies_instance().remove(a,b); },
|
2747
|
-
append(name, value, attributes) {return this.cookies_instance().set((this.get(name) || '') + value, attributes); },
|
2748
|
-
isset(cookiename) {return this.get(cookiename)!="";}, // document.cookie.indexOf('; '+cookiename+'=');
|
2749
|
-
// WORKING WITH ARRAY/OBJECTS
|
2750
|
-
getOption(cookieName, key, defaultValue)
|
2751
|
-
{
|
2752
|
-
var existingValue = this.get(cookieName);
|
2753
|
-
if(existingValue)
|
2754
|
-
{
|
2755
|
-
var parsed = JSON.parse(existingValue);
|
2756
|
-
if(key in parsed)
|
2757
|
-
return parsed[key];
|
2758
|
-
}
|
2759
|
-
return defaultValue;
|
2760
|
-
},
|
2761
|
-
setOption(cookieName, key, value, attributes)
|
2762
|
-
{
|
2763
|
-
var cookie = this.get(cookieName);
|
2764
|
-
var parsed = {};
|
2765
|
-
if(cookie) parsed = JSON.parse(cookie);
|
2766
|
-
parsed[key] = value;
|
2767
|
-
var attributes = attributes || { expires: 99999 };
|
2768
|
-
this.set(cookieName, JSON.stringify(parsed), attributes);
|
2769
|
-
return parsed;
|
2770
|
-
},
|
2771
|
-
removeOption(cookieName, key, attributes)
|
2772
|
-
{
|
2773
|
-
var cookie = this.get(cookieName);
|
2774
|
-
var parsed = {};
|
2775
|
-
if(cookie) parsed = JSON.parse(cookie);
|
2776
|
-
if(key in parsed) delete parsed[key];
|
2777
|
-
var attributes = attributes || { expires: 99999 };
|
2778
|
-
this.set(cookieName, JSON.stringify(parsed), attributes);
|
2779
|
-
return parsed;
|
2780
|
-
},
|
2781
|
-
//sub-array
|
2782
|
-
getOptionObject(cookieName, key){
|
2783
|
-
return JSON.parse( this.getOption(cookieName, key, "{}") );
|
2784
|
-
},
|
2785
|
-
setOptionObject(cookieName, key, subKey, subValue){
|
2786
|
-
var existing = JSON.parse( this.getOption(cookieName, key, "{}") );
|
2787
|
-
if (subValue==null) delete existing[subKey];
|
2788
|
-
else existing[subKey]=subValue;
|
2789
|
-
this.setOption(cookieName, key, JSON.stringify(existing));
|
2790
|
-
},
|
2791
|
-
setOptionArray(cookieName, key, subValue, Add_or_remove)
|
2792
|
-
{
|
2793
|
-
var existing = JSON.parse( this.getOption(cookieName, key, "[]") );
|
2794
|
-
if (Add_or_remove && !existing.includes(subValue) )
|
2795
|
-
{
|
2796
|
-
existing.push(subValue);
|
2797
|
-
}
|
2798
|
-
else if(!Add_or_remove && existing.includes(subValue) )
|
2799
|
-
{
|
2800
|
-
existing = this.removeItem(existing, subValue);
|
2801
|
-
}
|
2802
|
-
this.setOption(cookieName, key, JSON.stringify(existing));
|
2803
|
-
},
|
2804
|
-
//
|
2805
|
-
cookies_instance(){ if (!this.cookies_inited) this.cookies_inited=this.cookies(); return this.cookies_inited; } ,
|
2806
|
-
cookies_inited: null,
|
2807
|
-
// https://cdn.jsdelivr.net/npm/js-cookie@rc/dist/js.cookie.min.js
|
2808
|
-
cookies : function(){"use strict";function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}var t={read:function(e){return e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};return function n(r,o){function i(t,n,i){if("undefined"!=typeof document){"number"==typeof(i=e({},o,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),n=r.write(n,t);var c="";for(var u in i)i[u]&&(c+="; "+u,!0!==i[u]&&(c+="="+i[u].split(";")[0]));return document.cookie=t+"="+n+c}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},i=0;i<n.length;i++){var c=n[i].split("="),u=c.slice(1).join("=");'"'===u[0]&&(u=u.slice(1,-1));try{var f=t.read(c[0]);if(o[f]=r.read(u,f),e===f)break}catch(e){}}return e?o[e]:o}},remove:function(t,n){i(t,"",e({},n,{expires:-1}))},withAttributes:function(t){return n(this.converter,e({},this.attributes,t))},withConverter:function(t){return n(e({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(o)},converter:{value:Object.freeze(r)}})}(t,{path:"/"})}
|
2809
|
-
},
|
2810
|
-
|
2811
2742
|
|
2812
2743
|
|
2813
2744
|
jsonConcat(o1, o2) {
|
@@ -2882,62 +2813,174 @@ const puvox_library =
|
|
2882
2813
|
return this.privateAppName__;
|
2883
2814
|
},
|
2884
2815
|
|
2816
|
+
|
2817
|
+
// ######## Cookies: https://github.com/ttodua/useful-javascript/blob/master/cookies-library.js ######## //
|
2818
|
+
Cookies : {
|
2819
|
+
get(a,b) { return this.cookies_instance().get(a,b); },
|
2820
|
+
set(a,b,c) { return this.cookies_instance().set(a,b); },
|
2821
|
+
remove(a, b) {return this.cookies_instance().remove(a,b); },
|
2822
|
+
append(name, value, attributes) {return this.cookies_instance().set((this.get(name) || '') + value, attributes); },
|
2823
|
+
isset(cookiename) {return this.get(cookiename)!="";}, // document.cookie.indexOf('; '+cookiename+'=');
|
2824
|
+
// WORKING WITH ARRAY/OBJECTS
|
2825
|
+
getOption(cookieName, key, defaultValue)
|
2826
|
+
{
|
2827
|
+
var existingValue = this.get(cookieName);
|
2828
|
+
if(existingValue)
|
2829
|
+
{
|
2830
|
+
var parsed = JSON.parse(existingValue);
|
2831
|
+
if(key in parsed)
|
2832
|
+
return parsed[key];
|
2833
|
+
}
|
2834
|
+
return defaultValue;
|
2835
|
+
},
|
2836
|
+
setOption(cookieName, key, value, attributes)
|
2837
|
+
{
|
2838
|
+
var cookie = this.get(cookieName);
|
2839
|
+
var parsed = {};
|
2840
|
+
if(cookie) parsed = JSON.parse(cookie);
|
2841
|
+
parsed[key] = value;
|
2842
|
+
var attributes = attributes || { expires: 99999 };
|
2843
|
+
this.set(cookieName, JSON.stringify(parsed), attributes);
|
2844
|
+
return parsed;
|
2845
|
+
},
|
2846
|
+
removeOption(cookieName, key, attributes)
|
2847
|
+
{
|
2848
|
+
var cookie = this.get(cookieName);
|
2849
|
+
var parsed = {};
|
2850
|
+
if(cookie) parsed = JSON.parse(cookie);
|
2851
|
+
if(key in parsed) delete parsed[key];
|
2852
|
+
var attributes = attributes || { expires: 99999 };
|
2853
|
+
this.set(cookieName, JSON.stringify(parsed), attributes);
|
2854
|
+
return parsed;
|
2855
|
+
},
|
2856
|
+
//sub-array
|
2857
|
+
getOptionObject(cookieName, key){
|
2858
|
+
return JSON.parse( this.getOption(cookieName, key, "{}") );
|
2859
|
+
},
|
2860
|
+
setOptionObject(cookieName, key, subKey, subValue){
|
2861
|
+
var existing = JSON.parse( this.getOption(cookieName, key, "{}") );
|
2862
|
+
if (subValue==null) delete existing[subKey];
|
2863
|
+
else existing[subKey]=subValue;
|
2864
|
+
this.setOption(cookieName, key, JSON.stringify(existing));
|
2865
|
+
},
|
2866
|
+
setOptionArray(cookieName, key, subValue, Add_or_remove)
|
2867
|
+
{
|
2868
|
+
var existing = JSON.parse( this.getOption(cookieName, key, "[]") );
|
2869
|
+
if (Add_or_remove && !existing.includes(subValue) )
|
2870
|
+
{
|
2871
|
+
existing.push(subValue);
|
2872
|
+
}
|
2873
|
+
else if(!Add_or_remove && existing.includes(subValue) )
|
2874
|
+
{
|
2875
|
+
existing = puvox_library.removeItem(existing, subValue);
|
2876
|
+
}
|
2877
|
+
this.setOption(cookieName, key, JSON.stringify(existing));
|
2878
|
+
},
|
2879
|
+
//
|
2880
|
+
cookies_instance(){ if (!this.cookies_inited) this.cookies_inited=this.cookies(); return this.cookies_inited; } ,
|
2881
|
+
cookies_inited: null,
|
2882
|
+
// https://cdn.jsdelivr.net/npm/js-cookie@rc/dist/js.cookie.min.js
|
2883
|
+
cookies : function(){"use strict";function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}var t={read:function(e){return e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};return function n(r,o){function i(t,n,i){if("undefined"!=typeof document){"number"==typeof(i=e({},o,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),n=r.write(n,t);var c="";for(var u in i)i[u]&&(c+="; "+u,!0!==i[u]&&(c+="="+i[u].split(";")[0]));return document.cookie=t+"="+n+c}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],o={},i=0;i<n.length;i++){var c=n[i].split("="),u=c.slice(1).join("=");'"'===u[0]&&(u=u.slice(1,-1));try{var f=t.read(c[0]);if(o[f]=r.read(u,f),e===f)break}catch(e){}}return e?o[e]:o}},remove:function(t,n){i(t,"",e({},n,{expires:-1}))},withAttributes:function(t){return n(this.converter,e({},this.attributes,t))},withConverter:function(t){return n(e({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(o)},converter:{value:Object.freeze(r)}})}(t,{path:"/"})}
|
2884
|
+
},
|
2885
|
+
|
2886
|
+
|
2885
2887
|
cache: {
|
2886
|
-
|
2887
|
-
|
2888
|
-
|
2889
|
-
|
2890
|
-
|
2891
|
-
|
2892
|
-
|
2893
|
-
|
2894
|
-
|
2888
|
+
helper_read(groupName, storageType, expireSeconds = 0){
|
2889
|
+
const appName = puvox_library.getAppName();
|
2890
|
+
if (storageType === 'file'){
|
2891
|
+
const filepath = puvox_library.file.tempDir() + appName + '_' + groupName + '.json';
|
2892
|
+
// todo: add expiration
|
2893
|
+
return puvox_library.file.read(filepath);
|
2894
|
+
} else if (storageType === 'localStorage') {
|
2895
|
+
const storage = window.localStorage;
|
2896
|
+
let val = storage.getItem(appName + '_' + groupName);
|
2897
|
+
let expireVal = parseInt(storage.getItem(appName + '_' + groupName + '_t'));
|
2898
|
+
// if it's expired, then return null
|
2899
|
+
if (expireSeconds !== 0 && (new Date()).getTime() - expireVal > expireSeconds*1000){
|
2900
|
+
this.storage.removeItem(appName + '_' + groupName);
|
2901
|
+
this.storage.removeItem(appName + '_' + groupName + '_t');
|
2902
|
+
return null;
|
2895
2903
|
} else {
|
2896
|
-
|
2897
|
-
return val;
|
2898
|
-
} else {
|
2899
|
-
let now = (new Date()).getTime();
|
2900
|
-
if (now - expireVal > expireSeconds*1000){
|
2901
|
-
this.storage.removeItem(appName + '_' + name);
|
2902
|
-
this.storage.removeItem(appName + '_createtime_' + name);
|
2903
|
-
return defaultValue;
|
2904
|
-
}
|
2905
|
-
}
|
2904
|
+
return val;
|
2906
2905
|
}
|
2907
|
-
}
|
2908
|
-
|
2906
|
+
} else {
|
2907
|
+
alert(`storageType ${storageType} not supported`);
|
2908
|
+
throw new Error(`storageType ${storageType} not supported`);
|
2909
|
+
}
|
2910
|
+
},
|
2911
|
+
helper_write(groupName, content, storageType){
|
2912
|
+
const appName = puvox_library.getAppName();
|
2913
|
+
if (storageType == 'file'){
|
2914
|
+
const filepath = puvox_library.file.tempDir() + appName + '_' + groupName + '.json';
|
2915
|
+
// todo: add expiration
|
2916
|
+
puvox_library.file.write(filepath, content);
|
2917
|
+
return true;
|
2918
|
+
} else if (storageType === 'localStorage') {
|
2909
2919
|
try{
|
2910
|
-
const
|
2911
|
-
|
2912
|
-
|
2920
|
+
const storage = window.localStorage;
|
2921
|
+
storage.setItem(appName + '_' + groupName, content);
|
2922
|
+
storage.setItem(appName + '_' + groupName + '_t', (new Date()).getTime());
|
2913
2923
|
return true;
|
2914
2924
|
}
|
2915
|
-
catch(ex){ alert("Cache storage quote exceeded. can't save value. err598"
|
2916
|
-
}
|
2917
|
-
|
2918
|
-
|
2919
|
-
|
2920
|
-
|
2921
|
-
|
2922
|
-
|
2923
|
-
|
2924
|
-
|
2925
|
-
|
2926
|
-
|
2927
|
-
|
2928
|
-
|
2929
|
-
|
2930
|
-
|
2931
|
-
|
2932
|
-
|
2933
|
-
|
2934
|
-
|
2935
|
-
|
2936
|
-
|
2937
|
-
|
2938
|
-
|
2925
|
+
catch(ex){ alert("Cache storage quote exceeded. can't save value. err598 |" + ex.message); }
|
2926
|
+
} else {
|
2927
|
+
alert(`storageType ${storageType} not supported`);
|
2928
|
+
throw new Error(`storageType ${storageType} not supported`);
|
2929
|
+
}
|
2930
|
+
},
|
2931
|
+
helper_delete(groupName, storageType){
|
2932
|
+
const appName = puvox_library.getAppName();
|
2933
|
+
if (storageType == 'file'){
|
2934
|
+
const filepath = puvox_library.file.tempDir() + appName + '_' + groupName + '.json';
|
2935
|
+
// todo: better delete
|
2936
|
+
puvox_library.file.delete(filepath);
|
2937
|
+
return true;
|
2938
|
+
} else if (storageType === 'localStorage') {
|
2939
|
+
try{
|
2940
|
+
const storage = window.localStorage;
|
2941
|
+
storage.setItem(appName + '_' + groupName, content);
|
2942
|
+
storage.setItem(appName + '_' + groupName + '_t', (new Date()).getTime());
|
2943
|
+
return true;
|
2944
|
+
}
|
2945
|
+
catch(ex){ alert("Cache storage quote exceeded. can't save value. err598 |" + ex.message); }
|
2946
|
+
} else {
|
2947
|
+
alert(`storageType ${storageType} not supported`);
|
2948
|
+
throw new Error(`storageType ${storageType} not supported`);
|
2939
2949
|
}
|
2940
2950
|
},
|
2951
|
+
|
2952
|
+
get(groupName, defaultVal = null, storageType = 'localStorage', expireSeconds = 0){
|
2953
|
+
const content = this.helper_read(groupName, storageType, expireSeconds);
|
2954
|
+
return (content !== null && content !== '') ? content : defaultVal;
|
2955
|
+
},
|
2956
|
+
set(groupName, content, storageType = 'localStorage'){
|
2957
|
+
this.helper_write(groupName, content, storageType);
|
2958
|
+
},
|
2959
|
+
delete(groupName, storageType = 'localStorage'){
|
2960
|
+
this.helper_delete(groupName, storageType);
|
2961
|
+
},
|
2962
|
+
getChild(groupName, optName, defaultVal = null, storageType = 'localStorage', expireSeconds = 0){
|
2963
|
+
// todo: individual sub-item expiration
|
2964
|
+
const content = this.get(groupName, '{}', storageType, expireSeconds);
|
2965
|
+
const json = JSON.parse(content);
|
2966
|
+
return (optName in json) ? json[optName] : defaultVal;
|
2967
|
+
},
|
2968
|
+
setChild(groupName, optName, val, storageType = 'localStorage'){
|
2969
|
+
const content = this.get(groupName, '{}', storageType, expireSeconds);
|
2970
|
+
const json = JSON.parse(content);
|
2971
|
+
json[optName] = val;
|
2972
|
+
this.set(groupName, JSON.stringify(json), storageType);
|
2973
|
+
},
|
2974
|
+
deleteChild(groupName, optName, storageType = 'localStorage'){
|
2975
|
+
const content = this.get(groupName, '{}', storageType, expireSeconds);
|
2976
|
+
// if it's empty, no need to do anything
|
2977
|
+
if (content === '{}') return;
|
2978
|
+
const json = JSON.parse(content);
|
2979
|
+
delete json[optName];
|
2980
|
+
this.set(groupName, JSON.stringify(json), storageType);
|
2981
|
+
},
|
2982
|
+
|
2983
|
+
|
2941
2984
|
file: {
|
2942
2985
|
// ########## CACHE DIRS (server-side JS) ##########
|
2943
2986
|
customCacheDir:null,
|
@@ -3007,6 +3050,10 @@ const puvox_library =
|
|
3007
3050
|
return parent.file.write(filePath, contentFinal);
|
3008
3051
|
},
|
3009
3052
|
|
3053
|
+
|
3054
|
+
|
3055
|
+
|
3056
|
+
|
3010
3057
|
//
|
3011
3058
|
// writeFileAppendJson(filePath, jsonContent, callback){
|
3012
3059
|
// try{
|
@@ -3058,7 +3105,9 @@ const puvox_library =
|
|
3058
3105
|
}
|
3059
3106
|
return false;
|
3060
3107
|
},
|
3061
|
-
}
|
3108
|
+
},
|
3109
|
+
|
3110
|
+
|
3062
3111
|
},
|
3063
3112
|
|
3064
3113
|
// ################################################
|
@@ -3089,6 +3138,9 @@ const puvox_library =
|
|
3089
3138
|
return null;
|
3090
3139
|
}
|
3091
3140
|
},
|
3141
|
+
delete(filePath){
|
3142
|
+
return (this.unlink(filePath));
|
3143
|
+
},
|
3092
3144
|
unlink(filePath){
|
3093
3145
|
return (this.fs().unlinkSync(filePath));
|
3094
3146
|
},
|
@@ -3121,32 +3173,6 @@ const puvox_library =
|
|
3121
3173
|
return filesList;
|
3122
3174
|
},
|
3123
3175
|
},
|
3124
|
-
options: {
|
3125
|
-
fileLocation(suffix = '') {
|
3126
|
-
return puvox_library.file.tempDir() + puvox_library.getAppName() + '_' + suffix + '.json';
|
3127
|
-
},
|
3128
|
-
get(groupName, optName, defaultVal = null){
|
3129
|
-
const fileName = this.fileLocation(groupName);
|
3130
|
-
const content = puvox_library.file.read(fileName, '{}');
|
3131
|
-
const json = JSON.parse(content);
|
3132
|
-
return (optName in json) ? json[optName] : defaultVal;
|
3133
|
-
},
|
3134
|
-
set(groupName, optName, val){
|
3135
|
-
const fileName = this.fileLocation(groupName);
|
3136
|
-
const content = puvox_library.file.read(fileName, '{}');
|
3137
|
-
const json = JSON.parse(content);
|
3138
|
-
json[optName] = val;
|
3139
|
-
puvox_library.file.write(fileName, JSON.stringify(json));
|
3140
|
-
}
|
3141
|
-
},
|
3142
|
-
|
3143
|
-
|
3144
|
-
|
3145
|
-
|
3146
|
-
|
3147
|
-
|
3148
|
-
|
3149
|
-
|
3150
3176
|
|
3151
3177
|
|
3152
3178
|
|
package/package.json
CHANGED
File without changes
|