Hi, I am currently about to use Javascript code to show a website viewer one of two pages depending on whether it is daytime or nightime (This is simply to switch between a day webcam and a nightvision one)

I can do this using the time of day (As per the code below) but this isn't a great solution for a number of reasons. What I really want to do is use the values of 'Sunrise' and 'Sunset' generated from either your excellent module, or an external site such as Weather.com.

My question is do you know if it is possible to use this data from your module within my javascript please?

(I know this is probably an unusual request!)

Many thanks

Adrian

<script language="javascript">
<!-- 
var now = new Date();
var hour = now.getHours();
if (hour < 8)  {document.write('before 8am - show night cam');}
if (hour >= 8)  {document.write('between 8am-9pm - show day cam');}
if (hour >= 21)  {document.write('after 9pm - show night cam');}
// -->
</script>

Comments

adriancollins’s picture

Category: task » support
toddy’s picture

Hi Adrian,

I currently do not know an option to use the sunrise and sunset times from the Weather module within your JavaScript code, sorry. However, I'm not too familiar with JavaScript. What exactly do you need? An API? A database field? A PHP array? Any other structure?

Regards,
Tobias

adriancollins’s picture

Hi Tobias,

Thanks for your reply, the short answer is I'm not sure myself at this stage. I'm going to post this on a javascript forum instead and go from there. I know its possible but I will probably have to use part of a script from Weather.com or something similar instead.

Thanks again

Adrian

toddy’s picture

Assigned: Unassigned » toddy
Status: Active » Closed (fixed)