// Version 4.4 "use strict"; /*global Raphael*/ 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() { // Draw octal analogue clock face 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; // Create canvas and draw lines 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++; } // Draw hands and pin 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() { // Get time and compute binary seconds 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; // 0.32958984375 = 24 * 60^2 / 64^3 // Compute, format and output different new clocks if binary seconds changed 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; // Compute, format and output Gregorian clock 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; // Rotate hands of analogue clock lept_hand.transform("r" + Math.round (b_seconds * 0.001373291015625) + string); // 0.001373291015625 = 360 / 64^3 minute_hand.transform("r" + Math.round (b_seconds % 4096 * 0.087890625) + string); // 0.087890625 = 360 / 64^2 = 360 / 4096 second_hand.transform("r" + Math.round (b_seconds % 64 * 5.625) + string); // 5.625 = 360 / 64 } // Update clocks only every 100 milliseconds setTimeout('update_clocks();', 100); } function write_form() { // Build form for clocks var date, expression; document.writeln('

'); document.writeln('
'); document.writeln('
'); document.writeln('
'); // Draw analogue clock and updates all clocks draw_analogue_clock(); update_clocks(); // Build form for date conversion document.writeln('
'); document.writeln('
'); document.writeln('
'); // Check date if (window.location.href.lastIndexOf('date=') > 0) { expression = /(^[\w\W]*date=([\w\W]*)$)/g; if (expression.test(window.location.href)) { expression.exec(window.location.href); date = RegExp.$1; expression = /(^(0[1-9]|[1-3]\d)\.(0[1-9]|1[0-2])\.([1-3]\d{3})$)/g; if (expression.test(date)) { document.getElementById('date').value = date; } } window.document.forms[1].scrollIntoView(true); } } function convert_date() { // Initialise arrays and regular expression for date var i, inc, j, number = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], weekday = ["Sonntag", "Erdtag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"], months = ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"], value = document.getElementById('date').value, expression = /(0[1-9]|[1-3]\d)\.(0[1-9]|1[0-2])\.([1-3]\d{3})/g, cell, date, day, month, week, year, o_mon, Window; // Apply regular expression and check date if (expression.test(value)) { expression.exec(value); date = RegExp.$3 + RegExp.$2 + RegExp.$1; day = Number (RegExp.$1); month = Number (RegExp.$2) - 1; year = Number (RegExp.$3); inc = (year % 4 === 0 ) ? (year % 400 !== 0 && year % 100 === 0 ) ? 0 : 1 : 0; if (date >= '15821015' && (day <= number[month] || (month === 1 && day <= number[month] + inc))) { day += (month > 1 ) ? days[month] + inc : days[month]; o_mon = --day >> 5; // Open window and write results in table only if date is valid Window = window.open("https://hosting131729.a2e22.netcup.net/wp-content/bh_de_octal_calendar.html", "Window1", "width=400, height=400, left=600, top=250, resizable=yes"); Window.focus(); Window.document.writeln(''); Window.document.writeln(''); Window.document.writeln(''); Window.document.writeln(''); Window.document.writeln('"); Window.document.writeln('Oktalkalender'); Window.document.writeln(''); Window.document.writeln(''); Window.document.writeln(''); Window.document.writeln(''); Window.document.writeln(''); Window.document.writeln(''); Window.document.writeln(''); Window.document.writeln(''); Window.document.writeln(''); Window.document.writeln('\n\n
'); Window.document.writeln('\n'); Window.document.writeln(''); // Write four weeks, each with eight days for (j = 0; j < 4; j++) { week = ((o_mon << 2 ) + j). toString (8); Window.document.writeln(''); } Window.document.writeln('\n\n'); for (i = 0; i < 8; i++) { Window.document.writeln(''); for (j = 0; j < 4; j++) { cell = ( o_mon << 5 ) + ( j << 3 ) + i; if (cell === day) { Window.document.writeln(''); } else { if (cell < 365 + inc) { Window.document.writeln(''); } else { Window.document.writeln(''); } } } Window.document.writeln(''); } Window.document.writeln('
' + months[o_mon] + "
" + year. toString ( 8 ) + '
' + "Woche
" + week + '
' + weekday[i] + '' + "→" + cell. toString ( 8 ) + "←" + '' + cell. toString ( 8 ) + ' 
\n

'); Window.document.writeln('
'); Window.document.forms[0].close.focus(); } else { alert("Das Datum ist leider nicht gültig."); } } else { alert("Das Datum ist leider nicht gültig."); } } write_form();