Accueil/class/ClockAdvanced.php

37 lines
959 B
PHP
Raw Normal View History

2010-09-20 10:44:44 +02:00
<?php
class clockAdvanced {
public static $paramsList = array(
'visibility',
'x',
'y',
'fontFamily',
'fontSize',
'format',
'color'
);
public $params = array();
public function __construct($params){
$this->setParams($params);
echo '<script type="text/javascript" src="js/jquery.jclockAdvanced.js"></script>';
echo '<div class="jclockAdvanced" id="clockAdvanced" style="left:'.$params['x'].'; top:'.$params['y'].';"></div>';
$options = '';
foreach (self::$paramsList as $paramName){
if(isset($this->params[$paramName]))
$options .= $paramName.' : '.$this->params[$paramName].',';
}
echo '<script>$(document).ready(function(){
$(\'.jclockAdvanced\').jclock({'.substr($options,0,-1).'});
});
</script>';
}
private function setParams($params){
$this->params = $params;
}
public static function start($params){
$clockAdvanced = new clockAdvanced($params);
}
}