# serialize POST array into file
for key in ${(k)_POST}; do
- printf %s:%s\\n "$key" "${_POST[$key]//$BR/\\n}"
+ [ "$key" != imagedata ] && printf %s:%s\\n "$key" "${_POST[$key]//$BR/\\n}"
done >"$tempfile"
if [ -n "$_POST[delete_session]" ]; then
x="$_POST[dotmark.x]"
y="$_POST[dotmark.y]"
- case "$_POST[color]" in
- c000) c="#000000";;
- c001) c="#000088";;
- c010) c="#008800";;
- c011) c="#008888";;
- c100) c="#880000";;
- c101) c="#880088";;
- c110) c="#888800";;
- c111) c="#888888";;
- esac
+ convert "${tpyfile%.tpy}_${sid}.png" -draw "fill $_POST[color] circle $x,$y $(($x+5)),$y" "${tpyfile%.tpy}_${sid}.png"
- convert "${tpyfile%.tpy}_${sid}.png" -fill "$c" -stroke "$c" -draw "circle $x,$y $(($x+5)),$y" "${tpyfile%.tpy}_${sid}.png"
+elif [ -n "$_POST[imagedata]" ]; then
+ sed -rn 's;^(session[0-9]+)_open:checked$;\1;p' "$tempfile" \
+ | sort -n \
+ | tail -n1 \
+ | read sid
+ convert "${tpyfile%.tpy}_${sid}.png" -draw "${_POST[imagedata]}" -transparent white "${tpyfile%.tpy}_${sid}.png"
+ sync
fi
mv "$tempfile" "$tpyfile"
border: 1px solid black;
}
input.color:checked + label{ border-width: 3px;}
-input.color[value="c000"] + label { background-color: #888;}
-input.color[value="c001"] + label { background-color: #00F;}
-input.color[value="c010"] + label { background-color: #0F0;}
-input.color[value="c011"] + label { background-color: #0FF;}
-input.color[value="c100"] + label { background-color: #F00;}
-input.color[value="c101"] + label { background-color: #F0F;}
-input.color[value="c110"] + label { background-color: #FF0;}
-input.color[value="c111"] + label { background-color: #FFF;}
+input.color[value="#000"] + label,
+input.color[value="#888"] + label { background-color: #888;}
+input.color[value="#00A"] + label { background-color: #00F;}
+input.color[value="#0A0"] + label { background-color: #0F0;}
+input.color[value="#0AA"] + label { background-color: #0FF;}
+input.color[value="#A00"] + label { background-color: #F00;}
+input.color[value="#A0A"] + label { background-color: #F0F;}
+input.color[value="#AA0"] + label { background-color: #FF0;}
+input.color[value="#FFF"] + label { background-color: #FFF;}
h1, label.tab, div.tab, fieldset.tab,
div.patient, div.prescription {
font: normal 1em sans-serif;
}
div.tab > fieldset.note > input.color + label { margin: 0; display: block; }
-div.tab > fieldset.note > input.color[value="c000"]:checked ~ textarea { background-color: #AAA; }
-div.tab > fieldset.note > input.color[value="c001"]:checked ~ textarea { background-color: #88F; }
-div.tab > fieldset.note > input.color[value="c010"]:checked ~ textarea { background-color: #8F8; }
-div.tab > fieldset.note > input.color[value="c011"]:checked ~ textarea { background-color: #8FF; }
-div.tab > fieldset.note > input.color[value="c100"]:checked ~ textarea { background-color: #F88; }
-div.tab > fieldset.note > input.color[value="c101"]:checked ~ textarea { background-color: #F8F; }
-div.tab > fieldset.note > input.color[value="c110"]:checked ~ textarea { background-color: #FF8; }
-div.tab > fieldset.note > input.color[value="c111"]:checked ~ textarea { background-color: #FFF; }
+div.tab > fieldset.note > input.color[value="#888"]:checked ~ textarea { background-color: #AAA; }
+div.tab > fieldset.note > input.color[value="#00A"]:checked ~ textarea { background-color: #88F; }
+div.tab > fieldset.note > input.color[value="#0A0"]:checked ~ textarea { background-color: #8F8; }
+div.tab > fieldset.note > input.color[value="#0AA"]:checked ~ textarea { background-color: #8FF; }
+div.tab > fieldset.note > input.color[value="#A00"]:checked ~ textarea { background-color: #F88; }
+div.tab > fieldset.note > input.color[value="#A0A"]:checked ~ textarea { background-color: #F8F; }
+div.tab > fieldset.note > input.color[value="#AA0"]:checked ~ textarea { background-color: #FF8; }
+div.tab > fieldset.note > input.color[value="#FFF"]:checked ~ textarea { background-color: #FFF; }
div.tab > button.delete {float: right; display: inline-block;}
EOF
unset c0 c1 c2 c3 c4 c5 c6 c7
case "$tpy[$color]" in
- c000) c0=checked;;
- c001) c1=checked;;
- c010) c2=checked;;
- c011) c3=checked;;
- c100) c4=checked;;
- c101) c5=checked;;
- c110) c6=checked;;
+ \#888) c0=checked;;
+ \#00A) c1=checked;;
+ \#0A0) c2=checked;;
+ \#0AA) c3=checked;;
+ \#A00) c4=checked;;
+ \#A0A) c5=checked;;
+ \#AA0) c6=checked;;
*) c7=checked;;
esac
cat <<EOF
<fieldset class=note>
- <input class=color type=radio name="$color" value="c000" id=${color}_000 $c0><label for=${color}_000></label>
- <input class=color type=radio name="$color" value="c001" id=${color}_001 $c1><label for=${color}_001></label>
- <input class=color type=radio name="$color" value="c010" id=${color}_010 $c2><label for=${color}_010></label>
- <input class=color type=radio name="$color" value="c011" id=${color}_011 $c3><label for=${color}_011></label>
- <input class=color type=radio name="$color" value="c100" id=${color}_100 $c4><label for=${color}_100></label>
- <input class=color type=radio name="$color" value="c101" id=${color}_101 $c5><label for=${color}_101></label>
- <input class=color type=radio name="$color" value="c110" id=${color}_110 $c6><label for=${color}_110></label>
- <input class=color type=radio name="$color" value="c111" id=${color}_111 $c7><label for=${color}_111></label>
+ <input class=color type=radio name="$color" value="#888" id=${color}_000 $c0><label for=${color}_000></label>
+ <input class=color type=radio name="$color" value="#00A" id=${color}_001 $c1><label for=${color}_001></label>
+ <input class=color type=radio name="$color" value="#0A0" id=${color}_010 $c2><label for=${color}_010></label>
+ <input class=color type=radio name="$color" value="#0AA" id=${color}_011 $c3><label for=${color}_011></label>
+ <input class=color type=radio name="$color" value="#A00" id=${color}_100 $c4><label for=${color}_100></label>
+ <input class=color type=radio name="$color" value="#A0A" id=${color}_101 $c5><label for=${color}_101></label>
+ <input class=color type=radio name="$color" value="#AA0" id=${color}_110 $c6><label for=${color}_110></label>
+ <input class=color type=radio name="$color" value="#FFF" id=${color}_111 $c7><label for=${color}_111></label>
<textarea name="session${session_n}_note${note_n}">${tpy[session${session_n}_note${note_n}]}</textarea>
</fieldset>
EOF
unset c0 c1 c2 c3 c4 c5 c6 c7
case "$tpy[color]" in
- c001) c1=checked;;
- c010) c2=checked;;
- c011) c3=checked;;
- c100) c4=checked;;
- c101) c5=checked;;
- c110) c6=checked;;
- c111) c7=checked;;
- *) c0=checked;;
+ \#00A) c1="checked";;
+ \#0A0) c2="checked";;
+ \#0AA) c3="checked";;
+ \#A00) c4="checked";;
+ \#A0A) c5="checked";;
+ \#AA0) c6="checked";;
+ \#FFF) c7="checked";;
+ *) c0="checked";;
esac
cat <<EOF
$(therapy_sessions)
<fieldset class=color>
- <input class=color type=radio name=color value="c000" id=c000 $c0><label for=c000></label>
- <input class=color type=radio name=color value="c001" id=c001 $c1><label for=c001></label>
- <input class=color type=radio name=color value="c010" id=c010 $c2><label for=c010></label>
- <input class=color type=radio name=color value="c011" id=c011 $c3><label for=c011></label>
- <input class=color type=radio name=color value="c100" id=c100 $c4><label for=c100></label>
- <input class=color type=radio name=color value="c101" id=c101 $c5><label for=c101></label>
- <input class=color type=radio name=color value="c110" id=c110 $c6><label for=c110></label>
- <input class=color type=radio name=color value="c111" id=c111 $c7><label for=c111></label>
+ <input class=color type=radio name=color onclick="javascript:setcol('#000')" value="#000" id=c000 $c0><label for=c000></label>
+ <input class=color type=radio name=color onclick="javascript:setcol('#00A')" value="#00A" id=c001 $c1><label for=c001></label>
+ <input class=color type=radio name=color onclick="javascript:setcol('#0A0')" value="#0A0" id=c010 $c2><label for=c010></label>
+ <input class=color type=radio name=color onclick="javascript:setcol('#0AA')" value="#0AA" id=c011 $c3><label for=c011></label>
+ <input class=color type=radio name=color onclick="javascript:setcol('#A00')" value="#A00" id=c100 $c4><label for=c100></label>
+ <input class=color type=radio name=color onclick="javascript:setcol('#A0A')" value="#A0A" id=c101 $c5><label for=c101></label>
+ <input class=color type=radio name=color onclick="javascript:setcol('#AA0')" value="#AA0" id=c110 $c6><label for=c110></label>
+ <input class=color type=radio name=color onclick="javascript:setcol('#FFF')" value="#FFF" id=c111 $c7><label for=c111></label>
</fieldset>
<img class="dotmark bg" src="?action=static_file&name=therapy_background.png" alt="">
-
+ <canvas id="canvas" class="dotmark ov" width="${bg_dim%x*}" height="${bg_dim#*x}"></canvas>
+
+ <input type=hidden id=image_serialize name=imagedata value="">
+ <span id="jsdebug" style="display: none; position: fixed; right:0; bottom:0">Debug</span>
+
+ <script><!--
+ body = document.body
+ canvas = document.getElementById("canvas")
+ dbg = document.getElementById("jsdebug")
+ image = canvas.getContext("2d")
+ mouse = 0
+ image_serialize=""
+ data=document.getElementById("image_serialize")
+
+ function setcol(c) {
+ image.fillStyle = c
+ image_serialize += " fill " + c
+ }
+
+ 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
+ }
+
+ window.addEventListener( 'mouseup', function() { mouse = 0
+ dbg.innerHTML = image_serialize
+ data.value = image_serialize
+ } )
+ canvas.addEventListener( 'mousedown', function(e) {
+ 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) }
+ } )
+ --></script>
</form>
EOF