- 4.9k
- 4
- 36
- 54
There is Javascript code on the interface's HTML page which I reckon is making the webpage interactive and defining the behaviour of the page. Firstly, can I send Javascript commands from Python to switch the sockets using the web interface (if I have TCP/IP connection to the server opened from Python.) So, for that I would need to call a Javascript function in a Python shell. How to do that? Secondly, do I need cometcomet in this case, because I need to push Javascript command to a particular IP and port from Python.
There is Javascript code on the interface's HTML page which I reckon is making the webpage interactive and defining the behaviour of the page. Firstly, can I send Javascript commands from Python to switch the sockets using the web interface (if I have TCP/IP connection to the server opened from Python.) So, for that I would need to call a Javascript function in a Python shell. How to do that? Secondly, do I need comet in this case, because I need to push Javascript command to a particular IP and port from Python.
There is Javascript code on the interface's HTML page which I reckon is making the webpage interactive and defining the behaviour of the page. Firstly, can I send Javascript commands from Python to switch the sockets using the web interface (if I have TCP/IP connection to the server opened from Python.) So, for that I would need to call a Javascript function in a Python shell. How to do that? Secondly, do I need comet in this case, because I need to push Javascript command to a particular IP and port from Python.
I have a device precisely, a board of four programmable electric sockets (four to be exact). The device's interface with the pc is through tcpthe TCP/ipIP port. The device has itsa web browser user interface based on default ip, accessible at a local IP address.
There is javascriptJavascript code behindon the htmlinterface's HTML page of the interface which I reckon is making the webpage interactive and defining the behaviour of the page. Firstly, can I send javascriptJavascript commands from python shellPython to switch the sockets using the web interface ( ifif I have tcp ipTCP/IP connection betweento the server and client in python codeopened from Python.) So, for that I would need to call javascripta Javascript function in pythona Python shell. How to do that? secondlySecondly, do I need comet in this case, because I need to push javascriptJavascript command to a particular ipIP and port from pythonPython.
I have a device precisely a board of programmable electric sockets (four to be exact). The device's interface with pc is through tcp/ip port. The device has its web browser user interface based on default ip.
There is javascript code behind the html page of the interface which I reckon is making the webpage interactive and defining the behaviour of the page. Firstly, can I send javascript commands from python shell to switch the sockets ( if I have tcp ip connection between server and client in python code.) So, for that I need to call javascript function in python shell. How to do that? secondly, do I need comet in this case because I need to push javascript command to a particular ip and port from python.
I have a device, a board of four programmable electric sockets to be exact. The device's interface with the pc is through the TCP/IP port. The device has a web browser user interface, accessible at a local IP address.
There is Javascript code on the interface's HTML page which I reckon is making the webpage interactive and defining the behaviour of the page. Firstly, can I send Javascript commands from Python to switch the sockets using the web interface (if I have TCP/IP connection to the server opened from Python.) So, for that I would need to call a Javascript function in a Python shell. How to do that? Secondly, do I need comet in this case, because I need to push Javascript command to a particular IP and port from Python.
and this is the javascript function: function ChangeState(sn){f = document.forms.tForm;ind = sn * 1 - 1;f["cte" + sn].value = Math.abs(1 - sockstates[ind]);f.submit();}function
ActivateDeactivate(){f = document.forms.tForm2;f["activate"].value = actbtn;f.submit();}function TimerFunction(){clearTimeout(timer);if
(trycon==1&&active==1){document.location.href = "xyz.html";}}function StartTimer(){timer = setTimeout(TimerFunction, period);}window.onload =
function (){for(i = 0; i<4; i++){if(sockstates[i]==0){clsname = 'offstate';str1 = 'OFF';str2 = 'ON';}else{clsname = 'onstate';str1 = 'ON';str2 =
'OFF';}strhtml = '' + str1 + ' '
- str2 + '';el = document.getElementById('stCont' + i);el.innerHTML = strhtml;}statA = '';statB = '';statC = '';rmsg = '';if(ipid!=0){statA =
"Registered - ";tmpel = document.getElementById('regBtn');tmpel.innerHTML = 'Login';}else{rmsg = "Register to manage AB-xyz-LAN from Internet (
free service )";}if(active==1){statB = "Activated - ";}else{statB = "Not activated";}if(active==1){if(trycon==1){statC = "Trying to connect";}
else if(serv==1){statC = "Connected";}else if(serv==0){statC = "Not connected";}}statAel = document.getElementById('statusA');statAel.innerHTML =
statA;statBel = document.getElementById('statusB');statBel.innerHTML = statB;statCel = document.getElementById('statusC');statCel.innerHTML =
statC;rmsgel = document.getElementById('regmsg');rmsgel.innerHTML = rmsg;actBtnEl = document.getElementById("actBtn");if(actbtn==1)
{actBtnEl.innerHTML = 'Activate';}else{actBtnEl.innerHTML = 'Deactivate';}regBtnEl = document.getElementById("regBtn");regBtnEl.href =
"http://www.example.com/user/register.aspx?mac=" + mac;if (warn==1) {alert("Failed to connect. Please, check DNS server settings.");}if (warn==2)
{alert("Failed to activate. Please, check, that device is registered.");}StartTimer();}
function ChangeState(sn) {
f = document.forms.tForm;
ind = sn * 1 - 1;
f["cte" + sn].value = Math.abs(1 - sockstates[ind]);
f.submit();
}
function ActivateDeactivate() {
f = document.forms.tForm2;
f["activate"].value = actbtn;
f.submit();
}
function TimerFunction() {
clearTimeout(timer);
if (trycon == 1 && active == 1) {
document.location.href = "xyz.html";
}
}
function StartTimer() { timer = setTimeout(TimerFunction, period); }
window.onload = function() {
for (i = 0; i < 4; i++) {
if (sockstates[i] == 0) {
clsname = 'offstate';
str1 = 'OFF';
str2 = 'ON';
} else {
clsname = 'onstate';
str1 = 'ON';
str2 = 'OFF';
}
strhtml = '<span class="' + clsname + '">' + str1 +
'</span> <a href="javascript: ChangeState(\'' + (i + 1) +
'\')" class="onoffbtn">' + str2 + '</a>';
el = document.getElementById('stCont' + i);
el.innerHTML = strhtml;
}
statA = '';
statB = '';
statC = '';
rmsg = '';
if (ipid != 0) {
statA = "Registered - ";
tmpel = document.getElementById('regBtn');
tmpel.innerHTML = 'Login';
} else {
rmsg = "Register to manage AB-xyz-LAN from Internet ( free service )";
}
if (active == 1) {
statB = "Activated - ";
} else {
statB = "Not activated";
}
if (active == 1) {
if (trycon == 1) {
statC = "Trying to connect";
} else if (serv == 1) {
statC = "Connected";
} else if (serv == 0) {
statC = "Not connected";
}
}
statAel = document.getElementById('statusA');
statAel.innerHTML = statA;
statBel = document.getElementById('statusB');
statBel.innerHTML = statB;
statCel = document.getElementById('statusC');
statCel.innerHTML = statC;
rmsgel = document.getElementById('regmsg');
rmsgel.innerHTML = rmsg;
actBtnEl = document.getElementById("actBtn");
if (actbtn == 1) {
actBtnEl.innerHTML = 'Activate';
} else {
actBtnEl.innerHTML = 'Deactivate';
}
regBtnEl = document.getElementById("regBtn");
regBtnEl.href = "http://www.example.com/user/register.aspx?mac=" + mac;
if (warn == 1) {
alert("Failed to connect. Please, check DNS server settings.");
}
if (warn == 2) {
alert("Failed to activate. Please, check, that device is registered.");
}
StartTimer();
}
and this is the javascript function: function ChangeState(sn){f = document.forms.tForm;ind = sn * 1 - 1;f["cte" + sn].value = Math.abs(1 - sockstates[ind]);f.submit();}function
ActivateDeactivate(){f = document.forms.tForm2;f["activate"].value = actbtn;f.submit();}function TimerFunction(){clearTimeout(timer);if
(trycon==1&&active==1){document.location.href = "xyz.html";}}function StartTimer(){timer = setTimeout(TimerFunction, period);}window.onload =
function (){for(i = 0; i<4; i++){if(sockstates[i]==0){clsname = 'offstate';str1 = 'OFF';str2 = 'ON';}else{clsname = 'onstate';str1 = 'ON';str2 =
'OFF';}strhtml = '' + str1 + ' '
- str2 + '';el = document.getElementById('stCont' + i);el.innerHTML = strhtml;}statA = '';statB = '';statC = '';rmsg = '';if(ipid!=0){statA =
"Registered - ";tmpel = document.getElementById('regBtn');tmpel.innerHTML = 'Login';}else{rmsg = "Register to manage AB-xyz-LAN from Internet (
free service )";}if(active==1){statB = "Activated - ";}else{statB = "Not activated";}if(active==1){if(trycon==1){statC = "Trying to connect";}
else if(serv==1){statC = "Connected";}else if(serv==0){statC = "Not connected";}}statAel = document.getElementById('statusA');statAel.innerHTML =
statA;statBel = document.getElementById('statusB');statBel.innerHTML = statB;statCel = document.getElementById('statusC');statCel.innerHTML =
statC;rmsgel = document.getElementById('regmsg');rmsgel.innerHTML = rmsg;actBtnEl = document.getElementById("actBtn");if(actbtn==1)
{actBtnEl.innerHTML = 'Activate';}else{actBtnEl.innerHTML = 'Deactivate';}regBtnEl = document.getElementById("regBtn");regBtnEl.href =
"http://www.example.com/user/register.aspx?mac=" + mac;if (warn==1) {alert("Failed to connect. Please, check DNS server settings.");}if (warn==2)
{alert("Failed to activate. Please, check, that device is registered.");}StartTimer();}
and this is the javascript function:
function ChangeState(sn) {
f = document.forms.tForm;
ind = sn * 1 - 1;
f["cte" + sn].value = Math.abs(1 - sockstates[ind]);
f.submit();
}
function ActivateDeactivate() {
f = document.forms.tForm2;
f["activate"].value = actbtn;
f.submit();
}
function TimerFunction() {
clearTimeout(timer);
if (trycon == 1 && active == 1) {
document.location.href = "xyz.html";
}
}
function StartTimer() { timer = setTimeout(TimerFunction, period); }
window.onload = function() {
for (i = 0; i < 4; i++) {
if (sockstates[i] == 0) {
clsname = 'offstate';
str1 = 'OFF';
str2 = 'ON';
} else {
clsname = 'onstate';
str1 = 'ON';
str2 = 'OFF';
}
strhtml = '<span class="' + clsname + '">' + str1 +
'</span> <a href="javascript: ChangeState(\'' + (i + 1) +
'\')" class="onoffbtn">' + str2 + '</a>';
el = document.getElementById('stCont' + i);
el.innerHTML = strhtml;
}
statA = '';
statB = '';
statC = '';
rmsg = '';
if (ipid != 0) {
statA = "Registered - ";
tmpel = document.getElementById('regBtn');
tmpel.innerHTML = 'Login';
} else {
rmsg = "Register to manage AB-xyz-LAN from Internet ( free service )";
}
if (active == 1) {
statB = "Activated - ";
} else {
statB = "Not activated";
}
if (active == 1) {
if (trycon == 1) {
statC = "Trying to connect";
} else if (serv == 1) {
statC = "Connected";
} else if (serv == 0) {
statC = "Not connected";
}
}
statAel = document.getElementById('statusA');
statAel.innerHTML = statA;
statBel = document.getElementById('statusB');
statBel.innerHTML = statB;
statCel = document.getElementById('statusC');
statCel.innerHTML = statC;
rmsgel = document.getElementById('regmsg');
rmsgel.innerHTML = rmsg;
actBtnEl = document.getElementById("actBtn");
if (actbtn == 1) {
actBtnEl.innerHTML = 'Activate';
} else {
actBtnEl.innerHTML = 'Deactivate';
}
regBtnEl = document.getElementById("regBtn");
regBtnEl.href = "http://www.example.com/user/register.aspx?mac=" + mac;
if (warn == 1) {
alert("Failed to connect. Please, check DNS server settings.");
}
if (warn == 2) {
alert("Failed to activate. Please, check, that device is registered.");
}
StartTimer();
}