+ add/del + body color

This commit is contained in:
mikif70 2025-02-24 10:19:54 +01:00
parent 29ee89f9ba
commit e3d5c57101

View file

@ -44,8 +44,8 @@
console.log("ResetLocalCache"); console.log("ResetLocalCache");
window.sessionStorage.clear(); window.sessionStorage.clear();
surfers = [ surfers = [
{ name: "", score: 0, colore: "black" }, { id: 1, name: "", score: 0, colore: "black", delete: false },
{ name: "", score: 0, colore: "black" }, { id: 2, name: "", score: 0, colore: "black", delete: false },
]; ];
start = false; start = false;
info = { info = {
@ -69,7 +69,7 @@
console.log("StartHeat"); console.log("StartHeat");
start = true; start = true;
SaveToLocalCahe(); SaveToLocalCahe();
timer = setInterval(Timer, 200); timer = setInterval(Timer, 1000);
} }
function pad(n) { function pad(n) {
@ -77,14 +77,11 @@
} }
function Timer() { function Timer() {
console.log(mins + ":" + secs);
if (secs == 0) { if (secs == 0) {
mins = mins - 1; mins = mins - 1;
secs = 59; secs = 59;
console.log("sec = 0: " + mins + ":" + secs);
} else { } else {
secs = secs - 1; secs = secs - 1;
console.log("sec > 0: " + mins + ":" + secs);
} }
} }
@ -103,23 +100,25 @@
} }
} }
function hasDuplicateColors() { function AddSurfer() {
const colors = []; if (surfers.length < 5) {
let newSurfer = {
console.log(JSON.stringify(priority.surfers)); id: surfers.length + 1,
name: "",
for (let i = 0; i < priority.surfersCount; i++) { score: 0,
const color = priority.surfers[i].color; rank: 0,
delete: true,
if (colors.includes(color)) { };
console.log(`duplicate color: ${color}`); surfers.push(newSurfer);
return true; SaveToLocalCahe();
}
} }
colors.push(color); function DelSurfer() {
if (surfers.length > 2) {
surfers.pop();
SaveToLocalCahe();
} }
return false;
} }
</script> </script>
@ -270,26 +269,37 @@
{/each} {/each}
</ul> </ul>
</div> </div>
<button type="button" class="btn btn-primary mt-1 mb-1 w-100" <div class="d-grid gap-2 d-md-flex justify-content-md-center mb-2">
>Add</button>
<div class="btn-group w-100" role="group" aria-label="save">
<button <button
type="button" type="button"
class="btn btn-primary mt-1 mb-1 w-100" class="btn btn-primary w-50"
onclick={AddSurfer}>Add</button>
<button
type="button"
class="btn btn-warning w-50"
onclick={DelSurfer}>Del</button>
<!-- <div class="btn-group w-100" role="group" aria-label="save"> -->
</div>
<div class="d-grid gap-2 d-md-flex justify-content-md-center mt-2">
<button
type="button"
class="btn btn-primary w-50"
onclick={SaveToLocalCahe}>Save</button> onclick={SaveToLocalCahe}>Save</button>
<button <button
type="button" type="button"
class="btn btn-primary mt-1 mb-1 w-100" class="btn btn-danger w-50"
onclick={ResetLocalCache}>Reset</button> onclick={ResetLocalCache}>Reset</button>
</div> </div>
<!-- </div> -->
</form> </form>
</div> </div>
</div> </div>
<style> <style>
body { .body {
background-color: black; background-color: #dfffdf;
color: white; color: black;
font-family: Arial, sans-serif; font-family: Arial, sans-serif;
min-height: 1024px; min-height: 1024px;
min-width: 768px; min-width: 768px;
@ -393,7 +403,7 @@
width: 500px; width: 500px;
background: rgba(50, 50, 50, 0.7); background: rgba(50, 50, 50, 0.7);
color: white; color: white;
margin-left: 450px; margin-left: 550px;
margin-top: 100px; margin-top: 100px;
padding: 10px; padding: 10px;
} }