From 7cf745c40d1834aa55053159ec2b07faecc0dfe9 Mon Sep 17 00:00:00 2001 From: sbosse Date: Mon, 21 Jul 2025 23:20:41 +0200 Subject: [PATCH] Mon 21 Jul 22:43:21 CEST 2025 --- js/ui/webui/utils.js | 730 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 730 insertions(+) create mode 100644 js/ui/webui/utils.js diff --git a/js/ui/webui/utils.js b/js/ui/webui/utils.js new file mode 100644 index 0000000..fedd13e --- /dev/null +++ b/js/ui/webui/utils.js @@ -0,0 +1,730 @@ +var _ = undefined + +function empty(v) { + if (v == undefined) return true; + if (isString(v)) return v==''; + if (isArray(v)) return v.length==0; + if (isObject(v)) return Object.keys(v).length==0; + return false +} + +function isArray(o) { + if (o==_ || o ==null) return false; + else return typeof o == "array" || (typeof o == "object" && o.constructor === Array); +} +function isArrayArray(o) { + if (o==_ || o ==null) return false; + else return Utils.isArray(o) && + Utils.isArray(o[0]); + } +function isArrayArrayArray(o) { + if (o==_ || o ==null) return false; + else return Utils.isArray(o) && + Utils.isArray(o[0]) && + Utils.isArray(o[0][0]); + } +function isMatrix(o) { + if (o==_ || o ==null) return false; + else return isArray(o) && + isArray(o[0]); +} +function isBoolean (o) { + return typeof o == "boolean" +} +function isBuffer (o) { + if (o==_ || o ==null) return false; + else return o instanceof Buffer; +} +function isEmpty(o) { + for(var prop in o) { + if (o[prop]!=undefined) return false; + } + return true; +} +function isFunction(o) { + return typeof o == "function"; +} +function isObj(o) { + return typeof o == "object"; +} +function isObject(o) { + return typeof o == "object"; +} +function isRegex(o) { + return o instanceof RegExp; +} +function isString(o) { + return typeof o == "string" || (typeof o == "object" && o.constructor === String); +} +function isNumber(o) { + return typeof o == "number" || (typeof o == "object" && o.constructor === Number); +} + +function isTypedArray(o) { + return Utils.isObject(o) && o.buffer instanceof ArrayBuffer +} +function isVector(o,noarray) { + if (o==_ || o ==null) return false; + else return (!noarray && Utils.isArray(o)) || + (Math.VectorTA && Math.VectorTA.isVector(o)) || + (Math.Vector && Math.Vector.isVector(o)) + ; +} + + +function flatten(array) { + var res=[]; + var len=array.length; + var i; + for(i=0;i0) { + PostIt(null,Notes[i]); + } + } + } + if (typeof State != 'undefined' && o.this) State.this=o.this; + } + try { + if (from) parse(from); + else loadFile(parse); + } catch (e) { console.log(e) } +} + +function saveData(to) { + var base = appConfig.file||document.URL.match(/([a-zA-Z_0-9\-]+)\.html(#.+)?(\?.+)?$/)[1]; + var i,o = {editors:{}, styles:{}, textarea:{},input:{},tables:{}, points:{}},el; + var els = document.getElementsByTagName('textarea'); + // generic text input blocks (via textarea) + for(i=0;i