]> git.plutz.net Git - confetti/blobdiff - templates/therapy.html.sh
show date in therapy; handle touchscreens
[confetti] / templates / therapy.html.sh
index e9781e9bc52f7c27ad47b66e112e21b35bab0ac2..0b3bfbe2574298b5279bd7747d06a374b2cecb54 100755 (executable)
@@ -135,6 +135,7 @@ cat <<EOF
   <div class="prescription">
     <h2>$(l10n therapy_prescription)</h2>
     <span class="insurance">${mpx[insurance]}</span>
+    <span class="date">${mpx[date]}</span>
     <label class="checkbox ${mpx[prescreviewed]:+checked}" for="prescreviewed">
       $([ -n "${mpx[prescreviewed]}" ] && printf %s "$(l10n prescreviewed)" \
                                        || printf %s "$(l10n prescreview)" )
@@ -197,32 +198,45 @@ cat <<EOF
   setcol("$tpy[color]")
 
   function circle(x, y) {
-    sx=Math.floor(cscaleW * (x - canvas.offsetLeft + body.scrollLeft))
-    sy=Math.floor(cscaleH * (y - canvas.offsetTop + body.scrollTop))
-
-    image.beginPath()
-    image.arc( sx, sy, 5, 0, 2 * Math.PI )
-    image.fill()
-    image.closePath()
-
-    image_serialize += " circle " + sx + "," + sy + " " + (sx-5) + "," + sy
+    if ( mouse == 1){
+      if ( body.clientWidth >= 800 ){
+        sx=Math.floor(cscaleW * (x - canvas.offsetLeft))
+        sy=Math.floor(cscaleH * (y - canvas.offsetTop))
+      } else { 
+        sx=Math.floor(cscaleW * (x - canvas.offsetLeft + body.scrollLeft))
+        sy=Math.floor(cscaleH * (y - canvas.offsetTop + body.scrollTop))
+      }
+      image.beginPath()
+      image.arc( sx, sy, 5, 0, 2 * Math.PI )
+      image.fill()
+      image.closePath()
+
+      image_serialize += " circle " + sx + "," + sy + " " + (sx-5) + "," + sy
+    }
   }
 
-  window.addEventListener( 'mouseup', function() { mouse = 0
-   dbg.innerHTML = image_serialize
-   data.value = image_serialize
-   } )
-  canvas.addEventListener( 'mousedown', function(e) {
+  function drawstart(x, y) {
     mouse = 1
 
     cscaleW = canvas.width / canvas.clientWidth
     cscaleH = canvas.height / canvas.clientHeight
 
-    circle(e.clientX, e.clientY)
-  } )
-  canvas.addEventListener( 'mousemove', function(e) {
-    if ( mouse == 1 ) { circle(e.clientX, e.clientY) }
-  } )
+    circle(x, y)
+  }
+  function drawstop() {
+   mouse = 0
+   dbg.innerHTML = image_serialize
+   data.value = image_serialize
+  }
+
+  window.addEventListener( 'mouseup', function() { drawstop() } )
+  canvas.addEventListener( 'mousedown', function(e) { drawstart(e.clientX, e.clientY) } )
+  canvas.addEventListener( 'mousemove', function(e) { circle(e.clientX, e.clientY)    } )
+
+  window.addEventListener( 'touchend', function() { drawstop() } )
+  canvas.addEventListener( 'touchstart', function(e) { drawstart(e.touches[0].clientX, e.touches[0].clientY) } )
+  canvas.addEventListener( 'touchmove', function(e) { circle(e.touches[0].clientX, e.touches[0].clientY)    } )
+
   --></script>
 </form>