diff --git a/css/main.css b/css/main.css index 1eef52b..8ef825c 100644 --- a/css/main.css +++ b/css/main.css @@ -39,4 +39,18 @@ .block-pop { background: rgb(250, 135, 135); +} + +body { + padding: 0; + margin: 0; + display: grid; + width: 100vw; + height: 100vh; + grid-template-columns: 2fr 1fr; +} + +.menu-right { + + background: rgb(225,225,225); } \ No newline at end of file diff --git a/index.html b/index.html index e1df2a7..a367549 100644 --- a/index.html +++ b/index.html @@ -5,6 +5,11 @@ + + \ No newline at end of file diff --git a/js/index.mjs b/js/index.mjs index 6325660..8c2974e 100644 --- a/js/index.mjs +++ b/js/index.mjs @@ -2,6 +2,15 @@ import { unparser } from "./unparser.mjs"; import { parser, runner, openers } from "./parser.mjs"; import objsI from "./objs.mjs"; +let scriptData = parser(` + { + echo(add([2][3])) + echo([Hello World!]) + echo(add([2][3])) + echo([Hello World!]) +} +`); + let data = parser(` on( [compile] @@ -26,16 +35,16 @@ async function runWrap() { let clickedBlock = false; let clickedArea = false; let clickedClone = false; -let bodyThing = document.body; +let bodyThing = document.body.querySelector('.menu-left'); -async function createBlocks(dat, parent = bodyThing) { +async function createBlocks(dat, parent = bodyThing, dupe = false) { if (dat.canDelete) return false; let args = Object.assign([], dat.args); if (!args || !args[0]) args = [dat.args]; if (!args || !args[0]) args = []; for (let i in args) { - args[i] = await createBlocks(args[i]) + args[i] = await createBlocks(args[i],parent,dupe) } let o = dat.op ? dat.op.charCodeAt() : 'nil'; @@ -45,9 +54,9 @@ async function createBlocks(dat, parent = bodyThing) { div.classList.add(`block-${dat.context}`) div.classList.add(`block`) div.textContent = dat.str || dat.context; - parent.appendChild(div); + if (div) parent.appendChild(div); - if (dat.op == '{') { + if (dat.op == '{' && !dupe) { //todo: clean let button = document.createElement('div'); button.classList.add(`block`) @@ -77,12 +86,12 @@ async function createBlocks(dat, parent = bodyThing) { let swap = {}; console.log(clickedArea, dat) Object.assign(swap, clickedArea); - Object.assign(clickedArea, dat); + if (!dupe) Object.assign(clickedArea, dat); Object.assign(dat, swap); bodyThing.innerHTML = ''; - createBlocks(data); + createBlocks(data,parent,dupe); runWrap(); } @@ -127,4 +136,5 @@ document.onclick = function(e) { } runWrap(); -createBlocks(data); \ No newline at end of file +createBlocks(data,bodyThing); +createBlocks(scriptData,document.body.querySelector('.menu-right'),true); \ No newline at end of file