// world.js // RJM Programming // March, 2016 // Help out world.html and others like it var polyco=[]; var fdstart=''; var fdnumber=' [2]'; var fdinc=' [1]'; var fdformat=' [d/m]'; var fdinitiald=''; var fdinitialf=''; var fdsuffix=''; var fddate=null; var jpegok=false; var wlsdval=''; var wlsnval=''; var wlsselect=''; var wlsname=''; var wlsask=false; var wlsprefix='For a future Standing Order, please have static images and signatures established in canvas before coming here. It is best to have made the two clicks necessary ahead of coming here too. An optional fifth field can be including in the Standing Order name (yyyymmdd_ prefix can facilitate overriding the one Standing Order a day restriction). Append format with a space for no Standing Order recall usage in this session. Comma separate First Date(Time)/Number'; var preinpr=''; var prebpic=false; var vials=false; var wlsnamesuffix=''; var wlsaddonto=false; var wlsusedata=true; var wlsls=true; var whiteize=null; var ourfdnumber=0; var ourfdinc=0; var ourfdincunit=''; var ourfdstart; var ourfdformat=''; var ourzhr=null; var ourzform=null; var icover=false; var icontain=false; var myimgdata=""; var beforetransparent="black"; var midataw=0; var midatah=0; var longhover=""; var firsthover=1; var winois=null; var onlyonce=true; var ssuffix='', forlater='', naming=[]; var ovr=0; var lasturl=''; var agdu=''; var maptype='img'; var mapext=''; var start=0, stop=0; var bmode=' an image '; var imageclickmode=0; // 0=scaling not based on click/touch, 1=fit to click/touch dimensions, 2=scale proportionally to fit width, 3=scale proportionally to fit height var rotcmd='', xxtds; var dmfcnt=0; var ewtwo=0.0; ehtwo=0.0; var zeroone=0.0; var txtoffx=0.0, txtoffy=0.0; var rotoffx=0.0, rotoffy=0.0; var scalex=1.0, scaley=1.0; var origih=0.0, origiw=0.0; var curih=0.0, curiw=0.0; var newih=0.0, newiw=0.0; var cropx=0.00, cropy=0.00; var cropwidth=100.00, cropheight=100.00; var butnotfirst=0; var fcont, w, isScribble=0, isSnapshot=0; var xua = navigator.userAgent; //if (document.getElementById('myh1')) document.getElementById('myh1').innerHTML+='' + xua; //var isiPad = /iPad/i.test(xua) || /iPhone OS 3_1_2/i.test(xua) || /Android/i.test(xua) || /iPhone OS 3_2_2/i.test(xua); var isiPad = /iPad/i.test(xua) || /iPhone/i.test(xua) || /Android/i.test(xua); var isTouch = /touch/i.test(xua) || /Touch/i.test(xua); var oimg=null; var ximg; var laststop = -1; var foreachon=true; var origimg; var canvascommands = []; var majors = [-1]; var xxlworld = 'world'; var xxuworld = 'World'; var xxuubits=document.referrer.split('.ht'); var xxuuubits, dot='.'; var thisim=null, thisimo=null; var iscontact=parent.document.URL.indexOf('Contact'); if (iscontact == -1) iscontact=document.URL.indexOf('contact=contact'); if (xxuubits.length == 1) { xxuubits=document.URL.split('.ht'); } if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) dot=''; xxuuubits=xxuubits[0].split('/'); xxlworld=xxuuubits[eval(-1 + xxuuubits.length)]; xxuubits=document.URL.split('.ht'); xxuuubits=xxuubits[0].split('/'); xxuworld=xxuuubits[eval(-1 + xxuuubits.length)].substring(0,1).toUpperCase() + xxuuubits[eval(-1 + xxuuubits.length)].substring(1).replace('_s',' S'); var dograyscale=false; var doinverse=false; var doflop=false; var doflip=false; if (!String.fromCodePoint) { // thanks to http://xahlee.info/js/js_unicode_code_point.html // ES6 Unicode Shims 0.1 , © 2012 Steven Levithan , MIT License String.fromCodePoint = function fromCodePoint () { var chars = [], point, offset, units, i; for (i = 0; i < arguments.length; ++i) { point = arguments[i]; offset = point - 0x10000; units = point > 0xFFFF ? [0xD800 + (offset >> 10), 0xDC00 + (offset & 0x3FF)] : [point]; chars.push(String.fromCharCode.apply(null, units)); } return chars.join(""); } } var bcols=['red','#ff0000', 'black','#000000', 'white','#ffffff', 'yellow','#ffff00', 'green','#00ff00', 'blue','#0000ff', 'cyan','#00ffff', 'magenta','#ff00ff', 'pink','#ffc0cb', 'lightblue','#add8e6', 'lightgreen','#90ee90', 'pink','#ffc0cb', 'lightpink','#ffb6c1' ,'hotpink','#ff69b4' ,'deeppink','#ff1493' ,'palevioletred','#db7093' ,'mediumvioletred','#c71585' ,'lightsalmon','#ffa07a' ,'salmon','#fa8072' ,'darksalmon','#e9967a' ,'lightcoral','#f08080' ,'indianred','#cd5c5c' ,'crimson','#dc143c' ,'firebrick','#b22222' ,'darkred','#8b0000' ,'red','#ff0000' ,'orangered','#ff4500' ,'tomato','#ff6347' ,'coral','#ff7f50' ,'darkorange','#ff8c00' ,'orange','#ffa500' ,'yellow','#ffff00' ,'lightyellow','#ffffe0' ,'lemonchiffon','#fffacd' ,'lightgoldenrodyellow','#fafad2' ,'papayawhip','#ffefd5' ,'moccasin','#ffe4b5' ,'peachpuff','#ffdab9' ,'palegoldenrod','#eee8aa' ,'khaki','#f0e68c' ,'darkkhaki','#bdb76b' ,'gold','#ffd700' ,'cornsilk','#fff8dc' ,'blanchedalmond','#ffebcd' ,'bisque','#ffe4c4' ,'navajowhite','#ffdead' ,'wheat','#f5deb3' ,'burlywood','#deb887' ,'tan','#d2b48c' ,'rosybrown','#bc8f8f' ,'sandybrown','#f4a460' ,'goldenrod','#daa520' ,'darkgoldenrod','#b8860b' ,'peru','#cd853f' ,'chocolate','#d2691e' ,'saddlebrown','#8b4513' ,'sienna','#a0522d' ,'brown','#a52a2a' ,'maroon','#800000' ,'olive','#808000' ,'olivedrab','#6b8e23' ,'yellowgreen','#9acd32' ,'limegreen','#32cd32' ,'lime','#00ff00' ,'lawngreen','#7cfc00' ,'chartreuse','#7fff00' ,'greenyellow','#adff2f' ,'springgreen','#00ff7f' ,'mediumspringgreen','#00fa9a' ,'lightgreen','#90ee90' ,'palegreen','#98fb98' ,'darkseagreen','#8fbc8f' ,'mediumseagreen','#3cb371' ,'seagreen','#2e8b57' ,'forestgreen','#228b22' ,'green','#008000' ,'darkgreen','#006400' ,'mediumaquamarine','#66cdaa' ,'aqua','#00ffff' ,'cyan','#00ffff' ,'lightcyan','#e0ffff' ,'paleturquoise','#afeeee' ,'aquamarine','#7fffd4' ,'turquoise','#40e0d0' ,'mediumturquoise','#48d1cc' ,'darkturquoise','#00ced1' ,'lightseagreen','#20b2aa' ,'cadetblue','#5f9ea0' ,'darkcyan','#008b8b' ,'teal','#008080' ,'lightsteelblue','#b0c4de' ,'powderblue','#b0e0e6' ,'lightblue','#add8e6' ,'skyblue','#87ceeb' ,'lightskyblue','#87cefa' ,'deepskyblue','#00bfff' ,'dodgerblue','#1e90ff' ,'cornflowerblue','#6495ed' ,'steelblue','#4682b4' ,'royalblue','#4169e1' ,'blue','#0000ff' ,'mediumblue','#0000cd' ,'darkblue','#00008b' ,'navy','#000080' ,'midnightblue','#191970' ,'thistle','#d8bfd8' ,'plum','#dda0dd' ,'violet','#ee82ee' ,'orchid','#da70d6' ,'fuchsia','#ff00ff' ,'magenta','#ff00ff' ,'mediumorchid','#ba55d3' ,'mediumpurple','#9370db' ,'blueviolet','#8a2be2' ,'darkviolet','#9400d3' ,'darkorchid','#9932cc' ,'darkmagenta','#8b008b' ,'purple','#800080' ,'indigo','#4b0082' ,'darkslateblue','#483d8b' ,'rebeccapurple','#663399' ,'slateblue','#6a5acd' ,'mediumslateblue','#7b68ee' ,'snow','#fffafa' ,'honeydew','#f0fff0' ,'mintcream','#f5fffa' ,'azure','#f0ffff' ,'aliceblue','#f0f8ff' ,'ghostwhite','#f8f8ff' ,'whitesmoke','#f5f5f5' ,'seashell','#fff5ee' ,'beige','#f5f5dc' ,'oldlace','#fdf5e6' ,'floralwhite','#fffaf0' ,'ivory','#fffff0' ,'antiquewhite','#faebd7' ,'linen','#faf0e6' ,'lavenderblush','#fff0f5' ,'mistyrose','#ffe4e1' ,'gainsboro','#dcdcdc' ,'lightgrey','#d3d3d3' ,'silver','#c0c0c0' ,'darkgray','#a9a9a9' ,'gray','#808080' ,'dimgray','#696969' ,'lightslategray','#778899' ,'slategray','#708090' ,'darkslategray','#2f4f4f']; function hexdec (hexString) { // thanks to https://locutus.io/php/math/hexdec/ // discuss at: https://locutus.io/php/hexdec/ // original by: Philippe Baumann // example 1: hexdec('that') // returns 1: 10 // example 2: hexdec('a0') // returns 2: 160 hexString = (hexString + '').replace(/[^a-f0-9]/gi, ''); return parseInt(hexString, 16); } function hex2dec(couleur, inopac) { var dolR = couleur.toLowerCase().replace('#','').substring(0,2); var dolrouge = hexdec(dolR); var dolV = couleur.toLowerCase().replace('#','').replace(dolR,'').substring(0,2); var dolvert = hexdec(dolV); var dolB = couleur.toLowerCase().replace('#','').replace(dolR,'').replace(dolV,'').substring(0,2); var dolbleu = hexdec(dolB); if (inopac != '') { return 'rgba(' + dolrouge + ',' + dolvert + ',' + dolbleu + ',' + inopac + ')'; } else { return couleur.toLowerCase(); } } function opacitymaybe(incvalo) { var incval=incvalo.value; var origincval=incval.toLowerCase(); var opac=''; var colwords=incval.split(' '); if (colwords.length > 1) { if ((colwords[eval(-1 + colwords.length)] + ' ').substring(0,1) == '.' || ((colwords[eval(-1 + colwords.length)] + ' ').substring(0,1) >= '0' && (colwords[eval(-1 + colwords.length)] + ' ').substring(0,1) <= '9')) { opac=colwords[eval(-1 + colwords.length)]; incval=incval.replace(' ' + opac, ''); } } //if ((incval + ' ').substring(0,1) != '#') { // alert(incval + ' ... ' + bcols.indexOf(incval.toLowerCase().replace(/\ /g,'')) + ' --- ' + bcols[1 + bcols.indexOf(incval.toLowerCase().replace(/\ /g,''))]); //} if ((incval.toLowerCase + ' ').substring(0,3) != 'rgb') { if ((incval + ' ').substring(0,1) == '#') { incval=hex2dec(incval, opac); } else if (bcols.indexOf(incval.toLowerCase().replace(/\ /g,'')) != -1) { incval=hex2dec(bcols[1 + bcols.indexOf(incval.toLowerCase().replace(/\ /g,''))], opac); } } if (incval != origincval) { incvalo.value=incval; } return incval; } function myiminteresting(iois) { if (iois != null) { if (iois.src.replace(document.URL,'').trim() != '') { if (document.getElementById('myimx').src.replace(document.URL,'') != '') { //elem.width=elem.width; //elem.height=elem.height; if (parent.document.getElementById('canvaselement')) { console.log('parent1: ' + parent.document.getElementById('canvaselement').width + ',' + parent.document.getElementById('canvaselement').height + ' vs ' + document.getElementById('myimx').width + ',' + document.getElementById('myimx').height); if (vials) { vials=false; parent.document.getElementById('canvaselement').width=document.getElementById('myimx').width; parent.document.getElementById('canvaselement').height=document.getElementById('myimx').height; if (document.getElementById('myh1')) { if (document.getElementById('myh1').innerHTML.indexOf('<') == -1) { document.getElementById('myh1').innerHTML+='  🔄'; } if (document.getElementById('maybetoggle').innerHTML == '') { document.getElementById('maybetoggle').innerHTML=' 🔄'; } //alert('Parent 7: ' + elem.width + ',' + elem.height + ' vs ' + ioo.width + ',' + ioo.height); } else if (parent.document.getElementById('myh1')) { //alert('ParenT 7: ' + elem.width + ',' + elem.height + ' vs ' + ioo.width + ',' + ioo.height); doinverse=doinverse; } else { //alert('parent 7: ' + elem.width + ',' + elem.height + ' vs ' + ioo.width + ',' + ioo.height); doinverse=doinverse; } document.getElementById('divannotation').style.zIndex='-9'; document.getElementById('divannotation').style.opacity='0.6'; } parent.document.getElementById('canvaselement').getContext('2d').drawImage(document.getElementById('myimx'), 0, 0, document.getElementById('myimx').width, document.getElementById('myimx').height); parent.document.getElementById('phpsel').value=''; } else { console.log('nonparent1: ' + elem.width + ',' + elem.height + ' vs ' + document.getElementById('myimx').width + ',' + document.getElementById('myimx').height); context.drawImage(document.getElementById('myimx'), 0, 0, document.getElementById('myimx').width, document.getElementById('myimx').height); document.getElementById('phpsel').value=''; } canvascommands.push("context.drawImage(document.getElementById('myimx'), 0, 0);"); } } } } function postphpselit() { document.getElementById('duis').innerHTML=elem.toDataURL("image/png",0); document.getElementById('myimx').src=document.URL; document.getElementById('bduis').click(); } function phpselit(tv) { if (tv.trim() != '') { if (document.getElementById('myimx').src.replace(document.URL,'') != '') { //alert(document.getElementById('myimx').src + ' vs ' + document.URL); postphpselit(); } else { //alert(document.getElementById('myimx').src + ' vs ' + document.URL); document.getElementById('bduis').name=tv.trim(); icontain=true; icover=false; document.getElementById('pcbut').click(); setTimeout(postphpselit, 3000); } } } function oureval(incmd, twot) { eval(incmd + twot); twot='!' + incmd.split("=")[0] + "; document.getElementById('" + incmd.split("=")[0].replace('do','chk') + "').checked=" + incmd.split("=")[0] + ";"; canvascommands.push(incmd + twot); } function togglea() { if (('' + document.getElementById('divannotation').style.zIndex).indexOf('-') != -1) { document.getElementById('divannotation').style.zIndex='9'; } else { document.getElementById('divannotation').style.zIndex='-9'; } } function ourDrawImage(ioo, ione, itwo, ithree, ifour, ifive, isix, iseven, ieight) { // thanks to https://stackoverflow.com/questions/3129099/how-to-flip-images-horizontally-with-html5 if (doflip) { context.setTransform(-1,0,0,1,elem.width,0); // thanks to https://stackoverflow.com/questions/42844470/how-to-rotate-and-mirror-canvas-element } else if (doflop) { context.setTransform(1,0,0,-1,0,elem.height); // thanks to https://stackoverflow.com/questions/42844470/how-to-rotate-and-mirror-canvas-element } if (typeof ieight !== 'undefined') { //alert('parent 5: ' + elem.width + ',' + elem.height + ' vs ' + ioo.width + ',' + ioo.height); context.drawImage(ioo, ione, itwo, ithree, ifour, ifive, isix, iseven, ieight); if (dograyscale) { grayscale(ioo, ione, itwo, ithree, ifour, ifive, isix, iseven, ieight); } if (doinverse) { inverse(ioo, ione, itwo, ithree, ifour, ifive, isix, iseven, ieight); } } else if (typeof isix !== 'undefined') { //alert('parent 6: ' + elem.width + ',' + elem.height + ' vs ' + ioo.width + ',' + ioo.height); context.drawImage(ioo, ione, itwo, ithree, ifour, ifive, isix); if (dograyscale) { grayscale(ioo, ione, itwo, ithree, ifour, ifive, isix); } if (doinverse) { inverse(ioo, ione, itwo, ithree, ifour, ifive, isix); } } else { if (prebpic && (elem.width != ioo.width || elem.height != ioo.height)) { jpegok=true; if (document.getElementById('myh1')) { if (document.getElementById('myh1').innerHTML.indexOf('<') == -1) { document.getElementById('myh1').innerHTML+='  🔄'; } if (document.getElementById('maybetoggle').innerHTML == '') { document.getElementById('maybetoggle').innerHTML=' 🔄'; } //alert('Parent 7: ' + elem.width + ',' + elem.height + ' vs ' + ioo.width + ',' + ioo.height); } else if (parent.document.getElementById('myh1')) { //alert('ParenT 7: ' + elem.width + ',' + elem.height + ' vs ' + ioo.width + ',' + ioo.height); doinverse=doinverse; } else { //alert('parent 7: ' + elem.width + ',' + elem.height + ' vs ' + ioo.width + ',' + ioo.height); doinverse=doinverse; } elem.width = ioo.width; elem.height = ioo.height; } if (prebpic) { ione=0; itwo=0; ithree=elem.width; ifour=elem.height; document.getElementById('divannotation').style.zIndex='-9'; document.getElementById('divannotation').style.opacity='0.6'; context.drawImage(ioo, 0, 0, elem.width, elem.height); prebpic=false; } else { context.drawImage(ioo, ione, itwo, ithree, ifour); } if (dograyscale) { grayscale(ioo, ione, itwo, ithree, ifour); } if (doinverse) { inverse(ioo, ione, itwo, ithree, ifour); } } document.getElementById('myimx').src=document.URL + '#r' + Math.floor(Math.random() * 19875643); } function inverse(ioo, ione, itwo, ithree, ifour, ifive, isix, iseven, ieight) { // thanks to https://www.w3schools.com/tags/canvas_getimagedata.asp var i; var imgData; if (typeof ieight !== 'undefined') { imgData=context.getImageData(ione, itwo, ithree, ifour); } else if (typeof isix !== 'undefined') { imgData=context.getImageData(ione, itwo, ithree, ifour); } else { imgData=context.getImageData(ione, itwo, ithree, ifour); } var data = imgData.data; for (i=0;i'; startdatauriimage = startcookie; laststop=0; var lines=startdatauriimage.split("\n"); for (var ij=0; ij'; if (eval(1 + ij) != eval(lines.length)) { storecanvascommands(lines[ij], false); majors[laststop]=ij; } else { storecanvascommands(lines[ij], false); majors[laststop]=ij; } } //setcurrentsnapshot(startdatauriimage); //redo(); for (var iup=0; iup < canvascommands.length; iup++) { eval(reworked(canvascommands[iup])); } if (document.getElementById('dsnapshot').innerHTML.indexOf('Overlay snapshot ' + nameof(isuffix) + '<') == -1) forlater=forlater.replace('',''); } } //if (ij == 0) document.getElementById('dsnapshot').innerHTML = '' + document.getElementById('dsnapshot').innerHTML + ''; if (eval(1 + ij) != eval(lines.length)) { storecanvascommands(lines[ij], false); majors[laststop]=ij; } else { storecanvascommands(lines[ij], false); majors[laststop]=ij; } } //setcurrentsnapshot(startdatauriimage); //redo(); for (var iup=0; iup < canvascommands.length; iup++) { eval(reworked(canvascommands[iup])); } if (document.getElementById('dsnapshot').innerHTML.indexOf('Overlay snapshot ' + nameof(isuffix) + '<') == -1) forlater=forlater.replace('',''); } else { if (forlater.indexOf('>Overlay snapshot ' + nameof(isuffix) + '<') == -1) forlater=forlater.replace('',''); } } //if (ij == 0) document.getElementById('dsnapshot').innerHTML = '' + document.getElementById('dsnapshot').innerHTML + ''; if (eval(1 + ij) != eval(lines.length)) { storecanvascommands(lines[ij], false); majors[laststop]=ij; } else { storecanvascommands(lines[ij], false); majors[laststop]=ij; } } //setcurrentsnapshot(startdatauriimage); //redo(); iisuffix++; imagedatauri=cookievalue("snapshot" + iisuffix); if (imagedatauri != '') forlater=forlater.replace('',''); //alert('iisuffix=' + iisuffix + ' imagedatauri=' + imagedatauri); } if (document.getElementById('dsnapshot').innerHTML.indexOf(' 0) { dmfcnt=Math.abs(dmfcnt); if (dmfcnt == 0) dmfcnt=1; } else { if (eval(dmfcnt) > 0) { var dmisone=document.getElementById('mapcoords' + dmfcnt); var dmis=document.getElementById('dmyform'); var dmxis=document.getElementById('dmyxform'); if (dmis != null) { if (dmisone == null) { audiobit="' + dot + ''; //audiobit="'; recbit='
Url ' + dmfcnt + ": at ' + audiobit; dmis.innerHTML+=recbit; recbit="'; dmxis.innerHTML+=recbit; dmisone=document.getElementById('mapcoords' + dmfcnt); } dmfcnt++; } } } } } function postpostnewiw(proposediw, oh, ow, oheight, ycrop) { var deg; deg=eval(document.getElementById('rotation').value); var xx=Math.abs(Math.sin(deg*Math.PI/180)) * Math.abs(lasty - y) + Math.abs(Math.cos(deg*Math.PI/180)) * Math.abs(lastx - x); var yy=Math.abs(Math.sin(deg*Math.PI/180)) * Math.abs(lastx - x) + Math.abs(Math.cos(deg*Math.PI/180)) * Math.abs(lasty - y); if (imageclickmode == 0 || xx == 0.0) return proposediw; if (imageclickmode == 1) { //alert("proposediw=" + proposediw + " vs returned=" + xx); return Math.abs(lastx - x); //Math.abs(xx); } if (imageclickmode == 2) return Math.abs(lastx - x); //Math.abs(xx); //alert("Math.abs(lasty - y)=" + Math.abs(lasty - y) + " and proposedH=" + Math.abs(oh) + " and Math.abs(lastx - x)=" + Math.abs(lastx - x) + " so newiw becomes=" + eval( (Math.abs(lasty - y) / Math.abs(oh)) * Math.abs(lastx - x))); return eval( (Math.abs(yy) / Math.abs(oh)) * Math.abs(ow)); //lastx - x)); } function postpostnewih(proposedih, ow, oh, owidth, xcrop) { var deg; deg=eval(document.getElementById('rotation').value); var xx=Math.abs(Math.sin(deg*Math.PI/180)) * Math.abs(lasty - y) + Math.abs(Math.cos(deg*Math.PI/180)) * Math.abs(lastx - x); var yy=Math.abs(Math.sin(deg*Math.PI/180)) * Math.abs(lastx - x) + Math.abs(Math.cos(deg*Math.PI/180)) * Math.abs(lasty - y); if (imageclickmode == 0 || yy == 0.0) return proposedih; if (imageclickmode == 1) { //alert("proposedih=" + proposedih + " vs returned=" + yy); return Math.abs(lasty - y); //Math.abs(yy); } if (imageclickmode == 3) return Math.abs(lasty - y); //Math.abs(yy); return eval( (Math.abs(xx) / Math.abs(ow)) * Math.abs(oh)); //lasty - y)); } function offymaybe(pxoff, nh, nw) { var deg; if (imageclickmode != 0 && eval(document.getElementById('rotation').value) != 0) { deg=eval(document.getElementById('rotation').value); //alert("Xwas=" + pxoff + " but now to become " + eval(pxoff + Math.abs(Math.sin(deg*Math.PI/180)) * nh / 2 + Math.abs(Math.cos(deg*Math.PI/180)) * nw / 2)); return eval(pxoff + Math.abs(Math.sin(deg*Math.PI/180)) * nh / 2 + Math.abs(Math.cos(deg*Math.PI/180)) * nw / 2); } return pxoff; } function offxmaybe(pyoff, nw, nh) { var deg; if (imageclickmode != 0 && eval(document.getElementById('rotation').value) != 0) { deg=eval(document.getElementById('rotation').value); //alert("Ywas=" + pyoff + " but now to become " + eval(pyoff + Math.abs(Math.cos(deg*Math.PI/180)) * nw / 2 + Math.abs(Math.sin(deg*Math.PI/180)) * nh / 2)); return eval(pyoff + Math.abs(Math.cos(deg*Math.PI/180)) * nw / 2 + Math.abs(Math.sin(deg*Math.PI/180)) * nh / 2); } return pyoff; } function postscalew(proposedscalew, oh, ow) { var deg; deg=eval(document.getElementById('rotation').value); var yy=Math.abs(Math.sin(deg*Math.PI/180)) * Math.abs(lasty - y) + Math.abs(Math.cos(deg*Math.PI/180)) * Math.abs(lastx - x); var xx=Math.abs(Math.sin(deg*Math.PI/180)) * Math.abs(lastx - x) + Math.abs(Math.cos(deg*Math.PI/180)) * Math.abs(lasty - y); if (imageclickmode == 0 || xx == 0.0) return proposedscalew; if (imageclickmode == 1) { //alert("proposedscalew=" + proposedscalew + " vs returned=" + Math.abs(xx) / Math.abs(ow)); return Math.abs(xx) / Math.abs(ow); } if (imageclickmode == 2) return Math.abs(xx) / Math.abs(ow); //alert("Math.abs(lasty - y)=" + Math.abs(lasty - y) + " and proposedH=" + Math.abs(oh) + " and Math.abs(lastx - x)=" + Math.abs(lastx - x) + " so newiw becomes=" + eval( (Math.abs(lasty - y) / Math.abs(oh)) * Math.abs(lastx - x))); return eval( (Math.abs(yy) / Math.abs(oh)) * Math.abs(ow)) / Math.abs(oh); //lastx - x)); } function postscaleh(proposedscaleh, ow, oh) { var deg; deg=eval(document.getElementById('rotation').value); var yy=Math.abs(Math.sin(deg*Math.PI/180)) * Math.abs(lasty - y) + Math.abs(Math.cos(deg*Math.PI/180)) * Math.abs(lastx - x); var xx=Math.abs(Math.sin(deg*Math.PI/180)) * Math.abs(lastx - x) + Math.abs(Math.cos(deg*Math.PI/180)) * Math.abs(lasty - y); if (imageclickmode == 0 || yy == 0.0) return proposedscaleh; if (imageclickmode == 1) { //alert("proposedscaleh=" + proposedscaleh + " vs returned=" + Math.abs(yy) / Math.abs(oh)); return Math.abs(yy) / Math.abs(oh); } if (imageclickmode == 3) return Math.abs(yy) / Math.abs(oh); return eval( (Math.abs(xx) / Math.abs(ow)) * Math.abs(oh)) / Math.abs(ow); //lasty - y)); } function okpostscalew(proposedscalew, oh, ow) { if (imageclickmode == 0 || Math.abs(lastx - x) == 0.0) return proposedscalew; if (imageclickmode == 1) { //alert("proposediw=" + proposediw + " vs returned=" + Math.abs(lastx - x)); return Math.abs(lastx - x) / Math.abs(ow); } if (imageclickmode == 2) return Math.abs(lastx - x) / Math.abs(ow); //alert("Math.abs(lasty - y)=" + Math.abs(lasty - y) + " and proposedH=" + Math.abs(oh) + " and Math.abs(lastx - x)=" + Math.abs(lastx - x) + " so newiw becomes=" + eval( (Math.abs(lasty - y) / Math.abs(oh)) * Math.abs(lastx - x))); return eval( (Math.abs(lasty - y) / Math.abs(oh)) * Math.abs(ow)) / Math.abs(oh); //lastx - x)); } function okpostscaleh(proposedscaleh, ow, oh) { if (imageclickmode == 0 || Math.abs(lasty - y) == 0.0) return proposedscaleh; if (imageclickmode == 1) { //alert("proposedih=" + proposedih + " vs returned=" + Math.abs(lasty - y)); return Math.abs(lasty - y) / Math.abs(oh); } if (imageclickmode == 3) return Math.abs(lasty - y) / Math.abs(oh); return eval( (Math.abs(lastx - x) / Math.abs(ow)) * Math.abs(oh)) / Math.abs(ow); //lasty - y)); } function postnewiw(proposediw, oh, ow, oheight, ycrop) { if (imageclickmode == 0 || Math.abs(lastx - x) == 0.0) return proposediw; if (imageclickmode == 1) { //alert("proposediw=" + proposediw + " vs returned=" + Math.abs(lastx - x)); return Math.abs(lastx - x); } if (imageclickmode == 2) return Math.abs(lastx - x); //alert("Math.abs(lasty - y)=" + Math.abs(lasty - y) + " and proposedH=" + Math.abs(oh) + " and Math.abs(lastx - x)=" + Math.abs(lastx - x) + " so newiw becomes=" + eval( (Math.abs(lasty - y) / Math.abs(oh)) * Math.abs(lastx - x))); return eval( (Math.abs(lasty - y) / Math.abs(oh)) * Math.abs(ow)); //lastx - x)); } function postnewih(proposedih, ow, oh, owidth, xcrop) { if (imageclickmode == 0 || Math.abs(lasty - y) == 0.0) return proposedih; if (imageclickmode == 1) { //alert("proposedih=" + proposedih + " vs returned=" + Math.abs(lasty - y)); return Math.abs(lasty - y); } if (imageclickmode == 3) return Math.abs(lasty - y); return eval( (Math.abs(lastx - x) / Math.abs(ow)) * Math.abs(oh)); //lasty - y)); } function capture(toh, tos, toe) { // if (navigator.userAgent.match(/Android/i)) alert('iscontact=' + iscontact); //if (iscontact != -1 && navigator.userAgent.match(/Android/i)) alert(700000); if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) && iscontact == -1) { if (document.getElementById('myiemail').value.indexOf('@') == -1) { var femail = prompt('Please supply the Email To address', ''); if (femail == null) femail = ''; if (femail.indexOf('@') != -1) { fixmyemail(femail, 0); } } } else { //if (iscontact != -1 && navigator.userAgent.match(/Android/i)) alert(70000); //if (iscontact != -1 && !document.getElementById('myiemail')) alert(7); if (document.getElementById('myiemail')) { if (document.getElementById('myiemail').value.indexOf('@') != -1) { // if (iscontact != -1) alert(70); document.getElementById('mode').value = ''; document.getElementById('ismobile').value = 'y'; document.getElementById('myisubject').style.display = 'inline'; document.getElementById('myiemail').style.display = 'inline'; document.getElementById('myform').action = document.getElementById('myform').action.replace('?mode=1', ''); document.getElementById('myform').action = document.getElementById('myform').action.replace('mode=1', 'mode='); //document.getElementById('myemail').href = '#' + document.getElementById('myemail').href; // if (iscontact != -1) alert(700); } } } //if (iscontact != -1 && navigator.userAgent.match(/Android/i)) alert(7000); var pretoh = elem.toDataURL("image/png",0); //toh.value = pretoh.substr(22, pretoh.length); var xbits=pretoh.split(','); //toh.value = pretoh.substr(eval(pretoh.indexOf(',') + 1), pretoh.length); //if (iscontact != -1 && navigator.userAgent.match(/Android/i)) alert(xbits[0]); toh.value = pretoh.replace(xbits[0] + ',', ''); //if (iscontact != -1 && navigator.userAgent.match(/Android/i)) alert(70000); if (iscontact == -1) { if (1 == 1) { tos.click(); } else { document.getElementById('myform').submit(); } } //if (iscontact != -1 && navigator.userAgent.match(/Android/i)) alert(700000); var things = document.URL.split("?"); //if (iscontact != -1 && navigator.userAgent.match(/Android/i)) alert("document.getElementById('myfname').value=" + document.getElementById('myfname').value); if (iscontact != -1) { toe.href = toe.href.split('ody=')[0].replace('fill.in.email@address',document.getElementById('myto').value).replace('tJUNK=', 't=' + encodeURIComponent(document.getElementById('mysubject').value) + '%20to%20').replace('&b','&cc=' + encodeURIComponent(document.getElementById('mycc').value) + '&bcc=' + encodeURIComponent(document.getElementById('mybcc').value) + '&b') + 'ody=' + encodeURIComponent(document.getElementById('myfeedback').value); // + (things[0] + "/~").replace("world.html/~", document.getElementById('myfname').value).replace(xxlworld + ".html/~", document.getElementById('myfname').value).replace("index.html/~", document.getElementById('myfname').value).replace("//~", "/" + document.getElementById('myfname').value).replace("/~", "/" + document.getElementById('myfname').value); } else { toe.href = toe.href + (things[0] + "/~").replace("world.html/~", document.getElementById('myfname').value).replace(xxlworld + ".html/~", document.getElementById('myfname').value).replace("index.html/~", document.getElementById('myfname').value).replace("//~", "/" + document.getElementById('myfname').value).replace("/~", "/" + document.getElementById('myfname').value); } //if (iscontact != -1 && navigator.userAgent.match(/Android/i)) alert(toe.href); if (iscontact != -1) { if (navigator.userAgent.match(/Android/i)) { aemail(toe); } else { toe.click(); } } else { if (document.getElementById('to').value.indexOf('@') != -1 || navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) { toe=toe; } else { toe.click(); } } } function reworked(inm) { var koff=-1; var inmbits=inm.split('/' + '/'); if (inmbits.length > 1) { var ybits=inmbits[0].split('('); if (ybits.length > 1 && inmbits[1].substring(0,6) != ' Name:') { var zbits=ybits[1].split(','); xxtds=document.getElementsByTagName('img'); xxtds[eval(koff + xxtds.length)].src=inmbits[1].replace(';','').trim(); eval(zbits[0] + " = xxtds[" + eval(koff + xxtds.length) + "]"); } } return inmbits[0].trim(); } function nameof(what) { var nwhat = cookievalue("snapshot" + ("~" + what + "~").replace("~1~","").replace("~","").replace("~","")); if (nwhat != "") { var namebits=nwhat.split('/' + '/ Name:'); if (namebits.length > 1) { var postnamebits=namebits[1].split("\n"); return what + ' [' + postnamebits[0].replace(';','').trim() + ']'; } } return what; } function fullcookieredo() { var xssuffix="", isuffix=1, xprefix="", fc="", jsuffix=0; if (("" + ssuffix).indexOf("-") != -1) jsuffix=eval(ssuffix); while (cookievalue("snapshot" + xssuffix) != "") { if (eval(jsuffix + isuffix) != 0) { if (eval(naming.length) < isuffix) { scol=';'; naming.push(nameof(isuffix)); } else { scol=';'; if (naming[isuffix] != '') { if (cookievalue("snapshot" + xssuffix).indexOf('Name:' + naming[isuffix] + ';') == -1) { if (naming.length > isuffix) scol+=' /' + '/ Name:' + naming[isuffix] + ";\n"; } } } if (scol != ';') { var expiredate = new Date(); expiredate.setYear(expiredate.getFullYear() + 1); document.cookie = "snapshot" + xssuffix + "=" + encodeURIComponent(cookievalue("snapshot" + xssuffix).replace(';',scol)) + "; expires=" + expiredate.toGMTString() + "; path=/"; } fc += xprefix + encodeURIComponent(cookievalue("snapshot" + xssuffix).replace(';',scol)); if (forlater.indexOf('>Overlay snapshot ' + nameof(isuffix) + '<') == -1) forlater=forlater.replace('',''); } else { fc += xprefix + ""; if (forlater.indexOf('>Name snapshot ' + nameof(isuffix) + '<') == -1) forlater=forlater.replace('',''); } isuffix++; xssuffix="" + isuffix; xprefix="; snapshot" + isuffix + "="; } return fc; } function cookieredo() { var cstr=" ", isuffix=1; //alert(canvascommands.length); if (ssuffix.trim() == '') { for (var iup=0; iup < canvascommands.length; iup++) { cstr += canvascommands[iup] + " \n"; } } if (ssuffix == ' ') { if (naming.length <= 1) naming.push(""); isuffix=eval(0 + naming.length); //alert('isuffix=' + isuffix); ssuffix=isuffix; document.getElementById('selcookie').innerHTML+=''; } else if (cookievalue("snapshot") != "") { if (ssuffix == '' && forlater.indexOf('Overlay snapshot ' + nameof(isuffix) + '<') == -1) forlater=forlater.replace('',''); setTimeout(xforlater, 1000); } else { document.getElementById('selcookie').innerHTML+=''; } } //document.getElementById('dsnapshot').innerHTML+=''; } //alert("forlater=" + forlater); return encodeURIComponent(cstr); } function xforlater() { //alert(forlater); if (cookievalue("snapshot") != "") document.getElementById('dsnapshot').innerHTML+=forlater; } function selcchange(selc) { //alert(selc); var nameit=selc.replace('name',''); var overlayit=selc.replace('overlay',''); var clearit=selc.replace('clear',''); var deleteit=selc.replace('delete',''); var addit=selc.replace('add',''); if (nameit != selc) { var nm=prompt("Please name snapshot " + nameof(nameit), nameof(nameit).replace(nameit,'').replace(' [','').replace(']','')); if (nm != null) { if (nm != '' && nm != nameof(nameit).replace(nameit,'').replace(' [','').replace(']','')) { ssuffix=eval(nameit); var huhn='[' + nameof(nameit).replace(nameit,'').replace(' [','').replace(']','').trim() + ']'; if (("" + nameit) == "1") { var expiredate = new Date(); expiredate.setYear(expiredate.getFullYear() + 1); document.cookie = "snapshot=" + encodeURIComponent(cookievalue("snapshot").replace(';','; /' + '/ Name:' + nm + ';')) + "; expires=" + expiredate.toGMTString() + "; path=/"; } naming[eval('0' + nameit)]=nm; //alert(document.getElementById('selcookie').innerHTML + ' ..... huhn=' + huhn); if (huhn == '[]') { huhn=' snapshot ' + nameit + '<'; nm=' snapshot ' + nameit + ' [' + nm + ']<'; } else { if (document.getElementById('selcookie').innerHTML.indexOf(huhn) == -1) { huhn=' snapshot ' + nameit + '<'; nm=' snapshot ' + nameit + ' [' + nm + ']<'; } else { nm='[' + nm + ']'; } } //alert(document.getElementById('selcookie').innerHTML + ' ... huhn=' + huhn); document.getElementById('selcookie').innerHTML=document.getElementById('selcookie').innerHTML.replace(huhn,nm).replace(huhn,nm).replace(huhn,nm); getchosensnapshot("2"); //alert(cookievalue("snapshot")); ssuffix=''; } } } if (overlayit != selc) { ssuffix=eval(overlayit); //alert('ssuffix=' + eval(overlayit)); querycurrentsnapshot("setifthere"); ssuffix=''; } if (clearit != selc) { ssuffix=eval(-clearit); getchosensnapshot("2"); ssuffix=''; } if (deleteit != selc) { var expiredate = new Date(); expiredate.setYear(expiredate.getFullYear() - 1); document.cookie = "snapshot=; expires=" + expiredate.toGMTString() + "; path=/"; var ksuffix=1; while (ksuffix < naming.length) { ksuffix++; document.cookie = "snapshot" + ksuffix + "=; expires=" + expiredate.toGMTString() + "; path=/"; } document.getElementById('selcookie').innerHTML=''; ssuffix=''; naming=[]; } if (addit != selc) { ssuffix=' '; var appbits=cookieredo(); //alert('was=' + document.cookie); //document.cookie = document.cookie.replace("expires=", "snapshot" + ssuffix + "=" + appbits + "; expires="); var expiredate = new Date(); expiredate.setYear(expiredate.getFullYear() + 1); var wasi=naming.length; if (wasi == 0) naming.push(""); document.cookie = "snapshot" + ('~' + naming.length + '~').replace('~1~','').replace('~','').replace('~','') + "=" + appbits + "; expires=" + expiredate.toGMTString() + "; path=/"; //getchosensnapshot("2"); //alert('is=' + document.cookie); ssuffix=''; if (wasi != 0) naming.push(""); } } function redo() { var upto=-1, iup; if (eval(laststop) < eval(-1 + majors.length)) { laststop++; upto = majors[laststop]; } else if (eval(laststop) == eval(-1 + majors.length)) { upto = majors[laststop]; } context.clearRect(0, 0, elem.width, elem.height); if (imageclickmode != 0 || eval(scalex) != 1.0 || eval(scaley) != 1.0 || eval(cropwidth) != 100.00 || eval(cropheight) != 100.000 || eval(cropx) != 0.00 || eval(cropy) != 0.00) { newiw=postnewiw(eval(eval(origiw - cropx) * scalex), eval(origih - cropy), eval(origiw - cropx), origih, cropy); newih=postnewih(eval(eval(origih - cropy) * scaley), eval(origiw - cropx), eval(origih - cropy), origiw, cropx); //alert("newiw=" + newiw + " and newih=" + newih); if (imageclickmode != 0) { ourDrawImage(origimg,Math.min(x,lastx),Math.min(y,lasty),newiw,newih); } else if (eval(cropwidth) != 100.00 || eval(cropheight) != 100.000 || eval(cropx) != 0.00 || eval(cropy) != 0.00) { ourDrawImage(origimg,eval(cropx),eval(cropy),eval(eval(origiw - cropx) * cropwidth / ((document.getElementById('cselwidth').value == '%') ? 100.0 : 1.00)),eval(eval(origih - cropy) * cropheight / ((document.getElementById('cselheight').value == '%') ? 100.0 : 1.00)),0,0,newiw,newih); } else { ourDrawImage(origimg,0,0,newiw,newih); } } else { ourDrawImage(origimg,0,0); } if (eval(upto) >= 0) { for (var iup=0; iup <= upto; iup++) { eval(reworked(canvascommands[iup])); } } } function undo() { var upto=-1, iup; if (butnotfirst != 0) { if (oimg != null) origimg=oimg; upto=eval(-1 + canvascommands.length); elem.style.backgroundColor='transparent'; } else if (eval(laststop) > 0) { laststop--; upto = majors[laststop]; } else if (eval(laststop) == 0) { laststop = -1; } context.clearRect(0, 0, elem.width, elem.height); if (imageclickmode != 0 || eval(scalex) != 1.0 || eval(scaley) != 1.0 || eval(cropwidth) != 100.00 || eval(cropheight) != 100.000 || eval(cropx) != 0.00 || eval(cropy) != 0.00) { newiw=postnewiw(eval(eval(origiw - cropx) * scalex), eval(origih - cropy), eval(origiw - cropx), origih, cropy); newih=postnewih(eval(eval(origih - cropy) * scaley), eval(origiw - cropx), eval(origih - cropy), origiw, cropx); //alert("neWiw=" + newiw + " and newih=" + newih); if (imageclickmode != 0) { if (butnotfirst == 0) { ourDrawImage(origimg,Math.min(x,lastx),Math.min(y,lasty),newiw,newih); } } else if (eval(cropwidth) != 100.00 || eval(cropheight) != 100.000 || eval(cropx) != 0.00 || eval(cropy) != 0.00) { if (butnotfirst == 0) { ourDrawImage(origimg,eval(cropx),eval(cropy),eval(eval(origiw - cropx) * cropwidth / ((document.getElementById('cselwidth').value == '%') ? 100.0 : 1.00)),eval(eval(origih - cropy) * cropheight / ((document.getElementById('cselheight').value == '%') ? 100.0 : 1.00)),0,0,newiw,newih); } } else { if (butnotfirst == 0) { ourDrawImage(origimg,0,0,newiw,newih); } } } else { if (butnotfirst == 0) { ourDrawImage(origimg,0,0); } } if (eval(upto) >= 0) { for (var iup=0; iup <= upto; iup++) { eval(canvascommands[iup]); } } butnotfirst = 0; } function storecanvascommands(thecmd, major) { //alert(thecmd + " " + ewtwo + "," + ehtwo); if (thecmd.indexOf('.drawImage(') != -1) { if (document.getElementById('vsiurl').value.replace('+','') != '') { thecmd+=' /' + '/ ' + document.getElementById('vsiurl').value.replace('+','') + ';'; } } canvascommands.push(thecmd); if (major) { laststop = majors.length; majors.push(canvascommands.length); polyco=[]; } } function fixmyemail(tval, issubj) { // mailto:fill.in.email@address?subject=My%20World%20Map&body= if (tval != '') { ourbits = document.getElementById('myemail').href.split('?subject='); if (issubj == 0) { if (ourbits.length > 1) { prebits = ourbits[0].split(':'); document.getElementById('to').value = tval; if (iscontact != -1) { document.getElementById('myemail').href = prebits[0] + ':' + encodeURIComponent(tval) + '?subject=' + ourbits[eval(-1 + ourbits.length)] + '&body=' + encodeURIComponent(document.getElementById('myfeedback').value); } else { document.getElementById('myemail').href = prebits[0] + ':' + encodeURIComponent(tval) + '?subject=' + ourbits[eval(-1 + ourbits.length)]; } if (document.getElementById('myiemail').value.indexOf('@') != -1) { document.getElementById('mode').value = ''; document.getElementById('ismobile').value = 'y'; document.getElementById('myisubject').style.display = 'inline'; document.getElementById('myiemail').style.display = 'inline'; document.getElementById('myform').action = document.getElementById('myform').action.replace('?mode=1', ''); document.getElementById('myform').action = document.getElementById('myform').action.replace('mode=1', 'mode='); //document.getElementById('myemail').href = '#' + document.getElementById('myemail').href; } } } else { var pbits = ""; if (ourbits.length > 1) { pbits = ourbits[1].split('&'); document.getElementById('mysubject').value = tval; if (pbits.length > 1) { document.getElementById('myemail').href = ourbits[0] + '?subject=' + encodeURIComponent(tval) + '&' + pbits[1]; } else { document.getElementById('myemail').href = ourbits[0] + '?subject=' + encodeURIComponent(tval); } } } } } function dorectangle() { // new idea ... March, 2016 if (eval(document.getElementById('rotation').value) != 0 && rotcmd == "" && 'dorectangle' != 'dorectangle') { rotcmd="dorectangle();"; drawRotated(eval(document.getElementById('rotation').value)); } else { rotcmd=""; //context.strokeStyle=document.getElementById('mycolour').value; context.fillStyle=document.getElementById('mycolour').value; storecanvascommands("context.fillStyle='" + document.getElementById('mycolour').value + "';", false); context.fillRect(eval(rotoffx + Math.min(x,lastx)), eval(rotoffy + Math.min(y,lasty)), Math.abs(x - lastx), Math.abs(y - lasty)); storecanvascommands("context.fillRect(" + eval(rotoffx + Math.min(x,lastx)) + "," +eval(rotoffy + Math.min(y,lasty)) + "," + Math.abs(x - lastx) + "," + Math.abs(y - lasty) + ");", true); rotoffx=0.0; rotoffy=0.0; } } function dorectangleborder() { // new idea ... March, 2016 if (eval(document.getElementById('rotation').value) != 0 && rotcmd == "" && 'dorectangle' != 'dorectangle') { rotcmd="dorectangleborder();"; drawRotated(eval(document.getElementById('rotation').value)); } else { rotcmd=""; context.strokeStyle=document.getElementById('mycolour').value; //context.fillStyle=document.getElementById('mycolour').value; storecanvascommands("context.strokeStyle='" + document.getElementById('mycolour').value + "';", false); context.rect(eval(rotoffx + Math.min(x,lastx)), eval(rotoffy + Math.min(y,lasty)), Math.abs(x - lastx), Math.abs(y - lasty)); storecanvascommands("context.rect(" + eval(rotoffx + Math.min(x,lastx)) + "," + eval(rotoffy + Math.min(y,lasty)) + "," + Math.abs(x - lastx) + "," + Math.abs(y - lasty) + ");", false); context.stroke(); storecanvascommands("context.stroke();", true); rotoffx=0.0; rotoffy=0.0; } } function docirclefill() { // new idea ... June, 2020 if (eval(document.getElementById('rotation').value) != 0 && rotcmd == "" && 'docirclefill' != 'docirclefill') { rotcmd="docirclefill();"; drawRotated(eval(document.getElementById('rotation').value)); } else { rotcmd=""; context.fillStyle=document.getElementById('mycolour').value; storecanvascommands("context.fillStyle='" + document.getElementById('mycolour').value + "';", false); context.beginPath(); storecanvascommands("context.beginPath();", false); context.arc(eval(rotoffx + (x + lastx) / 2.0),eval(rotoffy + (y + lasty) / 2.0),eval(Math.pow(Math.abs(x - lastx) * Math.abs(x - lastx) + Math.abs(y - lasty) * Math.abs(y - lasty),0.5) / 2.0),0,2*Math.PI); storecanvascommands("context.arc(" + eval(rotoffx + (x + lastx) / 2.0) + "," + eval(rotoffy + (y + lasty) / 2.0) + "," + eval(Math.pow(Math.abs(x - lastx) * Math.abs(x - lastx) + Math.abs(y - lasty) * Math.abs(y - lasty),0.5) / 2.0) + ",0," + 2*Math.PI + ");", false); context.fill(); storecanvascommands("context.fill();", true); rotoffx=0.0; rotoffy=0.0; } } function docircle() { // new idea ... March, 2016 if (eval(document.getElementById('rotation').value) != 0 && rotcmd == "" && 'docircle' != 'docircle') { rotcmd="docircle();"; drawRotated(eval(document.getElementById('rotation').value)); } else { rotcmd=""; context.strokeStyle=document.getElementById('mycolour').value; storecanvascommands("context.strokeStyle='" + document.getElementById('mycolour').value + "';", false); context.beginPath(); storecanvascommands("context.beginPath();", false); context.arc(eval(rotoffx + (x + lastx) / 2.0),eval(rotoffy + (y + lasty) / 2.0),eval(Math.pow(Math.abs(x - lastx) * Math.abs(x - lastx) + Math.abs(y - lasty) * Math.abs(y - lasty),0.5) / 2.0),0,2*Math.PI); storecanvascommands("context.arc(" + eval(rotoffx + (x + lastx) / 2.0) + "," + eval(rotoffy + (y + lasty) / 2.0) + "," + eval(Math.pow(Math.abs(x - lastx) * Math.abs(x - lastx) + Math.abs(y - lasty) * Math.abs(y - lasty),0.5) / 2.0) + ",0," + 2*Math.PI + ");", false); context.stroke(); storecanvascommands("context.stroke();", true); rotoffx=0.0; rotoffy=0.0; } } function ajaxEntityIt(inval) { var waslastx=lastx, waslasty=lasty, wasx=x, wasy=y; if (inval != '') { ourfdstart=inval; } var lastxinc=eval(eval(x - lastx) / eval(-1 + eval(ourfdnumber))); var lastyinc=eval(eval(y - lasty) / eval(-1 + eval(ourfdnumber))); if (('' + ourfdstart).trim() != '') { for (var thisij=1; thisij= 4) { for (var ivb=4; ivb= 4) { wlsprefix='Comma separate Relative Value to [] at right or new Date(Time)/Number'; } if (thisseq.split(',').length >= 5) { wlsnamesuffix=thisseq.split(',')[4].replace(/\ /g,'+'); } } if (thisseq != '') { thiscsvl=thisseq.split(','); if (thiscsvl.length >= 4) { if (thiscsvl[0] != '') { fdstart=' [' + thiscsvl[0] + ']'; } else if (fdstart.indexOf('[') != -1) { thiscsvl[0]=fdstart.split('[')[1].split(']')[0]; } if (thiscsvl[1] != '') { if (thiscsvl[1].replace(/\.0/g,'').replace(/0/g,'').replace(/\./g,'') == thiscsvl[1].split('.')[0]) { fdnumber=' [' + thiscsvl[1].split('.')[0] + ']'; } else { fdnumber=' [' + thiscsvl[1] + ']'; } } else if (fdnumber.indexOf('[') != -1) { thiscsvl[1]=fdnumber.split('[')[1].split(']')[0]; } if (thiscsvl[2] != '') { if (thiscsvl[2].replace(/\.0/g,'').replace(/0/g,'').replace(/\./g,'') == thiscsvl[2].split('.')[0]) { fdinc=' [' + thiscsvl[2].split('.')[0] + ']'; } else { fdinc=' [' + thiscsvl[2] + ']'; } } else if (fdinc.indexOf('[') != -1) { thiscsvl[2]=fdinc.split('[')[1].split(']')[0]; } if (thiscsvl[3] != '') { fdformat=' [' + thiscsvl[3] + ']'; } else if (fdformat.indexOf('[') != -1) { thiscsvl[3]=fdformat.split('[')[1].split(']')[0]; } if (fdformat.indexOf(' ]') != -1) { wlsls=false; fdformat=fdformat.replace(' ]',']'); } if (inpr == '' && wlsls) { if (thiscsvl.length >= 5) { wlsset(thisseq, wlsnamesuffix); } else { wlsset(thisseq, ''); } } if (fdinitiald != '' && fdinitialf != '' && fdformat.toLowerCase().replace('c','').replace('n','') != '' && fdinitialf.toLowerCase().replace('c','').replace('n','') != '') { //alert('4 ' + fdstart); if (fdformat.toLowerCase().replace('c','').replace('n','') != '' && fddate != null) { //alert(34); anewdate.setDate(fddate.getDate() + 0); yourfdincunit=''; if (fdstart.split('[')[1].split(']')[0].indexOf(':') != -1 || fdstart.split('[')[1].split(']')[0].indexOf('/') != -1 || fdstart.split('[')[1].split(']')[0].indexOf(' ') != -1) { //alert(44); yourfdincunit=' '; } else { //alert(64); fdstart=fdstart.replace(/\+/g,''); if ('' + fdstart.split('[')[1].split(']')[0].toLowerCase().indexOf('hour') != -1) { yourfdincunit='hour'; yourfdinc=eval('' + fdstart.split('[')[1].split(']')[0].toLowerCase().replace('hour','').replace('s','').split('.')[0].trim()); } else if ('' + fdstart.split('[')[1].split(']')[0].toLowerCase().indexOf('month') != -1) { yourfdincunit='month'; yourfdinc=eval('' + fdstart.split('[')[1].split(']')[0].toLowerCase().replace('month','').replace('s','').split('.')[0].trim()); } else if ('' + fdstart.split('[')[1].split(']')[0].toLowerCase().indexOf('minute') != -1) { yourfdincunit='minute'; yourfdinc=eval('' + fdstart.split('[')[1].split(']')[0].toLowerCase().replace('minute','').replace('s','').split('.')[0].trim()); } else if ('' + fdstart.split('[')[1].split(']')[0].toLowerCase().indexOf('second') != -1) { yourfdincunit='second'; yourfdinc=eval('' + fdstart.split('[')[1].split(']')[0].toLowerCase().replace('second','').replace('s','').split('.')[0].trim()); } else if ('' + fdstart.split('[')[1].split(']')[0].toLowerCase().indexOf('year') != -1) { yourfdincunit='year'; yourfdinc=eval('' + fdstart.split('[')[1].split(']')[0].toLowerCase().replace('year','').replace('s','').split('.')[0].trim()); } else if ('' + fdstart.split('[')[1].split(']')[0].toLowerCase().indexOf('h') != -1) { yourfdincunit='hour'; yourfdinc=eval('' + fdstart.split('[')[1].split(']')[0].toLowerCase().replace('h','').replace('r','').replace('s','').split('.')[0].trim()); } else if ('' + fdstart.split('[')[1].split(']')[0].toLowerCase().indexOf('mth') != -1) { yourfdincunit='month'; yourfdinc=eval('' + fdstart.split('[')[1].split(']')[0].toLowerCase().replace('mth','').replace('s','').split('.')[0].trim()); } else if ('' + fdstart.split('[')[1].split(']')[0].toLowerCase().indexOf('m') != -1) { yourfdincunit='minute'; yourfdinc=eval('' + fdstart.split('[')[1].split(']')[0].toLowerCase().replace('m','').replace('i','').replace('n','').replace('s','').split('.')[0].trim()); } else if ('' + fdstart.split('[')[1].split(']')[0].toLowerCase().indexOf('s') != -1) { yourfdincunit='second'; yourfdinc=eval('' + fdstart.split('[')[1].split(']')[0].toLowerCase().replace('s','').replace('e','').replace('c','').replace('s','').split('.')[0].trim()); } else if ('' + fdstart.split('[')[1].split(']')[0].toLowerCase().indexOf('y') != -1) { yourfdincunit='year'; yourfdinc=eval('' + fdstart.split('[')[1].split(']')[0].toLowerCase().replace('y','').replace('r','').replace('s','').split('.')[0].trim()); } else { yourfdinc=eval('' + fdstart.split('[')[1].split(']')[0].toLowerCase().replace('day','').replace('d','').replace('s','').split('.')[0].trim()); } } if (yourfdincunit == '') { usedfddate=true; //alert('' + yourfdinc + ' days offset to ' + fddate.getDate()); anewdate.setDate(fddate.getDate() + eval('' + yourfdinc)); } else if (yourfdincunit == 'hour') { usedfddate=true; anewdate.setHours(fddate.getHours() + eval('' + yourfdinc)); } else if (yourfdincunit == 'minute') { //alert('' + eval('' + yourfdinc)); usedfddate=true; anewdate.setMinutes(fddate.getMinutes() + eval('' + yourfdinc)); } else if (yourfdincunit == 'second') { usedfddate=true; anewdate.setSecond(fddate.getSeconds() + eval('' + yourfdinc)); } else if (yourfdincunit == 'month') { usedfddate=true; anewdate.setMonth(fddate.getMonth() + eval('' + yourfdinc)); } else if (yourfdincunit == 'year') { usedfddate=true; anewdate.setFullYear(fddate.getFullYear() + eval('' + yourfdinc)); } else if (yourfdincunit != ' ') { usedfddate=true; anewdate.setDate(fddate.getDate() + eval('' + yourfdinc)); } } } if (fdinitiald == '' && fdstart != '') { isfirst=true; fdinitiald=fdstart; } if (fdinitialf == '' && fdformat != '') { isfirst=true; fdinitialf=fdformat; } } if (thisseq != '' && thiscsvl.length >= 4 && fdstart != '' && fdinc != '' && fdnumber != '' && fdformat != '') { thisseq=thisseq; } else { alert('Work in progress.'); thisseq=''; } } //var fdstart=''; //var fdnumber=''; //var fdinc=''; //var fdformat=''; if (thisseq != '' && thiscsvl.length >= 4 && fdstart != '' && fdinc != '' && fdnumber != '' && fdformat != '') { ourfdnumber=eval('' + fdnumber.split('[')[1].split(']')[0]); ourfdincunit=''; if ('' + fdinc.split('[')[1].split(']')[0].toLowerCase().indexOf('hour') != -1) { ourfdincunit='hour'; ourfdinc=eval('' + fdinc.split('[')[1].split(']')[0].toLowerCase().replace('hour','').replace('s','').split('.')[0].trim()); } else if ('' + fdinc.split('[')[1].split(']')[0].toLowerCase().indexOf('month') != -1) { ourfdincunit='month'; ourfdinc=eval('' + fdinc.split('[')[1].split(']')[0].toLowerCase().replace('month','').replace('s','').split('.')[0].trim()); } else if ('' + fdinc.split('[')[1].split(']')[0].toLowerCase().indexOf('minute') != -1) { ourfdincunit='minute'; ourfdinc=eval('' + fdinc.split('[')[1].split(']')[0].toLowerCase().replace('minute','').replace('s','').split('.')[0].trim()); } else if ('' + fdinc.split('[')[1].split(']')[0].toLowerCase().indexOf('second') != -1) { ourfdincunit='second'; ourfdinc=eval('' + fdinc.split('[')[1].split(']')[0].toLowerCase().replace('second','').replace('s','').split('.')[0].trim()); } else if ('' + fdinc.split('[')[1].split(']')[0].toLowerCase().indexOf('year') != -1) { ourfdincunit='year'; ourfdinc=eval('' + fdinc.split('[')[1].split(']')[0].toLowerCase().replace('year','').replace('s','').split('.')[0].trim()); } else if ('' + fdinc.split('[')[1].split(']')[0].toLowerCase().indexOf('h') != -1) { ourfdincunit='hour'; ourfdinc=eval('' + fdinc.split('[')[1].split(']')[0].toLowerCase().replace('h','').replace('r','').replace('s','').split('.')[0].trim()); } else if ('' + fdinc.split('[')[1].split(']')[0].toLowerCase().indexOf('mth') != -1) { ourfdincunit='month'; ourfdinc=eval('' + fdinc.split('[')[1].split(']')[0].toLowerCase().replace('mth','').replace('s','').split('.')[0].trim()); } else if ('' + fdinc.split('[')[1].split(']')[0].toLowerCase().indexOf('m') != -1) { ourfdincunit='minute'; ourfdinc=eval('' + fdinc.split('[')[1].split(']')[0].toLowerCase().replace('m','').replace('i','').replace('n','').replace('s','').split('.')[0].trim()); } else if ('' + fdinc.split('[')[1].split(']')[0].toLowerCase().indexOf('s') != -1) { ourfdincunit='second'; ourfdinc=eval('' + fdinc.split('[')[1].split(']')[0].toLowerCase().replace('s','').replace('e','').replace('c','').replace('s','').split('.')[0].trim()); } else if ('' + fdinc.split('[')[1].split(']')[0].toLowerCase().indexOf('y') != -1) { ourfdincunit='year'; ourfdinc=eval('' + fdinc.split('[')[1].split(']')[0].toLowerCase().replace('y','').replace('r','').replace('s','').split('.')[0].trim()); } else { ourfdinc=eval('' + fdinc.split('[')[1].split(']')[0].toLowerCase().replace('day','').replace('d','').replace('s','').split('.')[0].trim()); } //alert(fdstart); ourfdstart=fdstart.replace(' pm','').replace(' am','').replace(' PM','').replace(' AM','').split('[')[1].split(']')[0]; //alert(ourfdstart); ourfdformat=fdformat.split('[')[1].split(']')[0]; lastxinc=eval(eval(x - lastx) / eval(-1 + eval(ourfdnumber))); lastyinc=eval(eval(y - lasty) / eval(-1 + eval(ourfdnumber))); delimis=''; altdelimis=''; blkdelimis=''; if (ourfdformat.indexOf(' ') != -1) { blkdelimis=' '; delimis=' '; altdelimis=' '; } if (ourfdformat.indexOf('/') != -1) { delimis='/'; altdelimis='/'; if (ourfdformat.indexOf('-') != -1) { altdelimis='-'; } else if (ourfdformat.indexOf(':') != -1) { altdelimis=':'; } } else if (ourfdformat.indexOf('-') != -1) { delimis='-'; altdelimis='-'; if (ourfdformat.indexOf(':') != -1) { altdelimis=':'; } else if (ourfdformat.indexOf('/') != -1) { altdelimis='/'; } } else if (ourfdformat.indexOf(':') != -1) { delimis=':'; altdelimis=':'; } sclist=ourfdformat.replace(/\//g,' ').replace(/\:/g,' ').replace(/\-/g,' ').split(' '); //(':'); //slashlist=ourfdformat.split('/'); //anewdate=new Date(); if (ourfdformat == '') { anewdate=anewdate; } else if (ourfdformat.toLowerCase() == 'c') { ourfdstart=('' + fdstart.split('[')[1].split(']')[0]); if (ourfdstart != '') { if ((ourfdstart + ' ').substring(0,1) >= '0' && (ourfdstart + ' ').substring(0,1) <= '9' && (' ' + ourfdstart).slice(-1) >= '0' && (' ' + ourfdstart).slice(-1) <= '9') { ajaxEntityIt(ourfdstart); } else { ourzhr = new XMLHttpRequest(); ourzform=new FormData(); ourzform.append('inhename', ourfdstart); ourzhr.open('post', '//www.rjmprogramming.com.au/HTMLCSS/html_entity_name_to_codepoint.php', true); ourzhr.onreadystatechange = ajaxEntityNameIt; ourzhr.send(ourzform); } } } else if (ourfdformat.toLowerCase() == 'n') { ourfdstart=eval('' + fdstart.split('[')[1].split(']')[0]); for (thisij=1; thisij slashlist.length) { fdlist=ourfdstart.replace(/\//g,' ').replace(/\:/g,' ').replace(/\-/g,' ').split(' '); //(':'); origdelimis=delimis; for (thisij=0; thisij 0) { ourfdstart=''; delimis=origdelimis; } else if (usedfddate) { ourfdstart=''; delimis=origdelimis; } for (thisjk=0; thisjk 0) && sclist[thisjk].length != 2) { if (ourfdstart == '') { ourfdstart+='' + anewdate.getFullYear(); } else { ourfdstart+=delimis + anewdate.getFullYear(); } } else if ((usedfddate || thisij > 0) && sclist[thisjk].length == 2) { if (ourfdstart == '') { ourfdstart+=('' + anewdate.getFullYear()).slice(-2); } else { ourfdstart+=delimis + ('' + anewdate.getFullYear()).slice(-2); } } else { //alert('3:' + thisij); if (eval('' + fdlist[thisjk]) < 100) { anewdate.setFullYear(eval(2000 + eval('' + fdlist[thisjk]))); } else { anewdate.setFullYear(eval('' + fdlist[thisjk])); } } break; case 'Month': case 'month': case 'MONTH': if ((usedfddate || thisij > 0)) { if (ourfdstart == '') { if (monlen == -1) { ourfdstart+=months[eval('' + anewdate.getMonth())]; } else { ourfdstart+=months[eval('' + anewdate.getMonth())].substring(0,monlen); } } else { if (monlen == -1) { ourfdstart+=delimis + months[eval('' + anewdate.getMonth())]; } else { ourfdstart+=delimis + months[eval('' + anewdate.getMonth())].substring(0,monlen); } } } else { for (thisji=0; thisji 0)) { if (ourfdstart == '') { if (eval('' + anewdate.getMonth()) >= 9) { ourfdstart+=('' + ('' + eval(1 + eval('' + anewdate.getMonth()))) ); } else { ourfdstart+=('' + ('' + ('0' + eval(1 + eval('' + anewdate.getMonth()))).slice(eval('-' + sclist[thisjk].length))) ); } } else { if (eval('' + anewdate.getMonth()) >= 9) { ourfdstart+=(delimis + ('' + eval(1 + eval('' + anewdate.getMonth()))) ); } else { //alert(sclist[thisjk] + ' ... ' + anewdate.getMonth() + ' --- ' + eval('-' + sclist[thisjk].length)); ourfdstart+=(delimis + ('' + ('0' + eval(1 + eval('' + anewdate.getMonth()))).slice(eval('-' + sclist[thisjk].length))) ); } } } else { //alert('month set to ' + fdlist[thisjk]); //alert('5:' + thisij); anewdate.setMonth(eval(-1 + eval('' + fdlist[thisjk]))); } break; case 'DD': case 'dd': case 'D': case 'd': if ((usedfddate || thisij > 0)) { if (ourfdstart == '') { if (eval('' + anewdate.getDate()) >= 10) { ourfdstart+=('' + ('' + eval('' + anewdate.getDate())) ); } else { ourfdstart+=('' + ('' + ('0' + eval('' + anewdate.getDate())).slice(eval('-' + sclist[thisjk].length))) ); } } else { if (eval('' + anewdate.getDate()) >= 10) { ourfdstart+=(delimis + ('' + eval('' + anewdate.getDate())) ); } else { ourfdstart+=(delimis + ('' + ('0' + eval('' + anewdate.getDate())).slice(eval('-' + sclist[thisjk].length))) ); } } } else { //alert('day set to ' + fdlist[thisjk]); //alert('6:' + thisij); anewdate.setDate(eval('' + fdlist[thisjk])); } break; case 'HH24': case 'hh24': case 'HH': case 'hh': case 'H': case 'h': if ((usedfddate || thisij > 0)) { if (ourfdstart == '') { if (eval('' + anewdate.getHours()) >= 10) { ourfdstart+=('' + ('' + eval(0 + eval('' + anewdate.getHours()))) ); } else { ourfdstart+=('' + ('' + ('0' + eval('' + anewdate.getHours())).slice(eval('-' + sclist[thisjk].replace('24','').length))) ); } } else { delimis=altdelimis; if (eval('' + anewdate.getHours()) >= 10) { ourfdstart+=(blkdelimis + ('' + eval(0 + eval('' + anewdate.getHours()))) ); } else { ourfdstart+=(blkdelimis + ('' + ('0' + eval('' + anewdate.getHours())).slice(eval('-' + sclist[thisjk].replace('24','').length))) ); } } } else { //alert('7:' + thisij); if (fdstart.toLowerCase().indexOf(' pm') != -1) { fdstart=fdstart.replace(blkdelim + '0' + fdlist[thisjk] + altdelimis, blkdelim + eval(12 + eval('' + fdlist[thisjk])) + altdelimis); fdstart=fdstart.replace(blkdelim + '' + fdlist[thisjk] + altdelimis, blkdelim + eval(12 + eval('' + fdlist[thisjk])) + altdelimis); fdstart=fdstart.substring(0, fdstart.toLowerCase().indexOf(' pm')); anewdate.setHours(eval(12 + eval('' + fdlist[thisjk]))); } else { fdstart=fdstart.substring(0, fdstart.toLowerCase().indexOf(' am')); anewdate.setHours(eval('' + fdlist[thisjk])); } } break; case 'MI': case 'mi': case 'I': case 'i': if ((usedfddate || thisij > 0)) { if (ourfdstart == '') { if (eval('' + anewdate.getMinutes()) >= 10) { ourfdstart+=('' + ('' + eval(0 + eval('' + anewdate.getMinutes()))) ); } else { ourfdstart+=('' + ('' + ('0' + eval('' + anewdate.getMinutes())).slice(eval('-' + sclist[thisjk].length))) ); } } else { if (eval('' + anewdate.getMinutes()) >= 10) { ourfdstart+=(delimis + ('' + eval(0 + eval('' + anewdate.getMinutes()))) ); } else { ourfdstart+=(delimis + ('' + ('0' + eval('' + anewdate.getMinutes())).slice(eval('-' + sclist[thisjk].length))) ); } } } else { //alert('8:' + thisij); anewdate.setMinutes(eval('' + fdlist[thisjk])); } break; case 'SSSS': case 'ssss': case 'SS': case 'ss': case 'S': case 's': if ((usedfddate || thisij > 0)) { if (ourfdstart == '') { if (eval('' + anewdate.getSeconds()) >= 10) { ourfdstart+=('' + ('' + eval(0 + eval('' + anewdate.getSeconds()))) ); } else { ourfdstart+=('' + ('' + ('0' + eval('' + anewdate.getSeconds())).slice(eval('-' + sclist[thisjk].toLowerCase().replace('ssss','ss').length))) ); } } else { if (eval('' + anewdate.getSeconds()) >= 10) { ourfdstart+=(delimis + ('' + eval(0 + eval('' + anewdate.getSeconds()))) ); } else { ourfdstart+=(delimis + ('' + ('0' + eval('' + anewdate.getSeconds())).slice(eval('-' + sclist[thisjk].toLowerCase().replace('ssss','ss').length))) ); } } } else { //alert('9:' + thisij); anewdate.setSeconds(eval('' + fdlist[thisjk])); } break; default: break; } } if (('' + document.getElementById('rof').value) == '' && ('' + document.getElementById('rotation').value).replace(/0/g,'').replace('.','') != '') { waslastx=lastx; waslasty=lasty; wasx=x; wasy=y; x=lastx; y=lasty; document.getElementById('iannotation').value='' + ourfdstart; placeannotation(document.getElementById('iannotation')); lastx=waslastx; lasty=waslasty; x=wasx; y=lasty; } else { context.font = document.getElementById('myfont').value; storecanvascommands("context.font = '" + document.getElementById('myfont').value + "';", false); context.strokeStyle=document.getElementById('mycolour').value; storecanvascommands("context.strokeStyle='" + document.getElementById('mycolour').value + "';", false); //if (inpr != '') { alert('ourfdstart=' + ourfdstart + ' ' + lastx + "," + lasty + ' ' + document.getElementById('myfont').value); } context.strokeText(ourfdstart,lastx,lasty); storecanvascommands("context.strokeText(" + ourfdstart + "," + lastx + "," + lasty + ");", false); } lastx+=lastxinc; lasty+=lastyinc; //ourfdstart+=eval('' + ourfdinc); //alert('' + anewdate.getDate() + '/' + anewdate.getMonth()); if (isfirst && thisij == 0 && fddate == null) { fddate=new Date(); fddate.setDate(anewdate.getDate() + 0); } if (ourfdincunit == '') { anewdate.setDate(anewdate.getDate() + eval('' + ourfdinc)); } else if (ourfdincunit == 'hour') { anewdate.setHours(anewdate.getHours() + eval('' + ourfdinc)); } else if (ourfdincunit == 'minute') { //alert('' + eval('' + ourfdinc)); anewdate.setMinutes(anewdate.getMinutes() + eval('' + ourfdinc)); } else if (ourfdincunit == 'second') { anewdate.setSecond(anewdate.getSeconds() + eval('' + ourfdinc)); } else if (ourfdincunit == 'month') { anewdate.setMonth(anewdate.getMonth() + eval('' + ourfdinc)); } else if (ourfdincunit == 'year') { anewdate.setFullYear(anewdate.getFullYear() + eval('' + ourfdinc)); } else { anewdate.setDate(anewdate.getDate() + eval('' + ourfdinc)); } //alert(' ... to ... ' + anewdate.getDate() + '/' + anewdate.getMonth()); } //context.font = document.getElementById('myfont').value; //storecanvascommands("context.font = '" + document.getElementById('myfont').value + "';", false); //context.strokeStyle=document.getElementById('mycolour').value; //storecanvascommands("context.strokeStyle='" + document.getElementById('mycolour').value + "';", false); //context.strokeText(ourfdstart,lastx,lasty); //storecanvascommands("context.strokeText(" + ourfdstart + "," + lastx + "," + lasty + ");", false); } //context.font = document.getElementById('myfont').value; //storecanvascommands("context.font = '" + document.getElementById('myfont').value + "';", false); //context.strokeStyle=document.getElementById('mycolour').value; //storecanvascommands("context.strokeStyle='" + document.getElementById('mycolour').value + "';", false); //context.strokeText(ourfdstart,lastx,lasty); //storecanvascommands("context.strokeText(" + ourfdstart + "," + lastx + "," + lasty + ");", false); } else if (1 == 2) { rotcmd=""; context.strokeStyle=document.getElementById('mycolour').value; storecanvascommands("context.strokeStyle='" + document.getElementById('mycolour').value + "';", false); context.beginPath(); storecanvascommands("context.beginPath();", false); context.moveTo(x,y); storecanvascommands("context.moveTo(" + eval(rotoffx + x) + "," + eval(rotoffy + y) + ");", false); context.lineTo(lastx,lasty); storecanvascommands("context.lineTo(" + eval(rotoffx + lastx) + "," + eval(rotoffy + lasty) + ");", false); context.stroke(); storecanvascommands("context.stroke();", true); rotoffx=0.0; rotoffy=0.0; } } //} } function dobzto(dofill) { // new idea ... June, 2020 var ipl=0,mx=0, my=0,mmx=0, mmy=0; if (eval(document.getElementById('rotation').value) != 0 && rotcmd == "" && 'dobz' != 'dobz') { rotcmd="dobz();"; drawRotated(eval(document.getElementById('rotation').value)); } else { rotcmd=""; context.fillStyle=document.getElementById('mycolour').value; if (dofill) { storecanvascommands("context.fillStyle='" + document.getElementById('mycolour').value + "';", false); } else { storecanvascommands("context.strokeStyle='" + document.getElementById('mycolour').value + "';", false); } context.beginPath(); storecanvascommands("context.beginPath();", false); console.log(polyco); //if (dofill) { //polyco.push(polyco[0]); //polyco.push(polyco[1]); //} while (eval('' + ipl) < eval('' + polyco.length)) { if (eval('' + ipl) == 0) { console.log('pen up ' + eval('' + polyco.length)); context.moveTo(eval('' + polyco[ipl]),eval('' + polyco[eval(1 + eval('' + ipl))])); mx=eval('' + polyco[ipl]); my=eval('' + polyco[eval(1 + eval('' + ipl))]); mmx=eval('' + polyco[ipl]); mmy=eval('' + polyco[eval(1 + eval('' + ipl))]); storecanvascommands("context.moveTo(" + eval(rotoffx + eval('' + polyco[ipl])) + "," + eval(rotoffy + eval('' + polyco[eval(1 + eval('' + ipl))])) + ");", false); } else { console.log('pen down ' + ipl); if (eval(2 + eval('' + ipl)) < eval('' + polyco.length)) { if (eval('' + ipl) <= eval(eval('' + polyco.length) / 3)) { mx=eval('' + polyco[ipl]); my=eval('' + polyco[eval(1 + eval('' + ipl))]); } else if (eval('' + ipl) <= eval(eval(eval('' + polyco.length) * 2) / 3)) { mmx=eval('' + polyco[ipl]); mmy=eval('' + polyco[eval(1 + eval('' + ipl))]); } } else if (eval(2 + eval('' + ipl)) >= eval('' + polyco.length)) { if (dofill) { context.bezierCurveTo(mx, my, mmx, mmy, eval('' + polyco[ipl]),eval('' + polyco[eval(1 + eval('' + ipl))])); storecanvascommands("context.bezierCurveTo(" + eval(rotoffx + mx) + "," + eval(rotoffy + my) + "," + + eval(rotoffx + mmx) + "," + eval(rotoffy + mmy) + "," + eval(rotoffx + eval('' + polyco[ipl])) + "," + eval(rotoffy + eval('' + polyco[eval(1 + eval('' + ipl))])) + ");", false); context.closePath(); storecanvascommands("context.closePath();", false); context.fill(); storecanvascommands("context.fill();", true); } else { context.bezierCurveTo(mx, my, mmx, mmy, eval('' + polyco[ipl]),eval('' + polyco[eval(1 + eval('' + ipl))])); storecanvascommands("context.bezierCurveTo(" + eval(rotoffx + mx) + "," + eval(rotoffy + my) + "," + eval(rotoffx + mmx) + "," + eval(rotoffy + mmy) + "," + eval(rotoffx + eval('' + polyco[ipl])) + "," + eval(rotoffy + eval('' + polyco[eval(1 + eval('' + ipl))])) + ");", false); context.stroke(); storecanvascommands("context.stroke();", true); } } else if (1 == 2) { context.strokeStyle=document.getElementById('mycolour').value; context.beginPath(); storecanvascommands("context.beginPath();", false); storecanvascommands("context.strokeStyle='" + document.getElementById('mycolour').value + "';", false); context.moveTo(eval('' + polyco[ipl]),eval('' + polyco[eval(1 + eval('' + ipl))])); storecanvascommands("context.moveTo(" + eval(rotoffx + eval('' + polyco[ipl])) + "," + eval(rotoffy + eval('' + polyco[eval(1 + eval('' + ipl))])) + ");", false); } } ipl=eval(2 + eval('' + ipl)); console.log('pre pen up ' + ipl); } } polyco=[]; rotoffx=0.0; rotoffy=0.0; } function doarcto(dofill) { // new idea ... June, 2020 var ipl=0,mx=0, my=0; if (eval(document.getElementById('rotation').value) != 0 && rotcmd == "" && 'doarcto' != 'doarcto') { rotcmd="doarcto();"; drawRotated(eval(document.getElementById('rotation').value)); } else { var hmd=prompt("What is radius of arc?", "50"); if (hmd != null) { rotcmd=""; if (dofill) { context.fillStyle=document.getElementById('mycolour').value; storecanvascommands("context.fillStyle='" + document.getElementById('mycolour').value + "';", false); } else { context.strokeStyle=document.getElementById('mycolour').value; storecanvascommands("context.strokeStyle='" + document.getElementById('mycolour').value + "';", false); } context.beginPath(); storecanvascommands("context.beginPath();", false); console.log(polyco); //if (dofill) { //polyco.push(polyco[0]); //polyco.push(polyco[1]); //} while (eval('' + ipl) < eval('' + polyco.length)) { if (eval('' + ipl) == 0) { console.log('pen up ' + eval('' + polyco.length)); context.moveTo(eval('' + polyco[ipl]),eval('' + polyco[eval(1 + eval('' + ipl))])); mx=eval('' + polyco[ipl]); my=eval('' + polyco[eval(1 + eval('' + ipl))]); storecanvascommands("context.moveTo(" + eval(rotoffx + eval('' + polyco[ipl])) + "," + eval(rotoffy + eval('' + polyco[eval(1 + eval('' + ipl))])) + ");", false); } else { console.log('pen down ' + ipl); if (eval(2 + eval('' + ipl)) < eval('' + polyco.length)) { if (eval('' + ipl) <= eval(eval('' + polyco.length) / 2)) { mx=eval('' + polyco[ipl]); my=eval('' + polyco[eval(1 + eval('' + ipl))]); } } else if (eval(2 + eval('' + ipl)) >= eval('' + polyco.length)) { if (dofill) { //alert('mx=' + mx + ' and my=' + my); context.arcTo(mx, my, eval('' + polyco[ipl]),eval('' + polyco[eval(1 + eval('' + ipl))]), eval('' + hmd)); storecanvascommands("context.arcTo(" + eval(rotoffx + mx) + "," + eval(rotoffy + my) + "," + eval(rotoffx + eval('' + polyco[ipl])) + "," + eval(rotoffy + eval('' + polyco[eval(1 + eval('' + ipl))])) + "," + hmd + ");", false); context.closePath(); storecanvascommands("context.closePath();", false); context.fill(); storecanvascommands("context.fill();", true); } else { //alert('Mx=' + mx + ' and My=' + my); context.arcTo(mx, my, eval('' + polyco[ipl]),eval('' + polyco[eval(1 + eval('' + ipl))]), eval('' + hmd)); storecanvascommands("context.arcTo(" + eval(rotoffx + mx) + "," + eval(rotoffy + my) + "," + eval(rotoffx + eval('' + polyco[ipl])) + "," + eval(rotoffy + eval('' + polyco[eval(1 + eval('' + ipl))])) + "," + hmd + ");", false); context.stroke(); storecanvascommands("context.stroke();", true); } } else if (1 == 2) { context.strokeStyle=document.getElementById('mycolour').value; context.beginPath(); storecanvascommands("context.beginPath();", false); storecanvascommands("context.strokeStyle='" + document.getElementById('mycolour').value + "';", false); context.moveTo(eval('' + polyco[ipl]),eval('' + polyco[eval(1 + eval('' + ipl))])); storecanvascommands("context.moveTo(" + eval(rotoffx + eval('' + polyco[ipl])) + "," + eval(rotoffy + eval('' + polyco[eval(1 + eval('' + ipl))])) + ");", false); } } ipl=eval(2 + eval('' + ipl)); console.log('pre pen up ' + ipl); } } } polyco=[]; rotoffx=0.0; rotoffy=0.0; } function doqcto(dofill) { // new idea ... June, 2020 var ipl=0,mx=0, my=0; if (eval(document.getElementById('rotation').value) != 0 && rotcmd == "" && 'doqc' != 'doqc') { rotcmd="doqc();"; drawRotated(eval(document.getElementById('rotation').value)); } else { rotcmd=""; if (dofill) { context.fillStyle=document.getElementById('mycolour').value; storecanvascommands("context.fillStyle='" + document.getElementById('mycolour').value + "';", false); } else { context.strokeStyle=document.getElementById('mycolour').value; storecanvascommands("context.strokeStyle='" + document.getElementById('mycolour').value + "';", false); } context.beginPath(); storecanvascommands("context.beginPath();", false); console.log(polyco); //if (dofill) { //polyco.push(polyco[0]); //polyco.push(polyco[1]); //} while (eval('' + ipl) < eval('' + polyco.length)) { if (eval('' + ipl) == 0) { console.log('pen up ' + eval('' + polyco.length)); context.moveTo(eval('' + polyco[ipl]),eval('' + polyco[eval(1 + eval('' + ipl))])); mx=eval('' + polyco[ipl]); my=eval('' + polyco[eval(1 + eval('' + ipl))]); storecanvascommands("context.moveTo(" + eval(rotoffx + eval('' + polyco[ipl])) + "," + eval(rotoffy + eval('' + polyco[eval(1 + eval('' + ipl))])) + ");", false); } else { console.log('pen down ' + ipl); if (eval(2 + eval('' + ipl)) < eval('' + polyco.length)) { if (eval('' + ipl) <= eval(eval('' + polyco.length) / 2)) { mx=eval('' + polyco[ipl]); my=eval('' + polyco[eval(1 + eval('' + ipl))]); } } else if (eval(2 + eval('' + ipl)) >= eval('' + polyco.length)) { if (dofill) { context.quadraticCurveTo(mx, my, eval('' + polyco[ipl]),eval('' + polyco[eval(1 + eval('' + ipl))])); storecanvascommands("context.quadraticCurveTo(" + eval(rotoffx + mx) + "," + eval(rotoffy + my) + "," + eval(rotoffx + eval('' + polyco[ipl])) + "," + eval(rotoffy + eval('' + polyco[eval(1 + eval('' + ipl))])) + ");", false); context.closePath(); storecanvascommands("context.closePath();", false); context.fill(); storecanvascommands("context.fill();", true); } else { context.quadraticCurveTo(mx, my, eval('' + polyco[ipl]),eval('' + polyco[eval(1 + eval('' + ipl))])); storecanvascommands("context.quadraticCurveTo(" + eval(rotoffx + mx) + "," + eval(rotoffy + my) + "," + eval(rotoffx + eval('' + polyco[ipl])) + "," + eval(rotoffy + eval('' + polyco[eval(1 + eval('' + ipl))])) + ");", false); context.stroke(); storecanvascommands("context.stroke();", true); } } else if (1 == 2) { context.strokeStyle=document.getElementById('mycolour').value; context.beginPath(); storecanvascommands("context.beginPath();", false); storecanvascommands("context.strokeStyle='" + document.getElementById('mycolour').value + "';", false); context.moveTo(eval('' + polyco[ipl]),eval('' + polyco[eval(1 + eval('' + ipl))])); storecanvascommands("context.moveTo(" + eval(rotoffx + eval('' + polyco[ipl])) + "," + eval(rotoffy + eval('' + polyco[eval(1 + eval('' + ipl))])) + ");", false); } } ipl=eval(2 + eval('' + ipl)); console.log('pre pen up ' + ipl); } } polyco=[]; rotoffx=0.0; rotoffy=0.0; } function dopolygon(dofill) { // new idea ... June, 2020 var ipl=0; if (eval(document.getElementById('rotation').value) != 0 && rotcmd == "" && 'dopolygon' != 'dopolygon') { rotcmd="dopolygon();"; drawRotated(eval(document.getElementById('rotation').value)); } else { rotcmd=""; if (dofill) { context.fillStyle=document.getElementById('mycolour').value; storecanvascommands("context.fillStyle='" + document.getElementById('mycolour').value + "';", false); } else { context.strokeStyle=document.getElementById('mycolour').value; storecanvascommands("context.strokeStyle='" + document.getElementById('mycolour').value + "';", false); } context.beginPath(); storecanvascommands("context.beginPath();", false); console.log(polyco); if (dofill) { polyco.push(polyco[0]); polyco.push(polyco[1]); } while (eval('' + ipl) < eval('' + polyco.length)) { if (eval('' + ipl) == 0) { console.log('pen up ' + eval('' + polyco.length)); context.moveTo(eval('' + polyco[ipl]),eval('' + polyco[eval(1 + eval('' + ipl))])); storecanvascommands("context.moveTo(" + eval(rotoffx + eval('' + polyco[ipl])) + "," + eval(rotoffy + eval('' + polyco[eval(1 + eval('' + ipl))])) + ");", false); } else { context.lineTo(eval('' + polyco[ipl]),eval('' + polyco[eval(1 + eval('' + ipl))])); storecanvascommands("context.lineTo(" + eval(rotoffx + eval('' + polyco[ipl])) + "," + eval(rotoffy + eval('' + polyco[eval(1 + eval('' + ipl))])) + ");", false); console.log('pen down ' + ipl); if (eval(2 + eval('' + ipl)) >= eval('' + polyco.length)) { if (dofill) { context.closePath(); storecanvascommands("context.closePath();", false); context.fill(); storecanvascommands("context.fill();", true); } else { context.stroke(); storecanvascommands("context.stroke();", true); } } else if (1 == 2) { context.strokeStyle=document.getElementById('mycolour').value; context.beginPath(); storecanvascommands("context.beginPath();", false); storecanvascommands("context.strokeStyle='" + document.getElementById('mycolour').value + "';", false); context.moveTo(eval('' + polyco[ipl]),eval('' + polyco[eval(1 + eval('' + ipl))])); storecanvascommands("context.moveTo(" + eval(rotoffx + eval('' + polyco[ipl])) + "," + eval(rotoffy + eval('' + polyco[eval(1 + eval('' + ipl))])) + ");", false); } } ipl=eval(2 + eval('' + ipl)); console.log('pre pen up ' + ipl); } } polyco=[]; rotoffx=0.0; rotoffy=0.0; } function doline() { // new idea ... March, 2016 if (eval(document.getElementById('rotation').value) != 0 && rotcmd == "" && 'doline' != 'doline') { rotcmd="doline();"; drawRotated(eval(document.getElementById('rotation').value)); } else { rotcmd=""; context.strokeStyle=document.getElementById('mycolour').value; storecanvascommands("context.strokeStyle='" + document.getElementById('mycolour').value + "';", false); context.beginPath(); storecanvascommands("context.beginPath();", false); context.moveTo(x,y); storecanvascommands("context.moveTo(" + eval(rotoffx + x) + "," + eval(rotoffy + y) + ");", false); context.lineTo(lastx,lasty); storecanvascommands("context.lineTo(" + eval(rotoffx + lastx) + "," + eval(rotoffy + lasty) + ");", false); context.stroke(); storecanvascommands("context.stroke();", true); rotoffx=0.0; rotoffy=0.0; } } function clearall() { // new idea ... March, 2016 context.clearRect(0, 0, elem.width, elem.height); storecanvascommands("context.clearRect(" + 0 + "," + 0 + "," + elem.width + "," + elem.height + ");", false); elem.style.borderRight='1px solid black'; storecanvascommands("elem.style.borderRight='1px solid black';", false); elem.style.borderBottom='1px solid black'; storecanvascommands("elem.style.borderBottom='1px solid black';", true); rotoffx=0.0; rotoffy=0.0; } function placeannotation(anno) { // new idea ... March, 2016 if (eval(document.getElementById('rotation').value) != 0 && rotcmd == "" && anno.value != '') { rotcmd="placeannotation(document.getElementById('" + anno.id + "'));"; //if (eval(document.getElementById('rotation').value) != 0) alert(rotcmd); txtoffx=eval(0 + 2 + Math.min(x,lastx)); txtoffy=eval((Math.min(y,lasty) + Math.max(y,lasty)) / 2); drawRotated(eval(document.getElementById('rotation').value)); } else { rotcmd=""; //if (eval(document.getElementById('rotation').value) != 0) alert('before:' + anno.value); if (anno.value != '') { //if (eval(document.getElementById('rotation').value) != 0) alert(anno.value); if (anno.id == 'jannotation') { context.clearRect(eval(rotoffx + Math.min(x,lastx)), eval(rotoffy + Math.min(y,lasty)), Math.abs(x - lastx), Math.abs(y - lasty)); storecanvascommands("context.clearRect(" + eval(rotoffx + Math.min(x,lastx)) + "," + eval(rotoffx + Math.min(y,lasty)) + "," + Math.abs(x - lastx) + "," + Math.abs(y - lasty) + ");", false); context.strokeStyle = "black"; storecanvascommands("context.strokeStyle = 'black';", false); document.getElementById('iannotation').value=''; storecanvascommands("document.getElementById('iannotation').value='';", false); } else { context.strokeStyle = "blue"; storecanvascommands("context.strokeStyle = 'blue';", false); document.getElementById('jannotation').value=''; storecanvascommands("document.getElementById('jannotation').value='';", false); } //context.font = cf; if (anno.id == 'jannotation') { context.font = document.getElementById('myfont').value; storecanvascommands("context.font = '" + document.getElementById('myfont').value + "';", false); if (document.getElementById('mycolour').value.toLowerCase().indexOf('rgba(') == 0) { context.strokeStyle = "rgba(0,0,0," + document.getElementById('mycolour').value.split(',')[3]; storecanvascommands("context.strokeStyle = '" + context.strokeStyle.split(';')[0] + "';", false); } else { context.strokeStyle = "black"; storecanvascommands("context.strokeStyle = 'black';", false); } } else { context.font = document.getElementById('myfont').value; storecanvascommands("context.font = '" + document.getElementById('myfont').value + "';", false); context.strokeStyle=document.getElementById('mycolour').value; storecanvascommands("context.strokeStyle='" + document.getElementById('mycolour').value + "';", false); } context.strokeText(anno.value,eval(rotoffx + 2 + Math.min(x,lastx)),eval(rotoffy + eval((Math.min(y,lasty) + Math.max(y,lasty)) / 2))); storecanvascommands("context.strokeText(" + anno.value + "," + eval(rotoffx + 2 + Math.min(x,lastx)) + "," + eval(rotoffy + eval((Math.min(y,lasty) + Math.max(y,lasty)) / 2)) + ");", false); anno.value = ''; storecanvascommands("document.getElementById('" + anno.id + "').value='';", true); rotoffx=0.0; rotoffy=0.0; txtoffx=0.0; txtoffy=0.0; } } } function readUBlob(uval, opt_startByte, opt_stopByte) { //var oimg; dmyformit(-1); ewtwo = eval(zeroone * eval( Math.min(x,lastx) + Math.abs(x - lastx) / 2 )); ehtwo = eval(zeroone * eval( Math.min(y,lasty) + Math.abs(y - lasty) / 2 )); if (uval.replace('+','') != '') { if (uval.substring(0,1) == '+') { document.getElementById('spareimg').src=uval.substring(1); //document.getElementById('spareimg').style.filter="brightness(50%) sepia(100%) saturate(100%) hue-rotate(25deg)"; //alert('YeS'); lasturl=uval.substring(1); oimg=document.getElementById('spareimg'); curih=oimg.height; curiw=oimg.width; if (eval(document.getElementById('rotation').value) != 0) { drawRotated(eval(document.getElementById('rotation').value)); } else { lasturl=uval; ewtwo -= eval(zeroone * oimg.width / 2); ehtwo -= eval(zeroone * oimg.height / 2); if (imageclickmode != 0 || eval(scalex) != 1.0 || eval(scaley) != 1.0 || eval(cropwidth) != 100.00 || eval(cropheight) != 100.000 || eval(cropx) != 0.00 || eval(cropy) != 0.00) { curih=oimg.height; curiw=oimg.width; newiw=postnewiw(eval(eval(curiw - cropx) * scalex), eval(curih - cropy), eval(curiw - cropx), curih, cropy); newih=postnewih(eval(eval(curih - cropy) * scaley), eval(curiw - cropx), eval(curih - cropy), curiw, cropx); //alert("newiw=" + newiw + " and newIh=" + newih); if (imageclickmode != 0) { ourDrawImage(ximg,Math.min(x,lastx),Math.min(y,lasty),newiw,newih); storecanvascommands("ourDrawImage(oimg," + Math.min(x,lastx) + "," + Math.min(y,lasty) + "," + newiw + "," + newih + ");", true); //alert(7); } else if (eval(cropwidth) != 100.00 || eval(cropheight) != 100.000 || eval(cropx) != 0.00 || eval(cropy) != 0.00) { ourDrawImage(oimg,eval(cropx),eval(cropy),eval(eval(curiw - cropx) * cropwidth / ((document.getElementById('cselwidth').value == '%') ? 100.0 : 1.00)),eval(eval(curih - cropy) * cropheight / ((document.getElementById('cselheight').value == '%') ? 100.0 : 1.00)),eval(eval(ewtwo) + eval(document.getElementById("xoff").value)),eval(eval(ehtwo) + eval(document.getElementById("yoff").value)),newiw,newih); storecanvascommands("ourDrawImage(oimg," + cropx + "," + cropy + "," + eval(eval(curiw - cropx) * cropwidth / ((document.getElementById('cselwidth').value == '%') ? 100.0 : 1.00)) + "," + eval(eval(curih - cropy) * cropheight / ((document.getElementById('cselheight').value == '%') ? 100.0 : 1.00)) + "," + eval(eval(ewtwo) + eval(document.getElementById("xoff").value)) + "," + eval(eval(ehtwo) + eval(document.getElementById("yoff").value)) + "," + newiw + "," + newih + ");", true); //alert(77); } else { ourDrawImage(oimg,eval(eval(ewtwo) + eval(document.getElementById("xoff").value)),eval(eval(ehtwo) + eval(document.getElementById("yoff").value)),newiw,newih); storecanvascommands("ourDrawImage(oimg," + eval(eval(ewtwo) + eval(document.getElementById("xoff").value)) + "," + eval(eval(ehtwo) + eval(document.getElementById("yoff").value)) + "," + newiw + "," + newih + ");", true); //alert(777); } } else { ourDrawImage(oimg,eval(eval(ewtwo) + eval(document.getElementById("xoff").value)),eval(eval(ehtwo) + eval(document.getElementById("yoff").value))); storecanvascommands("ourDrawImage(oimg," + eval(eval(ewtwo) + eval(document.getElementById("xoff").value)) + "," + eval(eval(ehtwo) + eval(document.getElementById("yoff").value)) + ");", true); //alert(7777); } } } else { context.clearRect(0,0,elem.width,elem.height); document.getElementById('spareimg').src=uval; //document.getElementById('spareimg').style.filter="brightness(50%) sepia(100%) saturate(100%) hue-rotate(25deg)"; //alert('YES'); oimg=document.getElementById('spareimg'); curih=oimg.height; curiw=oimg.width; if (eval(document.getElementById('rotation').value) != 0) { drawRotated(eval(document.getElementById('rotation').value)); } else { if (imageclickmode != 0 || eval(scalex) != 1.0 || eval(scaley) != 1.0 || eval(cropwidth) != 100.00 || eval(cropheight) != 100.000 || eval(cropx) != 0.00 || eval(cropy) != 0.00) { newiw=postnewiw(eval(eval(curiw - cropx) * scalex), eval(curih - cropy), eval(curiw - cropx), curih, cropy); newih=postnewih(eval(eval(curih - cropy) * scaley), eval(curiw - cropx), eval(curih - cropy), curiw, cropx); //alert("newiW=" + newiw + " and newih=" + newih); if (imageclickmode != 0) { ourDrawImage(oimg,Math.min(x,lastx),Math.min(y,lasty),newiw,newih); storecanvascommands("ourDrawImage(oimg," + Math.min(x,lastx) + "," + Math.min(y,lasty) + "," + newiw + "," + newih + ");", true); //alert(8); } else if (eval(cropwidth) != 100.00 || eval(cropheight) != 100.000 || eval(cropx) != 0.00 || eval(cropy) != 0.00) { ourDrawImage(oimg,eval(cropx),eval(cropy),eval(eval(curiw - cropx) * cropwidth / ((document.getElementById('cselwidth').value == '%') ? 100.0 : 1.00)),eval(eval(curih - cropy) * cropheight / ((document.getElementById('cselheight').value == '%') ? 100.0 : 1.00)),eval(eval(ewtwo) + eval(document.getElementById("xoff").value)),eval(eval(ehtwo) + eval(document.getElementById("yoff").value)),newiw,newih); storecanvascommands("ourDrawImage(oimg," + cropx + "," + cropy + "," + eval(eval(curiw - cropx) * cropwidth / ((document.getElementById('cselwidth').value == '%') ? 100.0 : 1.00)) + "," + eval(eval(curih - cropy) * cropheight / ((document.getElementById('cselheight').value == '%') ? 100.0 : 1.00)) + "," + eval(eval(ewtwo) + eval(document.getElementById("xoff").value)) + "," + eval(eval(ehtwo) + eval(document.getElementById("yoff").value)) + "," + newiw + "," + newih + ");", true); //alert(88); } else { ourDrawImage(oimg,eval(eval(ewtwo) + eval(document.getElementById("xoff").value)),eval(eval(ehtwo) + eval(document.getElementById("yoff").value)),newiw,newih); storecanvascommands("ourDrawImage(oimg," + eval(eval(ewtwo) + eval(document.getElementById("xoff").value)) + "," + eval(eval(ehtwo) + eval(document.getElementById("yoff").value)) + "," + newiw + "," + newih + ");", true); //alert(888); } } else { ourDrawImage(oimg,eval(eval(ewtwo) + eval(document.getElementById("xoff").value)),eval(eval(ehtwo) + eval(document.getElementById("yoff").value))); storecanvascommands("ourDrawImage(oimg," + eval(eval(ewtwo) + eval(document.getElementById("xoff").value)) + "," + eval(eval(ehtwo) + eval(document.getElementById("yoff").value)) + ");", true); //alert(8888); } } } } } function readOBlob(opt_startByte, opt_stopByte) { for (var ii=0; ii<1; ii++) { ewtwo = eval(zeroone * eval( Math.min(x,lastx) + Math.abs(x - lastx) / 2 )); ehtwo = eval(zeroone * eval( Math.min(y,lasty) + Math.abs(y - lasty) / 2 )); var files = document.getElementById("file").files; if (!files.length) { var ivo=document.getElementById('vsiurl'); if (ivo) { if (ivo.value.replace('+','') == '') alert("Please select " + bmode + " file!"); } else { alert("Please select " + bmode + " file!"); } return; } else { var w = files[0].name; document.getElementById("fil").value = w; } var file = files[0]; // Only process image files. if (bmode == ' an image ' && !file.type.match('image.*')) { continue; } //maptype='img'; if (bmode != ' an image ' && file.type.match('video.*')) { maptype=file.type; //'video'; mapext=''; var vexts=file.name.split('.'); if (vexts.length > 1) { mapext='.' + vexts[eval(-1 + vexts.length)]; } else { mapext='.mv4'; } document.getElementById('mapext' + eval(-1 + dmfcnt)).value=mapext; document.getElementById('maptype' + eval(-1 + dmfcnt)).value=maptype; document.getElementById('mapxext' + eval(-1 + dmfcnt)).value=mapext; document.getElementById('mapxtype' + eval(-1 + dmfcnt)).value=maptype; } else if (bmode != ' an image ') { maptype=file.type; //'audio'; mapext=''; var exts=file.name.split('.'); if (exts.length > 1) { mapext='.' + exts[eval(-1 + exts.length)]; } else { mapext='.ma4'; } document.getElementById('mapext' + eval(-1 + dmfcnt)).value=mapext; document.getElementById('maptype' + eval(-1 + dmfcnt)).value=maptype; document.getElementById('mapxext' + eval(-1 + dmfcnt)).value=mapext; document.getElementById('mapxtype' + eval(-1 + dmfcnt)).value=maptype; } start = parseInt(opt_startByte) || 0; stop = parseInt(opt_stopByte) || file.size - 1; if (eval(file.size) > 8000000) { alert('Sorry ... too big ' + maptype + " (" + file.type + ")"); continue; } dmyformit(-1); var reader = new FileReader(); // If we use onloadend, we need to check the readyState. reader.onloadend = function(evt) { if (evt.target.readyState == FileReader.DONE) { // DONE == 2 //cis = window.open("", "_blank", "top=20,left=20,width=200,height=200"); //ww = cis; //cis.document.write(evt.target.result); //document.getElementById("url").value = evt.target.result; //document.getElementById("acont").value = evt.target.result; //document.getElementById("submit").click(); //cis.document.write(evt.target.result.replace(//g, ">")); //document.body.innerHTML = document.body.innerHTML + "
" + evt.target.result.replace(//g, ">") + "
"; document.getElementById("byte_content").textContent = evt.target.result; document.getElementById("byte_range").textContent = ["Read bytes: ", start + 1, " - ", stop + 1, " of ", file.size, " byte file"].join(""); if (mapext == '.gif' && document.getElementById('tdhuhta')) { agdu="data:image/gif;base64," + windowbtoa(evt.target.result); } else { agdu=""; } process(evt.target.result); } }; var blob = file.slice(start, stop + 1); reader.readAsDataURL(blob); // Thanks to //stackoverflow.com/questions/22255580/javascript-upload-image-file-and-draw-it-into-a-canvas reader.onload = function(e) { ximg = new Image(); ximg.onload = function() { if (eval(document.getElementById('rotation').value) != 0) { oimg = ximg; curih=oimg.height; curiw=oimg.width; drawRotated(eval(document.getElementById('rotation').value)); } else { ewtwo -= eval(zeroone * ximg.width / 2); ehtwo -= eval(zeroone * ximg.height / 2); if (imageclickmode != 0 || eval(scalex) != 1.0 || eval(scaley) != 1.0 || eval(cropwidth) != 100.00 || eval(cropheight) != 100.000 || eval(cropx) != 0.00 || eval(cropy) != 0.00) { curih=ximg.height; curiw=ximg.width; newiw=postnewiw(eval(eval(curiw - cropx) * scalex), eval(curih - cropy), eval(curiw - cropx), curih, cropy); newih=postnewih(eval(eval(curih - cropy) * scaley), eval(curiw - cropx), eval(curih - cropy), curiw, cropx); //alert("newiw=" + newiw + " and nEwih=" + newih); if (imageclickmode != 0) { //alert("newiw=" + newiw + " and NEwih=" + newih); ourDrawImage(ximg,Math.min(x,lastx),Math.min(y,lasty),newiw,newih); storecanvascommands("ourDrawImage(oimg," + Math.min(x,lastx) + "," + Math.min(y,lasty) + "," + newiw + "," + newih + ");", true); //alert(9); } else if (eval(cropwidth) != 100.00 || eval(cropheight) != 100.000 || eval(cropx) != 0.00 || eval(cropy) != 0.00) { ourDrawImage(ximg,eval(cropx),eval(cropy),eval(eval(curiw - cropx) * cropwidth / ((document.getElementById('cselwidth').value == '%') ? 100.0 : 1.00)),eval(eval(curih - cropy) * cropheight / ((document.getElementById('cselheight').value == '%') ? 100.0 : 1.00)),eval(eval(ewtwo) + eval(document.getElementById("xoff").value)),eval(eval(ehtwo) + eval(document.getElementById("yoff").value)),newiw,newih); storecanvascommands("ourDrawImage(oimg," + cropx + "," + cropy + "," + eval(eval(curiw - cropx) * cropwidth / ((document.getElementById('cselwidth').value == '%') ? 100.0 : 1.00)) + "," + eval(eval(curih - cropy) * cropheight / ((document.getElementById('cselheight').value == '%') ? 100.0 : 1.00)) + "," + eval(rwtwo + document.getElementById("xoff").value) + "," + eval(eval(ehtwo) + eval(document.getElementById("yoff").value)) + "," + newiw + "," + newih + ");", true); //alert(99); } else { ourDrawImage(ximg,eval(eval(ewtwo) + eval(document.getElementById("xoff").value)),eval(eval(ehtwo) + eval(document.getElementById("yoff").value)),newiw,newih); storecanvascommands("ourDrawImage(oimg," + eval(eval(ewtwo) + eval(document.getElementById("xoff").value)) + "," + eval(eval(ehtwo) + eval(document.getElementById("yoff").value)) + "," + newiw + "," + newih + ");", true); //alert(999); } } else { if (icover && !icontain) { ourDrawImage(ximg,0,0,elem.width,elem.height); storecanvascommands("ourDrawImage(ximg,0,0," + elem.width + "," + elem.height + ");", true); icover=false; icontain=false; } else if (icontain && eval(eval('' + ximg.width) / eval('' + elem.width)) >= eval(eval('' + ximg.height) / eval('' + elem.height))) { //alert('19999 width ratio=' + eval(eval('' + ximg.width) / eval('' + elem.width)) + ' height ratio=' + eval(eval('' + ximg.height) / eval('' + elem.height))); ourDrawImage(ximg,0,0,elem.width,eval(eval('' + ximg.height) / eval(eval('' + ximg.width) / eval('' + elem.width)))); storecanvascommands("ourDrawImage(ximg,0,0," + elem.width + "," + eval(eval('' + ximg.height) / eval(eval('' + ximg.width) / eval('' + elem.width))) + ");", true); icover=false; icontain=false; } else if (icontain) { //alert('29999 width ratio=' + eval(eval('' + ximg.width) / eval('' + elem.width)) + ' height ratio=' + eval(eval('' + ximg.height) / eval('' + elem.height)) + ' img=(' + ximg.width + ',' + ximg.height + ') canvas=(' + elem.width + ',' + elem.height + ')'); ourDrawImage(ximg,0,0,eval(eval('' + ximg.width) / eval(eval('' + ximg.height) / eval('' + elem.height))),elem.height); storecanvascommands("ourDrawImage(ximg,0,0," + eval(eval('' + ximg.width) / eval(eval('' + ximg.height) / eval('' + elem.height))) + "," + elem.height + ");", true); icover=false; icontain=false; } else { ourDrawImage(ximg,eval(eval(ewtwo) + eval(document.getElementById("xoff").value)),eval(eval(ehtwo) + eval(document.getElementById("yoff").value))); storecanvascommands("ourDrawImage(oimg," + eval(eval(ewtwo) + eval(document.getElementById("xoff").value)) + "," + eval(eval(ehtwo) + eval(document.getElementById("yoff").value)) + ");", true); } //alert(9999); } } } ximg.src = e.target.result; //ximg.style.filter="brightness(50%) sepia(100%) saturate(100%) hue-rotate(25deg)"; //alert('yes'); }; } } function readBlob(opt_startByte, opt_stopByte) { for (var ii=0; ii<1; ii++) { ewtwo = eval(zeroone * eval( Math.min(x,lastx) + Math.abs(x - lastx) / 2 )); ehtwo = eval(zeroone * eval( Math.min(y,lasty) + Math.abs(y - lasty) / 2 )); var files = document.getElementById("file").files; if (!files.length) { var ivo=document.getElementById('vsiurl'); if (ivo) { if (ivo.value.replace('+','') == '') alert("Please select " + bmode + " file!"); } else { alert("Please select " + bmode + " file!"); } return; } else { var w = files[0].name; document.getElementById("fil").value = w; } var file = files[0]; // Only process image files. if (bmode == ' an image ' && !file.type.match('image.*')) { continue; } //maptype='img'; if (bmode != ' an image ' && file.type.match('video.*')) { maptype=file.type; //'video'; mapext=''; var vexts=file.name.split('.'); if (vexts.length > 1) { mapext='.' + vexts[eval(-1 + vexts.length)]; } document.getElementById('mapext' + eval(-1 + dmfcnt)).value=mapext; document.getElementById('maptype' + eval(-1 + dmfcnt)).value=maptype; document.getElementById('mapxext' + eval(-1 + dmfcnt)).value=mapext; document.getElementById('mapxtype' + eval(-1 + dmfcnt)).value=maptype; } else if (bmode != ' an image ') { maptype=file.type; //'audio'; mapext=''; var exts=file.name.split('.'); if (exts.length > 1) { mapext='.' + exts[eval(-1 + exts.length)]; } document.getElementById('mapext' + eval(-1 + dmfcnt)).value=mapext; document.getElementById('maptype' + eval(-1 + dmfcnt)).value=maptype; document.getElementById('mapxext' + eval(-1 + dmfcnt)).value=mapext; document.getElementById('mapxtype' + eval(-1 + dmfcnt)).value=maptype; } start = parseInt(opt_startByte) || 0; stop = parseInt(opt_stopByte) || file.size - 1; if (eval(file.size) > 8000000) { alert('Sorry ... too big ... ' + maptype + " (" + file.type + ")"); continue; } dmyformit(-1); var reader = new FileReader(); // If we use onloadend, we need to check the readyState. reader.onloadend = function(evt) { if (evt.target.readyState == FileReader.DONE) { // DONE == 2 //cis = window.open("", "_blank", "top=20,left=20,width=200,height=200"); //ww = cis; //cis.document.write(evt.target.result); //document.getElementById("url").value = evt.target.result; //document.getElementById("acont").value = evt.target.result; //document.getElementById("submit").click(); //cis.document.write(evt.target.result.replace(//g, ">")); //document.body.innerHTML = document.body.innerHTML + "
" + evt.target.result.replace(//g, ">") + "
"; document.getElementById("byte_content").textContent = evt.target.result; document.getElementById("byte_range").textContent = ["Read bytes: ", start + 1, " - ", stop + 1, " of ", file.size, " byte file"].join(""); if (mapext == '.gif' && document.getElementById('tdhuhta')) { agdu="data:image/gif;base64," + windowbtoa(evt.target.result); } else { agdu=""; } process(evt.target.result); } }; var blob = file.slice(start, stop + 1); reader.readAsDataURL(blob); // Thanks to //stackoverflow.com/questions/22255580/javascript-upload-image-file-and-draw-it-into-a-canvas reader.onload = function(e) { ximg = new Image(); ximg.onload = function() { context.clearRect(0,0,elem.width,elem.height); storecanvascommands("context.clearRect(" + 0 + "," + 0 + "," + elem.width + "," + elem.height + ");", false); if (eval(document.getElementById('rotation').value) != 0) { oimg = ximg; curih=oimg.height; curiw=oimg.width; drawRotated(eval(document.getElementById('rotation').value)); } else { ewtwo -= eval(zeroone * ximg.width / 2); ehtwo -= eval(zeroone * ximg.height / 2); if (imageclickmode != 0 || eval(scalex) != 1.0 || eval(scaley) != 1.0 || eval(cropwidth) != 100.00 || eval(cropheight) != 100.000 || eval(cropx) != 0.00 || eval(cropy) != 0.00) { curih=ximg.height; curiw=ximg.width; newiw=postnewiw(eval(eval(curiw - cropx) * scalex), eval(curih - cropy), eval(curiw - cropx), curih, cropy); newih=postnewih(eval(eval(curih - cropy) * scaley), eval(curiw - cropx), eval(curih - cropy), curiw, cropx); //alert("newiw=" + newiw + " and Newih=" + newih); if (imageclickmode != 0) { if (icover && !icontain) { ourDrawImage(ximg,0,0,elem.width,elem.height); storecanvascommands("ourDrawImage(ximg,0,0," + elem.width + "," + elem.height + ");", true); icover=false; icontain=false; } else if (icontain && eval(eval('' + ximg.width) / eval('' + elem.width)) >= eval(eval('' + ximg.height) / eval('' + elem.height))) { //alert('19999 width ratio=' + eval(eval('' + ximg.width) / eval('' + elem.width)) + ' height ratio=' + eval(eval('' + ximg.height) / eval('' + elem.height))); ourDrawImage(ximg,0,0,elem.width,eval(eval('' + ximg.height) / eval(eval('' + ximg.width) / eval('' + elem.width)))); storecanvascommands("ourDrawImage(ximg,0,0," + elem.width + "," + eval(eval('' + ximg.height) / eval(eval('' + ximg.width) / eval('' + elem.width))) + ");", true); icover=false; icontain=false; } else if (icontain) { //alert('29999 width ratio=' + eval(eval('' + ximg.width) / eval('' + elem.width)) + ' height ratio=' + eval(eval('' + ximg.height) / eval('' + elem.height)) + ' img=(' + ximg.width + ',' + ximg.height + ') canvas=(' + elem.width + ',' + elem.height + ')'); ourDrawImage(ximg,0,0,eval(eval('' + ximg.width) / eval(eval('' + ximg.height) / eval('' + elem.height))),elem.height); storecanvascommands("ourDrawImage(ximg,0,0," + eval(eval('' + ximg.width) / eval(eval('' + ximg.height) / eval('' + elem.height))) + "," + elem.height + ");", true); icover=false; icontain=false; } else { ourDrawImage(ximg,Math.min(x,lastx),Math.min(y,lasty),newiw,newih); storecanvascommands("ourDrawImage(ximg," + Math.min(x,lastx) + "," + Math.min(y,lasty) + "," + newiw + "," + newih + ");", true); } //alert(12); } else if (eval(cropwidth) != 100.00 || eval(cropheight) != 100.000 || eval(cropx) != 0.00 || eval(cropy) != 0.00) { ourDrawImage(ximg,eval(cropx),eval(cropy),eval(eval(curiw - cropx) * cropwidth / ((document.getElementById('cselwidth').value == '%') ? 100.0 : 1.00)),eval(eval(curih - cropy) * cropheight / ((document.getElementById('cselheight').value == '%') ? 100.0 : 1.00)),eval(eval(ewtwo) + eval(document.getElementById("xoff").value)),eval(eval(ehtwo) + eval(document.getElementById("xoff").value)),eval(eval(ehtwo) + eval(document.getElementById("yoff").value)),newiw,newih); storecanvascommands("ourDrawImage(ximg," + cropx + "," + cropy + "," + eval(eval(curiw - cropx) * cropwidth / ((document.getElementById('cselwidth').value == '%') ? 100.0 : 1.00)) + "," + eval(eval(curih - cropy) * cropheight / ((document.getElementById('cselheight').value == '%') ? 100.0 : 1.00)) + "," + eval(eval(ewtwo) + eval(document.getElementById("xoff").value)) + "," + eval(eval(ehtwo) + eval(document.getElementById("yoff").value)) + "," + newiw + "," + newih + ");", true); //alert(112); } else { ourDrawImage(ximg,eval(eval(ewtwo) + eval(document.getElementById("xoff").value)),eval(eval(ehtwo) + eval(document.getElementById("yoff").value)),newiw,newih); storecanvascommands("ourDrawImage(ximg," + eval(eval(ewtwo) + eval(document.getElementById("xoff").value)) + "," + eval(eval(ehtwo) + eval(document.getElementById("yoff").value)) + "," + newiw + "," + newih + ");", true); //alert(1112); } } else { if (icover && !icontain) { ourDrawImage(ximg,0,0,elem.width,elem.height); storecanvascommands("ourDrawImage(ximg,0,0," + elem.width + "," + elem.height + ");", true); icover=false; icontain=false; } else if (icontain && eval(eval('' + ximg.width) / eval('' + elem.width)) >= eval(eval('' + ximg.height) / eval('' + elem.height))) { //alert('19999 width ratio=' + eval(eval('' + ximg.width) / eval('' + elem.width)) + ' height ratio=' + eval(eval('' + ximg.height) / eval('' + elem.height))); ourDrawImage(ximg,0,0,elem.width,eval(eval('' + ximg.height) / eval(eval('' + ximg.width) / eval('' + elem.width)))); storecanvascommands("ourDrawImage(ximg,0,0," + elem.width + "," + eval(eval('' + ximg.height) / eval(eval('' + ximg.width) / eval('' + elem.width))) + ");", true); icover=false; icontain=false; } else if (icontain) { //alert('29999 width ratio=' + eval(eval('' + ximg.width) / eval('' + elem.width)) + ' height ratio=' + eval(eval('' + ximg.height) / eval('' + elem.height)) + ' img=(' + ximg.width + ',' + ximg.height + ') canvas=(' + elem.width + ',' + elem.height + ')'); ourDrawImage(ximg,0,0,eval(eval('' + ximg.width) / eval(eval('' + ximg.height) / eval('' + elem.height))),elem.height); storecanvascommands("ourDrawImage(ximg,0,0," + eval(eval('' + ximg.width) / eval(eval('' + ximg.height) / eval('' + elem.height))) + "," + elem.height + ");", true); icover=false; icontain=false; } else { ourDrawImage(ximg,eval(eval(ewtwo) + eval(document.getElementById("xoff").value)),eval(ehtwo + document.getElementById("yoff").value)); storecanvascommands("ourDrawImage(ximg," + eval(eval(ewtwo) + eval(document.getElementById("xoff").value)) + "," + eval(eval(ehtwo) + eval(document.getElementById("yoff").value)) + ");", true); } //alert(11112); } } } ximg.src = e.target.result; //ximg.style.filter="brightness(50%) sepia(100%) saturate(100%) hue-rotate(25deg)"; //alert('Yes'); }; } } function flop(ioo, ione, itwo, ithree, ifour, ifive, isix, iseven, ieight) { // thanks to https://www.w3schools.com/tags/canvas_getimagedata.asp var wasw=eval(eval('' + ithree) - eval('' + ione)), wash=eval(eval('' + ifour) - eval('' + itwo)); var origw=eval('' + elem.width), origh=eval('' + elem.height); elem.width=wasw; elem.height=wash; context.translate(wasw/2, wash/2); context.scale(1, -1); context.drawImage(ioo, -wasw/2, -wash/2, wasw, wash); var huhi=elem.toDataURL('image/png'); ioo.src=huhi; ioo.style.display='inline-block'; elem.width=origw; elem.height=origh; context.drawImage(ioo,ione,itwo); } function flip(ioo, ione, itwo, ithree, ifour, ifive, isix, iseven, ieight) { // thanks to https://www.w3schools.com/tags/canvas_getimagedata.asp var wasw=elem.width, wash=elem.height, huhi=''; elem.width=wasw; elem.height=wash; context.translate(wasw/2, wash/2); context.scale(-1, 1); context.drawImage(imgi, -wasw/2, -wash/2, wasw, wash); huhi=elem.toDataURL('image/png'); ioo.src=huhi; ioo.style.display='inline-block'; elem.width=wasw; elem.height=wash; context.drawImage(ioo,ione,itwo); //alert('flip done'); if (1 == 56) { //var wasw=eval(eval('' + ithree) - eval('' + ione)), wash=eval(eval('' + ifour) - eval('' + itwo)); var wasw=elem.width, wash=elem.height, huhi=''; var origw=elem.width, origh=elem.height; var xelem = document.createElement("canvas"); xelem.width=ioo.width; xelem.height=ioo.height; //elem.width=wasw; //elem.height=wash; var xcontext=xelem.getContext('2d'); if (typeof ieight !== 'undefined') { xcontext.drawImage(ioo, ione, itwo, ithree, ifour); } else if (typeof isix !== 'undefined') { xcontext.drawImage(ioo, ione, itwo, ithree, ifour); } else { xcontext.drawImage(ioo, ione, itwo, ithree, ifour); } xcontext.translate(wasw/2, wash/2); xcontext.scale(-1, 1); //xcontext.drawImage(ioo, -wasw/2, -wash/2, wasw, wash); huhi=xelem.toDataURL('image/png'); ioo.src=huhi; ioo.style.display='inline-block'; //elem.width=origw; //elem.height=origh; context.drawImage(ioo,ione,itwo); } } function process(infilecontents) { //if (1 == 7) { alert(infilecontents); } //var ourlines = infilecontents.split(String.fromCharCode(10)); //var ourwords = infilecontents.split(String.fromCharCode(32)); //var myfis = "

Filename is " + escape(document.getElementById("file").files[0].mozFullPath + document.getElementById("file").value) + " ... Type is (" + (document.getElementById("file").files[0].type || "n/a") + ") ... Date is " + (document.getElementById("file").files[0].lastModifiedDate ? document.getElementById("file").files[0].lastModifiedDate.toLocaleDateString() : "n/a") + " ... Size is " + infilecontents.length + " bytes ... Line Count is " + ourlines.length + " ... Word Count is " + ourwords.length + "

"; //document.body.innerHTML = document.body.innerHTML + myfis; //var huh = document.URL.split("?"); //if (huh.length > 1) { // location.href = huh[0] + "?myf=" + decodeURIComponent(myfis); //} else { // location.href = document.URL + "?myf=" + decodeURIComponent(myfis); //} //alert(infilecontents); fcont = infilecontents; //document.getElementById("byte_content").style.display='block'; document.getElementById("byte_range").style.display='block'; if (bmode != ' an image ') { //alert(bmode); var areader = new FileReader(); areader.onload = function(e) { //xaudio = new Audio(); //alert(e.target.result); }; areader.readAsDataURL(infilecontents); // Thanks to //stackoverflow.com/questions/22255580/javascript-upload-image-file-and-draw-it-into-a-canvas //alert(infilecontents.substring(0,30)); //alert("document.getElementById('mapcoords" + eval(-1 + dmfcnt) + "').value='" + document.getElementById('mapcoords' + eval(-1 + dmfcnt)).value + "'"); //alert("document.getElementById('mapaudio" + eval(-1 + dmfcnt) + "').value='" + infilecontents.substring(0,30) + "'"); document.getElementById('mapaudio' + eval(-1 + dmfcnt)).value=infilecontents; document.getElementById('mapxaudio' + eval(-1 + dmfcnt)).value=infilecontents; bmode = ' an image '; } } function intwo() { x=0; y=0; lastx=0; lasty=0; isScribble=2; } function touchWindowHandler(event) // thanks to //stackoverflow.com/questions/1517924/javascript-mapping-touch-events-to-mouse-events { var touches = event.changedTouches, first = touches[0], type = ""; switch(event.type) { case "touchstart": type = "onclick"; //alert(88 + moid + event.targetTouches.length); break; default: return; } //initMouseEvent(type, canBubble, cancelable, view, clickCount, // screenX, screenY, clientX, clientY, ctrlKey, // altKey, shiftKey, metaKey, button, relatedTarget); var simulatedEvent = document.createEvent("MouseEvent"); simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY, false, false, false, false, 0/*left*/, null); first.target.dispatchEvent(simulatedEvent); event.preventDefault(); } function touchHandler(event) // thanks to //stackoverflow.com/questions/1517924/javascript-mapping-touch-events-to-mouse-events { var touches = event.changedTouches, first = touches[0], type = ""; //if (event.targetTouches.length == 1) { switch(event.type) { //case "touchstart": type="mousedown"; break; case "touchmove": type="mousemove"; break; case "touchend": type="mouseup"; break; default: return; } //initMouseEvent(type, canBubble, cancelable, view, clickCount, // screenX, screenY, clientX, clientY, ctrlKey, // altKey, shiftKey, metaKey, button, relatedTarget); var simulatedEvent = document.createEvent("MouseEvent"); simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY, false, false, false, false, 0/*left*/, null); first.target.dispatchEvent(simulatedEvent); event.preventDefault(); event.stopPropagation(); switch(type) { //case "mousedown": if (isScribble == 1) { isScribble=2; storecanvascommands("context=context;", false); } break; case "mousemove": if (isScribble == 2 || isScribble == 1) { if (x == 0 && y == 0 && lastx == 0 && lasty == 0) { if (event.pageX || event.pageY) { x = event.pageX - elemLeft; y = event.pageY - elemTop; } else { x = event.clientX - elemLeft; y = event.clientY - elemTop; } lastx=x; lasty=y; } else { lastx=x; lasty=y; if (event.pageX || event.pageY) { x = event.pageX - elemLeft; y = event.pageY - elemTop; } else { x = event.clientX - elemLeft; y = event.clientY - elemTop; } } if (isScribble == 2) { if (x != lastx || y != lasty) { document.getElementById('divannotation').style.display='block'; document.getElementById('myisubject').style.display = 'inline'; document.getElementById('myiemail').style.display = 'inline'; context.strokeStyle=document.getElementById('mycolour').value; storecanvascommands("context.fillStyle='" + document.getElementById('mycolour').value + "';", false); context.beginPath(); storecanvascommands("context.beginPath();", false); context.moveTo(x,y); storecanvascommands("context.moveTo(" + x + "," + y + ");", false); context.lineTo(lastx,lasty); storecanvascommands("context.lineTo(" + lastx + "," + lasty + ");", false); context.stroke(); storecanvascommands("context.stroke();", false); } } isScribble=2; } break; case "mouseup": if (isScribble == 2) { x=0; y=0; lastx=0; lasty=0; isScribble=1; storecanvascommands("context=context;", true); } break; default: return; } //} } function drawRotated(degrees) { // thanks to //stackoverflow.com/questions/17411991/html5-canvas-rotate-image var needflip=0; var wasf=document.getElementById('rotation').value; var spareewtwo = eval(zeroone * eval( Math.min(x,lastx) + Math.abs(x - lastx) / 2 )); var spareehtwo = eval(zeroone * eval( Math.min(y,lasty) + Math.abs(y - lasty) / 2 )); ewtwo = eval(elem.width/2); ehtwo = eval(elem.height/2); if (document.getElementById('rof').value.indexOf('of ') != -1) { storecanvascommands("context.clearRect(" + 0 + "," + 0 + "," + elem.width + "," + elem.height + ");", false); context.clearRect(0,0,elem.width,elem.height); } //if (document.getElementById('rof').value == '' && oimg != null) { //storecanvascommands("context.clearRect(" + 0 + "," + 0 + "," + elem.width + "," + elem.height + ");", false); //context.clearRect(0,0,elem.width,elem.height); // save the unrotated context of the canvas so we can restore it later // the alternative is to untranslate & unrotate after drawing storecanvascommands("context.save();", false); context.save(); //} // move to the center of the canvas if (eval(txtoffx) != 0.0 || eval(txtoffy) != 0.0) { //alert("Ewtwo,Ehtwo=" + ewtwo + "," + ehtwo); storecanvascommands("context.translate(" + txtoffx + "," + txtoffy + ");", false); context.translate(txtoffx,txtoffy); if (rotcmd != '') { rotoffx=eval(-txtoffx); rotoffy=eval(-txtoffy); } } else if (eval(document.getElementById("xoff").value) != 0 || eval(document.getElementById("yoff").value) != 0) { ewtwo = eval(eval(spareeewtwo) * 0 + eval(document.getElementById("xoff").value)); ehtwo = eval(eval(spareeehtwo) * 0 + eval(document.getElementById("yoff").value)); //alert("Ewtwo,ehtwo=" + ewtwo + "," + ehtwo); storecanvascommands("context.translate(" + ewtwo + "," + ehtwo + ");", false); context.translate(ewtwo,ehtwo); ewtwo = eval(-ewtwo); ehtwo = eval(-ehtwo); } else if (0 == 0) { curih=oimg.height; curiw=oimg.width; //if (eval(degrees) >= 180) { // needflip=true; // degrees = eval(360 - wasf); // document.getElementById('rotation').value=degrees; //} var dx=0, dy=0; newiw=postnewiw(eval(eval(curiw - cropx) * scalex), eval(curih - cropy), eval(curiw - cropx), curih, cropy); newih=postnewih(eval(eval(curih - cropy) * scaley), eval(curiw - cropx), eval(curih - cropy), curiw, cropx); //alert(newiw + ' ' + newih); //ewtwo = eval(eval( Math.min(x,lastx) + 1 * offxmaybe(eval(document.getElementById("xoff").value),newih,newiw) + Math.abs(x - lastx) / 2 - postscalew(scalex,oimg.height,oimg.width) * oimg.width / 2 )); //ehtwo = eval(eval( Math.min(y,lasty) + 1 * offymaybe(eval(document.getElementById("yoff").value),newiw,newih) + Math.abs(y - lasty) / 2 - postscaleh(scaley,oimg.width,oimg.height) * oimg.height / 2 )); ewtwo = eval(eval( Math.min(x,lastx) + 1 * offxmaybe(eval(document.getElementById("xoff").value),newih,newiw) + Math.abs(x - lastx) / 2 - postscalew(scalex,oimg.height,oimg.width) * oimg.width / 2 )); ehtwo = eval(eval( Math.min(y,lasty) + 1 * offymaybe(eval(document.getElementById("yoff").value),newiw,newih) + Math.abs(y - lasty) / 2 - postscaleh(scaley,oimg.width,oimg.height) * oimg.height / 2 )); //alert("ewtwo,ehtwo=" + ewtwo + "," + ehtwo); if (eval(degrees) >= 270) { needflip=1; } else if (eval(degrees) >= 180) { needflip=-1; } storecanvascommands("context.translate(" + ewtwo + "," + ehtwo + ");", false); context.translate(ewtwo,ehtwo); if (needflip != 0) { context.scale(needflip, -needflip); storecanvascommands("context.scale(" + eval(needflip) + "," + eval(-needflip) + ");", false); } //ewtwo = eval(-ewtwo + Math.min(x,lastx) + 1 * offxmaybe(eval(document.getElementById("xoff").value),newih,newiw) + Math.abs(x - lastx) / 2 - postscalew(scalex,oimg.height,oimg.width) * oimg.width / 2 ); //ehtwo = eval(-ehtwo + Math.min(y,lasty) + 1 * offymaybe(eval(document.getElementById("yoff").value),newiw,newih) + Math.abs(y - lasty) / 2 - postscaleh(scaley,oimg.width,oimg.height) * oimg.height / 2 ); ewtwo = eval(-ewtwo + Math.min(x,lastx) + dx + 1 * offxmaybe(eval(document.getElementById("xoff").value),newih,newiw) + Math.abs(x - lastx) / 2 - postscalew(scalex,oimg.height,oimg.width) * oimg.width / 2 ); ehtwo = eval(-ehtwo + Math.min(y,lasty) + dy + 1 * offymaybe(eval(document.getElementById("yoff").value),newiw,newih) + Math.abs(y - lasty) / 2 - postscaleh(scaley,oimg.width,oimg.height) * oimg.height / 2 ); // New idea below ewtwo = eval(dx - (offxmaybe(eval(document.getElementById("xoff").value),newih,newiw))); //eval(-ewtwo + Math.min(x,lastx) + 1 * offxmaybe(eval(document.getElementById("xoff").value),newih,newiw) + Math.abs(x - lastx) / 2 - postscalew(scalex,oimg.height,oimg.width) * oimg.width / 2 ); ehtwo = eval(dy - (offymaybe(eval(document.getElementById("yoff").value),newiw,newih))); //eval(-ehtwo + Math.min(y,lasty) + 1 * offymaybe(eval(document.getElementById("yoff").value),newiw,newih) + Math.abs(y - lasty) / 2 - postscaleh(scaley,oimg.width,oimg.height) * oimg.height / 2 ); //alert("ewTwo,ehTwo=" + ewtwo + "," + ehtwo); } else { //alert("ewTwo,ehtwo=" + ewtwo + "," + ehtwo); storecanvascommands("context.translate(" + ewtwo + "," + ehtwo + ");", false); context.translate(ewtwo,ehtwo); ewtwo = eval(-ewtwo); ehtwo = eval(-ehtwo); } // rotate the canvas to the specified degrees storecanvascommands("context.rotate(" + degrees*Math.PI/180 + ");", false); context.rotate(degrees*Math.PI/180); if (rotcmd != '') { var sparerotcmd=rotcmd; //rotcmd=''; //alert("sparerotcmd=" + sparerotcmd); eval(sparerotcmd); } else { if (document.getElementById('rof').value != '') { oimg = origimg; curih=oimg.height; curiw=oimg.width; } if (document.getElementById('rof').value == '' || oimg != null) { // draw the image // since the context is rotated, the image will be rotated also if (imageclickmode != 0 || eval(scalex) != 1.0 || eval(scaley) != 1.0 || eval(cropwidth) != 100.00 || eval(cropheight) != 100.000 || eval(cropx) != 0.00 || eval(cropy) != 0.00) { curih=oimg.height; curiw=oimg.width; newiw=postpostnewiw(eval(eval(curiw - cropx) * scalex), eval(curih - cropy), eval(curiw - cropx), curih, cropy); newih=postpostnewih(eval(eval(curih - cropy) * scaley), eval(curiw - cropx), eval(curih - cropy), curiw, cropx); if (imageclickmode != 0) { ourDrawImage(oimg,eval(ewtwo + eval(document.getElementById("xoff").value)),eval(ehtwo + eval(document.getElementById("yoff").value)),newiw,newih); storecanvascommands("ourDrawImage(oimg," + eval(ewtwo + eval(document.getElementById("xoff").value)) + "," + eval(ehtwo + eval(document.getElementById("yoff").value)) + "," + newiw + "," + newih + ");", true); //alert(13); } else if (eval(cropwidth) != 100.00 || eval(cropheight) != 100.000 || eval(cropx) != 0.00 || eval(cropy) != 0.00) { //alert("newiw=" + newiw + " and newiH=" + newih); ourDrawImage(oimg,eval(cropx),eval(cropy),eval(eval(curiw - cropx) * cropwidth / ((document.getElementById('cselwidth').value == '%') ? 100.0 : 1.00)),eval(eval(curih - cropy) * cropheight / ((document.getElementById('cselheight').value == '%') ? 100.0 : 1.00)),eval(ewtwo + eval(document.getElementById("xoff").value)),eval(ehtwo + eval(document.getElementById("yoff").value)),newiw,newih); //storecanvascommands("ourDrawImage(oimg," + cropx + "," + cropy + "," + eval(eval(curiw - cropx) * cropwidth / ((document.getElementById('cselwidth').value == '%') ? 100.0 : 1.00)) + "," + eval(eval(curih - cropy) * cropheight / ((document.getElementById('cselheight').value == '%') ? 100.0 : 1.00)) + "," + -oimg.width/2 + eval(document.getElementById("xoff").value) + "," + -oimg.height/2 + eval(document.getElementById("yoff").value) + "," + newiw + "," + newih + ");", true); storecanvascommands("ourDrawImage(oimg," + cropx + "," + cropy + "," + eval(eval(curiw - cropx) * cropwidth / ((document.getElementById('cselwidth').value == '%') ? 100.0 : 1.00)) + "," + eval(eval(curih - cropy) * cropheight / ((document.getElementById('cselheight').value == '%') ? 100.0 : 1.00)) + "," + eval(ewtwo + eval(document.getElementById("xoff").value)) + "," + eval(ehtwo + eval(document.getElementById("yoff").value)) + "," + newiw + "," + newih + ");", true); //alert(113); } else { ourDrawImage(oimg,eval(ewtwo + eval(document.getElementById("xoff").value)),eval(ehtwo + eval(document.getElementById("yoff").value)),newiw,newih); storecanvascommands("ourDrawImage(oimg," + eval(ewtwo + eval(document.getElementById("xoff").value)) + "," + eval(ehtwo + eval(document.getElementById("yoff").value)) + "," + newiw + "," + newih + ");", true); //alert(1113); } } else { storecanvascommands("ourDrawImage(oimg," + eval(ewtwo + eval(document.getElementById("xoff").value)) + "," + eval(ehtwo + eval(document.getElementById("yoff").value)) + ");", false); //ourDrawImage(oimg, //eval(elem.width/2 + eval(document.getElementById("xoff").value) - Math.sin(degrees*Math.PI/180)*(oimg.height/1)*1), //eval(elem.height/2 + eval(document.getElementById("yoff").value) - Math.sin(degrees*Math.PI/180)*(oimg.width/1)*1)); //alert(98); ourDrawImage(oimg,eval(ewtwo + eval(document.getElementById("xoff").value)),eval(ehtwo + eval(document.getElementById("yoff").value))); //alert(11113); } //alert(980); document.getElementById('rof').value = ''; oimg = null; } } // we’re done with the rotating so restore the unrotated context storecanvascommands("context.restore();", false); context.restore(); document.getElementById('rotation').value=wasf; } function maybe(tv) { if (tv != "" && eval(document.getElementById("rotation").value) != 0) { drawRotated(eval(document.getElementById("rotation").value)); } } function audiomaybe() { if (bmode == ' an audio ') { document.getElementById('oic').click(); } else if (bmode == ' an image ') { var xfiles = document.getElementById("file").files; var xfile = xfiles[0]; if (xfile.type.match('image.gif')) { mapext='.gif'; } else { mapext=''; } } } function noforeach() { if (foreachon) { foreachon=false; try { blobc='transparent'; } catch(ewq) { } } } function closewinois() { if (winois != null) { winois.close(); winois=null; } } function switchzn() { if (longhover.trim() != "") { switchit(0, longhover); } } function switchit(aclick, blurb) { if (aclick == 0 && firsthover == 1) { if (longhover == "") { longhover=blurb; setTimeout(switchzn, 2000); return; } else { var bfp=confirm(blurb + ' ... OK proceeds on this basis, else Cancel will only listen for a click/touch of the Copy button here'); if (bfp == true) { firsthover=0; } else { firsthover=-1; } } } if (aclick == 1 || firsthover != -1) { var canvuri = elem.toDataURL("image/png",0); winois=window.open('','_blank','top=30,left=30,width=1000,height=800'); winois.document.write(''); setTimeout(closewinois, 5000); } longhover=" "; } function aemail(ame) { // thanks to //www.telerik.com/forums/proper-way-to-do-mailto-and-tel-links( //alert(ame.href); //navigator.app.loadUrl(ame.href, { openExternal:true } ); window.top.location = ame.href; } function dowhite() { if (whiteize) { whiteize.style.backgroundColor='white'; } //else { alert(0); } whiteize=null; } function wlsact(invalis) { var altvalgoes='', initval='', winitval='', initvals=[], updatebg=false; if (('' + invalis) != '') { //alert(wlsdval); var thisnameis=('' + wlsnval).split('`')[eval('' + invalis)]; //.split(',')[0]; winitval=('' + wlsdval).split('`')[eval('' + invalis)]; //.split(',')[0]; initvals=('' + winitval).split('#'); for (var iiu=0; iiu', ''); wlsi++; } } } } } if (wlsdval != '') { if (wlsdval.indexOf('#') != -1) { return " 
Standing Order Sequence
"; } else { return " Standing Order Sequence"; } } return ''; } function tryit() { var tds, hstuff='', koff=-1; //alert(9800); var imageurl = location.search.split('urlimage=')[1] ? location.search.split('urlimage=')[1].split('&')[0] : ''; var imageoverlay = location.search.split('overlay=')[1] ? location.search.split('overlay=')[1].split('&')[0] : ''; if (document.getElementById('myiframe')) { document.getElementById('myiframe').width='400px'; } tds=document.getElementsByTagName('img'); if (document.URL.indexOf('/india.') != -1) koff--; if (tds.length > 0) { origimg=tds[eval(koff + tds.length)]; lasturl=tds[eval(koff + tds.length)].src; origih=origimg.height; origiw=origimg.width; if (('~' + decodeURIComponent(imageurl)).toLowerCase().replace('file:','').replace('sftp:','').replace('ftp:','').indexOf('~http') == 0) { if (imageoverlay == '') { tds[eval(koff + tds.length)].src=decodeURIComponent(imageurl); tds=document.getElementsByTagName('img'); origimg=tds[eval(koff + tds.length)]; origih=origimg.height; origiw=origimg.width; context.clearRect(0, 0, elem.width, elem.height); elem.width=origiw; elem.height=origih; document.getElementById('myiframe').style.left=origiw + 'px'; ourDrawImage(tds[eval(koff + tds.length)],0,0); //alert(14); } else { tds[eval(koff + tds.length)].src=decodeURIComponent(imageurl); tds=document.getElementsByTagName('img'); ourDrawImage(tds[eval(koff + tds.length)],0,0); //alert(114); } } } tds=document.getElementsByTagName('td'); // if (iscontact == -1) alert("tds.length=" + tds.length); //var scalestuff="Scale Width: Height:
Cropping X: Y:
Cropping Width: Height:
"; var scalestuff="Scale Width: Height:   Cropping X: Y:   Cropping Width: Height:
"; if (tds.length > 0) { //alert(98); if (iscontact != -1) { hstuff+="