123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <style type="text/css">
- html , body { height: 100%; width: 100%; margin: 0px; padding: 0px; }
- #editor { width: 30%; background-color: #afafaf; height: 100%; position: relative; float: right; overflow: hidden;}
- #holder { width: 70%; background-color: #ffddff; height: 100%;}
- #editor textarea {height: 70%; width: 100%; font-family: monospace; font-size: 11px; line-height: 13px;}
- </style>
- </head>
- <body onload="startit();">
- <div id="editor"></div>
- <div id="holder">
- <div id="main"></div>
- </div>
- <script>
- function loada(){
- var header = document.getElementsByTagName("head")[0];
-
- var current_script = document.getElementById("current_script");
- var current_style = document.getElementById("current_style");
- header.removeChild(current_script);
- header.removeChild(current_style);
- var newscript = document.createElement("script");
- newscript.type = "text/javascript";
- newscript.src = "./current.js?"+Math.random();
- newscript.id = "current_script";
- header.appendChild(newscript);
- var newstyle = document.createElement("link");
- newstyle.type = "text/css";
- newstyle.rel = "stylesheet";
- newstyle.href = "./current.css?"+Math.random();
- newstyle.id = "current_style";
- header.appendChild(newstyle);
- }
- function MT(){
- this.modules = [];
- this.events = {};
- }
- MT.prototype.register = function(name,func) {
- console.log("register",name,func);
- this[name] = func;
- }
- MT.prototype.on = function(eventName,func){
- this.events[eventName] = this.events[eventName] || [];
- this.events[eventName].push(func);
- }
- MT.prototype.emit = function(eventName,content){
- (this.events[eventName]||[]).map(function(func){
- func.apply(func,[content]);
- })
- }
- var site = new MT();
- var data = new MT();
- var types = new MT();
- var register = function(name, func) {
- site.register(name, func)
- };
- function strip(str) {
- var reg = new RegExp(/\/\*([\s\S]*?)\*\//gi);
- str = str.replace(reg, function(matched, attrstr, content, line, d) {
- //console.log("COMMENT:;",attrstr)
- return "";
- })
- return str;
- }
- function tryparse(str) {
- var astr = strip(str);
- var ret = {};
- try{
- ret.res = eval('(function(d){ '+str+' ; return d})({})') ;// JSON.parse(astr);
- }catch(e){
- ret.error = e;
- }
- return ret;
- }
- var currentres={};
- function startit(){
- var status = document.createElement("div");
- var result = document.createElement("div");
- var editor = document.createElement("textarea");
- editor.addEventListener("input",function(ev){
- status.innerHTML = "";
- var res = tryparse(ev.target.value)
- if(res.error){
- status.innerHTML = res.error;
- }else{
- currentres = res;
- result.innerHTML = "Last known valid result: "+JSON.stringify(res);
- }
- });
- document.getElementById("editor").appendChild(editor);
- document.getElementById("editor").appendChild(result);
- document.getElementById("editor").appendChild(status);
- site.emit("start","helo");
- };
- site.on("addElement",function(type){
- console.log("ADDING",type);
- site.modules.push( type )
- render();
- });
- function guid() {
- function s4() {
- return Math.floor((1 + Math.random()) * 0x10000)
- .toString(16)
- .substring(1);
- }
- return s4() + '-' + s4() + s4();
- }
-
-
- </script>
- <script>
- console.log("OKOKOKO");
-
- /*
- raws: rendable
- im: a blog post type
- { def }
- im: a menu thing type
- im: a video window type
- im: a contact formular
- im: a privacy statment
- im: a note
- function Note(){}
- im: a comment
- im: a picture
- im: a window with collection
- im: a graphics
- im: a map
- im: a button
- im: a layout
- */
-
-
- </script>
- </body>
- </html>
|