///////////////////////////////////////////////////////////
// Avoid PHP code here. So we can use this very intelligent
// script outside of Joomla! framework with a minimum of
// effort.
/** The id of clock 'div'. */
var CLOCK_DIV_ID = "clock";
/** The clock number width (in em). */
var CLOCK_NUMBER_WIDTH = "1.7em";
///////////////////////////////////////////////////////////
// The following parameters are user specific.
/** Font family used by the clock. */
var fontFamily = "verdana, helvetica, arial, sans-serif";
/** Font size used by the clock. */
var fontSize = "10px";
/** Colour of clock numbers. */
var colnumbers = "#000000";
/** Colour of hour watch hand. */
var colhours = "#000000";
/** Colour of minute watch hand. */
var colminutes = "#000000";
/** Colour of second watch hand. */
var colseconds = "#000000";
/** The clock width. In the current implementation it equals the height. */
var width = 80;
/**
* The numbers style chosen for this clock.
* This is an index in clocknum array object.
*/
var numstyle = 0;
//
///////////////////////////////////////////////////////////
/**
* Common or default clock style.
*
* Do not forget to close this with a semicolon ';'. *
*/ var comstyle = "position:absolute;top:0px;left:0px;visibility:hidden;"; /** Length of second hand. */ var secln = width / 2; /** Length of minute hand. */ var minln = width / 2; /** * Length of hour hand. ** Just a bit smaller than second resp. minute hand. *
*/ var hourln = width / 3; /** The clock numbers style. '·' stands for 'middle dot'. */ var clocknum = [ ['','1','2','3','4','5','6','7','8','9','10','11','12'], ['','I','II','III','IIII','V','VI','VII','VIII','IX','X','XI','XII'], ['','·','·','-','·','·','|','·','·','-','·','·','||'] ]; /** Convenience variable which containsMATH.PI. */
var pi = Math.PI;
/** Convenience variable which contains MATH.PI / 2. */
var pi2 = pi / 2;
/**
* The offset is computed on-the-fly. This a clock number box width divided by 2.
* * As the clock number box width is given in em, we let the navigator to make * the conversion in px. *
*/ var offset; /** The clock y-coordinate offset. By default, this value is zero. */ var dy = 0; /** The clock x-coordinate offset. By default, this value is zero. */ var dx = 0; /** * Sets current width. * By doing so, udpatesminln, hourln and secln
* as well.
*/
function setWidth(width) {
this.width = width;
secln = minln = width / 2;
hourln = width / 3;
}
/**
* Returns a suitable time for given Date. Returned array has following
* format: [hour, minute, second].
*/
function getTime(time) {
var second = time.getSeconds();
var minute = time.getMinutes();
var hour = time.getHours();
return [hour, minute, second];
}
/**
* Creates 12 'div' elements inside the element 'datehour' for the clock numbers.
* * Created elements have an index of z-index of 1000 (the bigger the number is, the more ahead the element lies). *
*/ function createClockNumbers() { var clockDiv = document.getElementById(CLOCK_DIV_ID); var innerHTML = ''; for (var i = 1; i < 13; i++) { innerHTML += 'CLOCK_DIV_ID. */
function setParentDimension() {
var clockDiv = document.getElementById(CLOCK_DIV_ID);
clockDiv.style.width = width + offset[0] + "px";
clockDiv.style.height = width + offset[1] + "px";
}
/**
* This is the main method. Creates the clock but does not update it.
*
* To do so, you have to call updateClock().
*
offset.
displayClock();
setParentDimension();
}