beautify html
This commit is contained in:
parent
ecf1478e7e
commit
5342f628da
354 changed files with 13965 additions and 9486 deletions
|
@ -1,61 +1,62 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script>
|
||||
|
||||
var eventSource;
|
||||
<meta charset="utf-8">
|
||||
<script>
|
||||
var eventSource;
|
||||
|
||||
function start() { // при нажатии на Старт
|
||||
function start() { // при нажатии на Старт
|
||||
|
||||
if (!window.EventSource) {
|
||||
alert('В этом браузере нет поддержки EventSource.');
|
||||
return;
|
||||
}
|
||||
|
||||
eventSource = new EventSource('digits');
|
||||
|
||||
eventSource.onopen = function(e) {
|
||||
log("Соединение открыто");
|
||||
};
|
||||
|
||||
eventSource.onerror = function(e) {
|
||||
if (this.readyState == EventSource.CONNECTING) {
|
||||
log("Соединение порвалось, пересоединяемся...");
|
||||
} else {
|
||||
log("Ошибка, состояние: " + this.readyState);
|
||||
if (!window.EventSource) {
|
||||
alert('В этом браузере нет поддержки EventSource.');
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
eventSource.addEventListener('bye', function(e) {
|
||||
log("Bye: " + e.data);
|
||||
}, false);
|
||||
eventSource = new EventSource('digits');
|
||||
|
||||
eventSource.onmessage = function(e) {
|
||||
console.log(e);
|
||||
log(e.data);
|
||||
};
|
||||
}
|
||||
eventSource.onopen = function(e) {
|
||||
log("Соединение открыто");
|
||||
};
|
||||
|
||||
function stop() { // при нажатии на Стоп
|
||||
eventSource.close();
|
||||
log("Соединение завершено");
|
||||
}
|
||||
eventSource.onerror = function(e) {
|
||||
if (this.readyState == EventSource.CONNECTING) {
|
||||
log("Соединение порвалось, пересоединяемся...");
|
||||
} else {
|
||||
log("Ошибка, состояние: " + this.readyState);
|
||||
}
|
||||
};
|
||||
|
||||
function log(msg) {
|
||||
logElem.innerHTML += msg + "<br>";
|
||||
}
|
||||
|
||||
</script>
|
||||
eventSource.addEventListener('bye', function(e) {
|
||||
log("Bye: " + e.data);
|
||||
}, false);
|
||||
|
||||
eventSource.onmessage = function(e) {
|
||||
console.log(e);
|
||||
log(e.data);
|
||||
};
|
||||
}
|
||||
|
||||
function stop() { // при нажатии на Стоп
|
||||
eventSource.close();
|
||||
log("Соединение завершено");
|
||||
}
|
||||
|
||||
function log(msg) {
|
||||
logElem.innerHTML += msg + "<br>";
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<button onclick="start()">Старт</button>
|
||||
<button onclick="stop()">Стоп</button>
|
||||
<button onclick="start()">Старт</button>
|
||||
<button onclick="stop()">Стоп</button>
|
||||
|
||||
Нажмите "Старт" для начала.
|
||||
<div id="logElem"></div>
|
||||
Нажмите "Старт" для начала.
|
||||
<div id="logElem"></div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue