// Version 4.4 "use strict"; var days = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334], b_seconds_old = -1, lept_hand, minute_hand, second_hand, string; function draw_analogue_clock() { var angle = 0.0, arc = Math.PI / 2.0, canvas, centre = 125, colour = "#000000", cos, end_x, end_y, face_line, i, j, max = 4, pin, radius = 100, shrad = radius - 8, sin, start_x, start_y, twice = centre << 1; document.writeln('
'); canvas = new Raphael("clock_id", twice, twice); for (i = 0; i < 5; i++) { if (i > 0) { if (i > 1) { arc /= 2.0; max <<= 1; } angle = arc / 2.0; } for (j = 0; j < max; j++) { cos = Math.cos(angle); sin = Math.sin(angle); angle += arc; start_x = centre + Math.round(shrad * cos); start_y = centre + Math.round(shrad * sin); end_x = centre + Math.round(radius * cos); end_y = centre + Math.round(radius * sin); face_line = canvas.path("M" + start_x + " " + start_y + "L" + end_x + " " + end_y); face_line.attr({ "stroke": colour, "stroke-width": 1 }); } shrad++; } string = "M" + centre + " " + centre + "L" + centre + " "; lept_hand = canvas.path(string + "195"); lept_hand.attr({ "stroke": colour }); minute_hand = canvas.path(string + "210"); minute_hand.attr({ "stroke": colour }); second_hand = canvas.path(string + "216"); second_hand.attr({ "stroke": colour }); pin = canvas.circle(centre, centre, 2); pin.attr({ "stroke": colour }); string = "," + centre + "," + centre; } function update_clocks() { var now = new Date(), g_hours = now.getHours(), g_minutes = now.getMinutes(), g_seconds = now.getSeconds(), g_millisecs = now.getMilliseconds(), b_seconds = Math.round((g_hours * 3600 + g_minutes * 60 + g_seconds + g_millisecs / 1000.0) / 0.32958984375), g_year = now.getFullYear(), g_month = now.getMonth(), g_day = now.getDate(), b_day = (g_year % 4 === 0 && g_month > 1) ? g_day + days[g_month] : g_day + days[g_month] - 1, o_seconds = b_seconds.toString(8), t_seconds, d_seconds, g_time; if (b_seconds_old !== b_seconds) { b_seconds_old = b_seconds; o_seconds = "000000".substr(0, 6 - o_seconds.length) + o_seconds; document.getElementById('octal').value = g_year.toString(8) + "," + b_day.toString(8) + "." + o_seconds; t_seconds = b_seconds.toString(4); t_seconds = "000000000".substr(0, 9 - t_seconds.length) + t_seconds; document.getElementById('tetral').value = g_year.toString(4) + "," + b_day.toString(4) + "." + t_seconds; d_seconds = b_seconds.toString(2); d_seconds = "000000000000000000".substr(0, 18 - d_seconds.length) + d_seconds; document.getElementById('dual').value = g_year.toString(2) + "," + b_day.toString(2) + "." + d_seconds; g_month++; if (g_month < 10) { g_month = "0" + g_month; } if (g_day < 10) { g_day = "0" + g_day; } if (g_hours < 10) { g_hours = "0" + g_hours; } if (g_minutes < 10) { g_minutes = "0" + g_minutes; } if (g_seconds < 10) { g_seconds = "0" + g_seconds; } g_time = g_day + "." + g_month + "." + g_year + " " + g_hours + ":" + g_minutes + ":" + g_seconds; document.getElementById('greg').value = g_time; lept_hand.transform("r" + Math.round(b_seconds * 0.001373291015625) + string); minute_hand.transform("r" + Math.round(b_seconds % 4096 * 0.087890625) + string); second_hand.transform("r" + Math.round(b_seconds % 64 * 5.625) + string); } setTimeout('update_clocks();', 100); } function write_form() { var date, expression; document.writeln(''); draw_analogue_clock(); update_clocks(); document.writeln('