Created
February 3, 2021 04:23
-
-
Save aditagusta/2737b1f2d879a9052fca1539b570b845 to your computer and use it in GitHub Desktop.
Hak Akses Web dibatasi Oleh Waktu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function my_Clock() { | |
this.cur_date = new Date(); | |
this.hours = this.cur_date.getHours(); | |
this.minutes = this.cur_date.getMinutes(); | |
this.seconds = this.cur_date.getSeconds(); | |
} | |
my_Clock.prototype.run = function () { | |
setInterval(this.update.bind(this), 1000); | |
}; | |
my_Clock.prototype.update = function () { | |
this.updateTime(1); | |
// buka aplikasi jam 8 pagi | |
if(this.hours >= 8 && this.hours <= 16 ){ | |
// console.log('buka'); | |
if(this.hours <= 16 && this.minutes <= 59){ | |
// console.log('buka1'); | |
$('#jam_buka').css('display', 'block'); | |
$('#jam_tutup').css('display', 'none'); | |
}else{ | |
// console.log('tutup'); | |
$('#jam_buka').css('display', 'none'); | |
$('#jam_tutup').css('display', 'block'); | |
} | |
}else{ | |
// console.log('tutup1'); | |
$('#jam_buka').css('display', 'none'); | |
$('#jam_tutup').css('display', 'block'); | |
} | |
// console.log(this.hours + ":" + this.minutes + ":" + this.seconds); | |
}; | |
my_Clock.prototype.updateTime = function (secs) { | |
this.seconds += secs; | |
if (this.seconds >= 60) { | |
this.minutes++; | |
this.seconds = 0; | |
} | |
if (this.minutes >= 60) { | |
this.hours++; | |
this.minutes = 0; | |
} | |
if (this.hours >= 24) { | |
this.hours = 0; | |
} | |
}; | |
var clock = new my_Clock(); | |
clock.run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment