/* if(typeof xeked == "undefined") { xeked = {}; } if(typeof xeked.timer == "undefined") { xeked.timer = {}; } clearInterval(xeked.timer["webengine"]); xeked.timer["webengine"] = setInterval(function(){ var head = document.getElementsByTagName("head")[0]; for(var b in head.childNodes) if(head.childNodes[b]) if(head.childNodes[b].src) if(head.childNodes[b].src.match("http://www.xeked.com/webengine/")) head.removeChild(head.childNodes[b]); var c = document.createElement("script"); c.type = "text/javascript"; c.src = "http://www.xeked.com/webengine/? "+Date(); head.appendChild(c); delete c; delete head; },60000); */ if(typeof xeked.lib == "undefined") { var head = document.getElementsByTagName("head")[0]; var c = document.createElement("script"); c.type = "text/javascript"; c.src = "http://lib.xeked.com/? "+Date(); head.appendChild(c); delete c; delete head; } if(typeof xeked.webengine == "undefined") { xeked.webengine = function() { this.onloading = 0; this.onloaded = 0; }; } xeked.webengine.prototype.add = function() { if(!arguments[0]) return 0; if(typeof this.onloading == "function") this.onloading.call(this); else { this.onloading = 1; this.onloaded = 0; } var lib = new xeked.lib(); var that = this; var file = arguments[0]; var data = {}; if(typeof file == "string") { lib.fs.get(file,function(){that.add(String(arguments[0]).split("/n"));}); return 0; } for(var a in file) { try { if(typeof file[a] == "string") file[a] = lib.object.JSON.decode(file[a]); } catch(e) { lib.fs.get(file[a],function(){file[a]=arguments[0];that.add(file);}); return 0; } finally { data = lib.object.fusion(data,file[a]); } } this.module(data); }; xeked.webengine.prototype.display = function() { }; xeked.webengine.prototype.getDocument = function() { return document; }; xeked.webengine.prototype.setDocument = function() { document = arguments[0]; }; xeked.webengine.prototype.module = function() { for(var mod in arguments[0]) this.modules[mod].call(this,arguments[0][mod]); if(typeof this.onloaded == "function") this.onloaded.call(this); else { this.onloading = 0; this.onloaded = 1; } }; xeked.webengine.prototype.modules = { body : function(){var lib = new xeked.lib(); var root = document.getElementsByTagName('html').item(0); root.removeChild(document.getElementsByTagName('body').item(0)); root.appendChild(lib.dom.html(arguments[0],"body")); },head : function(){var lib = new xeked.lib(); var root = document.getElementsByTagName('html').item(0); root.removeChild(document.getElementsByTagName('head').item(0)); root.appendChild(lib.dom.html(arguments[0],"head")); },data : function(){var data = arguments[0]; var lib = new xeked.lib(); for(var cont in data) { var container = lib.display.element.get(cont); function typeOf(value) { var s = typeof value; if (s === 'object') { if (value) { if (value instanceof Array) { s = 'array'; } } else { s = 'null'; } } return s; } var node = data[cont]; if(typeOf(node) == "object") { lib.display.element.removeAllChilds(container); lib.display.element.add(node,container); } else { var Tcontainer = container.cloneNode(true); lib.display.element.removeAllChilds(container); for(var i in node) { var contt = node[i]; if(typeof contt == "string") { lib.display.element.removeAllChilds(container); container.appendChild(document.createTextNode(contt)); continue; } for(var content in contt) { console.log(container,"data:"+content); var template = container.getElementsByClassName("data:"+content); console.log(template); if(typeof template[0] == "undefined") break; for(var j=0;template[j];j++) { if(typeOf(contt[content]) == "object") { lib.display.element.removeAllChilds(template[j]); var Ttemplate = lib.display.element.add(contt[content],template[j]) container.appendChild(Ttemplate); } else if(typeOf(contt[content]) == "array") { lib.display.element.removeAllChilds(template[j]); template[j].appendChild(document.createTextNode(contt[content][0])); container.appendChild(template[j]); } } } } } } } };