Add all thing to the code
something
This commit is contained in:
94
www/css/style.css
Normal file
94
www/css/style.css
Normal file
@@ -0,0 +1,94 @@
|
||||
html, body {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
|
||||
.scene{
|
||||
display: none;
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
background: linear-gradient(to right, #583305,#8A5009 );
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
|
||||
|
||||
}
|
||||
|
||||
.button{
|
||||
position: absolute;
|
||||
width: 50%;
|
||||
height: 50vh;
|
||||
top: 50%;
|
||||
}
|
||||
|
||||
#black_button{
|
||||
right: 0%;
|
||||
background: linear-gradient(to top, #A55B00, #583305);
|
||||
}
|
||||
|
||||
#white_button{
|
||||
right: 50%;
|
||||
background: linear-gradient(to top , #E9BB82, #583305);
|
||||
}
|
||||
.click{
|
||||
filter:brightness(0.9);
|
||||
}
|
||||
.TextClock{
|
||||
position: absolute;
|
||||
font-family: "Dancing Script", cursive;
|
||||
font-optical-sizing: auto;
|
||||
font-weight: 0;
|
||||
font-style: normal;
|
||||
font-size: 3vw;
|
||||
}
|
||||
#TimeBlack{
|
||||
left: 70%;
|
||||
top: 35%;
|
||||
}
|
||||
#TimeWhite{
|
||||
top: 35%;
|
||||
left: 20%;
|
||||
}
|
||||
#BlockTime{
|
||||
top:5%;
|
||||
left: 35%;
|
||||
}
|
||||
#MoveLeftWhite{
|
||||
left: 13%;
|
||||
top: 25%
|
||||
}
|
||||
#MoveLeftBlack{
|
||||
left: 63%;
|
||||
top: 25%;
|
||||
}
|
||||
#BlockType{
|
||||
top:15%;
|
||||
left: 48%;
|
||||
}
|
||||
|
||||
body::before {
|
||||
content: "";
|
||||
position: fixed;
|
||||
top: 0;
|
||||
width: 50%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s ease, left 1s ease, right 1s ease;
|
||||
background: radial-gradient(
|
||||
circle at center,
|
||||
rgba(255, 255, 0, 0.6),
|
||||
transparent 50%
|
||||
);
|
||||
}
|
||||
|
||||
/* Glow à gauche */
|
||||
.glow-left::before {
|
||||
left: 0;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* Glow à droite */
|
||||
.glow-right::before {
|
||||
right: 0;
|
||||
opacity: 1;
|
||||
}
|
||||
BIN
www/img/logo.png
Normal file
BIN
www/img/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
34
www/index.html
Normal file
34
www/index.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<script src="js/scene.js"></script>
|
||||
<script src="cordova.js"></script>
|
||||
<link rel="manifest" href="manifest.json">
|
||||
<meta name="theme-color" content="#000000">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Dancing+Script:wght@400..700&display=swap" rel="stylesheet">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<div id="sceneClock" class="scene">
|
||||
<div class="button" id="black_button"></div>
|
||||
<div class="button" id="white_button"></div>
|
||||
<h1 id="TimeWhite" class="TextClock">10:00</h1>
|
||||
<h1 id="TimeBlack" class="TextClock">10:00</h1>
|
||||
<h1 id="BlockTime" class="TextClock">temps restant Block : 03:00</h1>
|
||||
<h1 id="MoveLeftWhite" class="TextClock">Coup restant Blanc : 8</h1>
|
||||
<h1 id="MoveLeftBlack" class="TextClock">Coup restant Noire : 8</h1>
|
||||
<h1 id="BlockType" class="TextClock">Block -</h1>
|
||||
</div>
|
||||
|
||||
<script src="js/ClockFrontEnd.js"></script>
|
||||
<script src="js/appload.js"></script>
|
||||
<script src="js/backend.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
87
www/js/ClockFrontEnd.js
Normal file
87
www/js/ClockFrontEnd.js
Normal file
@@ -0,0 +1,87 @@
|
||||
let white = document.getElementById("white_button");
|
||||
let black = document.getElementById("black_button");
|
||||
let white_time = document.getElementById("TimeWhite")
|
||||
let black_time = document.getElementById("TimeBlack")
|
||||
let black_move_left = document.getElementById("MoveLeftBlack")
|
||||
let white_move_left = document.getElementById("MoveLeftWhite")
|
||||
let BlockType = document.getElementById("BlockType")
|
||||
let BlockTime = document.getElementById("BlockTime")
|
||||
let trais = true
|
||||
|
||||
|
||||
function msToMinSec(ms) {
|
||||
const totalSeconds = Math.floor(ms / 1000);
|
||||
const minutes = Math.floor(totalSeconds / 60);
|
||||
const seconds = totalSeconds % 60;
|
||||
|
||||
return `${minutes}:${seconds.toString().padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
function toggle_trais(){
|
||||
trais = !trais
|
||||
if (trais){
|
||||
showGlowRight()
|
||||
}else{
|
||||
showGlowLeft()
|
||||
}
|
||||
}
|
||||
|
||||
function change_move_left_white(number){
|
||||
white_move_left.innerText = `Coup restant Blanc : ${number}`
|
||||
}
|
||||
|
||||
function change_move_left_black(number){
|
||||
black_move_left.innerText = `Coup restant Noire : ${number}`
|
||||
}
|
||||
|
||||
function change_time_block(Time){
|
||||
BlockTime.innerText = `temps restant Block : ${msToMinSec(Time)}`
|
||||
}
|
||||
|
||||
function set_block_type(type){
|
||||
// true = +
|
||||
// false = -
|
||||
if (type){
|
||||
BlockType.innerText = "Block +"
|
||||
}else{
|
||||
BlockType.innerText = "Block -"
|
||||
}
|
||||
}
|
||||
|
||||
function change_time_white(Time){
|
||||
white_time.innerText = msToMinSec(Time)
|
||||
}
|
||||
|
||||
function change_time_black(Time){
|
||||
black_time.innerText = msToMinSec(Time)
|
||||
}
|
||||
white.addEventListener("pointerdown", () => {
|
||||
if (!trais) white.classList.add("click");
|
||||
if (!has_start) start()
|
||||
else white_touch()
|
||||
});
|
||||
white.addEventListener("pointerup", () => {
|
||||
white.classList.remove("click");
|
||||
});
|
||||
|
||||
black.addEventListener("pointerdown", () => {
|
||||
if (trais )black.classList.add("click");
|
||||
black_touch()
|
||||
});
|
||||
black.addEventListener("pointerup", () => {
|
||||
black.classList.remove("click");
|
||||
});
|
||||
|
||||
function showGlowLeft() {
|
||||
document.body.classList.remove("glow-right");
|
||||
document.body.classList.add("glow-left");
|
||||
}
|
||||
|
||||
function showGlowRight() {
|
||||
document.body.classList.remove("glow-left");
|
||||
document.body.classList.add("glow-right");
|
||||
}
|
||||
|
||||
function hideGlow() {
|
||||
document.body.classList.remove("glow-left", "glow-right");
|
||||
}
|
||||
1
www/js/appload.js
Normal file
1
www/js/appload.js
Normal file
@@ -0,0 +1 @@
|
||||
show_scene("Clock");
|
||||
102
www/js/backend.js
Normal file
102
www/js/backend.js
Normal file
@@ -0,0 +1,102 @@
|
||||
|
||||
let White = {
|
||||
moveLeft : 0,
|
||||
Time : 0,
|
||||
TimeStartMove : 0
|
||||
}
|
||||
|
||||
let Black = {
|
||||
moveLeft : 0,
|
||||
Time : 0,
|
||||
TimeStartMove : 0
|
||||
}
|
||||
let has_start = false
|
||||
|
||||
Block = {
|
||||
Type : false,
|
||||
Time : 0,
|
||||
last_time : 0
|
||||
}
|
||||
|
||||
config = {
|
||||
StartTime : 600000,
|
||||
StartMoveLeft : 8,
|
||||
BlockTime : 180000,
|
||||
last_block : true
|
||||
}
|
||||
|
||||
inizalize_clock()
|
||||
|
||||
function inizalize_clock(){
|
||||
toggle_trais()
|
||||
White.Time = config.StartTime
|
||||
White.moveLeft = config.StartMoveLeft
|
||||
Black.Time = config.StartTime
|
||||
Black.moveLeft = config.StartMoveLeft
|
||||
Block.Time = config.BlockTime
|
||||
Block.Type = !config.last_block
|
||||
|
||||
change_move_left_black(Black.moveLeft)
|
||||
change_move_left_white(White.moveLeft)
|
||||
change_time_black(Black.Time)
|
||||
change_time_white(White.Time)
|
||||
change_time_block(Block.Time)
|
||||
}
|
||||
|
||||
function start(){
|
||||
White.TimeStartMove = Date.now()
|
||||
Black.TimeStartMove = Date.now()
|
||||
Block.last_time = Date.now()
|
||||
update()
|
||||
has_start = true
|
||||
}
|
||||
|
||||
function load_cube_scene(){
|
||||
hide_scene("Clock")
|
||||
hideGlow()
|
||||
show_scene("Cube")
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function white_touch(){
|
||||
if (trais) return null
|
||||
if (!has_start) return null
|
||||
toggle_trais()
|
||||
Black.TimeStartMove = Date.now()
|
||||
White.moveLeft -= 1
|
||||
change_move_left_white(White.moveLeft)
|
||||
}
|
||||
|
||||
function black_touch(){
|
||||
if (!trais) return null
|
||||
if (!has_start) return null
|
||||
toggle_trais()
|
||||
White.TimeStartMove = Date.now()
|
||||
Black.moveLeft -= 1
|
||||
change_move_left_black(Black.moveLeft)
|
||||
if (Black.moveLeft == 0){
|
||||
load_cube_scene()
|
||||
}
|
||||
}
|
||||
function update() {
|
||||
|
||||
if (!trais) {// trais au blanc
|
||||
White.Time -= (Date.now() - White.TimeStartMove)
|
||||
White.TimeStartMove = Date.now()
|
||||
}else{
|
||||
Black.Time -= (Date.now() - Black.TimeStartMove)
|
||||
Black.TimeStartMove = Date.now()
|
||||
}
|
||||
Block.Time -= (Date.now() - Block.last_time)
|
||||
Block.last_time = Date.now()
|
||||
if (Block.Time <= 0){
|
||||
load_cube_scene()
|
||||
}
|
||||
|
||||
change_time_white(White.Time)
|
||||
change_time_black(Black.Time)
|
||||
change_time_block(Block.Time)
|
||||
requestAnimationFrame(update);
|
||||
}
|
||||
13
www/js/scene.js
Normal file
13
www/js/scene.js
Normal file
@@ -0,0 +1,13 @@
|
||||
let last_scene = ""
|
||||
|
||||
function show_scene(name){
|
||||
scene = document.getElementById("scene" + name);
|
||||
console.log(scene)
|
||||
last_scene = name
|
||||
scene.style.display = "block";
|
||||
}
|
||||
|
||||
function hide_scene(name){
|
||||
scene = document.getElementById("scene" + name);
|
||||
scene.style.display = "none";
|
||||
}
|
||||
15
www/manifest.json
Normal file
15
www/manifest.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "Mon Timer",
|
||||
"short_name": "Timer",
|
||||
"start_url": "index.html",
|
||||
"display": "standalone",
|
||||
"background_color": "#000000",
|
||||
"theme_color": "#000000",
|
||||
"icons": [
|
||||
{
|
||||
"src": "icon.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user