lighthouse score

This commit is contained in:
iou1name 2019-06-24 09:06:41 -04:00
parent 50d8e1863e
commit e680c55fae
7 changed files with 25 additions and 15 deletions

View File

@ -54,7 +54,7 @@ nav span:hover {
.ip_address { .ip_address {
font-size: 0.8em; font-size: 0.8em;
font-style: italic; font-style: italic;
color: darkgray; color: dimgray;
margin: 0.2em; margin: 0.2em;
} }

View File

@ -2,7 +2,7 @@ function load() {
Object.entries(init_state).forEach(([device_id, sub_devs]) => { Object.entries(init_state).forEach(([device_id, sub_devs]) => {
let device = document.querySelector('#' + device_id); let device = document.querySelector('#' + device_id);
Object.entries(sub_devs).forEach(([sub_dev_id, state]) => { Object.entries(sub_devs).forEach(([sub_dev_id, state]) => {
let sub_dev = device.querySelector('#' + sub_dev_id); let sub_dev = device.querySelector('.' + sub_dev_id);
let svg = sub_dev.querySelector('object').getSVGDocument().firstElementChild; let svg = sub_dev.querySelector('object').getSVGDocument().firstElementChild;
if (state) { if (state) {
svg.classList.remove('off'); svg.classList.remove('off');
@ -26,7 +26,7 @@ function toggle_outlet(svg) {
let sub_dev = get_object_from_svg(svg).parentElement; let sub_dev = get_object_from_svg(svg).parentElement;
let params = { let params = {
device_id: sub_dev.parentElement.parentElement.id, device_id: sub_dev.parentElement.parentElement.id,
sub_dev_id: sub_dev.id sub_dev_id: sub_dev.querySelector('.id').innerText,
}; };
let query = Object.keys(params) let query = Object.keys(params)
.map(k => encodeURIComponent(k) + '=' + encodeURIComponent(params[k])) .map(k => encodeURIComponent(k) + '=' + encodeURIComponent(params[k]))
@ -37,7 +37,7 @@ function toggle_outlet(svg) {
}) })
.then(function(json) { .then(function(json) {
if (!json.ok) { throw new Error('HTTP error, status = ' + json.status + ', message = ' + json.message); } if (!json.ok) { throw new Error('HTTP error, status = ' + json.status + ', message = ' + json.message); }
if (json[sub_dev.id]) { if (json[sub_dev.querySelector('.id').innerText]) {
svg.classList.remove('off'); svg.classList.remove('off');
svg.classList.add('on'); svg.classList.add('on');
} else { } else {

View File

@ -1,11 +1,13 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<title>Juice</title> <title>Juice</title>
<link rel="stylesheet" type="text/css" href="/static/juice.css"> <link rel="stylesheet" type="text/css" href="/static/juice.css">
<script type="text/javascript" src="/static/juice.js"></script> <script type="text/javascript" src="/static/juice.js"></script>
<script>var init_state = {{ init_state|tojson|safe }};</script> <script>var init_state = {{ init_state|tojson|safe }};</script>
<script>window.onload = load;</script> <script>window.onload = load;</script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="An IOT hub.">
</head> </head>
<body> <body>
<header> <header>
@ -25,9 +27,9 @@
<div class="ip_address editable"><span class="field_value">{{ device.ip_address }}</span>{% if not device.locked %}<span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span>{% endif %}</div> <div class="ip_address editable"><span class="field_value">{{ device.ip_address }}</span>{% if not device.locked %}<span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span>{% endif %}</div>
<div class="sub_devices"> <div class="sub_devices">
{% for sub_dev in device.sub_devices %} {% for sub_dev in device.sub_devices %}
<div class="sub_device {{ sub_dev.type }}" id="{{ sub_dev.id }}"> <div class="sub_device {{ sub_dev.type }} {{ sub_dev.id }}">
<div class="id">{{ sub_dev.id }}</div> <div class="id">{{ sub_dev.id }}</div>
<object class="outlet_image" data="/static/outlet.svg"></object> <object class="outlet_image" aria-label="Outlet Image" data="/static/outlet.svg"></object>
<div class="description editable"><span class="field_value">{{ sub_dev.description }}</span>{% if not device.locked %}<span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span>{% endif %}</div> <div class="description editable"><span class="field_value">{{ sub_dev.description }}</span>{% if not device.locked %}<span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span>{% endif %}</div>
</div> </div>
{% endfor %} {% endfor %}
@ -43,14 +45,14 @@
<div class="location editable"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div> <div class="location editable"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
<div class="ip_address editable"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div> <div class="ip_address editable"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
<div class="sub_devices"> <div class="sub_devices">
<div class="sub_device RelayOutlet" id="OUT0"> <div class="sub_device RelayOutlet OUT0">
<div class="id">OUT0</div> <div class="id">OUT0</div>
<object class="outlet_image" data="/static/outlet.svg"></object> <object class="outlet_image" alt="Outlet Image" data="/static/outlet.svg"></object>
<div class="description editable"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div> <div class="description editable"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
</div> </div>
<div class="sub_device RelayOutlet" id="OUT2"> <div class="sub_device RelayOutlet OUT2">
<div class="id">OUT2</div> <div class="id">OUT2</div>
<object class="outlet_image" data="/static/outlet.svg"></object> <object class="outlet_image" alt="Outlet Image" data="/static/outlet.svg"></object>
<div class="description editable"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div> <div class="description editable"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
</div> </div>
</div> </div>

View File

@ -1,11 +1,13 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<title>Juice - Login</title> <title>Juice - Login</title>
<link rel="stylesheet" type="text/css" href="/static/juice.css"> <link rel="stylesheet" type="text/css" href="/static/juice.css">
<script type="text/javascript" src="/static/cbor.js"></script> <script type="text/javascript" src="/static/cbor.js"></script>
<script type="text/javascript" src="/static/juice-auth.js"></script> <script type="text/javascript" src="/static/juice-auth.js"></script>
<script>url_prefix = '{{ url_prefix }}';</script> <script>url_prefix = '{{ url_prefix }}';</script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="An IOT hub.">
</head> </head>
<body> <body>
<main> <main>

View File

@ -1,10 +1,12 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<title>Juice - Manage</title> <title>Juice - Manage</title>
<link rel="stylesheet" type="text/css" href="/static/juice.css"> <link rel="stylesheet" type="text/css" href="/static/juice.css">
<script type="text/javascript" src="/static/juice.js"></script> <script type="text/javascript" src="/static/juice.js"></script>
<script>url_prefix = '{{ url_prefix }}';</script> <script>url_prefix = '{{ url_prefix }}';</script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="An IOT hub.">
</head> </head>
<body> <body>
<main> <main>

View File

@ -1,8 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<title>Juice - Register</title> <title>Juice - Register</title>
<link rel="stylesheet" type="text/css" href="/static/juice.css"> <link rel="stylesheet" type="text/css" href="/static/juice.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="An IOT hub.">
</head> </head>
<body> <body>
<main> <main>

View File

@ -1,11 +1,13 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<title>Juice - Register Security Key</title> <title>Juice - Register Security Key</title>
<link rel="stylesheet" type="text/css" href="/static/juice.css"> <link rel="stylesheet" type="text/css" href="/static/juice.css">
<script type="text/javascript" src="/static/cbor.js"></script> <script type="text/javascript" src="/static/cbor.js"></script>
<script type="text/javascript" src="/static/juice-auth.js"></script> <script type="text/javascript" src="/static/juice-auth.js"></script>
<script>url_prefix = '{{ url_prefix }}';</script> <script>url_prefix = '{{ url_prefix }}';</script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="An IOT hub.">
</head> </head>
<body> <body>
<main> <main>