// signature_signature.js // RJM Programming // May, 2017 // Help out signature_signature.html and others like it var topfirst=true,toplthere=false, topelem=null, topielem=null, topcontext=null, topwidth=0, topheight=0, topvswidth=0, topvsheight=0, topvswidthoff=0, topvsheightoff=0; var firstcall=true;savenow=0, lastsavenow=0, ppx=-1,ppy=-1,pmore='', isScribble=1; //0; var xua = navigator.userAgent; var isiPad = /iPad/i.test(xua) || /iPhone/i.test(xua) || /iPhone OS 3_1_2/i.test(xua) || /Andrxoid/i.test(xua) || /iPhone OS 3_2_2/i.test(xua); var isTouch = /touch/i.test(xua) || /Touch/i.test(xua); var sscoords = (location.search.split('sscoords=')[1] ? decodeURIComponent(location.search.split('sscoords=')[1].split('&')[0]) : ''); var ninehundred = (location.search.split('ninehundred=')[1] ? eval(decodeURIComponent(location.search.split('ninehundred=')[1].split('&')[0])) : 900); if (ninehundred > 900) sscoords=''; function ssj_setCookie(thisg) { // thanks to JavaScript and Ajax by Tom Negrino and Dori Smith var expireDate = new Date(); expireDate.setMonth(expireDate.getMonth()+6); //alert(thisg); if (("sscoords=" + thisg + "; expires=" + expireDate.toGMTString()).length < ninehundred) { //alert(234); document.cookie = "sscoords=" + thisg + "; expires=" + expireDate.toGMTString(); } //else { //alert("length=" + thisg.length); //} } function ssj_deleteCookie() { // thanks to JavaScript and Ajax by Tom Negrino and Dori Smith var expireDate = new Date(); expireDate.setMonth(expireDate.getMonth()-6); document.cookie = "sscoords=; expires=" + expireDate.toGMTString(); } function ssj_cookieVal(fcall) { //document.title+=(" firstcall=" + firstcall + " and sscoords=" + sscoords); if (fcall && sscoords != '') { if (document.cookie == '') { //document.title+=(" Sscoords=" + sscoords); ssj_setCookie(sscoords); } } else { if (document.cookie != '') { var tCookie=document.cookie.split("; "); for (var j=0; j= eval(topvsheight) && eval(topwidth) >= eval(topvswidth)) { topvswidthoff=0; topvsheightoff=eval(eval(topheight) - eval(topvsheight)); if (document.getElementById('rest')) { document.getElementById('rest').style.display='none'; } //alert('yes yes'); } else { //alert(topvswidth + ' no ' + topwidth + ' ' + topvsheight + ' no ' + topheight); topelem=null; topielem=null; topcontext=null; topwidth=0; topheight=0; topvswidth=0; topvsheight=0; topvswidthoff=0; topvsheightoff=0; } } } if (sscoords != '') { var asscoords=sscoords.split(','); wassscoords=sscoords; sscoords = ''; sscoordsdelim=''; context.beginPath(); context.moveTo(Math.abs(eval(asscoords[0])),Math.abs(eval(asscoords[1]))); if (topelem) { topcontext.beginPath(); topcontext.moveTo(Math.abs(eval(asscoords[0]) + eval(topvswidthoff)),Math.abs(eval(asscoords[1]) + eval(topvsheightoff))); } for (var iss=2; iss= 0 && ppy >= 0) { lastx=ppx; lasty=ppy; ppx=-1; ppy=-1; } else { 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 (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; context.beginPath(); context.moveTo(x,y); context.lineTo(lastx,lasty); context.stroke(); if (topelem) { topcontext.beginPath(); topcontext.moveTo((eval(x) + eval(topvswidthoff)),(eval(y) + eval(topvsheightoff))); topcontext.lineTo((eval(lastx) + eval(topvswidthoff)),(eval(lasty) + eval(topvsheightoff))); topcontext.stroke(); toplthere=true; } if (sscoords == '') sscoordsdelim=''; if (('*' + sscoords + '*').indexOf(lastx + ',' + lasty + '*') == -1) { if (sscoords.indexOf(',') != -1) savenow=sscoords.length; sscoords+=sscordsdelim + '-' + lastx; sscordsdelim=','; sscoords+=sscordsdelim + lasty; if (savenow != 0) { lastsavenow=savenow; savenow=sscoords.length; } } if (('*' + sscoords + '*').indexOf(x + ',' + y + '*') == -1) { if (sscoords.indexOf(',') != -1) savenow=sscoords.length; sscoords+=sscordsdelim + x; sscordsdelim=','; sscoords+=sscordsdelim + y; if (savenow != 0) { lastsavenow=savenow; savenow=sscoords.length; } } wassscoords=''; if (document.getElementById('showit')) { document.getElementById('showit').style.display='inline'; if (1 == 2 && document.getElementById('animage')) { document.getElementById('animage').src = elem.toDataURL("image/png"); } } //document.title+=pmore + ' here'; } } }); } if (topielem && !toplthere) { // no signature, so allow for one to be created //alert('visible') showornot; } else if (topielem) { // a signature, so hide iframe //alert('invisible'); showornot(); } } function showornot() { if (topielem && !toplthere) { // no signature, so allow for one to be created //alert('visible'); topielem.style.display='block'; topielem.style.zIndex='9'; topielem.style.position='absolute'; topielem.style.left=eval(topvswidthoff) + 'px'; topielem.style.top=eval(topvsheightoff) + 'px'; topielem.style.width=eval(topvswidth) + 'px'; topielem.style.height=eval(topvsheight) + 'px'; if (parent.document.getElementById('toptd')) { if (parent.document.getElementById('toptd').innerHTML.indexOf('button') == -1) { parent.document.getElementById('toptd').innerHTML+="
"; } else { parent.document.getElementById('dmycbox').innerHTML=""; } } } else if (topielem) { // a signature, so hide iframe //alert('invisible'); topielem.style.display='none'; topielem.style.zIndex='9'; topielem.style.position='absolute'; topielem.style.left=eval(topvswidthoff) + 'px'; topielem.style.top=eval(topvsheightoff) + 'px'; topielem.style.width=eval(topvswidth) + 'px'; topielem.style.height=eval(topvsheight) + 'px'; if (parent.document.getElementById('toptd')) { if (parent.document.getElementById('toptd').innerHTML.indexOf('button') == -1) { parent.document.getElementById('toptd').innerHTML+="
"; } else { parent.document.getElementById('dmycbox').innerHTML=""; } } } } setTimeout(canvas_events, 2000);