This commit is contained in:
biglyderv 2024-11-30 04:36:07 -05:00
parent 31fddfaaff
commit 6320e5b9a2
3 changed files with 37 additions and 8 deletions

View file

@ -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);
}

View file

@ -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>

View file

@ -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);