From 8a8fc90a1ffde823d6abf9cd655d3bab03d3ba38 Mon Sep 17 00:00:00 2001 From: Jonas Weinz Date: Mon, 21 Jun 2021 10:18:31 +0200 Subject: [PATCH] improve js client --- js_client/grid.js | 10 ++++++-- js_client/index.html | 43 ++++++++++++++++++++++++++++--- js_client/infoBox.js | 61 +++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 106 insertions(+), 8 deletions(-) diff --git a/js_client/grid.js b/js_client/grid.js index 5be412e..dd24986 100644 --- a/js_client/grid.js +++ b/js_client/grid.js @@ -196,6 +196,7 @@ export class GridLetter extends GridBox { if (this.revealed) { this.value = oldVal; + this.crosswordGrid.focusNextCell(this.x, this.y); return } @@ -696,12 +697,17 @@ export class CrosswordGrid extends LitElement { if (left_end.getGridType() === gridType.HINT) { var box = left_end.getHintBox(); - hHint = `${box.hint_id}: ${box.horizontal_hint}`; + if (box.hasHorizontalHint()){ + hHint = `${box.hint_id}: ${box.horizontal_hint}`; + } } if (upper_end.getGridType() === gridType.HINT) { var box = upper_end.getHintBox() - vHint = `${box.hint_id}: ${box.vertical_hint}`; + if (box.hasVerticalHint()) + { + vHint = `${box.hint_id}: ${box.vertical_hint}`; + } } this.infobox.horizontal_hint = hHint; diff --git a/js_client/index.html b/js_client/index.html index c519bc6..06ad975 100644 --- a/js_client/index.html +++ b/js_client/index.html @@ -7,14 +7,51 @@ + + // Original viewport definition, note the "id" that I use to modify the viewport later on: + + + + - + - + - + \ No newline at end of file diff --git a/js_client/infoBox.js b/js_client/infoBox.js index 94abc4a..4710b5b 100644 --- a/js_client/infoBox.js +++ b/js_client/infoBox.js @@ -1,4 +1,15 @@ import { html, css, LitElement, unsafeCSS } from 'https://unpkg.com/lit-element/lit-element.js?module'; +import { getCookie, setCookie } from './cookie.js'; + +function copyToClipboard(text) { + var input = document.body.appendChild(document.createElement("input")); + input.value = text; + input.focus(); + input.select(); + document.execCommand('copy'); + input.parentNode.removeChild(input); + alert("copied url to clipboard"); +} export class InfoBox extends LitElement { static get styles() { @@ -7,13 +18,19 @@ export class InfoBox extends LitElement { color: white; margin-left: 1em; margin-top: 0.8em; - + } + .hintbox { + grid-column: 1; + grid-row: 1; } .infobox { + font-size = 1em; z-index: 20; position: fixed; + display: grid; + grid-template-columns: auto min-content; top: 0em; left: 0em; right: 0em; @@ -25,6 +42,27 @@ export class InfoBox extends LitElement { background-color: #333; color: white; } + + .buttonbox { + grid-column: 2; + grid-row: 1; + padding: 0.3em; + } + + .button { + background-color: black; + border-color: white; + border-width: 0.2em; + border-style: solid; + min-width: 10em; + min-height: 2.5em; + box-shadow: none; + outline: none; + margin: 0.1em 0.1em; + color: white; + font-size: 1em; + } + `; } @@ -41,11 +79,28 @@ export class InfoBox extends LitElement { this.horizontal_hint = ""; } + onNew(){ + setCookie("session",""); + window.location.href = location.protocol + '//' + location.host + location.pathname; + + } + + onShare(){ + copyToClipboard(window.location.href); + } + render() { return html`
-
▶ ${this.horizontal_hint}
-
▼ ${this.vertical_hint}
+
+
▶ ${this.horizontal_hint}
+
▼ ${this.vertical_hint}
+
+
+ + + +
`; }