Jump to content

Clock and slideshow


qbox

Recommended Posts

Hi there

I use a little clock JS to show the clock on the page.

The code for this script is here

 

function Calendar(m, y, cM, cH, cDW, cD, brdr){
var mn=['Януари','Февруари','Март','Април','Май','Юни','Юли','Август','Септември','Октомври','Ноември','Декември'];
var dim=[31,0,31,30,31,30,31,31,30,31,30,31];

var oD = new Date(y, m-1, 1);
oD.od=oD.getDay()+1;

var todaydate=new Date()
var scanfortoday=(y==todaydate.getFullYear() && m==todaydate.getMonth()+1)? todaydate.getDate() : 0

dim[1]=(((oD.getFullYear()%100!=0)&&(oD.getFullYear()%4==0))||(oD.getFullYear()%400==0))?29:28;
var t='<div class="'+cM+'"><table class="'+cM+'" cols="7" cellpadding="0" border="'+brdr+'" cellspacing="0"><tr align="center">';
t+='<td colspan="7" align="center" class="'+cH+'"><div id="txt"></div>'+mn[m-1]+' - '+y+'</td></tr><tr align="center">';
for(s=0;s<7;s++)t+='<td class="'+cDW+'">'+"SMTWTFS".substr(s,1)+'</td>';
t+='</tr>';
t+='<tr align="center">';
for(i=1;i<=42;i++){
var x=((i-oD.od>=0)&&(i-oD.od<dim[m-1]))? i-oD.od+1 : ' ';
if (x==scanfortoday)
	x='<span id="today">'+x+'</span>';
t+='<td class="'+cD+'">'+x+'</td>';
if(((i)%7==0)&&(i<36))t+='</tr><tr align="center">';
}	
t+='</table></div>';
t+='<table id="calendar_bottom" width="300">';
t+='</tr>';
t+='<tr>';
t+='<td colspan ="7"> </td>';
t+='</tr>';
return t+='</table>';
}

function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
// add a zero in front of numbers<10
m=checkTime(m);
s=checkTime(s);
document.getElementById('txt').innerHTML=h+":"+m+":"+s;
t=setTimeout('startTime()',500);
}

function checkTime(i)
{
if (i<10)
  {
  i="0" + i;
  }
return i;
}

 

I call this script with this lines from the html

				  <script type="text/javascript">
            		var todaydate=new Date();
            		var curmonth=todaydate.getMonth()+1;
            		var curyear=todaydate.getFullYear();
            		document.write(Calendar(curmonth ,curyear, "main", "month", "daysofweek", "days", 1));
			</script>

 

so I install a JS for slide show and the clock script doesn't work any more.

Here it is the code

var slideshowgap=5

var copyspeed=slidespeed
leftrightslide='<nobr>'+leftrightslide.join(imagegap)+'</nobr>'
var iedom=document.all||document.getElementById
if (iedom)
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">'+leftrightslide+'</span>')
var actualwidth=''
var cross_slide, ns_slide

function fillup(){
if (iedom){
cross_slide=document.getElementById? document.getElementById("test2") : document.all.test2
cross_slide2=document.getElementById? document.getElementById("test3") : document.all.test3
cross_slide.innerHTML=cross_slide2.innerHTML=leftrightslide
actualwidth=document.all? cross_slide.offsetWidth : document.getElementById("temp").offsetWidth
cross_slide2.style.left=actualwidth+slideshowgap+"px"
}
else if (document.layers){
ns_slide=document.ns_slidemenu.document.ns_slidemenu2
ns_slide2=document.ns_slidemenu.document.ns_slidemenu3
ns_slide.document.write(leftrightslide)
ns_slide.document.close()
actualwidth=ns_slide.document.width
ns_slide2.left=actualwidth+slideshowgap
ns_slide2.document.write(leftrightslide)
ns_slide2.document.close()
}
lefttime=setInterval("slideleft()",30)
}
window.onload=fillup

function slideleft(){
if (iedom){
if (parseInt(cross_slide.style.left)>(actualwidth*(-1)+)
cross_slide.style.left=parseInt(cross_slide.style.left)-copyspeed+"px"
else
cross_slide.style.left=parseInt(cross_slide2.style.left)+actualwidth+slideshowgap+"px"

if (parseInt(cross_slide2.style.left)>(actualwidth*(-1)+)
cross_slide2.style.left=parseInt(cross_slide2.style.left)-copyspeed+"px"
else
cross_slide2.style.left=parseInt(cross_slide.style.left)+actualwidth+slideshowgap+"px"

}
else if (document.layers){
if (ns_slide.left>(actualwidth*(-1)+)
ns_slide.left-=copyspeed
else
ns_slide.left=ns_slide2.left+actualwidth+slideshowgap

if (ns_slide2.left>(actualwidth*(-1)+)
ns_slide2.left-=copyspeed
else
ns_slide2.left=ns_slide.left+actualwidth+slideshowgap
}
}


if (iedom||document.layers){
with (document){
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
if (iedom){
write('<div style="position:relative;width:'+sliderwidth+';height:'+sliderheight+';overflow:hidden">')
write('<div style="position:absolute;width:'+sliderwidth+';height:'+sliderheight+';background-color:'+slidebgcolor+'" onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed">')
write('<div id="test2" style="position:absolute;left:0px;top:0px"></div>')
write('<div id="test3" style="position:absolute;left:-1000px;top:0px"></div>')
write('</div></div>')
}
else if (document.layers){
write('<ilayer width='+sliderwidth+' height='+sliderheight+' name="ns_slidemenu" bgColor='+slidebgcolor+'>')
write('<layer name="ns_slidemenu2" left=0 top=0 onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed"></layer>')
write('<layer name="ns_slidemenu3" left=0 top=0 onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed"></layer>')
write('</ilayer>')
}
document.write('</td></table>')
}
}

 

I call this script with this lines in PHP

 

<?php 
	$image = explode( ",", trim($params->get( 'images' )) );
	$url = explode( ",", trim($params->get( 'urls' )) );
	$title = explode( ",", trim($params->get( 'titles' )) );
	?>
	<script language="JavaScript1.2">
	var sliderwidth="<?php echo trim($params->get( 'width' )); ?>px"
	var sliderheight="<?php echo trim($params->get( 'height' )); ?>px"
	var slidebgcolor="<?php echo trim($params->get( 'bgcolor' )); ?>"
	var slidespeed=<?php echo trim($params->get( 'speed' )); ?>

	var imagegap="  "
	var leftrightslide=new Array()
	var finalslide=''
	<?php 
	for($i=0;$i<count($image);$i++)
	{
		$alt =  $title[$i] ? ' alt="'. $title[$i] .'"' : '';

		if ( $params->get( 'linked' ) ) 
		{
			$link =  $url[$i] ? '<a href="'. $url[$i] .'">' : '';
			$link_end =  $url[$i] ? '</a>' : '';
		}

		$templink = $link.'<img src=" trim($params->get( 'folder' ))."/". $image[$i].'" border="0"'.$alt.">".$link_end;
	?>
	leftrightslide[<?php echo $i; ?>]='<?php echo $templink; ?>'
	<?php 
	} 
	?>
	</script>
	<script src="script.js" language="JavaScript1.2"></script>

 

I think that problem is in line

document.getElementById('txt').innerHTML=h+":"+m+":"+s;

from clock script but Im not sure.... can anyone give me some clue how to resolve this problem.....

Thank you.

(sorry for all this codes.... you can delete it if there is a conflict with forum rules)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.