Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Ponali committed Dec 18, 2023
1 parent df8fbad commit 810843d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions files/scratch-exp/script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function run(){
let exprs = document.querySelector("#experiments");
fetch("/experiments.json").then(data=>data.text()).then((body)=>{
fetch("experiments.json").then(data=>data.text()).then((body)=>{
try{
exprs.innerHTML="";
let json = JSON.parse(body);
Expand All @@ -9,11 +9,11 @@ function run(){
let elem = document.createElement("div");
let item = json[i];
elem.setAttribute("class","expr-box");
if(item.type=="project"){item.img="/examples/project.png"}
if(item.type=="project"){item.img="examples/project.png"}
if(item.img){elem.setAttribute("style",`background:url("${item.img}"); background-size:cover;`)}
elem.innerHTML=`<div class="expr-hvname"><span>${item.name}</span></div>`;
let requirements = "You need a(n) "+(item.type=="css" ? "CSS injector" : (item.type=="js" ? "JS Injector" : (item.type=="project" ? "working scratch client" : "[unknown]") ) );
let code = (item.type=="css" ? `Use the code <pre>@import url("https://scratchexperimentation.ponali.repl.co${item.code}");</pre> to launch the experiment.` : (item.type=="js" ? `Use the code <pre>fetch("https://scratchexperimentation.ponali.repl.co${item.code}").then(d=>d.text()).then(b=>eval(b));</pre> to launch the experiment.` : (item.type=="project" ? `Use the link <a href='https://turbowarp.org/${item.projectId}'>here</a> to run the project.` : "[unknown]") ) );
let code = (item.type=="css" ? `Use the code <pre>@import url("https://ponali.github.io/files/scratch-exp/${item.code}");</pre> to launch the experiment.` : (item.type=="js" ? `Use the code <pre>fetch("https://ponali.github.io/files/scratch-exp/${item.code}").then(d=>d.text()).then(b=>eval(b));</pre> to launch the experiment.` : (item.type=="project" ? `Use the link <a href='https://turbowarp.org/${item.projectId}'>here</a> to run the project.` : "[unknown]") ) );
elem.addEventListener("click",(()=>{popup({display:1,title:item.name,description:item.how+"<br><span class='popup-title'>Requirements</span>"+requirements+"<br>"+code});}),false)
exprs.appendChild(elem);
}
Expand Down

0 comments on commit 810843d

Please sign in to comment.