Hi,
I have the source webserver running and I have a powerfailure script which checks every minute if a plug comes online. If this happens the script turns off some of the scripts. This works perfect.
Now, I want to turn off/on some plugs based on sunrise /sunset times. I found a javascript which calculates these times and put the sunrise and sunset time in a javascript variable. Now it seems impossible for me to get these variables into the plugwise scripting environment.
So, is it possible to assign variables set in javascript to the plugwise scripting environment?
Some examples would help.
scripting
Re: scripting
In the www folder there is a script called SunRiseSunSet.pte
Dont know what it does, but by the name it should do the job.
Never tryed it myself.
Dont know what it does, but by the name it should do the job.
Never tryed it myself.
Re: scripting
Yes, I know, I have looked at it. The script basically gets the Sun rise / sun set time from a table from website for given date. It then echos it on the web page.In the www folder there is a script called SunRiseSunSet.pte
However, I would prefer not to fetch the sun rise and sun set times from an extern web site. I already have the calculation at hand in a javascript.
I have googled a bit and it seems to be problematic as javascript is executed at the client side and the scripting of plugwise source site is at the server side.
What I did is making an html page with the javascript and call a pte script at the server side. This sort of works.
testsunrise.html:
Code: Select all
<script type='text/javascript'>
/* a lot of lines of code, eventually giving sun_rise and sun_set times
*/
/*call server script and give sun_rise and sun_set as variables
*/
window.location.href = "http://localhost:8089/testsunrise.pte?sun_rise=" + sun_rise + "&sun_set=" + sun_set;
</script>
testsunrise.pte
Code: Select all
<%
$sun_rise=Request.Get["sun_rise"]
$sun_set= Request.Get["sun_set"]
$t = System.Time;
$d = System.Date;
echo "current date: ", $d, '<br>'
echo "current time: ", $t, '<br>'
echo "sunrise: ", $sun_rise, "sunset: ", $sun_set, '<br>'
if $t>$sun_set
echo "later than ", $sun_set
/if
%>
<script type='text/javascript'>
setInterval('redirect()',10000)
function redirect()
{
window.location.href = "http://localhost:8089/testsunrise.html"
}
</script>
But is this really the way to go or are there other solutions?
Are there any practical scripts and examples out there? I have studied the example source web site which does al kinds of tricks with ajax and javascript but this was too complex for me.
Would love to see what others have done with scripting and would appreciate any pointers.
Re: scripting
Same problem here... I reverted back to the nON beta release. Im not using the smile anymore so no need for the beta.!!!!!!!!!!!!!!!!!!!!!!!
We offer best quality Certkiller ccnp route pdf test papers and ccie a+ practice 220-801 exam