aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorroot <root@frank.tg14.gathering.org>2014-04-18 00:43:25 +0200
committerroot <root@frank.tg14.gathering.org>2014-04-18 00:43:25 +0200
commitb171dcf084ca6a04351cf8b338c6882bda869547 (patch)
tree4fab71d2558dc885899df04e143d4d59eca3130f
parent54bd5cf16524fca37556a99a63ff6128e6583e26 (diff)
Add an option to turn off the edit UI.
-rw-r--r--web/nms.gathering.org/ping.html1
-rw-r--r--web/nms.gathering.org/ping.js52
2 files changed, 28 insertions, 25 deletions
diff --git a/web/nms.gathering.org/ping.html b/web/nms.gathering.org/ping.html
index 3aea383..44d6d89 100644
--- a/web/nms.gathering.org/ping.html
+++ b/web/nms.gathering.org/ping.html
@@ -14,6 +14,7 @@
var switches_url = "/switches-json.pl";
var ping_url = "/ping-json.pl";
var draw_linknets = true;
+ var can_edit = true;
</script>
<script type="text/javascript" src="ping.js"></script>
</body>
diff --git a/web/nms.gathering.org/ping.js b/web/nms.gathering.org/ping.js
index 3b99257..73aced3 100644
--- a/web/nms.gathering.org/ping.js
+++ b/web/nms.gathering.org/ping.js
@@ -196,35 +196,37 @@ function create_switch(switchnum, sysname, x, y, zorder, width, height) {
var dragging_switch = null;
var delta_x = null, delta_y = null;
-document.onmousedown = function(e) {
- var switchnum = e.target.getAttribute("data-switchnum");
- if (switchnum === null) {
- return;
+if (can_edit) {
+ document.onmousedown = function(e) {
+ var switchnum = e.target.getAttribute("data-switchnum");
+ if (switchnum === null) {
+ return;
+ }
+ dragging_switch = switchnum;
+ delta_x = parseInt(e.target.style.left.replace("px", "")) - e.clientX;
+ delta_y = parseInt(e.target.style.top.replace("px", "")) - e.clientY;
}
- dragging_switch = switchnum;
- delta_x = parseInt(e.target.style.left.replace("px", "")) - e.clientX;
- delta_y = parseInt(e.target.style.top.replace("px", "")) - e.clientY;
-}
-document.onmousemove = function(e) {
- if (dragging_switch === null) {
- return;
+ document.onmousemove = function(e) {
+ if (dragging_switch === null) {
+ return;
+ }
+ switches[dragging_switch].style.left = (e.clientX + delta_x) + 'px';
+ switches[dragging_switch].style.top = (e.clientY + delta_y) + 'px';
}
- switches[dragging_switch].style.left = (e.clientX + delta_x) + 'px';
- switches[dragging_switch].style.top = (e.clientY + delta_y) + 'px';
-}
-document.onmouseup = function(e) {
- if (dragging_switch === null) {
- return;
- }
- var x = e.clientX + delta_x - map.getBoundingClientRect().top;
- var y = e.clientY + delta_y - map.getBoundingClientRect().left;
+ document.onmouseup = function(e) {
+ if (dragging_switch === null) {
+ return;
+ }
+ var x = e.clientX + delta_x - map.getBoundingClientRect().top;
+ var y = e.clientY + delta_y - map.getBoundingClientRect().left;
- var request = new XMLHttpRequest();
- request.open('POST', '/change-switch-pos.pl', true);
- request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
- request.send("switch=" + dragging_switch + "&x=" + x + "&y=" + y);
+ var request = new XMLHttpRequest();
+ request.open('POST', '/change-switch-pos.pl', true);
+ request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
+ request.send("switch=" + dragging_switch + "&x=" + x + "&y=" + y);
- dragging_switch = null;
+ dragging_switch = null;
+ }
}