var EventEmitter = require("events").EventEmitter; var opath = require("opath"); var async = require("async"); var tool = require("tools2")(); var getthezip = require("libs/getthezip"); var unpackzip = require("libs/unpackzip"); var generatezip = require("libs/generatezip"); var random = require("sharedkey-thing").randoma(0xbadebabe)("#CHANGE BEFORE CHRISTMAS#"); var _ = require("lodash"); var templates = require("./templates"); var ignores = "_created _data _events _extends _hasa _inherits _isa _maxListeners _metas _references _relations _rootname addListener children data data2 domain emit emita emitas eventNames export export2 exportFlatSync exportSerialised exportSync exporta extends getMaxListeners getStuff getStuff2 getStuff3 inherits innerExport isa listenerCount listeners metas metas2 metas3 name on once parents path pickdeep pingup prependListener prependOnceListener rawListeners relatesAsToWith removeAllListeners removeListener setMaxListeners test unextends uninherits unisa withAll withAllSync" .split(" "); function template_helpers(self) { return { "toTextArea": function(str) { return '' }, "toWrap": function(str, tag, attr) { return '<' + tag + ' ' + attr + '>' + str + ''; }, toLowerCase: function(str) { return str.toLowerCase(); }, toUpperCase: function(str) { return str.toUpperCase(); }, "pagecontent": function(obj) { console.log("pagecontent", obj, arguments); return self.template(obj._data.content, obj); }, "siblings": function(obj) { return [_.keys(obj.parents).shift()].map(function(parentpath) { var ares = _.map(obj.parents[parentpath] ? obj.parents[parentpath].children : [], function(a) { return a(); }) ares.sort(sorter(function(a) { return a._metas.menu_order || 100 }, -1)); var ss = _.map(ares, function(child, name) { return child.path }); if (ss.length > 12) { var cindex = ss.indexOf(obj.path); cindex = cindex < 6 ? 6 : cindex; var spp = _.map(ares, renderlin(obj)) var sasa = [].concat(spp.slice(cindex - 6, cindex + 7)) } else { var sasa = _.map(ares, renderlin(obj)) } return sasa.join("\n") }).join("\n") }, "parents": function(obj, ss_, sss_) { if (typeof(ss_) !== "undefined" && typeof(sss_) !== "undefined") { return gpath(obj, []).slice(parseInt(ss_), parseInt(sss_)).map(function(p, i) { return '' + self.oget(p + "/._data.title", p) + ''; }).join("\n"); } else { return gpath(obj, []).slice(1).map(function(p, i) { return '' + self.oget(p + "/._data.title", p) + ''; }).join("\n"); } }, "parent": function(obj) { return _.map(obj.parents, function(par, nam) { self.rendertemplate(par) }).join("\n"); }, "children2": function(obj) { var ret = []; _.map(obj.children, function(child) { var cho = typeof(child) === "function" ? child() : child; ret.push(self.rendertemplate(cho)) }) return ret.join("\n") }, "children": function(obj) { var ret = []; _.map(obj.children, function(child) { var cho = typeof(child) === "function" ? child() : child; ret.push(renderlin(cho)(cho, cho.name)) }) return ret.join("\n"); }, "relations": function(obj) { var stash = []; _.map(obj._relations, function(rels, relname) { var relators = _.keys(rels); var sss = relators.slice(0, 25).map(function(relator) { return '
  • ' + relator + '
  • ' }).join("\n");; stash.push([relname + "(" + relators.length + ")", sss]); }) var ss = ('
    ' + stash.map(function(a) { return '
    ' + (a[0] === false ? "" : a[0] + "") + '
    ' + a[1] + '
    ' }).join("\n") + '
    '); return ss }, "grandchildren": function(obj) { var ret = []; _.map(obj.children, function(child) { var cho = typeof(child) === "function" ? child() : child; ret = [].concat.apply(ret, _.map(cho.children, renderlin(cho))) }) return ret }, "created": function(obj) { return obj._created.toJSON(); }, "_isa": function(obj) { return _.map(obj._isa, renderlin(obj)).join("\n") }, "_isa2": function(obj) { return _.map(obj._isa, function(o, n) { return self.rendertemplate(o) }).join("\n") }, "_isa3": function(obj, a, b) { console.log(";;;;;;;;;;;", a, b); return _.map(obj._isa, function(o, n) { return self.rendertemplate(o) }).slice(parseInt(a), parseInt(b)).join("\n") }, "_hasa": function(obj) { return _.map(obj._hasa, renderlin(obj)).join("\n") }, "findall": function(obj, withprop, target_) { var target = target_ || "content"; var aa = [] _.keys(self.oo).filter(aa => ["trash", "system", ""].indexOf(aa) === -1 && typeof(self.oo[aa]) === "function").map(function(key) { aa = [].concat.apply(aa, allchildren(self.oo[key]()).filter(function(a) { return a._isdirty })) }) return aa.map(function(a) { return renderlin2(obj, { target: target })(a, a.name) }).join("\n"); }, "jsondata": function(obj) { return JSON.stringify(obj._data, true, 2).toHtmlEntities(); } } } function gpath(cc, p) { if (cc.parents) { var k = _.keys(cc.parents).shift(); if (k) { return gpath(cc.parents[k], p.concat(cc.path)) } else { return p.concat(cc.path) } } } function renderlin2(obj, opt) { return function(child, name) { var pp = typeof(child) === "function" ? child() : child; return '' + (pp._data.title ? pp._data.title : pp.name) + '' } } function renderlin(obj) { return function(child, name) { var pp = typeof(child) === "function" ? child() : child; return '' + (pp._data.title ? pp._data.title : pp.name) + '' } } function Asystem(oo) { this.oo = oo; this.name = "noname" this._logs = []; this._linked = {}; this._templatefunction = templates(this, template_helpers(this)); } Asystem.prototype.__proto__ = EventEmitter.prototype; Asystem.prototype.slugger = function(str) { var ret = ("" + str).replace(/\/+/g, '/').replace(/[^\x20-\x7E]/g, '') // ret=decodeURIComponent(ret); ret = ret.replace(/[\<\>]/g, '') if (ret.indexOf("/") == ret.length - 1) { ret = ret.substring(0, ret.length - 1); } return ret } Asystem.prototype.t_content = function(path) { return this.oget(path)._data.content } Asystem.prototype.odelete = function(path) { var self = this; self.omove(path, "trash/" + path) if (self.oo[path]) { _.map(self.oo[path]().children, function(child, name) { self.odelete(child().path) }) delete self.oo[path] } self.emit("deleted", path) } Asystem.prototype.ozap = function(path) { var t = path.split("/"); var ta = t.pop(); delete this.oget(t.join("/")).children[ta]; this.emit("deleted", path) } Asystem.prototype.omove = function(path, topath) { var self = this; var newa = self.oget(topath) var olda = self.oget(path); var ss = olda.exportSync(); if (!ss) { return false; } ss.name = topath.split("/").pop(); ss.path = topath; var np = topath.split("/") np.pop(); _.map(olda._relations, function(rels, relsname) { _.map(rels, function(rel, name) { delete rel.ref._relations[rel.context.out] }) delete olda._relations[relsname] }) _.map(olda._isa, function(isa, name) { delete isa._hasa[name] delete olda._isa[name] }) _.map(olda._hasa, function(hasa, name) { delete hasa._isa[olda.path] delete olda._hasa[name] }) _.map(olda._inherits, function(inheri, name) { delete inheri._extends[olda.path] delete olda._inherits[name] }) _.map(olda._extends, function(extendi, name) { delete extendi._inherits[olda.path] delete olda._extends[name] }) _.map(olda.parents, function(par, nam) { delete par.children[olda.name]; }) _.keys(olda.children, function(key) { delete olda.children[key]; }) delete olda; self.rev_conv2(ss, np.join("/")); self.emit("moved", path, topath) } Asystem.prototype.oclone = function(path, topath) { var self = this; var newa = self.oget(topath) var olda = self.oget(path); var ss = olda.exportSync(); ss.name = topath.split("/").pop(); ss.path = topath; var np = topath.split("/") np.pop(); self.rev_conv2(ss, np.join("/")); self.emit("cloned", path, topath) } Asystem.prototype.oset = function(path_, data) { var self = this; var path = self.slugger(path_); var ar = path.split("/"); var first = ar.shift(); var prop, obj; if (typeof(self.oo[first]) === "undefined") { self.oo[first] = self.oo(first); self.oo[first]()._isdirty = true; self.emit("rootcreated", self.oo[first]()) } if (ar.length > 0 && ar[ar.length - 1].indexOf(".") === 0) { prop = ar.pop().substring(1); } path = ar.join("/") if (path !== "") { var exists = self.ofind(path_); if (exists.remainder !== "") { obj = self.oo[first](path)(); self.emit("created1", obj) } else { obj = self.oo[first](path)(); } } else { obj = self.oo[first]() } if (prop) { obj._isdirty = true; opath.set(obj, prop, data); //return obj[prop] || getpath(obj, prop) self.emit("changed", obj.path + "/" + prop, data) } return obj; } Asystem.prototype.ogetsilent = function(path_, alternative) { var self = this; var path = self.slugger(path_); var ar = path.split("/"); var first = ar.shift(); var prop, obj; if (typeof(self.oo[first]) === "undefined") { self.oo[first] = self.oo(first); } if (ar.length > 0 && ar[ar.length - 1].indexOf(".") === 0) { prop = ar.pop().substring(1); } path = ar.join("/") if (path !== "") { var exists = self.ofind(path_); if (exists.remainder !== "") { obj = self.oo[first](path)(); } else { obj = self.oo[first](path)(); } } else { obj = self.oo[first]() } if (prop) { return obj[prop] || opath.get(obj, prop) || alternative; } return obj; } Asystem.prototype.oget = function(path_, alternative) { var self = this; var path = self.slugger(path_); var ar = path.split("/"); var first = ar.shift(); var prop, obj; if (typeof(self.oo[first]) === "undefined") { self.oo[first] = self.oo(first); self.oo[first]()._isdirty = true; self.emit("rootcreated", self.oo(first)()) } if (ar.length > 0 && ar[ar.length - 1].indexOf(".") === 0) { prop = ar.pop().substring(1); } path = ar.join("/") if (path !== "") { var exists = self.ofind(path_); if (exists.remainder !== "" && exists.remainder.indexOf("/") > -1) { obj = self.oo[first](path)(); obj._isdirty = true; self.emit("created2", obj) } else { obj = self.oo[first](path)(); } } else { obj = self.oo[first]() } if (prop) { return obj[prop] || opath.get(obj, prop) || alternative; } return obj; } Asystem.prototype.getele = function(action) { var self = this; action = self.slugger(action); var a = action.split("/"); var roo = a.shift(); var ffu; if (a[a.length - 1].indexOf(".") > -1) { //function call; ffu = a.pop().split(".").pop(); } else { //straight } var name = a.join("/"); var eles = self.oo[roo](name)(); if (ffu && eles[ffu]) { return { ele: eles, func: eles[ffu] }; } return { ele: eles } } Asystem.prototype.ofind = function(path) { /* returns {found: "spath"|false , remainder: "rest"|"" , obj: obj}*/ var self = this; path = self.slugger(path); var ar = path.split("/"); var first = ar.shift(); if (typeof(self.oo[first]) === "undefined") { return { found: false } } else { var pa = self.oo[first]() var ch = ""; var rest = []; while (ar.length) { ch = ar.shift(); if (pa.children[ch]) { pa = pa.children[ch](); } else { rest.push(ch) } } return { found: pa.path, /* is false if not found*/ remainder: rest.join("/"), /* is not "" if not found rest of path*/ obj: pa /* the found object*/ } } } Asystem.prototype.rev_conv = function(obj, path) { if (typeof(obj) !== "object" || obj == null) { return false; } var self = this; var zzz = self.ogetsilent(obj.path); zzz.data(obj.data) zzz._created = new Date(obj.created); zzz.metas(obj.meta); if (_.size(obj.rel) > 0) { _.map(obj.rel, function(rels, name) { _.map(rels, function(dats, relator) { if (name === dats.in) {} else { // console.log("RR: ", obj.path, relator, name, dats.in, dats.out); zzz.relatesAsToWith(dats.out, self.ogetsilent(relator), dats.in, dats) } }) }) } if (obj.inherits && obj.inherits.length) { obj.inherits.map(function(alp) { zzz.inherits(self.ogetsilent(alp)) }) } if (obj.extends && obj.extends.length) { obj.extends.map(function(alp) { zzz.extends(self.ogetsilent(alp)) }) } if (obj.isa && obj.isa.length) { obj.isa.map(function(alp) { zzz.isa(self.ogetsilent(alp)) }) } if (obj.hasa && obj.hasa.length) { obj.hasa.map(function(alp) { self.ogetsilent(alp).isa(zzz) }) } _.map(_.omit(obj, ["getStuff3", "name", "hasa", "meta", "data", "parents", "children", "path", "_rootname", "created", "rel", "inherits", "extends", "isa", "children", "_isdirty" ]), function( val, ke) { if (typeof(val) === "string" && val.indexOf("$$$FUNCTION$$$") === 0) { if (zzz._metas && zzz._metas.protected && zzz._metas.protected[ke]) {} else { var ttt = {}; try { eval("(function(tt){ tt.func = " + val.split("$$$FUNCTION$$$").pop() + ";})(ttt)"); zzz[ke] = ttt.func; } catch (ea) { console.log("error func: ", ea) } } } else { if (typeof(val) === "object") { var r = {} _.map(val, function(v, kp) { if (typeof(v) === "string" && v.indexOf("$$$FUNCTION$$$") === 0) { var ttt = {}; try { eval("(function(tt){ tt.func = " + v.split("$$$FUNCTION$$$").pop() + ";})(ttt)"); r[kp] = ttt.func; } catch (ea) { console.log("error func: ", ea) } } else { r[kp] = v } }) zzz[ke] = r; } else { zzz[ke] = val } } }) delete obj._isdirty; if (obj.children && obj.children.length) { obj.children.map(function(child) { self.rev_conv(child) }) } } Asystem.prototype.rev_conv2 = function(obj, path) { var self = this; var zzz = self.ogetsilent(path + "/" + obj.name); zzz.data(obj.data) zzz._created = new Date(obj.created); zzz.metas(obj.meta); if (_.size(obj.rel) > 0) { _.map(obj.rel, function(rels, name) { _.map(rels, function(dats, relator) { if (name === dats.in) {} else { // console.log("RR: ", obj.path, relator, name, dats.in, dats.out); zzz.relatesAsToWith(dats.out, self.ogetsilent(relator), dats.in, dats) } }) }) } if (obj.inherits && obj.inherits.length) { obj.inherits.map(function(alp) { zzz.inherits(self.ogetsilent(alp)) }) } if (obj.extends && obj.extends.length) { obj.extends.map(function(alp) { zzz.extends(self.ogetsilent(alp)) }) } if (obj.isa && obj.isa.length) { obj.isa.map(function(alp) { zzz.isa(self.ogetsilent(alp)) }) } if (obj.hasa && obj.hasa.length) { obj.hasa.map(function(alp) { self.ogetsilent(alp).isa(zzz) }) } _.map(_.omit(obj, ["getStuff3", "name", "hasa", "meta", "data", "parents", "children", "path", "_rootname", "created", "rel", "inherits", "extends", "isa", "children", "_isdirty" ]), function( val, ke) { if (typeof(val) === "string" && val.indexOf("$$$FUNCTION$$$") === 0) { // console.log(val.split("$$$FUNCTION$$$").pop()) if (zzz._metas && zzz._metas.protected && zzz._metas.protected[ke]) {} else { var ttt = {}; try { eval("(function(tt){ tt.func = " + val.split("$$$FUNCTION$$$").pop() + ";})(ttt)"); zzz[ke] = ttt.func; } catch (ea) { console.log("error func: ", ea) } } } else { if (typeof(val) === "object") { var r = {} _.map(val, function(v, kp) { if (typeof(v) === "string" && v.indexOf("$$$FUNCTION$$$") === 0) { var ttt = {}; try { eval("(function(tt){ tt.func = " + v.split("$$$FUNCTION$$$").pop() + ";})(ttt)"); r[kp] = ttt.func; } catch (ea) { console.log("error func: ", ea) } } else { r[kp] = v } }) zzz[ke] = r; } else { zzz[ke] = val } } }) delete obj._isdirty; if (obj.children && obj.children.length) { obj.children.map(function(child) { self.rev_conv2(child, zzz.path) }) } } /*Asystem.prototype.save = function() { var self = this; return new Promise(function(resolve, reject) { $lib.exporter(self, function(err, data) { $lib.generate_thezip(self.name + "-" + $lib.getTimedName() + ".zip", $lib.arrayedToObject(data, "name"), function(err, zz) { console.log(err); resolve(zz) }) }) }) } */ Asystem.prototype.exporter = function(cb) { var self = this; var obj = self.oo; var stores = _.keys(obj).filter(function(a) { return typeof(obj[a]) === "function" }).map(function(a) { return obj[a]() }).map(function(a) { var da = a.exportSync(""); return da }); stores.unshift({ "name": "namespace.manifest", "data": { "namespace": self.name } }) var ret = {} stores.map(function(a) { ret[a.name] = a; }) cb(null, ret) } Asystem.prototype.log = function() {} Asystem.prototype.template = function() { return this._templatefunction.apply(this, arguments) } Asystem.prototype.loadInto = function(url, callback, linked) { var self = this; getthezip(url, function(res) { return res.json() }) .then(function(obj) { self.rev_conv(obj); self.restart(); }) } Asystem.prototype.loadZipLocal = function(blob, callback) { var self = this; var importer = self.importer_zip(); unpackzip(importer)(blob) .then( function() { self.emit("status", "early ready yes yes") if (self._loadqueue && self._loadqueue.length) { var ff = self._loadqueue.shift() self.ozap(importer.path); self.loadZip(ff[1], callback, ff[0]); } else { if (self.name_imported) { self.name = self.name_imported; } self.ozap(importer.path); callback(null, self); } } ).catch(console.log) } Asystem.prototype.loadZip = function(url, callback, linked) { var self = this; if (linked) { self._linked[linked] = url; } getthezip(url) .then(function(data) { self.emit("status", "got data" + data.length) var importer = self.importer_zip(); unpackzip(importer)(data) .then( function() { self.emit("status", "early ready yes yes") if (self._loadqueue && self._loadqueue.length) { var ff = self._loadqueue.shift() self.ozap(importer.path); self.loadZip(ff[1], callback, ff[0]); } else { if (self.name_imported) { self.name = self.name_imported; } self.ozap(importer.path); callback(null, self); } } ) .catch(console.log) }) .catch(console.log) } Asystem.prototype.saveZip = function() { var self = this; return new Promise(function(resolve, reject) { self.exporter(function(err, data) { var seperate_save = _.keys(data).filter(function(name) { return self._linked && self._linked[name + ".link"] }) var ddata = _.omit(data, seperate_save); seperate_save.map(function(om) { var url = self._linked[om + ".link"].split("/"); url.pop(); url.push(self.name + "-" + om + ".zip"); ddata[om + ".link"] = url.join("/"); }) generatezip(self.name + "-" + "" + ".zip", ddata, function(err, zz) { async.mapSeries(seperate_save, function(name, next) { var dda = {}; dda[name] = data[name]; generatezip(self.name + "-" + name + ".zip", dda, next) }, function(err, all) { all.push(zz); resolve(all) }) }) }) }) } Asystem.prototype.saveAsJS = function() { var self = this; return new Promise(function(resolve, reject) { self.exporterJS(function(err, data) { var tm = {} _.map(data, function(dat, name) { if (typeof(dat.data) === "object" && dat.data.length) { tm[name + ".js"] = { data: dat.data.map(function(a) { return '$E(' + JSON.stringify(a) + ');' }).join("\n") }; } else { tm[name] = { data: dat.data }; } }) generatezip(self.name + "-" + "" + ".zip", tm, function(err, zz) { resolve(zz); }) //console.log("TTTT",tm); // console.log("DDD",data); }) }) } Asystem.prototype.exporterJS = function(cb) { var self = this; var obj = self.oo; var stores = _.keys(obj).filter(function(a) { return typeof(obj[a]) === "function" }).map(function(a) { return obj[a]() }).map(function(a) { var da = a.exportFlatSync(a.name); return { name: a.name, data: da } }); stores.unshift({ "name": "namespace.manifest", "data": { "namespace": self.name } }) var ret = {} stores.map(function(a) { ret[a.name] = a; }) cb(null, ret) } Asystem.prototype.importer_zip = function() { var self = this; self.oget("system/emmm").metas("_hide", true); var emname = "system/emmm/a/" + random(0xffffff) var emmm = self.oget(emname); emmm.metas("unsaveable", true); emmm.on("file", function(filename, data) { if (filename.indexOf(".link") > -1) { emmm.emit("link", data); self._loadqueue = self._loadqueue || []; self._loadqueue.push([filename, data]) self.emit("status", "gotlink", filename); } else { self.emit("status", "gotfile", filename + " : " + typeof(data) + " : " + data.substring(0, 20)); self.oget("folders/" + filename.indexOf("/") > -1 ? filename : "folders/" + filename).data("data", data); } }) emmm.on("json", function(filename, data) { self.emit("status", "gotfile", filename); self.rev_conv(data) }) emmm.on("namespace", function(data, cont) { self.emit("status", "gotnamespace", data.namespace); self.name_imported = data.namespace; cont(); }) emmm.on("nonamespace", function(cont) { //self.name = url.split("/").pop().split(".").shift(); self.emit("status", "gotnonamespace", self.name); cont(); }) return emmm } function createnav(rk, key) { return '#' + key; } $linkstr2 = '
  • {{title}} {{size}}
  • '; function allchildpaths(obj_) { var obj = typeof(obj_) === "function" ? obj_() : obj_; return [].concat.apply([obj.path], _.map(obj.children, allchildpaths)) } function allchildren(obj_) { var obj = typeof(obj_) === "function" ? obj_() : obj_; return [].concat.apply([obj], _.map(obj.children, allchildren)) } function sorter(prop, dir) { return function(aa, bb) { var a = prop(aa); var b = prop(bb); return a > b ? dir * -1 : a < b ? dir * 1 : 0; } } Asystem.prototype.t_icon = function(obj) { var self = this; if (obj._data.iconclass) { var dd = self.oget(obj._data.iconclass)._data.data; if (!dd) { return ""; } if (dd.indexOf("data:") === 0) { return ''; } else { return '' + dd + ''; } } return " " } Asystem.prototype.t_title = function(obj) { var self = this; //contexts; return opath.get(obj._data, "title") || obj.name } Asystem.prototype.renderme = function(obj, maxlevels, atlevel, viewa) { var self = this; var ssi = _.size(obj.children); var childas = obj; if (ssi === 1) { var ooj = obj.children[_.keys(obj.children).shift()]() if (ooj._metas.skipme) { childas = ooj; } } var ssia = allchildpaths(obj).length - 1; //(ssi > 0 ? ssi : '') + if (obj._metas.pickchild) { childas = obj.children[obj._metas.pickchild](); } if (obj._metas.pickpath) { childas = self.oget(obj._metas.pickpath); } var s = ""; if (viewa && typeof(viewa) === "function") { s += "" + viewa(obj, atlevel); } if (obj._metas._hide) { return ""; } s += '
    ' s += '' + self.t_icon(obj) + self.t_title(obj) + '' + (ssia > 0 ? ssia : '') + '' if (atlevel < maxlevels) { if (ssi > 0) { var xxx = _.map(childas.children, function(cc) { return cc() }) xxx.sort(sorter(function(a) { return a._metas.menu_order || 100 }, -1)); var aa = xxx.slice(0, 25).map(function(cc) { return self.renderme(cc, maxlevels, atlevel + 1, viewa) }).join("\n") return s + '
    ' + aa + '
    ' } else { return s + ''; } } else { return s + '' } } Asystem.prototype.render = function() { var self = this; return new Promise(function(resolve, reject) { var rooten = self.oget("root"); var ss = [self.template('
    ', rooten)]; // ss.push('
    ' + self.oget("root/._data.title") + '

    ') /* var kka = _.keys(self.oo).filter(aa => ["trash", "system", "root"].indexOf(aa) === -1 && typeof(self.oo[aa]) === "function") kka.sort(function(aa, bb) { var a = self.oo[aa]()._metas.menu_order; var b = self.oo[bb]()._metas.menu_order; return a > b ? 1 : a < b ? -1 : 0 }) */ var kkas = _.filter(self.oo, function(sto) { return typeof(sto) === "function" }).map(function(sto, nam) { return sto(); }) kkas.sort(sorter(function(a) { return a._metas.menu_order || 100 }, -1)); var privates = []; var publics = []; kkas.filter(function(obj) { return obj._metas.public !== true }).map(function(obj) { privates.push(self.rendera("menulink", obj, 0, 0)); }) kkas.filter(function(obj) { return obj._metas.public === true }).map(function(obj) { publics.push(self.rendera("menulink", obj, 2, 0)); }) publics.map(function(a) { ss.push(a); }) /* kka.map(function(key) { ss.push(self.rendera("menulink", self.oo[key](), 0, 0)); }) */ ss.push('
    ') ss.push('') resolve(ss.join("\n")); }) } Asystem.prototype.render_editorlinks = function(levels) { var self = this; var kkas = _.filter(self.oo, function(sto) { return typeof(sto) === "function" }).map(function(sto, nam) { return sto(); }) kkas.sort(sorter(function(a) { return a._metas.menu_order || 100 }, -1)); return kkas.map(function(obj) { return self.renderme(obj, levels || 0, 0); }).join("\n"); } Asystem.prototype.rendermenu = function(obj, levels) { var self = this; var temps = obj.getStuff3("_data.menuobj", function(a) { return a }, "_data.menuobj") console.log("TEMenu", temps); if (temps.length > 0) { return self.renderme(self.oget(temps[0].data), levels || 0, 0); } return self.renderme(obj, levels || 0, 0); } Asystem.prototype.renderq = function(kkey) { var self = this; return new Promise(function(resolve, reject) { var rooten = self.oget("root"); var ss = [self.template('
    ', rooten)]; // ss.push('
    ' + self.oget("root/._data.title") + '

    ') if (!self.oo[kkey]) { self.oget(kkey); } ss.push(self.rendera("menulink", self.oo[kkey](), 1, 0)); ss.push('
    ') resolve(ss.join("\n")); }) } Asystem.prototype.rendera = function(template) { var args = Array.prototype.slice.apply(arguments, [1]); if (template == "view") { return "VIEW" } if (template == "menulink") { return this.renderme.apply(this, args); } if (template == "editor") { return this.renderEditorTools(args[0], "editor"); } return "NOT VIEW " + template } // Asystem.prototype.renderEditorTools = function(obj, state) { var buts = []; if (obj.path.indexOf("trash") == 0) { buts.push('') } if (state == "editor") { buts.push('') if (!(obj._metas.nochildren)) { buts.push('') } if (obj.path.indexOf("trash") == -1 && !(obj._metas.undeletable)) { buts.push('') } buts.push('') } else { buts.push('') } return '
    ' + buts.map(function(a) { return a }).join(" ") + '
    ' } tool.add_filters("editor_sections", function(arr, obj) { arr.push({ title: "Template", content: function() { return "
    x
    ' } }) return arr; }, 100, "Template") function wrap(tag, obj, content) { var args = Array.prototype.slice.apply(arguments, [2]); return '<' + tag + ' ' + _.map(obj, (val, prop) => prop + '="' + val + '"').join(" ") + '>' + args.join("\n") + '' } Asystem.prototype.renderEditor = function(obj) { var self = this; var ss = ""; //"
    x
    ' // ss += self.template(self.oget("system/editor")._data.template,obj); var self = this; var aa = [] _.keys(self.oo).filter(aa => ["trash", ""].indexOf(aa) === -1 && typeof(self.oo[aa]) === "function").map(function(key) { aa = [].concat.apply(aa, allchildren(self.oo[key]()).filter(function(a) { return a.editor_function })) }) ss += aa.map(function(a) { return wrap("div", { elepath: a.path, class: "editor_module" }, wrap("h3", {}, a.name), wrap("div", {}, a._metas.help), wrap("div", {}, a.editor_function(obj))) }).join("\n") // return aa.map( function(a){ return renderlin(a)(a,a.name) } ).join("\n"); ss += '
    ' ss += self.renderEditor2(obj); return ss } String.prototype.toHtmlEntities = function() { return this.replace(/./gm, function(s) { return "&#" + s.charCodeAt(0) + ";"; }); }; /** * Create string from HTML entities */ String.fromHtmlEntities = function(string) { return (string + "").replace(/&#\d+;/gm, function(s) { return String.fromCharCode(s.match(/\d+/gm)[0]); }) }; Asystem.prototype.uniq_relnames = function() { var self = this; var rels = {} self.allchildren().map(function(c) { _.keys(c._relations).map(function(relname) { rels[relname] = rels[relname] || 0; rels[relname] = rels[relname] + 1; }) }) return _.keys(rels).map(function(a) { return { name: a, cnt: rels[a] } }); } function mmb(t, d) { return '

    ' + t + '

    ' + d + '
    '; } Asystem.prototype.addEditorContext = function(conobj) { this.editorContexts = this.editorContexts || []; this.editorContexts.push(conobj); } Asystem.prototype.renderEditor2 = function(obj) { var self = this; var types = self.editorTypes(); var tabs_links = ''; /* var tabs_content = _.map(self.editorContexts,function(con, name){ return self.template('
    {{body}}', {body: con(), name: name, }); }).join("\n"); */ var str = ""; if (self.current_tab) {} else { self.current_tab = self.editorContexts[0].name; } str = self.editorContexts.filter((con) => con.name === self.current_tab).pop().func(obj, types); return tabs_links + '
    ' + str + '
    '; } Asystem.prototype.editorTypes = function() { var self = this; var types = { jsfuncs: function(obj, fiels) { var qq = []; _.map(_.omit(obj, ignores), function(val, prop) { if (typeof(val) === "function") { qq.push(["JS " + prop + '
  • ', "
    ' ]); } }) qq.push(["JS ", " "]); var ss = ('
    ' + qq.map(function(a) { return '
    ' + (a[0] === false ? "" : a[0] + "") + '
    ' + a[1] + '
    ' }).join("\n") + '
    '); return ss }, relations: function(obj, field) { var s = ""; var ss = [] _.map(obj._relations, function(rels, relname) { var relators = _.keys(rels); var sss = relators.slice(0, 25).map(function(relator) { return '
  • ' + relator + '
  • ' }).join("\n");; ss.push([relname + "(" + relators.length + ")", sss]); }); s += ss.map(function(a) { return '

    ' + a[0] + '

    ' + a[1] + '
    ' }).join("\n") return s; }, relationsadd: function(obj, field) { var s = ""; s += '
  • ' + '
    to:
    as:
    with:
  • '; return s; }, templatepaths: function(obj, field) { return "
    " + _.map(self.getRenderTemplate(obj), function(a) { return '
  • ' + a.name + '
  • ' }).join("\n"); }, visa: function(obj, field) { function mkaa(obja) { } setTimeout(function() { var cols = { parent: "#000000", child: "#ff00ff", extends: "#00ff00", inherits: "#ff0000", isa: "#ff9900", hasa: "#00ff99" } function lokup(tp) { return cols[tp]; } var graph = Viva.Graph.graph(); var graphics = Viva.Graph.View.svgGraphics(), nodeSize = 10; self.allchildren().filter(function(c) { return c.path.indexOf("trash/") === -1 && c.path.indexOf("folders/") === -1 && c.path.indexOf("blobs/") === -1 }).slice(0, 100).map(function(c) { graph.addNode(c.path); _.map(c.children, function(child, name) { graph.addLink(c.path, child().path, 'child') }); _.map(c._isa, function(child, name) { graph.addLink(c.path, child.path, 'isa') }); _.map(c._hasa, function(child, name) { graph.addLink(c.path, child.path, 'hasa') }); _.map(c._extends, function(child, name) { graph.addLink(c.path, child.path, 'extends') }); _.map(c._inherits, function(child, name) { graph.addLink( c.path,child.path, 'inherits') }); _.map(c._relations, function(rels, relname) { _.map(rels, function(child, name) { graph.addLink(c.path, name, relname) }) }); }) var a = obj.path //graph.addNode(a, '91bad8ceeec43ae303790f8fe238164b'); /* _.map(obj.parents, function(parent, name) { graph.addNode(name, ''); graph.addLink(name, a, 'parent') }); */ /* var ogs = gpath(obj, []); console.log("OOOOOOOOOOOO", ogs); var roo = obj.path, nexta; graph.addNode(roo, ''); while (ogs.length) { nexta = ogs.shift(); graph.addLink(roo, nexta, 'parent') roo = nexta; } roo = obj.path _.map(obj.children, function(child, name) { graph.addNode(name, ''); graph.addLink(roo, name, 'child') }); _.map(obj._isa, function(child, name) { graph.addNode(name, ''); graph.addLink(roo, name, 'isa') }); _.map(obj._hasa, function(child, name) { graph.addNode(name, ''); graph.addLink(roo, name, 'hasa') }); _.map(obj._extends, function(child, name) { graph.addNode(name, ''); graph.addLink(roo, name, 'extends') }); _.map(obj._inherits, function(child, name) { graph.addNode(name, ''); graph.addLink(name, roo, 'inherits') }); */ var idas = 1; var ida = function(){ return "ida"+(idas++) } graphics.node(function(node) { var ui = Viva.Graph.svg('g'); var circle = Viva.Graph.svg('circle') .attr('cx', 2) .attr('cy', 2) .attr('r', 2) .attr('fill', obj.path === node.id ? "#ff0000" : "#dadada"); ui.append(circle); var svgText = Viva.Graph.svg('text').attr('font-size', '12px').attr('y', '4px').text(node.id.split("/").pop()); ui.append(svgText); return ui; }).placeNode(function(nodeUI, pos) { nodeUI.attr('transform', 'translate(' + (pos.x - nodeSize / 2) + ',' + (pos.y - nodeSize / 2) + ')'); }); var createMarker = function(id) { return Viva.Graph.svg('marker') .attr('id', id) .attr('viewBox', "0 0 10 10") .attr('refX', "10") .attr('refY', "5") .attr('markerUnits', "strokeWidth") .attr('markerWidth', "10") .attr('markerHeight', "5") .attr('orient', "auto"); }, marker = createMarker('Triangle'); marker.append('path').attr('d', 'M 0 0 L 10 5 L 0 10 z'); // Marker should be defined only once in child element of root element: var defs = graphics.getSvgRoot().append('defs'); defs.append(marker); var geom = Viva.Graph.geom(); graphics.link(function(link) { // Notice the Triangle marker-end attribe: var isParent = (link.data === 'parent'); var ui = Viva.Graph.svg('g'); var p = Viva.Graph.svg('path') .attr('stroke', lokup(link.data) || "#000000") .attr('fill', 'none') .attr('marker-end', 'url(#Triangle)') .attr('id', ida() ) ui.isParent = isParent; // remember for future. ui.linka = link.data; ui.ry = 50 //- (Math.random() * 100); ui.pp = p; var svgText = Viva.Graph.svg('text').attr("dy",-4).attr("class","slabel"); var textPath = Viva.Graph.svg("textPath"); textPath.attr("href","#"+p.id).attr("startOffset","25%").text( link.data+ " >"); svgText.append(textPath) ui.tt = svgText; //// // svgText.attr('xlink', link.id); ui.append(svgText) ui.append(p); return ui; }).placeLink(function(linkUI, fromPos, toPos) { // using arc command: http://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands //var data = 'M' + fromPos.x + ',' + fromPos.y + // ' A 4,' + linkUI.ry + ',-' + linkUI.ry + ',0,1,' + toPos.x + ',' + toPos.y; var data = 'M' + fromPos.x + ',' + fromPos.y + ' C ' + (fromPos.x+50)+' '+(fromPos.y+10)+','+ (toPos.x-50) + ' ' +(toPos.y-10) + ',' +toPos.x + ' ' + toPos.y ; linkUI.pp.attr("d", data); return; // linkUI.tt.attr("y", ((fromPos.y + toPos.y) / 2) - linkUI.ry); // linkUI.tt.attr("x", ((fromPos.x + toPos.x) / 2) ); if (linkUI.isParent) { /* var ry = linkUI.isParent ? 4 : 0, // using arc command: http://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands data = 'M' + fromPos.x + ',' + fromPos.y + ' A 4,' + ry + ',-4,0,1,' + toPos.x + ',' + toPos.y; linkUI.attr("d", data); */ var data = 'M' + fromPos.x + ',' + fromPos.y + 'L' + toPos.x + ',' + toPos.y; linkUI.pp.attr("d", data); } if (linkUI.linka === 'isa') { var data = 'M' + fromPos.x + ',' + fromPos.y + 'L' + toPos.x + ',' + toPos.y; linkUI.pp.attr("d", data); } if (linkUI.linka === 'hasa') { // var data = 'M' + fromPos.x + ',' + fromPos.y + // 'L' + toPos.x + ',' + toPos.y; var ry = 4; // using arc command: http://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands var data = 'M' + fromPos.x + ',' + fromPos.y + ' A 4,' + ry + ',-4,0,1,' + toPos.x + ',' + toPos.y; linkUI.pp.attr("d", data); } if (linkUI.linka === 'inherits') { var data = 'M' + fromPos.x + ',' + fromPos.y + 'L' + toPos.x + ',' + toPos.y; linkUI.pp.attr("d", data); } if (linkUI.linka === 'extends') { var data = 'M' + fromPos.x + ',' + fromPos.y + 'L' + toPos.x + ',' + toPos.y; linkUI.pp.attr("d", data); } if (linkUI.linka === 'child') { var toNodeSize = nodeSize, fromNodeSize = nodeSize; var from = geom.intersectRect( // rectangle: fromPos.x - fromNodeSize / 2, // left fromPos.y - fromNodeSize / 2, // top fromPos.x + fromNodeSize / 2, // right fromPos.y + fromNodeSize / 2, // bottom // segment: fromPos.x, fromPos.y, toPos.x, toPos.y) || fromPos; // if no intersection found - return center of the node var to = geom.intersectRect( // rectangle: toPos.x - toNodeSize / 2, // left toPos.y - toNodeSize / 2, // top toPos.x + toNodeSize / 2, // right toPos.y + toNodeSize / 2, // bottom // segment: toPos.x, toPos.y, fromPos.x, fromPos.y) || toPos; // if no intersection found - return center of the node var data = 'M' + from.x + ',' + from.y + 'L' + to.x + ',' + to.y; linkUI.pp.attr("d", data); } }); // graph.addNode( b, 'd43e8ea63b61e7669ded5b9d3c2e980f'); // graph.addLink(a, b); /* graphics.link(function(link) { var isParent = (link.data === 'parent'), ui = Viva.Graph.svg('path') .attr('stroke', isParent ? 'red' : 'blue') .attr('fill', 'none'); ui.isParent = isParent; // remember for future. return ui; }).placeLink(function(linkUI, fromPos, toPos) { // linkUI - is the object returend from link() callback above. var ry = linkUI.isParent ? 10 : 0, // using arc command: http://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands data = 'M' + fromPos.x + ',' + fromPos.y + ' A 10,' + ry + ',-30,0,1,' + toPos.x + ',' + toPos.y; // 'Path data' (http://www.w3.org/TR/SVG/paths.html#DAttribute ) // is a common way of rendering paths in SVG: linkUI.attr("d", data); }); */ var layout = Viva.Graph.Layout.forceDirected(graph, { springLength: 80, springCoeff: 0.00001, dragCoeff: 0.001, gravity: -1.2 }); var renderer = Viva.Graph.View.renderer(graph, { graphics: graphics, container: document.getElementById('visagraf'), layout: layout }); renderer.run(); }, 200) return '
    v
    ' }, meta: function(obj, field) { return "
    ' }, data: function(obj, field) { return "
    ' }, hasas: function(obj, field) { return '
    ' + _.map(obj._hasa, function(tob, name) { return self.template( '
  • {{name}}
  • ', { tob: tob, obj: obj, name: name }); }).join("\n") + '
    ' }, isas: function(obj, field) { return '
    ' + _.map(obj._isa, function(tob, name) { return self.template( '
  • {{name}}
  • ', { tob: tob, obj: obj, name: name }); }).join("\n") + '
    ' + self.template('', { obj: obj }); }, extends: function(obj, field) { return '
    ' + _.map(obj._extends, function(tob, name) { return self.template( '
  • {{name}}
  • ', { tob: tob, obj: obj, name: name }); }).join("\n") + '
    ' + self.template('', { obj: obj }); }, inherits: function(obj, field) { return '
    ' + _.map(obj._inherits, function(tob, name) { return self.template( '
  • {{name}}
  • ', { tob: tob, obj: obj, name: name }); }).join("\n") + '
    ' + self.template('', { obj: obj }); }, children: function(obj, field) { var s = ''; s += mmb("Add child", " '); s += '
    ' + _.map(obj.children, function(a) { return a().path }).map(function(k) { return '
  • ' + k + ' ' }).join("\n") + '
  • ' return s; }, info: function(obj, field) { return "Path: " + obj.path }, upload: function(obj, field) { return ( '
    '); }, content: function(obj, field) { var content_type = "
    ' + "
    "; var s = ''; s += mmb("Title", types.propeditor(obj, { "path": "_data.title" })) if (obj._metas.type && obj._metas.type == "html") { s += mmb("Content", "
    ') } else { s += mmb("Body", "
    ') } s += mmb("Type", content_type); return s; }, template: function(obj, field) { return "' }, texteditor: function(obj, field) { var s = ""; s += '' return s }, propeditor: function(obj, field) { var s = ""; s += '' return s }, lookup: function(obj, field) { var temps = obj.getStuff3(field.path, function(a) { return a }, field.path) var current_name = "", current_data = ""; if (temps.length > 0) { current_name = temps[0].name current_data = temps[0].data; } var s = ''; //' ' var path = opath.get(obj, field.path); if (current_name !== "" && !path) { path = opath.get(self.oget(current_name), field.path); s += ' inherit ' + path + ''; s += ' from ' + ' ' + current_name + '' } else { if (!path) { s += 'no object selected' } else { s += 'Current:
  • ' + path + '
  • '; } } s += "
    "; return s; }, lookup2: function(obj, field) { var temps = obj.getStuff3(field.path, function(a) { return a }, field.path) var current_name = "", current_data = ""; if (temps.length > 0) { current_name = temps[0].name current_data = temps[0].data; } var s = ''; //' ' s += ""; var path = opath.get(obj, field.path); if (current_name !== "" && !path) { path = opath.get(self.oget(current_name), field.path); s += ' inherit ' + path + ''; s += ' from ' + ' ' + current_name + '' } else { s += ' ' + path + ''; } return s; } } return types; } Asystem.prototype.renderEditor2a = function(obj) { var self = this; var stash = []; // stash.push(["Parent", '
    ' + self.template("{{parents::}}", obj) + '
    ']); // stash.push(["Path", "']); /* stash.push(["Title", "
    ' ]); */ /* if (obj.name !== "root") { (self.oget("root")._metas.fields || []).map(function(field) { stash.push([field.title, types[field.type](obj, field)]); }) }*/ /* if (obj._metas && obj.name !== "root") { (obj._metas.fields || []).map(function(field) { stash.push([field.title, types[field.type](obj, field)]); }) }*/ function mkmod(obj, field) { var data = ""; if (types[field.type]) { data = types[field.type](obj, field) } else { data = field.data; } var s = '
    ' + field.title + '
    ' + data + '
    ' return s } function mkmodg(name, title, data) { var s = '
    ' + title + '
    ' + data + '
    ' return s } function mktab() { } var xx = [] if (obj._metas.notself) {} else { var fff = obj.getStuff("_metas.fields", function(a) { return a }, "fi"); fff.map(function(ff) { ff.data.map(function(field) { xx.push(mkmod(obj, field)); }) }) } stash.push([" ", mkmodg("info", " ", [mkmod(obj, { "type": "info", "title": "Info", "data": "Path: " + obj.path }), '
    '].join("\n"))]); /* var qq = [] qq.push(mkmod(obj, { "title": "Path", "data": "' })); qq.push(mkmod(obj, { "title": "Parents", "data": self.template("{{parents::}}", obj) })); stash.push([" ", mkmodg("content", " ", qq.join("\n"))]); */ stash.push([" ", mkmodg("content", " ", xx.join("\n"))]); var left = []; var right = []; right.push(mkmod(obj, { "type": "children", "title": "Children" })); left.push(mkmod(obj, { "type": "inherits", "title": "Inherits" })); left.push(mkmod(obj, { "type": "extends", "title": "Extends" })); stash.push([" ", '
    ' + mkmodg("x", " ", left.join("\n")) + '
    ' + mkmodg("y", " ", right.join("\n")) + '
    ']); stash.push([" ", '
    ' + mkmodg("tools", " ", [mkmod(obj, { "type": "upload", "title": "Upload" }), mkmod(obj, { "type": "clone", "title": "Clone", "data": "
    ' }), mkmod(obj, { "type": "delete", "title": "Delete", "data": '
  • ' })].join("\n")) + '
    ']); var left = []; var right = []; left.push(mkmod(obj, { "type": "isas", "title": "Is a thing" })) right.push(mkmod(obj, { "type": "hasas", "title": "Is thing to something" })) stash.push([" ", '
    ' + mkmodg("xx", " ", left.join("\n")) + '
    ' + mkmodg(",yy", " ", right.join("\n")) + '
    ']); var xx = []; xx.push(mkmod(obj, { "type": "template", "title": "Template" })) xx.push(mkmod(obj, { "type": "templatepaths", "title": "Paths" })) stash.push([" ", mkmodg("x", "Template", xx.join("\n"))]); stash.push([" ", "
    "]); /* stash.push(["Icon", "
    ' ]); */ if (obj._data.data && obj._data.data.length > 8192) { stash.push(["Data too big", obj._data.data.length + " :" + obj._data.data.substring(0, 200)]) } else { stash.push(["Data", "
    ' ]); } stash.push(["Meta", "
    ' ]); _.map(_.omit(obj, ignores), function(val, prop) { if (typeof(val) === "function") { stash.push(["JS " + prop + '
  • ', "
    ' ]); } }) stash.push(["JS ", " "]); var ss = ('
    ' + stash.map(function(a) { return '
    ' + (a[0] === false ? "" : a[0] + "") + '
    ' + a[1] + '
    ' }).join("\n") + '
    '); return ss } Asystem.prototype.renderEditor3 = function(obj) { var self = this; var stash = []; var prot = {} var meta = {} allchildren(obj).map(function(c) { var arr = opath.flatten(c._data, ""); arr.map(function(a) { prot[a[0]] = prot[a[0]] || {} prot[a[0]][a[1]] = prot[a[0]][a[1]] || 0 prot[a[0]][a[1]] += 1; }) var arr = opath.flatten(c._metas, ""); arr.map(function(a) { if (a[0].indexOf('_wp_attachment_backup_sizes') > -1) { return; } meta[a[0]] = meta[a[0]] || {} meta[a[0]][a[1]] = meta[a[0]][a[1]] || 0 meta[a[0]][a[1]] += 1; }) }); var prota = _.map(prot, function(vala, nama) { return nama + " : " + _.size(vala) }); var metas = _.map(meta, function(vala, nama) { return nama + " : " + _.size(vala) }); stash.push(["Data Properties", '
    ' + JSON.stringify(prota, true, 2) + '
    ']) stash.push(["Meta Properties", '
    ' + JSON.stringify(metas, true, 2) + '
    ']) var ss = ('
    ' + stash.map(function(a) { return '
    ' + (a[0] === false ? "" : a[0] + "") + '
    ' + a[1] + '
    ' }).join("\n") + '
    '); return ss } Asystem.prototype.getRenderTemplate = function(obj) { var self = this; var stash = []; var templates = [] var temps = obj.getStuff3("_data.template", function(a) { return a }, "_data.template") var myself; var x = {}; temps.map(function(a) { x[a.name] = a }); temps = _.map(x, function(a) { return a }); return temps } Asystem.prototype.rendertemplate2 = function(obj) { var self = this; var stash = []; var templates = [] var temps = obj.getStuff3("_data.template", function(a) { return a }, "_data.template") var myself; var x = {}; temps.map(function(a) { x[a.name] = a }); temps = _.map(x, function(a) { return a }); var ss = '
    ' + self.template(obj._data.template, obj) + '
    ' return ss; } Asystem.prototype.rendertemplate = function(obj) { var self = this; var stash = []; var templates = [] var temps = obj.getStuff3("_data.template", function(a) { return a }, "_data.template") var myself; var x = {}; temps.map(function(a) { x[a.name] = a }); temps = _.map(x, function(a) { return a }); if (obj._data.template && obj._data.template.indexOf("{{output}}") > -1) { myself = temps.shift(); } var outer = temps.filter(function(a) { return a.data.indexOf("{{output}}") > -1 }) var otemp = "{{output}}" var outera = ""; if (outer.length) { outera = outer[0]; otemp = outer[0].data; } var output = temps.filter(function(a) { return a.data.indexOf("{{output}}") === -1 && a.name.indexOf("menu") === -1 && a.name.indexOf("header") === -1 && a.from.indexOf("isa_") === -1 }).map(function(tmp) { return '
    ' + self.template(tmp.data, obj) + '
    '; }).join("\n") var menus = temps.filter(function(a) { return a.name.indexOf("menu") > -1 }).slice(0, 1).map(function(tmp) { return '
    ' + self.template(tmp.data, obj) + '
    '; }).join("\n") var headers = temps.filter(function(a) { return a.name.indexOf("header") > -1 }).slice(0, 1).map(function(tmp) { return '
    ' + self.template(tmp.data, obj) + '
    '; }).join("\n") /* var isas = temps.filter(function(a) { return a.from.indexOf("isa_") > -1 }).map(function(tmp) { console.log("ISA,",tmp); if(tmp.inas.length>2){ var tma=tmp.inas.pop(); tma=tmp.inas.pop(); return '
    IIS ' + self.template(tmp.data, self.oget(tma)) + '
    '; }else{ return '
    IIS ' + self.template(tmp.data, self.oget(tmp.name)) + '
    '; } }).join("\n") */ if (myself) { var ai = Object.assign({ "output": output, "menu": menus, "header": headers, "selfie": JSON.stringify(temps, true, 2) }, obj); var ss = '
    ' + self.template(myself.data, ai) + '
    ' } else { var ai = Object.assign({ "output": output, "menu": menus, "header": headers, "selfie": JSON.stringify(temps, true, 2) }, obj); var ss = '
    ' + self.template(otemp, ai) + '
    ' } return ss } Asystem.prototype.allchildren = function(ronly) { var self = this; var arr = []; if (ronly) { return [].concat.apply(arr, allchildren(self.oo[ronly])) } _.keys(self.oo).filter((k) => typeof(self.oo[k]) === "function").map(function(key) { arr = [].concat.apply(arr, allchildren(self.oo[key])) }) return arr; } Asystem.prototype.allchildpaths = function(ronly) { var self = this; var arr = []; _.keys(self.oo).filter((k) => typeof(self.oo[k]) === "function").map(function(key) { ronly ? (ronly === key ? arr = [].concat.apply(arr, allchildpaths(self.oo[key])) : null) : arr = [].concat.apply(arr, allchildpaths(self.oo[key])) }) return arr; } module.exports = Asystem;