about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2024-09-02 21:36:39 -0400
committerelioat <elioat@tilde.institute>2024-09-02 21:36:39 -0400
commit86c0b4d1a3bb115ef6d0be271a350c18290d13dc (patch)
tree425ab1c8bb558509c2a62d7e83a5de780aab0fd4
parentbfa68403b33104e80337b87c958492219955210e (diff)
downloadtour-86c0b4d1a3bb115ef6d0be271a350c18290d13dc.tar.gz
*
-rw-r--r--html/playground/APL386.ttfbin0 -> 203668 bytes
-rw-r--r--html/playground/index.html160
-rw-r--r--uiua/life.ua7
3 files changed, 164 insertions, 3 deletions
diff --git a/html/playground/APL386.ttf b/html/playground/APL386.ttf
new file mode 100644
index 0000000..5e3a338
--- /dev/null
+++ b/html/playground/APL386.ttf
Binary files differdiff --git a/html/playground/index.html b/html/playground/index.html
new file mode 100644
index 0000000..a55ede3
--- /dev/null
+++ b/html/playground/index.html
@@ -0,0 +1,160 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>JavaScript Playground</title>
+    <style>
+    
+        @font-face {
+            font-family: "APL386";
+            src: url("./APL386.ttf") format("truetype");
+        }
+
+        body {
+            display: flex;
+            flex-direction: column;
+            align-items: center;
+            background-color: #ddd;
+            padding: 10px;
+            height: 100vh;
+            margin: 0;
+        }
+
+        textarea {
+            width: 100%;
+            height: 64%;
+            font-family: "APL386", "APL385", "Go Mono", monospace;
+            background-color: #FFFEEC;
+            border: 2px solid #000;
+            scrollbar-width: none;            
+            font-size: 1rem;
+            margin-bottom: 10px;
+            padding: 10px;
+            box-sizing: border-box;
+            resize: none;
+            border-bottom: 12px solid teal;
+            -webkit-user-modify: read-write-plaintext-only;
+        }
+
+        textarea::-webkit-scrollbar {
+            display: none;
+        }
+
+        textarea::selection {
+            background-color: #EFECA7;
+        }
+
+        textarea:focus {
+            outline: none;
+        }
+
+        #console {
+            width: 100%;
+            height: 22%;
+            background-color: #000;
+            color: teal;
+            font-family: monospace;
+            font-size: 1rem;
+            overflow-y: auto;
+            padding: 10px;
+            box-sizing: border-box;
+            white-space: pre-wrap;
+        }
+
+        .button-container {
+            width: 100%;
+            display: flex;
+            justify-content: flex-end;
+            margin-bottom: 10px;
+        }
+
+        button {
+            padding: 10px 20px;
+            font-size: 1rem;
+            margin-left: 10px;
+            cursor: pointer;
+            border: none;
+            transition: background-color 0.3s ease;
+        }
+
+        button:hover, button:focus {
+            outline: none; 
+        }
+
+        button.run {
+            background-color: teal;
+            color: #FFFFFF;
+        }
+
+    </style>
+</head>
+<body>
+
+    <div class="button-container">
+        <button onclick="shareCode()">Share</button>
+        <button onclick="evaluateCode()" class="run">Run Code</button>
+    </div>
+    <textarea id="codeInput" placeholder="Enter JavaScript..."></textarea>
+    <div id="console"></div>
+
+    <script>
+        document.getElementById('codeInput').addEventListener('keydown', function(event) {
+            if (event.metaKey && event.key === 'Enter') {
+                event.preventDefault();
+                evaluateCode();
+            }
+        });
+
+        function evaluateCode() {
+            const code = document.getElementById('codeInput').value;
+            const consoleDiv = document.getElementById('console');
+            consoleDiv.innerHTML = '';
+
+            // Custom console.log function to output to the console div
+            const originalConsoleLog = console.log;
+            console.log = function(...args) {
+                args.forEach(arg => {
+                    const output = document.createElement('div');
+                    output.textContent = typeof arg === 'object' ? JSON.stringify(arg, null, 2) : arg;
+                    consoleDiv.appendChild(output);
+                });
+                originalConsoleLog.apply(console, args);
+            };
+
+            try {
+                eval(code);
+            } catch (error) {
+                const errorOutput = document.createElement('div');
+                errorOutput.textContent = error;
+                errorOutput.style.color = 'red';
+                consoleDiv.appendChild(errorOutput);
+            }
+
+            // Restore browser's console.log
+            console.log = originalConsoleLog;
+        }
+
+        function shareCode() {
+            const code = document.getElementById('codeInput').value;
+            const encodedCode = btoa(encodeURIComponent(code));
+            window.location.hash = encodedCode;
+        }
+
+        function loadCodeFromHash() {
+            const hash = window.location.hash.substring(1);
+            if (hash) {
+                try {
+                    const decodedCode = decodeURIComponent(atob(hash));
+                    document.getElementById('codeInput').value = decodedCode;
+                } catch (error) {
+                    console.error('Failed to decode the URL hash:', error);
+                }
+            }
+        }
+
+        window.onload = loadCodeFromHash;
+    </script>
+
+</body>
+</html>
diff --git a/uiua/life.ua b/uiua/life.ua
index 7027301..706c2da 100644
--- a/uiua/life.ua
+++ b/uiua/life.ua
@@ -1,5 +1,6 @@
 # lifted from the uiua docs
 Life ← ↥⊙↧∩=3,2-,/+≡↻☇1-1⇡3_3¤.
-⁅×0.6∵⋅⚂↯⊟.30 0       # Init
-⇌;⍥(⊃∘⊂Life)100⊃∘(↯1) # Run
-≡(▽↯⧻,:⍉▽↯⧻,,:5)      # Upscale
+⁅×0.6∵⋅⚂↯⊟.30 0     # Init
+⍥(⊃∘⊂Life)100⊃∘(↯1) # Run
+⇌
+≡(▽↯⧻,:⍉▽↯⧻,,:5) # Upscale