var alarm_counter = -1; var digit_to_name = 'zero one two three four five six seven eight nine'.split(' '); var digits = {}; var positions = ['h1', 'h2', ':', 'm1', 'm2', ':', 's1', 's2']; var digit_holder = document.querySelector('#clock .digits');
for (let i = 0; i < positions.length; i++) { if (positions[i] == ':') { var dots = document.createElement('div'); dots.className = 'dots' digit_holder.appendChild(dots) } else {
var pos = document.createElement('div');
for (let j = 1; j < 8; j++) { var span = document.createElement('sapn'); span.className = 'd'+j pos.appendChild(span) }
// Set the digits as key:value pairs in the digits object digits[positions[i]] = pos;
// Add the digit elements to the page digit_holder.append(pos); } }
var weekday_names = '周日 周一 周二 周三 周四 周五 周六'.split(' '), weekday_holder = document.querySelector('#clock .weekdays'); var dow = new Date().getDay(); for (let i = 0; i < weekday_names.length; i++) { var span = document.createElement('sapn'); span.innerText = weekday_names[i] span.className = 'weekday_name' // span.style = 'opacity:0.2;padding:0 10px;'; if (i == dow) { span.className = 'weekday_name active' span.style = 'opacity:1;'; } weekday_holder.appendChild(span); }
var weekdays = document.querySelector('#clock .weekdays').children;
update_time()
function update_time() { // var now = moment().format("hhmmssdA"); var h = new Date().getHours(); var m = new Date().getMinutes(); var s = new Date().getSeconds(); var now = (h>10?h:'0'+h) +''+(m>10?m:'0'+m) +''+ (s>10?s:'0'+s);
if (alarm_counter > 0) { alarm_counter--; } else if (alarm_counter == 0) { alarm_counter--; } // Schedule this function to be run again in 1 sec setTimeout(update_time, 1000); } })()