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
|
@ -39,4 +39,18 @@
|
||||||
|
|
||||||
.block-pop {
|
.block-pop {
|
||||||
background: rgb(250, 135, 135);
|
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'>
|
<link rel='stylesheet' href='/css/main.css'>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<div class='menu-left'>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class='menu-right'>
|
||||||
|
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</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 { parser, runner, openers } from "./parser.mjs";
|
||||||
import objsI from "./objs.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(`
|
let data = parser(`
|
||||||
on(
|
on(
|
||||||
[compile]
|
[compile]
|
||||||
|
@ -26,16 +35,16 @@ async function runWrap() {
|
||||||
let clickedBlock = false;
|
let clickedBlock = false;
|
||||||
let clickedArea = false;
|
let clickedArea = false;
|
||||||
let clickedClone = 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;
|
if (dat.canDelete) return false;
|
||||||
|
|
||||||
let args = Object.assign([], dat.args);
|
let args = Object.assign([], dat.args);
|
||||||
if (!args || !args[0]) args = [dat.args];
|
if (!args || !args[0]) args = [dat.args];
|
||||||
if (!args || !args[0]) args = [];
|
if (!args || !args[0]) args = [];
|
||||||
for (let i in 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';
|
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-${dat.context}`)
|
||||||
div.classList.add(`block`)
|
div.classList.add(`block`)
|
||||||
div.textContent = dat.str || dat.context;
|
div.textContent = dat.str || dat.context;
|
||||||
parent.appendChild(div);
|
if (div) parent.appendChild(div);
|
||||||
|
|
||||||
if (dat.op == '{') {
|
if (dat.op == '{' && !dupe) {
|
||||||
//todo: clean
|
//todo: clean
|
||||||
let button = document.createElement('div');
|
let button = document.createElement('div');
|
||||||
button.classList.add(`block`)
|
button.classList.add(`block`)
|
||||||
|
@ -77,12 +86,12 @@ async function createBlocks(dat, parent = bodyThing) {
|
||||||
let swap = {};
|
let swap = {};
|
||||||
console.log(clickedArea, dat)
|
console.log(clickedArea, dat)
|
||||||
Object.assign(swap, clickedArea);
|
Object.assign(swap, clickedArea);
|
||||||
Object.assign(clickedArea, dat);
|
if (!dupe) Object.assign(clickedArea, dat);
|
||||||
Object.assign(dat, swap);
|
Object.assign(dat, swap);
|
||||||
|
|
||||||
bodyThing.innerHTML = '';
|
bodyThing.innerHTML = '';
|
||||||
|
|
||||||
createBlocks(data);
|
createBlocks(data,parent,dupe);
|
||||||
|
|
||||||
runWrap();
|
runWrap();
|
||||||
}
|
}
|
||||||
|
@ -127,4 +136,5 @@ document.onclick = function(e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
runWrap();
|
runWrap();
|
||||||
createBlocks(data);
|
createBlocks(data,bodyThing);
|
||||||
|
createBlocks(scriptData,document.body.querySelector('.menu-right'),true);
|
Loading…
Reference in a new issue