mirror of
https://github.com/Anonym-tsk/smart-domofon.git
synced 2026-03-30 01:39:53 +03:00
Code moved
This commit is contained in:
24
native/data/index.html
Normal file
24
native/data/index.html
Normal file
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Domofon</title>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QkUEBQ2PpUhggAAAM5JREFUOMut0rFKQzEUANBDXwfpWnDoB9i5v1C/wJ9wcLCCu6sfIAodWwehLh3qIrjW1T8QB10FEV2kdcmDy4O25tlAICHJyc3N5Z+tCOMO5mjhsQ52iWXqp7mHh9jDLCBHOcAnngOywGEO8JZuLZGD3CfchtAf6iRwPwAvaNZBbgJyjUYusBtyscRVBWngAsfrkB4+AjLGTlob/LVO+hXkHU/oVurkZFMkr2Fz+cVd3KX5ZFNO2hitQM7KpxVrgG9McZ8qs0jIF87xYxvtFxFQQMNN792iAAAAAElFTkSuQmCC">
|
||||
<link rel="stylesheet" href="style.css"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="content">
|
||||
<h2>Domofon</h2>
|
||||
|
||||
<textarea id="terminal" readonly></textarea>
|
||||
|
||||
<div class="controls">
|
||||
<input id="clear" type="button" value="Clear"/>
|
||||
<input id="restart" type="button" value="Restart"/>
|
||||
</div>
|
||||
</div>
|
||||
<script src="script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
63
native/data/script.js
Normal file
63
native/data/script.js
Normal file
@@ -0,0 +1,63 @@
|
||||
(function() {
|
||||
var terminal = document.getElementById('terminal'),
|
||||
clear = document.getElementById('clear'),
|
||||
restart = document.getElementById('restart'),
|
||||
ws = null,
|
||||
reconnectTimeout = null,
|
||||
prefix = '';
|
||||
|
||||
function _connect() {
|
||||
if (!ws || ws.readyState === WebSocket.CLOSED) {
|
||||
try {
|
||||
ws = new WebSocket('ws://' + window.location.hostname + '/ws');
|
||||
ws.onopen = _onOpen;
|
||||
ws.onmessage = _onMessage;
|
||||
ws.onclose = _onClose;
|
||||
} catch (e) {
|
||||
_onClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _onOpen() {
|
||||
clearTimeout(reconnectTimeout);
|
||||
}
|
||||
|
||||
function _onClose(e) {
|
||||
var code = e && e.code || 1012;
|
||||
ws = null;
|
||||
if (code > 1000) {
|
||||
reconnectTimeout = setTimeout(_connect, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
function _onMessage(message) {
|
||||
var data = message && message.data;
|
||||
if (data) {
|
||||
data = prefix + data;
|
||||
|
||||
if (data.endsWith("\n")) {
|
||||
prefix = "\n";
|
||||
data = data.substr(0, data.length - 1);
|
||||
} else {
|
||||
prefix = '';
|
||||
}
|
||||
|
||||
terminal.value += data;
|
||||
terminal.scrollTop = terminal.scrollHeight;
|
||||
}
|
||||
}
|
||||
|
||||
clear.addEventListener('click', function(e) {
|
||||
terminal.value = '';
|
||||
prefix = '';
|
||||
});
|
||||
|
||||
restart.addEventListener('click', function(e) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', '/restart', true);
|
||||
xhr.send(null);
|
||||
});
|
||||
|
||||
_connect();
|
||||
})();
|
||||
80
native/data/style.css
Normal file
80
native/data/style.css
Normal file
@@ -0,0 +1,80 @@
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
.content {
|
||||
line-height: 1.6em;
|
||||
margin: 0 auto;
|
||||
padding: 30px 0 50px;
|
||||
max-width: 50pc;
|
||||
padding: 0 2em;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 3em;
|
||||
font-weight: 300;
|
||||
margin: .5em 0 .3em;
|
||||
text-align: center;
|
||||
line-height: 1em;
|
||||
}
|
||||
|
||||
input, textarea {
|
||||
border-radius: 4px;
|
||||
padding: .5em .6em;
|
||||
box-sizing: border-box;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
input {
|
||||
height: 36px;
|
||||
width: 20%;
|
||||
min-width: 140px;
|
||||
font-family: sans-serif;
|
||||
vertical-align: middle;
|
||||
line-height: normal;
|
||||
display: inline-block;
|
||||
white-space: nowrap;
|
||||
font-size: 100%;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
color: #fff;
|
||||
text-shadow: 0 1px 1px rgba(0,0,0,.2);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
input:active {
|
||||
box-shadow: 0 0 0 1px rgba(0,0,0,.15) inset, 0 0 6px rgba(0,0,0,.2) inset;
|
||||
}
|
||||
|
||||
.controls {
|
||||
margin: .5em 0 1em;
|
||||
}
|
||||
|
||||
#clear {
|
||||
background: #009a3e;
|
||||
}
|
||||
|
||||
#restart {
|
||||
float: right;
|
||||
background: #c01200;
|
||||
}
|
||||
|
||||
#terminal {
|
||||
display: block;
|
||||
width: 100%;
|
||||
background: #222;
|
||||
height: 25pc;
|
||||
max-height: 60vh;
|
||||
color: #c9ea7b;
|
||||
font-family: Courier New, monospace;
|
||||
font-size: 80%;
|
||||
line-height: 110%;
|
||||
resize: none;
|
||||
box-shadow: inset 0 1px 3px #ddd;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
Reference in New Issue
Block a user