You are not logged in.

Announcement

Forum database was corrupt and an old backup was restored as temporary replacement. Registrations closed until the database is recovered. Please ask questions using the Contact form

#1 14-11-2013 11:27:37

deci0
Contributors
Registered: 30-08-2013
Posts: 26

Dynamic clock in a Tile

Hi all,

I try to find a way to insert a dynamic clock in a tile. For the moment, I found a solution to put it in the header of index.php, by putting a javascript code and call it with <div> tag.

This is my code :

[== Undefined ==]
<script language="javascript">
function clock()
{

    today = new Date();

	var hour = today.getHours();
	var mins = today.getMinutes();

	if (hour < 10)
	{
		hour = "0" + hour;
	}
	if (mins < 10)
	{
		mins = "0" + mins;
	}
 
    time = hour+":"+mins;
 
    setTimeout("clock()", 1000);
 
    document.getElementById("clock").innerHTML = time;
}

clock();
</script>

... and this is the <div> I used to insert the clock in the header of my index.php file :

[== Undefined ==]
<div id="clock">&nbsp;</div>

Well, could someone help me to make it works in a tile ?

This is my last attempt ; I put the javascript (mentioned) at the top of my tiles.php file and this is the code of my tile :

[== Undefined ==]
// SELECT DATE LANGUAGE
setlocale(LC_TIME, 'fr_FR.utf8','fra');
$date1 = strftime('%A');
$date2 = strftime('%d');
$date3 = strftime('%B');

$MyFunctionClock = '<div class="clock">'&nbsp;'</div>'; 

$tile[] = array("type"=>"simple","group"=>0,"x"=>2,"y"=>1,"width"=>1,"height"=>1,"background"=>"rgba(60, 60, 60, 0.0)","url"=>"",

	"title"=>"<span class='clock' style='font-size:32px;'>$MyFunctionClock</span>",

	"text"=>"<span style='font-size:18px;'>$date1<br> $date2 $date3",

	"img"=>"","imgSize"=>"","imgToTop"=>"","imgToLeft"=>"",

	"labelText"=>"","labelColor"=>"","labelPosition"=>"bottom",
	"classes"=>"");

By the way, the tile shows this result :

,`ap
jeudi
14 novembre

... not really I expected (the first line) !

Please, I need your kind help !

Thanks in advance,

Decio

Offline

Board footer

Powered by FluxBB