Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
7 changes: 3 additions & 4 deletions index.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ body {
background-color: #80d4ea;
}

#clock {
div {
height: 100px;
width: 800px;
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;

padding-top: 70px;
font-family: courier, monospace;
text-align: center;
color: white;
font-size: 100px;
font-size: 70px;
}
27 changes: 17 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<title>Clock Tower</title>
<meta charset="utf-8">
<link href="index.css" media="screen" rel="stylesheet" type="text/css"/>
</head>
<head>
<title>Clock Tower</title>
<meta charset="utf-8">
<link href="index.css" media="screen" rel="stylesheet" type="text/css"/>
</head>

<body>
<div id='clock'></div>
</body>
</html>
<body>
<div id='seoul'></div>
<div id='seattle'></div>
<div id='new_york'></div>
<div id='hongkong'></div>
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<script src="index.js"></script>

<script src="index.js"></script>
</body>
</html>
51 changes: 50 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1,50 @@
// Your code here
$(document).ready(function(){

var startTime = function(time_difference){
var today = new Date();
var year = today.getFullYear();
var month = today.getMonth() + 1;
var date = today.getDate();
var h = today.getHours() + time_difference;
if (h >= 24) {
date = date + 1;
h = h - 24;
}
var m = today.getMinutes();
var s = today.getSeconds();
h = checkTime(h);
m = checkTime(m);
s = checkTime(s);
return (year + "/" + month + "/" + date + " " + h + ":" + m + ":" + s);
} ;

var checkTime = function(i) {
if (i < 10) {i = "0" + i};
return i;
};

// var time = startTime()
// $('#clock').append(time);
$('#seoul').append(startTime(16));
$('#seattle').append(startTime(0));
$('#new_york').append(startTime(3)); //call the function and append
$('#hongkong').append(startTime(15));

var liveClock = function(){
// var clock = document.getElementById('clock');
// var clock = $('#clock'); jquery
$('#seoul').html(startTime(16));
$('#seattle').html(startTime(0));
$('#new_york').html(startTime(3));
$('#hongkong').html(startTime(15));
};
setInterval(liveClock, 1000);

});


//
// var checkTime(function(i) {
// if (i < 10) {i = "0" + i};
// return i;
// });