// world.js
// RJM Programming
// March, 2016
// Help out world.html and others like it
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='';
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;
var xua = navigator.userAgent;
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 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;
if (xxuubits.length == 1) {
xxuubits=document.URL.split('.ht');
}
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');
function dmyformit(newval) {
var recbit='';
if (eval(newval) == 0) {
dmfcnt=-Math.abs(dmfcnt);
} else if (eval(newval) > 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) {
recbit='
Url ' + dmfcnt + ": at ';
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|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
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 (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;
}
}
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);
//alert(xbits[0]);
toh.value = pretoh.replace(xbits[0] + ',', '');
if (1 == 1) {
tos.click();
} else {
document.getElementById('myform').submit();
}
var things = document.URL.split("?");
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 (document.getElementById('to').value.indexOf('@') != -1 || navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
toe=toe;
} else {
toe.click();
}
}
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) {
context.drawImage(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) {
context.drawImage(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 {
context.drawImage(origimg,0,0,newiw,newih);
}
} else {
context.drawImage(origimg,0,0);
}
if (eval(upto) >= 0) {
for (var iup=0; iup <= upto; iup++) {
eval(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) context.drawImage(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) context.drawImage(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) context.drawImage(origimg,0,0,newiw,newih);
}
} else {
if (butnotfirst == 0) context.drawImage(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);
canvascommands.push(thecmd);
if (major) {
laststop = majors.length;
majors.push(canvascommands.length);
}
}
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;
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.fillRect(" + 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 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) + "," + 2*Math.PI + ");", false);
context.stroke();
storecanvascommands("context.stroke();", true);
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;
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);
oimg=document.getElementById('spareimg');
curih=oimg.height;
curiw=oimg.width;
if (eval(document.getElementById('rotation').value) != 0) {
drawRotated(eval(document.getElementById('rotation').value));
} else {
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) {
context.drawImage(ximg,Math.min(x,lastx),Math.min(y,lasty),newiw,newih);
storecanvascommands("context.drawImage(oimg," + Math.min(x,lastx) + "," + Math.min(y,lasty) + "," + newiw + "," + newih + ");", true);
} else if (eval(cropwidth) != 100.00 || eval(cropheight) != 100.000 || eval(cropx) != 0.00 || eval(cropy) != 0.00) {
context.drawImage(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("context.drawImage(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);
} else {
context.drawImage(oimg,eval(eval(ewtwo) + eval(document.getElementById("xoff").value)),eval(eval(ehtwo) + eval(document.getElementById("yoff").value)),newiw,newih);
storecanvascommands("context.drawImage(oimg," + eval(eval(ewtwo) + eval(document.getElementById("xoff").value)) + "," + eval(eval(ehtwo) + eval(document.getElementById("yoff").value)) + "," + newiw + "," + newih + ");", true);
}
} else {
context.drawImage(oimg,eval(eval(ewtwo) + eval(document.getElementById("xoff").value)),eval(eval(ehtwo) + eval(document.getElementById("yoff").value)));
storecanvascommands("context.drawImage(oimg," + eval(eval(ewtwo) + eval(document.getElementById("xoff").value)) + "," + eval(eval(ehtwo) + eval(document.getElementById("yoff").value)) + ");", true);
}
}
} else {
context.clearRect(0,0,elem.width,elem.height);
document.getElementById('spareimg').src=uval;
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) {
context.drawImage(oimg,Math.min(x,lastx),Math.min(y,lasty),newiw,newih);
storecanvascommands("context.drawImage(oimg," + Math.min(x,lastx) + "," + Math.min(y,lasty) + "," + newiw + "," + newih + ");", true);
} else if (eval(cropwidth) != 100.00 || eval(cropheight) != 100.000 || eval(cropx) != 0.00 || eval(cropy) != 0.00) {
context.drawImage(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("context.drawImage(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);
} else {
context.drawImage(oimg,eval(eval(ewtwo) + eval(document.getElementById("xoff").value)),eval(eval(ehtwo) + eval(document.getElementById("yoff").value)),newiw,newih);
storecanvascommands("context.drawImage(oimg," + eval(eval(ewtwo) + eval(document.getElementById("xoff").value)) + "," + eval(eval(ehtwo) + eval(document.getElementById("yoff").value)) + "," + newiw + "," + newih + ");", true);
}
} else {
context.drawImage(oimg,eval(eval(ewtwo) + eval(document.getElementById("xoff").value)),eval(eval(ehtwo) + eval(document.getElementById("yoff").value)));
storecanvascommands("context.drawImage(oimg," + eval(eval(ewtwo) + eval(document.getElementById("xoff").value)) + "," + eval(eval(ehtwo) + eval(document.getElementById("yoff").value)) + ");", true);
}
}
}
}
}
function readOBlob(opt_startByte, opt_stopByte) {
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 ));
var files = document.getElementById("file").files;
if (!files.length) {
var ivo=document.getElementById('vsiurl');
if (ivo) {
if (ivo.value.replace('+','') == '') alert("Please select a file!");
} else {
alert("Please select a file!");
}
return;
} else {
w = files[0].name;
document.getElementById("fil").value = w;
}
var file = files[0];
var start = parseInt(opt_startByte) || 0;
var stop = parseInt(opt_stopByte) || file.size - 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 + "
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'; } function intwo() { x=0; y=0; lastx=0; lasty=0; isScribble=2; } function touchWindowHandler(event) // thanks to http://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 http://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 http://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) { context.drawImage(oimg,eval(ewtwo + eval(document.getElementById("xoff").value)),eval(ehtwo + eval(document.getElementById("yoff").value)),newiw,newih); storecanvascommands("context.drawImage(oimg," + eval(ewtwo + eval(document.getElementById("xoff").value)) + "," + eval(ehtwo + eval(document.getElementById("yoff").value)) + "," + newiw + "," + newih + ");", true); } else if (eval(cropwidth) != 100.00 || eval(cropheight) != 100.000 || eval(cropx) != 0.00 || eval(cropy) != 0.00) { //alert("newiw=" + newiw + " and newiH=" + newih); context.drawImage(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("context.drawImage(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("context.drawImage(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); } else { context.drawImage(oimg,eval(ewtwo + eval(document.getElementById("xoff").value)),eval(ehtwo + eval(document.getElementById("yoff").value)),newiw,newih); storecanvascommands("context.drawImage(oimg," + eval(ewtwo + eval(document.getElementById("xoff").value)) + "," + eval(ehtwo + eval(document.getElementById("yoff").value)) + "," + newiw + "," + newih + ");", true); } } else { storecanvascommands("context.drawImage(oimg," + eval(ewtwo + eval(document.getElementById("xoff").value)) + "," + eval(ehtwo + eval(document.getElementById("yoff").value)) + ");", false); //context.drawImage(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); context.drawImage(oimg,eval(ewtwo + eval(document.getElementById("xoff").value)),eval(ehtwo + eval(document.getElementById("yoff").value))); } //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 noforeach() { if (foreachon) { foreachon=false; try { blobc='transparent'; } catch(ewq) { } } } 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] : ''; document.getElementById('myiframe').width='400px'; tds=document.getElementsByTagName('img'); if (document.URL.indexOf('/india.') != -1) koff--; origimg=tds[eval(koff + tds.length)]; origih=origimg.height; origiw=origimg.width; if (('~' + decodeURIComponent(imageurl)).toLowerCase().replace('file:','http:').replace('sftp:','http:').replace('ftp:','http:').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'; context.drawImage(tds[eval(koff + tds.length)],0,0); } else { tds[eval(koff + tds.length)].src=decodeURIComponent(imageurl); tds=document.getElementsByTagName('img'); context.drawImage(tds[eval(koff + tds.length)],0,0); } } tds=document.getElementsByTagName('td'); var scalestuff="Scale Width: Height: