Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
bacionejs authored Aug 9, 2024
1 parent 5b71388 commit 1eceeb5
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions bacione.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@
* T.P - paste buffer
*/

let keys, T=createtextarea(), pretty=createpretty();
let KEYS, T=createtextarea(), PRETTY=createpretty();
T.V=striplinesfirstlast(gameprograms);
sinceopened=sincesaved=filecontent();
T.S=T.E=T.V.indexOf("{")+1;
T.focus();
setTimeout(()=>{keys=createkeys(), theme();},200);
setTimeout(createkeys,200);
new Promise(r=>setTimeout(r,500)).then(()=>new Promise(r=>requestAnimationFrame(a=>requestAnimationFrame(b=>r(floor(1000/(b-a))))))).then(r=>FPS=r);

/* code layout below:
Expand All @@ -97,15 +97,15 @@
function theme(){
colors.next();
let style;
keys.forEach(k=>{
KEYS.forEach(k=>{
style=k.e.style;
style.backgroundColor=colors.keybackground;
style.color=colors.keyforeground;
style.border=colors.border=="none"?"none":`2px outset ${colors.border}`;
k.e.querySelector("path")?.style.setProperty("stroke",colors.keyforeground);
});
T.style.caretColor=colors.caret;
style=pretty.style;
style=PRETTY.style;
style.backgroundColor=colors.background;
style.color=colors.foreground;
syncpretty();
Expand Down Expand Up @@ -159,16 +159,18 @@
}

function zoom(){
let p=PRETTY.style;
let t=T.style;
if(parseInt(T.style.fontSize)==fontsizesmall){
T.style.whiteSpace="normal";
pretty.style.whiteSpace="pre-wrap";
T.style.fontSize=fontsizebig;
pretty.style.fontSize=fontsizebig;
t.whiteSpace="normal";
p.whiteSpace="pre-wrap";
t.fontSize=fontsizebig;
p.fontSize=fontsizebig;
}else{
T.style.whiteSpace="nowrap";
pretty.style.whiteSpace="pre";
T.style.fontSize=fontsizesmall;
pretty.style.fontSize=fontsizesmall;
t.whiteSpace="nowrap";
p.whiteSpace="pre";
t.fontSize=fontsizesmall;
p.fontSize=fontsizesmall;
}
setTimeout(()=>{T.blur(); T.focus();},0);
}
Expand Down Expand Up @@ -208,7 +210,7 @@

function capslock(){
if(running){run(); return;}
keys.filter(k=>!k.f).forEach(k=>k.e.textContent=k.d[k.d.indexOf(k.e.textContent)^1]);
KEYS.filter(k=>!k.f).forEach(k=>k.e.textContent=k.d[k.d.indexOf(k.e.textContent)^1]);
}

function undo(){ restore(-1); }
Expand Down Expand Up @@ -438,7 +440,7 @@
e.className="view";
e.addEventListener("click",()=>view(f));
}
pretty.classList.toggle("unhide");
PRETTY.classList.toggle("unhide");
if(e.classList.toggle("unhide")){
title=document.title;
document.title=alt || f;
Expand Down Expand Up @@ -704,7 +706,7 @@

let con=element("div",e);
con.insertAdjacentHTML("beforeend", "<b>Buttons</b><br><br>");
keys.filter(k=>k.f).forEach(k=>{
KEYS.filter(k=>k.f).forEach(k=>{
con.appendChild(k.d()).querySelector("path").style.stroke="black";
con.insertAdjacentHTML("beforeend"," "+k.name.replace(/^\w/,c=>c.toUpperCase())+"<br><br>");
});
Expand Down Expand Up @@ -895,12 +897,14 @@
setTimeout(()=>k.e.style.backgroundColor=colors.keybackground,200);
},false);

return keys;
KEYS=keys;
theme();

}//end createkeys

function createtextarea(){
let T=element("textarea");
T.addEventListener('scroll',function(){pretty.scrollTop=T.scrollTop;pretty.scrollLeft=T.scrollLeft;});
T.addEventListener('scroll',function(){PRETTY.scrollTop=T.scrollTop;PRETTY.scrollLeft=T.scrollLeft;});
T.addEventListener('paste', function(ev){ ev.preventDefault(); T.I(ev.clipboardData.getData('text'),T.S,T.S,"end"); });
T.addEventListener('cut', function(ev){ ev.preventDefault(); ev.clipboardData.setData("text",document.getSelection().toString()); });
Object.defineProperty(T,"V",{get(){return this.value;}, set(v){this.value=v; syncpretty();}});
Expand Down Expand Up @@ -960,7 +964,7 @@
let s=T.V.replace(/</g,'&'+'lt;');
s=c(s,colors.pairs,`[(){}[\\]]`);
s=c(s,colors.keywords,`\\b(function|let|if|else|for|forEach|while|true|false|this|return|undefined)\\b`);
pretty.innerHTML=s;
PRETTY.innerHTML=s;
}

}//end ide
Expand Down

0 comments on commit 1eceeb5

Please sign in to comment.