puvox-library 1.0.26 → 1.0.28
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 +61 -23
- package/package.json +1 -1
package/library_standard.js
CHANGED
@@ -229,7 +229,7 @@ const puvox_library =
|
|
229
229
|
);
|
230
230
|
},
|
231
231
|
|
232
|
-
move_to_top_in_parent
|
232
|
+
move_to_top_in_parent(el_tag)
|
233
233
|
{
|
234
234
|
$(el_tag).each(function() {
|
235
235
|
$(this).parent().prepend(this);
|
@@ -665,6 +665,29 @@ const puvox_library =
|
|
665
665
|
);
|
666
666
|
},
|
667
667
|
|
668
|
+
MakeIframeFullHeight(iframeElement, cycling, overwrite_margin){
|
669
|
+
cycling= cycling || false;
|
670
|
+
overwrite_margin= overwrite_margin || false;
|
671
|
+
iframeElement.style.width = "100%";
|
672
|
+
var ifrD = iframeElement.contentDocument || iframeElement.contentWindow.document;
|
673
|
+
var mHeight = parseInt( window.getComputedStyle( ifrD.documentElement).height ); // Math.max( ifrD.body.scrollHeight, .. offsetHeight, ....clientHeight,
|
674
|
+
var margins = ifrD.body.style.margin + ifrD.body.style.padding + ifrD.documentElement.style.margin + ifrD.documentElement.style.padding;
|
675
|
+
if(margins=="") { margins=0; if(overwrite_margin) { ifrD.body.style.margin="0px"; } }
|
676
|
+
(function(){
|
677
|
+
var interval = setInterval(function(){
|
678
|
+
if(ifrD.readyState == 'complete' ){
|
679
|
+
setTimeout( function(){
|
680
|
+
if(!cycling) { setTimeout( function(){ clearInterval(interval);}, 500); }
|
681
|
+
iframeElement.style.height = (parseInt(window.getComputedStyle( ifrD.documentElement).height) + parseInt(margins)+1) +"px";
|
682
|
+
}, 200 );
|
683
|
+
}
|
684
|
+
},200)
|
685
|
+
})();
|
686
|
+
//var funcname= arguments.callee.name;
|
687
|
+
//window.setTimeout( function(){ console.log(funcname); console.log(cycling); window[funcname](iframeElement, cycling); }, 500 );
|
688
|
+
},
|
689
|
+
|
690
|
+
getYtIdFromURL(URLL){let r=URLL.match(/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?]*).*/); return r[1];},
|
668
691
|
|
669
692
|
//state url change
|
670
693
|
//function processAjaxData(response, urlPath){
|
@@ -804,7 +827,7 @@ const puvox_library =
|
|
804
827
|
},
|
805
828
|
|
806
829
|
|
807
|
-
|
830
|
+
datetime : {
|
808
831
|
// 0940 type time-ints
|
809
832
|
isBetweenHMS(target, start, end, equality) { }, // datetime, int/datetime, int/datetime, bool
|
810
833
|
equalDays(d1,d2) {
|
@@ -2406,7 +2429,7 @@ const puvox_library =
|
|
2406
2429
|
};
|
2407
2430
|
},
|
2408
2431
|
|
2409
|
-
compare(a,
|
2432
|
+
compare(a, operator, b) {
|
2410
2433
|
if(operator === '==') return a == b;
|
2411
2434
|
else if (operator === '===') return a === b;
|
2412
2435
|
else if (operator === '!=') return a != b;
|
@@ -2417,7 +2440,7 @@ const puvox_library =
|
|
2417
2440
|
else if (operator === '<=') return a <= b;
|
2418
2441
|
else throw "Unknown operator";
|
2419
2442
|
},
|
2420
|
-
calculate(a,
|
2443
|
+
calculate(a, operator, b) {
|
2421
2444
|
if(operator === '+') return a + b;
|
2422
2445
|
else if (operator === '-') return a - b;
|
2423
2446
|
else if (operator === '*') return a * b;
|
@@ -2711,17 +2734,24 @@ const puvox_library =
|
|
2711
2734
|
},
|
2712
2735
|
// if(setHashInAddress) { window.location.hash = id_or_Name; }
|
2713
2736
|
|
2714
|
-
|
2715
|
-
|
2737
|
+
unTrailingSlash(str){
|
2738
|
+
while (str.endsWith('/') || str.endsWith('\\')) {
|
2739
|
+
str = str.slice(0, -1);
|
2740
|
+
}
|
2741
|
+
return str;
|
2742
|
+
},
|
2743
|
+
trailingSlash(str){
|
2744
|
+
return this.unTrailingSlash(str) + '/';
|
2745
|
+
},
|
2716
2746
|
|
2717
2747
|
// ######## CACHE ITEMS (client-side JS) ########
|
2718
|
-
|
2719
|
-
setAppName (name){ this.
|
2748
|
+
privateAppName__ : null, //override with anything you want
|
2749
|
+
setAppName (name){ this.privateAppName__ = name; },
|
2720
2750
|
getAppName(){
|
2721
|
-
if (!this.
|
2751
|
+
if (!this.privateAppName__){
|
2722
2752
|
throw new Error ('Before you start using caching functions, please at first define your appplication\'s name(identifier) at first with .setAppName("whatever_my_app_name"), so it will get its own cache-storage');
|
2723
2753
|
}
|
2724
|
-
return this.
|
2754
|
+
return this.privateAppName__;
|
2725
2755
|
},
|
2726
2756
|
|
2727
2757
|
cache: {
|
@@ -2783,18 +2813,28 @@ const puvox_library =
|
|
2783
2813
|
file: {
|
2784
2814
|
// ########## CACHE DIRS (server-side JS) ##########
|
2785
2815
|
customCacheDir:null,
|
2786
|
-
|
2816
|
+
get_dir(){
|
2787
2817
|
if (!this.customCacheDir){
|
2788
|
-
this.customCacheDir = puvox_library.file.
|
2818
|
+
this.customCacheDir = puvox_library.file.tempDir();
|
2789
2819
|
}
|
2790
|
-
let finaldir = this.customCacheDir + '_cache_' + puvox_library.getAppName()
|
2820
|
+
let finaldir = puvox_library.trailingSlash(this.customCacheDir + '_cache_' + puvox_library.getAppName());
|
2791
2821
|
return finaldir;
|
2792
2822
|
},
|
2823
|
+
set_dir(dir, auto_clear_seconds=null){
|
2824
|
+
if(dir) this.customCacheDir = dir;
|
2825
|
+
const res = puvox_library.file.createDirectory(this.customCacheDir);
|
2826
|
+
if( !is_null(auto_clear_seconds))
|
2827
|
+
{
|
2828
|
+
throw new Error("Not implemented yet! 345346");
|
2829
|
+
//$this->clearCacheDir($auto_clear_seconds);
|
2830
|
+
}
|
2831
|
+
return res;
|
2832
|
+
},
|
2793
2833
|
filePath(uniqFileName){
|
2794
2834
|
const parent = puvox_library;
|
2795
2835
|
uniqFileName = parent.isString(uniqFileName) || parent.isNumeric(uniqFileName) ? uniqFileName : JSON.stringify(uniqFileName);
|
2796
2836
|
uniqFileName = parent.sanitize_key_dashed(parent.getCharsFromStart(uniqFileName, 15)) + "_"+ parent.md5(uniqFileName);
|
2797
|
-
filePath= this.
|
2837
|
+
filePath= this.get_dir() + uniqFileName + "_tmp"; //"/".
|
2798
2838
|
return filePath;
|
2799
2839
|
},
|
2800
2840
|
//
|
@@ -2802,8 +2842,6 @@ const puvox_library =
|
|
2802
2842
|
{
|
2803
2843
|
const parent = puvox_library;
|
2804
2844
|
let filePath = this.filePath(uniqFileName);
|
2805
|
-
if ( filePath.length < 3) return "too tiny filename";
|
2806
|
-
|
2807
2845
|
if ( parent.file.exists(filePath) ){
|
2808
2846
|
if ( parent.file.mtime(filePath) + expire_seconds *1000 < (new Date()).getTime() ){
|
2809
2847
|
parent.file.unlink(filePath);
|
@@ -2871,14 +2909,14 @@ const puvox_library =
|
|
2871
2909
|
},
|
2872
2910
|
getIds(containerSlug) {
|
2873
2911
|
if (! (containerSlug in this.tempIds)) {
|
2874
|
-
const content = puvox_library.file.read(this.
|
2912
|
+
const content = puvox_library.file.read(this.get_dir() + this.containerDefaultPrefix + containerSlug, '{}');
|
2875
2913
|
this.tempIds[containerSlug] = JSON.parse(content);
|
2876
2914
|
}
|
2877
2915
|
return this.tempIds[containerSlug];
|
2878
2916
|
},
|
2879
2917
|
setIds(containerSlug, idsDict) {
|
2880
2918
|
this.tempIds[containerSlug] = idsDict;
|
2881
|
-
return puvox_library.file.write(this.
|
2919
|
+
return puvox_library.file.write(this.get_dir() + this.containerDefaultPrefix + containerSlug, JSON.stringify(this.tempIds[containerSlug]));
|
2882
2920
|
},
|
2883
2921
|
addId(containerSlug, id){
|
2884
2922
|
const ids = this.getIds(containerSlug);
|
@@ -2907,12 +2945,11 @@ const puvox_library =
|
|
2907
2945
|
// }
|
2908
2946
|
// },
|
2909
2947
|
file: {
|
2910
|
-
parent() {return puvox_library;},
|
2911
2948
|
fs() {return require('fs');}, //puvox_library.modules('fs')
|
2912
2949
|
os() {return require('os');},
|
2913
2950
|
path() {return require('path');},
|
2914
2951
|
//
|
2915
|
-
|
2952
|
+
tempDir(){ return puvox_library.trailingSlash(this.os().tmpdir()); },
|
2916
2953
|
|
2917
2954
|
exists(filePath){
|
2918
2955
|
return this.fs().existsSync(filePath);
|
@@ -2927,10 +2964,11 @@ const puvox_library =
|
|
2927
2964
|
unlink(filePath){
|
2928
2965
|
return (this.fs().unlinkSync(filePath));
|
2929
2966
|
},
|
2930
|
-
createDirectory(dirPath
|
2931
|
-
if (!this.exists(dirPath)
|
2932
|
-
this.fs().mkdirSync(dirPath, { recursive: true });
|
2967
|
+
createDirectory(dirPath){
|
2968
|
+
if (!this.exists(dirPath)){
|
2969
|
+
return this.fs().mkdirSync(dirPath, { recursive: true });
|
2933
2970
|
}
|
2971
|
+
return true;
|
2934
2972
|
},
|
2935
2973
|
read(filePath, defaultContent = ''){
|
2936
2974
|
if (!this.exists(filePath)){
|