diff --git a/client/client.js b/client/client.js index 4d591fd4b2fc3818686921bdd1267a7f1814fad3..91d9e4283885d082273fccee3b27d3093ecf8cf5 100644 --- a/client/client.js +++ b/client/client.js @@ -516,7 +516,7 @@ document.onkeydown = function(evt) { function writeModuleOptionMenu(modRep) { var menuDom = document.createElement('div') menuDom.id = 'perModuleMenu' - menuDom.style.left = 10 + modrep.dom.domElem.offsetLeft + modrep.dom.domElem.offsetWidth + 'px' + menuDom.style.left = 10 + modRep.dom.domElem.offsetLeft + modRep.dom.domElem.offsetWidth + 'px' menuDom.style.top = modRep.dom.domElem.offsetTop + 'px' // future: rm all inputs, rm all outputs, rename, open (heirarchy) var opts = ['delete', 'copy'] diff --git a/client/divtools.js b/client/divtools.js index 81c28db3c7adce8aa9aa90edb7cf62be092b8467..228bb6d11af97c6e3e53afe008ba876438867b57 100644 --- a/client/divtools.js +++ b/client/divtools.js @@ -256,42 +256,29 @@ function writeUiElement(container, rep, key) { // pull the representation object from what we were sent var ui = rep.ui[key] console.log('write ui', ui) + console.log('at rep', rep) + + //import script from ui.clientPath // load this thing, + ui.script = document.createElement('script') + container.appendChild(ui.script) + // it loads and executes when this is set + ui.script.src = ui.clientPath + // events + ui.script.onerror = function(err){ console.log('ERR from ui script', err) } - ui.script.onload = function(msg){ - console.log('script loaded ?') - } - container.appendChild(ui.script) - - ui.script.src = ui.clientPath - - - - // make an xhttp request for the code - /* - var request = new XMLHttpRequest() - request.open('GET', ui.clientPath) - request.responseType = 'text/javascript' - request.onLoad = function() { - console.log(request.response) + ui.script.onload = function(msg){ + console.log('script loaded') + // how many of these functions exist ? + registerNewModule(rep.description.id, key) } - request.send() - - fetch(ui.clientPath).then(function(response) { - response.text().then(function(text) { - console.log(text) - console.log(ui) - ui.script.appendChild(document.createTextNode(text)) - container.apppendChild(ui.script) - }) - }) - */ + // now we'll hook it up to the socket ? /* // give it access to the socket, diff --git a/client/ui/uiButton.js b/client/ui/uiButton.js index dada8bdafad5c846919af0d97981907a9709263e..fc8e551805239904e02c334ac00a5a4610aaf90b 100644 --- a/client/ui/uiButton.js +++ b/client/ui/uiButton.js @@ -1 +1,14 @@ -console.log('hello lib load') \ No newline at end of file +(function(){ + socketSend('console', 'loading new iife') + + this.init = function(){ + socketSend('console', 'hello from' + this.parentId + this.key) + } + + // expect this to only be used once + window.registerNewModule = function(id, key){ + this.parentId = id + this.key = key + this.init() + } +})() \ No newline at end of file