From: paul <paul@plutz.net> Date: Fri, 8 Apr 2016 13:05:19 +0000 (+0000) Subject: show date in therapy; handle touchscreens X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=ef6fdf91d47347a43164ae8edfcc0dce6329af3f;p=confetti show date in therapy; handle touchscreens svn path=/trunk/; revision=94 --- diff --git a/templates/therapy.html.sh b/templates/therapy.html.sh index e9781e9..0b3bfbe 100755 --- a/templates/therapy.html.sh +++ b/templates/therapy.html.sh @@ -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>