Проекты с блоком WebServerPage
Код: Выделить всё
<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN>
<META content=text/html; charset=utf-8 http-equiv=Content-Type>
<html></body></html>
Код: Выделить всё
<head>
<title>Client</title>
<!-- ===== НАШИ СТИЛИ CSS ===== -->
<style>
/* для всей страницы */
body{color:#6b1a1a;background-color:#efdece80;font-family:'Times New Roman',Times,serif;}
</style>
</head>
<!-- ===== ТЕЛО СТРАНИЦЫ HTML ===== -->
<body>
<p>Привет FLProg!!!</p>
<!-- ===== НАШИ СКРИПТЫ JS ===== -->
<script>
</script>
Код: Выделить всё
<head>
<title>Client</title>
<!-- ===== НАШИ СТИЛИ CSS ===== -->
<style>
/* для всей страницы */
body{color:#6b1a1a;background-color:#efdece80;font-family:'Times New Roman',Times,serif;}
/* для времени */
.time{line-height:1.0;text-align:center;font-weight:600;font-size:800%;}
</style>
</head>
<!-- ===== ТЕЛО СТРАНИЦЫ HTML ===== -->
<body>
<!-- ВРЕМЯ -->
<p class="time" id="time">**:**:**</p>
<!-- ===== НАШИ СКРИПТЫ JS ===== -->
<script></script>
<!-- АВТО ОБНОВЛЕНИЕ ВЫБРАННЫХ ДАННЫХ -->
<script>
function sendRequest(){
setInterval(function(){loadDoc();},1000);function loadDoc(){var xhttp=new XMLHttpRequest();xhttp.onreadystatechange=function(){if(this.readyState==4&&this.status==200){document.getElementById("time").innerHTML=this.responseText;}};xhttp.open("GET","server_info",true);xhttp.send();}}
sendRequest();
</script>
Код: Выделить всё
<head><title>Client</title>
<!-- ===== НАШИ СТИЛИ CSS ===== --><style>
/* для всей страницы */
body{color:#6b1a1a;background-color:#efdece;font-family:'Times New Roman',Times,serif;}
/* верх страницы */
.header{background:#60ECEC;text-align:center;font-weight:600;font-size:200%;}
/* время на странице */
.time{line-height:1.0;text-align:center;font-weight:600;font-size:370%;}
/* для кнопок */
.button{margin:auto;display:block;font-size:25px;line-height:1.6;letter-spacing:0.88px;font-weight:600;padding:5px;border-radius:8px;border:3px solid green;width:200px;box-shadow:0 0 0 60px rgba(0,0,0,0)inset,2px 2px 8px #a990c3;}
.button:active{top:2px;left:2px;box-shadow:0 0 0 60px rgba(0,0,0,.05)inset;}
/* низ страницы */
.footer{background:#60ECEC;text-align:center;font-weight:350;font-size:100%;}
</style>
</head>
<!-- ===== ТЕЛО СТРАНИЦЫ HTML ===== -->
<body>
<!-- ВЕРХ -->
<h1 class="header">Сделано в FLProg</h1>
<!-- ВРЕМЯ -->
<p class="time" id="time">**:**:**</p>
<!-- КНОПКА 1 -->
<p><button type="button" class="button" id="kn1" onclick="sendKn('sendkn1')">****** *\n***</button></p>
<!-- КНОПКА 2 -->
<p><button type="button" class="button" id="kn2" onclick="sendKn('sendkn2')">****** *\n***</button></p>
<!-- КНОПКА 3 -->
<p><button type="button" class="button" id="kn3" onclick="sendKn('sendkn3')">****** *\n***</button></p>
<!-- НИЗ -->
<p class="footer">=== rw6cm 2020 ===</p>
<!-- ===== НАШИ СКРИПТЫ JS ===== -->
<script></script>
<!-- КОМАНДА С КНОПКИ НА СЕРВЕР -->
<script>
function sendKn(url){var xhttp=new XMLHttpRequest();xhttp.open("HEAD",url,true);xhttp.send();}
</script>
<!-- АВТО ОБНОВЛЕНИЕ ВЫБРАННЫХ ДАННЫХ -->
<script>
function sendRequest(){
setInterval(function(){loadDoc();},1000);function loadDoc(){var xhttp=new XMLHttpRequest();xhttp.onreadystatechange=function(){if(this.readyState==4&&this.status==200){var arr=xhttp.responseText.split(",");
document.getElementById("time").innerHTML=arr[0];
var k1=document.getElementById("kn1");
k1.innerHTML=arr[1];if(k1.innerHTML==="КНОПКА 1 ВКЛ"){k1.style.backgroundColor=('#7bf27b');}else{k1.style.backgroundColor=('#d9ddf7');}
var k2=document.getElementById("kn2");
k2.innerHTML=arr[2];if(k2.innerHTML==="КНОПКА 2 ВКЛ"){k2.style.backgroundColor=('#7bf27b');}else{k2.style.backgroundColor=('#d9ddf7');}
var k3=document.getElementById("kn3");
k3.innerHTML=arr[3];if(k3.innerHTML==="КНОПКА 3 ВКЛ"){k3.style.backgroundColor=('#7bf27b');}else{k3.style.backgroundColor=('#d9ddf7');}}};xhttp.open("GET","server_info",true);xhttp.send();}}
sendRequest();
</script>
Код: Выделить всё
<script>
function sendRequest(){
setInterval(function(){loadDoc();},1000);function loadDoc(){var xhttp=new XMLHttpRequest();xhttp.onreadystatechange=function(){if(this.readyState==4&&this.status==200){document.getElementById("time").innerHTML=this.responseText;}};xhttp.open("GET","server_info",true);xhttp.send();}}
sendRequest();
</script>
Код: Выделить всё
<input type="text" value="Sec" id="gz" class="" />
<script>
var relay = document.getElementById("gz");
var relay_status = 0;
function relay_state() {
var request = new XMLHttpRequest();
request.open('GET','/Sec',true);
request.onload = function() {
if (request.readyState == 4 && request.status == 200) {
var response = request.responseText;
relay_status = Number.parseInt(response);
if (relay_status == 0)
relay.classList.add('off');
else
relay.classList.add('on');
}
}
request.send();
}
Здравствуйте AlexQwert855 писал(а): ↑25.09.2021{, 13:49}Добрый день.
помогите по двум вопросам.
- есть ли пример как читать значения например с веб страниц типа <input type="range"> и транслировать их на контроллер в переменную.
из возможностей стандартного блока не не нашел ничего кроме передачи булена
- так же прошу помощи как минимальным кодом обновлять локальные динамические данные на странице. (без CCS и прочих стилей только минимальный набор скрипта)
как это сделано с часами в одном из примеров.
<!-- АВТО ОБНОВЛЕНИЕ ВЫБРАННЫХ ДАННЫХ -->дёргать всю страницу как предлагает стандартный блок, это совсем не вариант.Код: Выделить всё
<script> function sendRequest(){ setInterval(function(){loadDoc();},1000);function loadDoc(){var xhttp=new XMLHttpRequest();xhttp.onreadystatechange=function(){if(this.readyState==4&&this.status==200){document.getElementById("time").innerHTML=this.responseText;}};xhttp.open("GET","server_info",true);xhttp.send();}} sendRequest(); </script>
в блоке ФЛП введен "доступный вход" - Sec
значение переменной с контроллера "Sec" отображается на странице, но оно не обновляется.Код: Выделить всё
<input type="text" value="Sec" id="gz" class="" /> <script> var relay = document.getElementById("gz"); var relay_status = 0; function relay_state() { var request = new XMLHttpRequest(); request.open('GET','/Sec',true); request.onload = function() { if (request.readyState == 4 && request.status == 200) { var response = request.responseText; relay_status = Number.parseInt(response); if (relay_status == 0) relay.classList.add('off'); else relay.classList.add('on'); } } request.send(); }
полагаю request.open('GET','/Sec',true); тут нужно что то иное прописывать. может еще где то.
Спасибо
Код: Выделить всё
<script>
function sendKn(url){
var xhttp=new XMLHttpRequest();
var body = "InputText="+document.getElementById("input_text1").value+"&InputNumber="+document.getElementById("input_number1").value;
console.log(body);
xhttp.open("HEAD",url+"?"+body,true);
xhttp.send();}
</script>
Код: Выделить всё
int _parseWebServerReqest(String reqestAddres)
{
String reqestAddresCopy=reqestAddres;//Копируем переменную reqestAddres
int index;
int result=0;
index=reqestAddres.indexOf("/");
reqestAddres =reqestAddres.substring(index+1);
if (reqestAddres.indexOf("?")==-1){//Если в строке не находим "?"
index=reqestAddres.indexOf(" ");}//Идем до конца стори
else{index=reqestAddres.indexOf("?");}//Если нашли "?", то заканчиваес строку на ?
reqestAddres =reqestAddres.substring(0, index);
if (reqestAddres=="")
{
result= 1;
}
if (reqestAddres=="sendsave")
{
reqestAddres =reqestAddresCopy;//Восстанавливаем начальное значение переменной
index=reqestAddres.indexOf("?");//Ищем индекс "?"
reqestAddres =reqestAddres.substring(index+1);//Извлекаем строку начиная с "?"
index=reqestAddres.indexOf(" ");//Ищем индекс конца строки
reqestAddres =reqestAddres.substring(0, index);//Извлекаем строку с ? до конца
_gtv10 =reqestAddres;//Записываем строку в переменную
result= 1;
}
Код: Выделить всё
int _parseWebServerReqest(String reqestAddres)
{
String index2=reqestAddres;
int index;
int result=0;
index=reqestAddres.indexOf("/");
reqestAddres =reqestAddres.substring(index+1);
if (reqestAddres.indexOf("?")==-1){
index=reqestAddres.indexOf(" ");}
else{index=reqestAddres.indexOf("?");}
reqestAddres =reqestAddres.substring(0, index);
if (reqestAddres=="")
{
result= 1;
}
if (reqestAddres=="sendsave")
{
reqestAddres=index2;
index=reqestAddres.indexOf("?");
reqestAddres =reqestAddres.substring(index+1);
index=reqestAddres.indexOf(" ");
reqestAddres =reqestAddres.substring(0, index);
_gtv1 =reqestAddres;
result= 1;
}
return result;
}
Проблем не будет когда блоки появятся Интересно сколько web клиентов один веб сервер потянет одновременно при не большой интенсивности обмена данными?