52 lines
1.8 KiB
PHP
52 lines
1.8 KiB
PHP
<?php
|
|
function insertJavascript()
|
|
{
|
|
global $listenPort;
|
|
return '<script language="javascript">
|
|
<!--
|
|
function setPropertyValue(topic, fn, value, property)
|
|
{
|
|
document.getElementById(topic+"/"+fn+"/"+property+"/"+value.toLowerCase()).value = value;
|
|
let xhr = new XMLHttpRequest();
|
|
xhr.open("GET", "http://192.168.1.253:' . $listenPort . '/set&fn="+fn+"&property="+property+"&topic="+topic+"&value="+value);
|
|
xhr.onload = function () {};
|
|
xhr.send();
|
|
}
|
|
function setPropertyNumberValue(topic, fn, value, property)
|
|
{
|
|
document.getElementById(topic+"/"+fn+"/"+property).value = value;
|
|
let xhr = new XMLHttpRequest();
|
|
xhr.open("GET", "http://192.168.1.253:' . $listenPort . '/set&fn="+fn+"&property="+property+"&topic="+topic+"&value="+value);
|
|
xhr.onload = function () {};
|
|
xhr.send();
|
|
}
|
|
function setPropertyMethod(topic, fn, method, property)
|
|
{
|
|
let xhr = new XMLHttpRequest();
|
|
xhr.open("GET", "http://192.168.1.253:' . $listenPort . '/set&fn="+fn+"&property="+property+"&topic="+topic+"&method="+method);
|
|
xhr.onload = function () {};
|
|
xhr.send();
|
|
}
|
|
function getPropertyValue(topic, fn, property)
|
|
{
|
|
let xhr = new XMLHttpRequest();
|
|
xhr.open("GET", "http://192.168.1.253:' . $listenPort . '/get&fn="+fn+"&property="+property+"&topic="+topic );
|
|
xhr.onload = function () {};
|
|
xhr.send();
|
|
setTimeout(function()
|
|
{
|
|
location.reload();
|
|
}, 1000);
|
|
}
|
|
function deleteDevice($topic, fn)
|
|
{
|
|
let xhr = new XMLHttpRequest();
|
|
xhr.open("GET", "http://192.168.1.253:' . $listenPort . '/deleteDevice&fn="+fn+"&topic="+topic);
|
|
xhr.onload = function () {};
|
|
xhr.send();
|
|
}
|
|
// -->
|
|
</script>';
|
|
}
|
|
?>
|