about summary refs log tree commit diff stats
path: root/html/playground/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'html/playground/index.html')
-rw-r--r--html/playground/index.html55
1 files changed, 39 insertions, 16 deletions
diff --git a/html/playground/index.html b/html/playground/index.html
index 522f3da..a7395d4 100644
--- a/html/playground/index.html
+++ b/html/playground/index.html
@@ -4,14 +4,8 @@
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>JavaScript Playground</title>
+    <meta name="description" content="A JavaScript jungle-gym for doing experiments and sharing scrappy fiddles.">
     <style>
-        /*
-        @font-face {
-            font-family: "APL386";
-            src: url("./APL386.ttf") format("truetype");
-        }
-        */
-
         body {
             display: flex;
             flex-direction: column;
@@ -25,7 +19,7 @@
         textarea {
             width: 100%;
             height: 64%;
-            font-family: "APL386", "APL385", "Go Mono", monospace;
+            font-family: monospace;
             background-color: #FFFEEC;
             border: 2px solid #000;
             scrollbar-width: none;            
@@ -87,13 +81,11 @@
             background-color: teal;
             color: #FFFFFF;
         }
-
     </style>
 </head>
 <body>
 
     <div class="playground" id="playground">    
-        <!-- use this empty div to mount stuff -->
         <div class="seesaw" id="seesaw"></div>
         <div class="slide" id="slide"></div>
     </div>
@@ -187,26 +179,57 @@
             const helpText = `
             Welcome to the JavaScript Playground! Here are some tips to get you started:
 
-            1. Enter your JavaScript code in the text area.
+            1. Enter your JavaScript code in the textarea.
             2. Click the "Run Code" button to execute your code.
-            3. The console output will be displayed below the text area.
+            3. The console output will be displayed below the textarea.
             4. Click the "Clear" button to reset the playground.
             5. Click the "Download" button to save your code and editor as an HTML file.
             6. Click the "Share" button to generate a URL to share your code with others.
             7. You can also press "Cmd + Enter" to run your code.
-            8. There's an empty div, with the id "playground"
-            9. That playground div contains 2 child divs, with the ids "seesaw" and "slide"
-            10. You can use those divs to mount stuff to the DOM
+            8. There's an empty div above the buttons with the id "playground"
+            9. You can mount stuff to it using the "mount" function, for more info run "mountHelp()"
+            10. You can use the "clear()" function to clear the content's of the console.
 
             Go nuts! Share scrappy fiddles!
             `;
             console.log(helpText);
         }
 
-        function clearLog() {
+        function clear() {
             document.getElementById('console').innerHTML = '';
         }
 
+        function mountHelp() {
+            console.log(`
+            The mount function is used to mount stuff to the playground div.
+            It takes a function as an argument, which in turn receives the playground div as an argument.
+            Before mounting, it clears the playground div.
+            Here's an example of how to use the mount function:
+
+            mount(playground => {
+                const h1 = document.createElement('h1');
+                h1.textContent = 'Hell is empty and all the devils are here.';
+                playground.appendChild(h1);
+            });
+
+            This will add an h1 element to the playground div.
+            `);
+        }
+
+        function mount(mountFunction) {
+            const playground = document.getElementById('playground');
+            if (!playground) {
+                console.error("Couldn't find a div with the id 'playground'! You may need to reload the page.");
+                return;
+            }
+
+            if (playground.innerHTML.trim() !== "") {
+                playground.innerHTML = "";
+            }
+            mountFunction(playground);
+        }
+
+
         document.getElementById('codeInput').addEventListener('keydown', function(event) {
             if (event.metaKey && event.key === 'Enter') {
                 event.preventDefault();