moved svg back to external reference
This commit is contained in:
parent
77727249a5
commit
c70e57c69d
|
@ -1,10 +1,11 @@
|
||||||
body {
|
body {
|
||||||
padding: 5%;
|
|
||||||
font-family: Helvetica,sans-serif;
|
font-family: Helvetica,sans-serif;
|
||||||
background-color: lightblue;
|
background-color: lightblue;
|
||||||
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#container {
|
#devices {
|
||||||
|
padding: 5%;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
@ -46,18 +47,6 @@ body {
|
||||||
height: 5em;
|
height: 5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
path {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.on {
|
|
||||||
stroke: red;
|
|
||||||
}
|
|
||||||
|
|
||||||
.off {
|
|
||||||
stroke: black;
|
|
||||||
}
|
|
||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: FontAwesome;
|
font-family: FontAwesome;
|
||||||
src: url("/static/fontawesome-webfont.woff2");
|
src: url("/static/fontawesome-webfont.woff2");
|
||||||
|
|
|
@ -1,5 +1,15 @@
|
||||||
|
function get_object_from_svg(svg) {
|
||||||
|
var all_objects = document.getElementsByTagName("object");
|
||||||
|
for (var i=0; i < all_objects.length; i++) {
|
||||||
|
if (svg === all_objects[i].getSVGDocument().firstElementChild) {
|
||||||
|
return all_objects[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
function toggle_outlet(svg) {
|
function toggle_outlet(svg) {
|
||||||
let sub_dev = 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.id
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
<svg class="off" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
<svg class="off" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path fill="none" stroke="red"
|
<style>
|
||||||
d="M 23,10
|
path, rect {
|
||||||
L 77,10
|
cursor: pointer;
|
||||||
A 50 49 0 0 1 77,91
|
}
|
||||||
L 23,91
|
|
||||||
A 50 49 0 0 1 23,10
|
|
||||||
Z" />
|
|
||||||
|
|
||||||
<rect x="29" y="30" width="6" height="21" fill="none" stroke="red" />
|
.on {
|
||||||
|
stroke: red;
|
||||||
|
}
|
||||||
|
|
||||||
<rect x="65" y="30" width="6" height="21" fill="none" stroke="red" />
|
.off {
|
||||||
|
stroke: black;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
<path fill="none" stroke="red"
|
<rect x="29" y="30" width="6" height="21" fill="none" />
|
||||||
d="M 43, 75
|
<rect x="65" y="30" width="6" height="21" fill="none" />
|
||||||
A 1 1 0 0 1 57,75
|
<path fill="none" d="M 43, 75 A 1 1 0 0 1 57,75 L 57,84 L 43,84 Z" />
|
||||||
L 57,84
|
<path fill="white" fill-opacity="0.0" d="M 23,10 L 77,10 A 50 49 0 0 1 77,91 L 23,91 A 50 49 0 0 1 23,10 Z" onclick="top.toggle_outlet(this.parentElement)" />
|
||||||
L 43,84
|
|
||||||
Z" />
|
|
||||||
</svg>
|
</svg>
|
||||||
|
|
Before Width: | Height: | Size: 438 B After Width: | Height: | Size: 549 B |
|
@ -1,38 +1,35 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<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>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="container">
|
<main>
|
||||||
{% for dev_type, devices in network.items() %}
|
<div id="devices">
|
||||||
{% for device in devices %}
|
{% for dev_type, devices in network.items() %}
|
||||||
<div class="device {{ dev_type }}" id="{{ device.id }}">
|
{% for device in devices %}
|
||||||
<div class="id">{{ device.id }}</div>
|
<div class="device {{ dev_type }}" id="{{ device.id }}">
|
||||||
<div class="description"><span class="field_value">{{ device.description }}</span> <span class="edit" onclick="edit_field(this.parentElement)"></span></div>
|
<div class="id">{{ device.id }}</div>
|
||||||
<div class="location"><span class="field_value">{{ device.location }}</span> <span class="edit" onclick="edit_field(this.parentElement)"></span></div>
|
<div class="description"><span class="field_value">{{ device.description }}</span> <span class="edit" onclick="edit_field(this.parentElement)"></span></div>
|
||||||
<div class="ip_address"><i>{{ device.ip_address }}</i></div>
|
<div class="location"><span class="field_value">{{ device.location }}</span> <span class="edit" onclick="edit_field(this.parentElement)"></span></div>
|
||||||
<div class="sub_devices">
|
<div class="ip_address"><i>{{ device.ip_address }}</i></div>
|
||||||
{% for sub_dev_type, sub_devs in device.sub_devices.items() %}
|
<div class="sub_devices">
|
||||||
{% for sub_dev in sub_devs %}
|
{% for sub_dev_type, sub_devs in device.sub_devices.items() %}
|
||||||
<div class="sub_device {{ sub_dev_type }}" id="{{ sub_dev.id }}">
|
{% for sub_dev in sub_devs %}
|
||||||
<div class="id">{{ sub_dev.id }}</div>
|
<div class="sub_device {{ sub_dev_type }}" id="{{ sub_dev.id }}">
|
||||||
<svg class="outlet_image {% if sub_dev.state %}on{% else %}off{% endif %}" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
<div class="id">{{ sub_dev.id }}</div>
|
||||||
<rect x="29" y="30" width="6" height="21" fill="none" />
|
<object class="outlet_image" data="/static/outlet.svg"></object>
|
||||||
<rect x="65" y="30" width="6" height="21" fill="none" />
|
<div class="description"><span class="field_value">{{ sub_dev.description }}</span> <span class="edit" onclick="edit_field(this.parentElement)"></span></div>
|
||||||
<path fill="none" d="M 43, 75 A 1 1 0 0 1 57,75 L 57,84 L 43,84 Z" />
|
</div>
|
||||||
<path fill="white" fill-opacity="0.0" d="M 23,10 L 77,10 A 50 49 0 0 1 77,91 L 23,91 A 50 49 0 0 1 23,10 Z" onclick="toggle_outlet(this.parentElement)" />
|
{% endfor %}
|
||||||
</svg>
|
{% endfor %}
|
||||||
<div class="description"><span class="field_value">{{ sub_dev.description }}</span> <span class="edit" onclick="edit_field(this.parentElement)"></span></div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</main>
|
||||||
{% endfor %}
|
</body>
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user