changeset 548:b3dc81bee5b3

scaled zooming works
author Matt Johnston <matt@ucc.asn.au>
date Wed, 27 May 2015 22:37:43 +0800
parents 7689af9f56a8
children 0baa57b6d9ca
files web/templog.py web/templog.wsgi web/views/top.tpl
diffstat 3 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/web/templog.py	Wed May 27 22:17:39 2015 +0800
+++ b/web/templog.py	Wed May 27 22:37:43 2015 +0800
@@ -107,7 +107,8 @@
     if 'zoom' in request.query:
         orig_start = end - timedelta(minutes=minutes)
         orig_end = end
-        xpos = int(request.query.x)
+        scale = float(request.query.scaledwidth) / config.GRAPH_WIDTH
+        xpos = int(request.query.x) / scale
         xpos -= config.GRAPH_LEFT_MARGIN * config.ZOOM
 
         if xpos >= 0 and xpos < config.GRAPH_WIDTH * config.ZOOM:
--- a/web/templog.wsgi	Wed May 27 22:17:39 2015 +0800
+++ b/web/templog.wsgi	Wed May 27 22:37:43 2015 +0800
@@ -1,5 +1,6 @@
 #from gevent import monkey; monkey.patch_all()
 
+
 import os
 import sys
 # Change working directory so relative paths (and template lookup) work again
--- a/web/views/top.tpl	Wed May 27 22:17:39 2015 +0800
+++ b/web/views/top.tpl	Wed May 27 22:37:43 2015 +0800
@@ -14,16 +14,29 @@
  font-size: 70%;
  text-align: right;
 }
+
+#mainimage {
+	width: 100%;
+	max-width: {{graphwidth}}px;
+}
 //-->
 </style>
 <title></title>
 </head>
+<script type="text/javascript">
+function updatewidth() {
+	var width_input = document.getElementById("scaledwidth");
+	width_input.value = document.getElementById("mainimage").clientWidth;
+}
+
+</script>
 <body>
 <form action="" method="get">
-<span class="no_selection"><input type="image" style="width: 100%; max-width: {{graphwidth}}px" src="{{graphdata}}"/></span>
+<span class="no_selection"><input type="image" id="mainimage" src="{{graphdata}}" onclick="updatewidth();"/></span>
 <input type="hidden" name="length" value="{{length}}"/>
 <input type="hidden" name="end" value="{{end}}"/>
 <input type="hidden" name="zoom" value="yeah"/>
+<input type="hidden" name="scaledwidth" id="scaledwidth" value="-1"/>
 </form>
 <span class="codelink">Click to zoom in, click the left axis to zoom out. <a href="https://secure.ucc.asn.au/hg/templog/file/tip">Source code</a> for the Raspberry Pi controller and this web interface</a>. <a href="set">Adjustments</a> by phone.</span>
 </body>