News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

World Clock

Started by TheListener, March 09, 2012, 07:56:57 PM

Previous topic - Next topic

kat

Odd. It keeps telling that there's a syntax error with this line:

document.write('<span id="worldclock" style="font:bold 16px Arial;"></span><br>')

Bit odd, coz it works on my 1.1.16 forum.

I'm fiddlin'...

TheListener

QuoteI'm fiddlin'...

:-X

kat

If it helps...

If you put the code at the very top of the page, before even the opening php tag, it shows at the top of the page, on the left.

http://playing.twaddlehosting.co.uk/index.php

TheListener


Parse error: syntax error, unexpected ':' in /home/playing/public_html/Themes/PixelBreasts/index.template.php on line 69


All I saw was the error.

kat

Sorry. Been having hassles with the damned FTP client...

Gimme a while to figure that out.

kat

FFS... This is the kind of thing that makes me sooooooo glad that I've never "upgraded" to v2 of SMF.

I can put that code in all sorts of places, with v1, and it works.

I've tried loads of places with v2 and I keep getting errors.

Thing is, the errors are shown as being miles away from where I put the code.

I just put it at the top and it's telling me there's an error on line 506!!

I really abhor v2.

I'll keep fiddling, though.

* K@ goes to get a chainsaw...

kat

Right...

If you make this a file of it's own:


<div style = "text-align: center;">
<form name="where">
<select name="city" size="1" onchange="updateclock(this);">
<option value="" selected>Local time</option>
<option value="0">London GMT</option>
<option value="+2">Amsterdam</option>
<option value="7">Bangkok</option>
<option value="-3">Buenos Aires</option>
<option value="-5">Chicago</option>
<option value="+2">Dordrecht</option>
<option value="12">Fiji</option>
<option value="-10">Hawaii</option>
<option value="8">Hong Kong</option>
<option value="-4">New York</option>
<option value="+8">Perth</option>
<option value="2">Rome</option>
<option value="-7">San Francisco</option>
<option value="11">Sydney</option>
<option value="9">Tokyo</option>
</select>

<script language="JavaScript">

/*
Drop Down World Clock- By JavaScript Kit (http://www.javascriptkit.com)
Portions of code by Kurt @ http://www.btinternet.com/~kurt.grigg/javascript
This credit notice must stay intact
*/

if (document.all||document.getElementById)
document.write('<span id="worldclock" style="font:bold 16px Arial;"></span><br>')

zone=0;
isitlocal=true;
ampm='';

function updateclock(z){
zone=z.options[z.selectedIndex].value;
isitlocal=(z.options[0].selected)?true:false;
}

function WorldClock(){
now=new Date();
ofst=now.getTimezoneOffset()/60;
secs=now.getSeconds();
sec=-1.57+Math.PI*secs/30;
mins=now.getMinutes();
min=-1.57+Math.PI*mins/30;
hr=(isitlocal)?now.getHours():(now.getHours() + parseInt(ofst)) + parseInt(zone);
hrs=-1.575+Math.PI*hr/6+Math.PI*parseInt(now.getMinutes())/360;
if (hr < 0) hr+=24;
if (hr > 23) hr-=24;
ampm = (hr > 11)?"PM":"AM";
statusampm = ampm.toLowerCase();

hr2 = hr;
if (hr2 == 0) hr2=12;
(hr2 < 13)?hr2:hr2 %= 12;
if (hr2<10) hr2="0"+hr2

var finaltime=hr2+':'+((mins < 10)?"0"+mins:mins)+':'+((secs < 10)?"0"+secs:secs)+' '+statusampm;

if (document.all)
worldclock.innerHTML=finaltime
else if (document.getElementById)
document.getElementById("worldclock").innerHTML=finaltime
else if (document.layers){
document.worldclockns.document.worldclockns2.document.write(finaltime)
document.worldclockns.document.worldclockns2.document.close()
}


setTimeout('WorldClock()',1000);
}

window.onload=WorldClock
//-->
</script>

<!--Place holder for NS4 only-->
<ilayer id="worldclockns" width=100% height=35><layer id="worldclockns2" width=100% height=35 left=0 top=0 style="font:bold 16px Arial;"></layer></ilayer>
</form>
</div>


and save it to the root of your site, then put this as the second line of index.template.php, after <?php:

require 'banner.php';

It looks like this:

http://playing.twaddlehosting.co.uk (It's at the very top).

TheListener

Thanks K@

I moved it to where the usual clock would normally be.

Just needs to be moved to the right slightly then it will be perfect.

kat

I'm sure a man of your talents will figure that one out.

I'm on a high, after watching Chelsea beat Napoli. So, I'm not gonna be much use for the rest of the night.

Unless the wife wants to help me celebrate, of course. ;)

TheListener

Quote from: K@ on March 14, 2012, 06:17:50 PM
I'm sure a man of your talents will figure that one out.

QuoteI'm on a high, after watching Chelsea beat Napoli. So, I'm not gonna be much use for the rest of the night.

Nothing better to watch on tv?

Unless the wife wants to help me celebrate, of course. ;)

Night on the town?

Isn't it past ya bedtime?

This should go to tips n Tricks for 2.0.2

kat


TheListener

Sure did.

Is under the user info top right.

kat

Ah. Not for guest viewing, then.

That explains why I didn't see it.

Glad you got it figured, matey!

TheListener

Quote from: K@ on March 15, 2012, 03:34:10 PM
Ah. Not for guest viewing, then.

That explains why I didn't see it.


Didn't think of that.

Advertisement: