I have a slider which is sending its value to a web server by using the following line of code:
window.location = "http://172.20.2.1:83/trigger/1?" + value;
This code is within my TestSlider(value) function which is called from the onchange event from a range.
The problem is, of course when I move the slider, I am sending vast amounts of data to the web server.
I would like to create a buffer which sends the most recent value. I have created a timer function which for the moment I am happy for it to tick once a second. It should take the public variable Value and just for the moment write it to the log.
The problem I am seeing however is that it is still writing massive amounts of data to the log, so it will of course crash my web server.
Here is my javascript:
//Put a timer in to work as buffer. This should stop the lpc crashing. I think its
//as a result of to much data.
var c=0;
var t;
var timer_is_on=0;
// Holy Smoke Hacked...liked a pro!
calculateHost();
var ip = getControllerIP();
var triggerNumber = 1;
var Value;
function timedCount()
{
//console.log("Timer Ticked: " + c + "URL : " + url); //Write tick value and url to log.
c=c+1; //Add 1 to tick value.
t=setInterval("timedCount()",10000); //Set the old interval.
console.log(c);
}
function doTimer()
{
timer_is_on=1;
timedCount();
}
function testSlider(value)
{
var url = (ip + "/trigger/" + triggerNumber + "?" + value);
//Removed because its it would be better to see when the timer is executing.
//console.log(url);
Value = value;
//Removed because we need a buffer.
//window.location = "http://172.20.2.1:83/trigger/1?" + value;
}