menus
This commit is contained in:
parent
31fddfaaff
commit
6320e5b9a2
3 changed files with 37 additions and 8 deletions
14
css/main.css
14
css/main.css
|
@ -40,3 +40,17 @@
|
|||
.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);
|
||||
}
|
|
@ -5,6 +5,11 @@
|
|||
<link rel='stylesheet' href='/css/main.css'>
|
||||
</head>
|
||||
<body>
|
||||
<div class='menu-left'>
|
||||
|
||||
</div>
|
||||
<div class='menu-right'>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
26
js/index.mjs
26
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);
|
||||
createBlocks(data,bodyThing);
|
||||
createBlocks(scriptData,document.body.querySelector('.menu-right'),true);
|
Loading…
Reference in a new issue