Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

add new project#7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletionsprojects/countdown-timer/app.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
var button = document.getElementById("button");
const input = document.querySelectorAll(".select");

button.addEventListener('click', ()=> {
var enterDate = document.getElementById("enterDate").value;
var enterTime = document.getElementById("enterTime").value;

const last = enterDate + " " + enterTime;
const end = new Date(last);

calculate(end);

const myInterval = setInterval(
() => {
calculate(end);
},
1000
)

var stop = document.getElementById("stop");
stop.addEventListener('click', () => {
clearInterval(myInterval);
})
})

const calculate = (end) => {
const now = new Date();

if(end > now)
{
const diff = (end - now)/1000;

// convert into day
var day = Math.floor(diff / (3600 * 24));
input[0].value = day;

// convert into hour
var hour = Math.floor((diff / 3600) % 24);
input[1].value = hour;

// convert into min
var min = Math.floor((diff / 60) % 60);
input[2].value = min;

//convert into sec
var sec = Math.floor(diff % 60);
input[3].value = sec;
}
else
{
input[0].value = 0;
input[1].value = 0;
input[2].value = 0;
input[3].value = 0;
}
}

var reset = document.getElementById("reset");
reset.addEventListener('click', () => {
window.location.reload();
})
58 changes: 58 additions & 0 deletionsprojects/countdown-timer/index.html
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Countdown Timer</title>
<link rel="stylesheet" href="style.css">
</head>

<body>
<p class="title">Countdown Timer</p>
<div class="dateTime">
<table>
<tr>
<td><label for="date">Enter Date:</label></td>
<td> <input type="date" id="enterDate" required></td>
</tr>
<br>
<tr>
<td><label for="date">Enter Time:</label></td>
<td><input type="time" id="enterTime" required></td>
</tr>
</table>

</div>

<button id="button">calculate</button>
<button id="stop">stop</button>
<button id="reset">reset</button>

<div class="container">
<div class="innerContainer" id="day">
<input type="text" class="select" id="day" readonly>
<br>
<p>Day</p>
</div>
<div class="innerContainer" id="hour">
<input type="text" class="select" id="hour" readonly>
<br>
<p>Hour</p>
</div>
<div class="innerContainer" id="min">
<input type="text" class="select" id="min" readonly>
<br>
<p>Minutes</p>
</div>
<div class="innerContainer" id="sec">
<input type="text" class="select" id="sec" readonly>
<br>
<p>Seconds</p>
</div>
</div>
<script src="app.js"></script>
</body>

</html>
79 changes: 79 additions & 0 deletionsprojects/countdown-timer/style.css
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
html
{
height: 100%;
font-weight: bolder;
}

body
{
text-align: center;
background-image: url("https://img.freepik.com/free-photo/neutral-tone-abstract-invitation-card_53876-97500.jpg?w=360&t=st=1678787861~exp=1678788461~hmac=ddf4b178837a6bad7c846053fe79fdfbc1e65bb4e3ee5c298f828b653335b6ed");
background-position: center;
background-repeat: no-repeat;
background-size: 100%;
color:black;
}
table{
margin: auto;
}
tr, td{
text-align: left;
}

.title
{
font-size: 40px;
padding:1rem ;
border: 1px solid #ffdfdd;
}

.dateTime label
{
font-size: 20px;
margin: 10px;
}

.dateTime input
{
font-size: 20px;
margin: 10px;
padding: 5px 10px;
border: 2px solid #ffdfdd ;
background-color: #ffdfdd;
border-radius: 10px;
box-shadow: 3px 3px 3px #307d7e;
}

button
{
margin: 20px 5px;
padding: 5px 10px;
font-size: 20px;
background-color: #ffdfdd;
border: 1px solid #ffdfdd;
box-shadow: 3px 3px 3px #307d7e;
border-radius: 5px;
}

.container
{
display: flex;
justify-content: center;
}

.innerContainer
{
margin: 5px;
}

.innerContainer input
{
height: 8vw;
width: 8vw;
border-radius: 200px;
color: black;
background-color: #ffdfdd;
/* background: transparent; */
text-align: center;
font-size: 5vw;
}

[8]ページ先頭

©2009-2025 Movatter.jp