summaryrefslogtreecommitdiff
path: root/public/main.js
diff options
context:
space:
mode:
authorAlexis Hovorka <[email protected]>2022-02-19 22:56:15 -0700
committerAlexis Hovorka <[email protected]>2022-02-19 22:56:15 -0700
commit7e41581a34fe4a479dbd32fc44dcbb16f5540493 (patch)
tree713f547bd0f5e93198af4bce58254ba38b465cb9 /public/main.js
parent8a943500d97598a0b49ef655dc1b5484fe5e83d8 (diff)
[feat] Finish basic styles
Diffstat (limited to 'public/main.js')
-rw-r--r--public/main.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/public/main.js b/public/main.js
index dce51b8..3f7031b 100644
--- a/public/main.js
+++ b/public/main.js
@@ -4,6 +4,28 @@ const $ = (s,c) => (c||document).querySelector(s);
function $$(x,y,z,a){a=(z||document).querySelectorAll(x);if(typeof y=="function")[].forEach.call(a,y);return a}
function m(a,b,c){c=document;b=c.createElement(b||"p");b.innerHTML=a.trim();for(a=c.createDocumentFragment();c=b.firstChild;)a.appendChild(c);return a.firstChild}
+const boardEl = document.createElement("table");
+$("#board").appendChild(boardEl);
+
+for (let i=0;i<6;i++) {
+ let o = "<tr>";
+ for (let j=0;j<6;j++) {
+ o += `<td>&nbsp;</td>`
+ }
+ o = m(o, "table");
+ boardEl.appendChild(o);
+}
+
+function processKey(key) {
+ if (!/^([a-z]|enter|bspc)$/.test(key)) return;
+ console.log(key);
+}
+
+document.addEventListener("keydown", e =>
+ e.ctrlKey || e.altKey || e.metaKey ||
+ processKey(e.key.toLowerCase()
+ .replace("backspace", "bspc")));
+
//if ("serviceWorker" in navigator) {
// navigator.serviceWorker.register("sw.js")
// .then(() => console.log("Service worker registered"));