Skip to content

Instantly share code, notes, and snippets.

@aditagusta
Created February 3, 2021 04:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aditagusta/2737b1f2d879a9052fca1539b570b845 to your computer and use it in GitHub Desktop.
Save aditagusta/2737b1f2d879a9052fca1539b570b845 to your computer and use it in GitHub Desktop.
Hak Akses Web dibatasi Oleh Waktu
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