add difficulty param to client

This commit is contained in:
Jonas Weinz 2021-07-03 20:21:45 +02:00
parent 77882f4981
commit 3078813d37
3 changed files with 54 additions and 12 deletions

View File

@ -42,8 +42,8 @@
box-shadow: none; box-shadow: none;
outline: none; outline: none;
position: absolute; position: absolute;
width: 15em; width: 30em;
height: 10em; height: 20em;
top: 0; top: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
@ -54,17 +54,41 @@
font-size: 1em; font-size: 1em;
} }
.bigbox {
background-color: black;
border-color: white;
border-width: 0.2em;
border-style: solid;
max-width: 30em;
max-height: 6em;
box-shadow: none;
outline: none;
position: relative;
margin: 1em;
padding: 1em;
color: white;
font-size: 1em;
}
.flex {
display: flex;
width: 100%;
}
.box { .box {
background-color: black; background-color: black;
border-color: white; border-color: white;
border-width: 0.2em; border-width: 0.2em;
border-style: solid; border-style: solid;
max-width: 15em; flex: auto;
width: 33%;
text-decoration: none;
max-width: 30em;
max-height: 3em; max-height: 3em;
box-shadow: none; box-shadow: none;
outline: none; outline: none;
position: relative; position: relative;
margin: 1em; margin: 0.5em;
padding: 1em; padding: 1em;
color: white; color: white;
font-size: 1em; font-size: 1em;
@ -76,13 +100,25 @@
<body> <body>
<div class="centerbox"> <div class="centerbox">
<h3>Select the language:</h3> <h3>choose language and difficulty:</h3>
<a href="./german.html">
<div class="box"> German </div> <div class="bigbox"> <div> German </div>
</a> <div class="flex">
<a href="./english.html"> <a href="./german.html?difficulty=0" class="box"> easy </a>
<div class="box"> English </div> <a href="./german.html?difficulty=1" class="box"> normal </a>
</a> <a href="./german.html?difficulty=2" class="box"> hard </a>
</div>
</div>
<div class="bigbox"> <div> English </div>
<div class="flex">
<a href="./english.html?difficulty=0" class="box"> easy </a>
<a href="./english.html?difficulty=1" class="box"> normal </a>
<a href="./english.html?difficulty=2" class="box"> hard </a>
</div>
</div>
</div> </div>
</body> </body>

View File

@ -81,7 +81,8 @@ export class InfoBox extends LitElement {
onNew() { onNew() {
setCookie("session", ""); setCookie("session", "");
window.location.href = location.protocol + '//' + location.host + location.pathname; var crosswordRoot = location.pathname.substr(0, location.pathname.lastIndexOf("/"));
window.location.href = location.protocol + '//' + location.host + crosswordRoot;
} }

View File

@ -20,6 +20,7 @@ export class ServerConnection extends WebsocketConnection {
this.sessionId = null; this.sessionId = null;
this.isRegistered = false; this.isRegistered = false;
this.crossword_grid = null; this.crossword_grid = null;
this.difficulty = 0;
} }
@ -40,6 +41,9 @@ export class ServerConnection extends WebsocketConnection {
this.sessionId = params.get('session'); this.sessionId = params.get('session');
return; return;
} }
if (params.has('difficulty')) {
this.difficulty = parseInt(params.get('difficulty'));
}
const cookie_session = getCookie('session'); const cookie_session = getCookie('session');
if (cookie_session != "") { if (cookie_session != "") {
this.sessionId = cookie_session; this.sessionId = cookie_session;
@ -54,6 +58,7 @@ export class ServerConnection extends WebsocketConnection {
this.sendMessage({ this.sendMessage({
'type': 'register', 'type': 'register',
'sessionId': this.sessionId, 'sessionId': this.sessionId,
'difficulty': this.difficulty,
'lang': this.lang 'lang': this.lang
}); });
} }