var popped = 0 let mytimer; function CXMLReq(type, xmlhttp) { this.type = type; this.xmlhttp = xmlhttp; } function giv(id) { return doec(document.getElementById(id).value); } function givcheck(id) { var checkBox = document.getElementById(id); if (checkBox.checked == true){ return '1'; } else { return '0'; } } function givcheckdoclist(id,docidsel) { var checkBox = document.getElementById(id); if (checkBox.checked == true){ document.getElementById(docidsel).style.display = "none"; return '0'; } else { document.getElementById(docidsel).style.display = "inline"; return ''; } } function givmulti(id) { var selected = []; for (var option of document.getElementById(id).options) { if (option.selected) { selected.push(option.value); } } return selected; } function filxmltohtml(code) { var my_array = code.split(""); var to_arr= my_array.length-1; // alert(xmlreqs[j].xmlhttp.responseText); //off document.getElementById('loadingdiv').className = 'loadingdiv'; for (var i = 0; i < to_arr; ++i) { var layer = my_array[i].substr(my_array[i].search('="')+2,my_array[i].search('">')-my_array[i].search('="')-2); //Body if (layer != '') { if (layer == 'javascript') { //alert(my_array[i].substr(my_array[i].search('>')+1,my_array[i].length-my_array[i].search('>')-1)); eval(my_array[i].substr(my_array[i].search('>')+1,my_array[i].length-my_array[i].search('>')-1)); } else { if (document.getElementById(layer)) { document.getElementById(layer).innerHTML=my_array[i].substr(my_array[i].search('>')+1,my_array[i].length-my_array[i].search('>')-1); } } } } } function tiprocessstats() { //if (typeof(window['xmlreqs']) == "undefined") return; var xmldoc = null; //for (var j=0; j < xmlreqs.length; j++) { if ( this.readyState != 4 ) { return ; } filxmltohtml(this.responseText); //xmlreqs.splice(j,1); j--; //} } function tisendRequest(reqtype,baseurl,url) { var xmlDoc=null; // console.log('tisendRequest', reqtype, baseurl, url); if(typeof XMLHttpRequest != "undefined"){ xmlDoc = new XMLHttpRequest(); } else if(typeof window.ActiveXObject != "undefined"){ try { xmlDoc = new ActiveXObject("Msxml2.XMLHTTP.4.0"); } catch(e){ try { xmlDoc = new ActiveXObject("MSXML2.XMLHTTP"); } catch(e){ try { xmlDoc = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ xmlDoc = null; } } } } if (xmlDoc) { xmlDoc.onreadystatechange = function () { if (xmlDoc.readyState == 4) { filxmltohtml(xmlDoc.responseText); } }; xmlDoc.open( reqtype, baseurl); xmlDoc.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); if (reqtype=='POST') xmlDoc.send( "act="+url ); else xmlDoc.send(null); } } function showpw(id) { document.getElementById(id).type='text'; window.setTimeout("document.getElementById('"+id+"').type='password';", 2500); } function ShowPopup(msg) { document.getElementById('infobox').style.display = 'Inline'; document.getElementById("infobox").innerHTML=msg; window.setTimeout("document.getElementById('infobox').style.display = 'None';", 2000); } function ShowPopupW(msg) { document.getElementById('infobox').style.display = 'Inline'; document.getElementById("infobox").innerHTML=msg; } function MouseMove (Ereignis) { if (!Ereignis) Ereignis = window.event; if (document.getElementById) { window.setTimeout("document.getElementById('imagepopup').style.top = '"+(Ereignis.clientY+10)+"px';", 200); window.setTimeout("document.getElementById('imagepopup').style.left = '"+(Ereignis.clientX+10) +"px';", 200); } else if (document.all) { window.setTimeout("document.getElementById('imagepopup').style.top = "+(Ereignis.clientY+10)+";", 200); window.setTimeout("document.getElementById('imagepopup').style.left = "+(Ereignis.clientX+10)+";", 200); } } function MouseDown (Ereignis) { if (!Ereignis) Ereignis = window.event; if (document.getElementById) { window.setTimeout("document.getElementById('hoverpopup').style.top = '"+Ereignis.clientY+"px';", 200); window.setTimeout("document.getElementById('hoverpopup').style.left = '"+Ereignis.clientX +"px';", 200); } else if (document.all) { window.setTimeout("document.getElementById('hoverpopup').style.top = "+Ereignis.clientY+";", 200); window.setTimeout("document.getElementById('hoverpopup').style.left = "+Ereignis.clientX+";", 200); } } /* document.onmousedown = MouseDown; //document.onmousemove = MouseMove; try {//FF, webkit, opera, IE>8 document.addEventListener('mousemove',MouseMove,false); } catch (e) {//IE >6 (7?) document.attachEvent('onmousemove',MouseMove); } finally {//browsers that must die try { document.onmousemove = MouseMove; } catch(die) { //alert('Use a decent browser.'); //location.href = 'http://www.mozilla.org/en-US/firefox/new/'; } } */ function findPosX(obj) { var curleft = 0; if(obj.offsetParent) while(1) { curleft += obj.offsetLeft; if(!obj.offsetParent) break; obj = obj.offsetParent; } else if(obj.x) curleft += obj.x; return curleft; } function findPosY(obj) { var curtop = 0; if(obj.offsetParent) while(1) { curtop += obj.offsetTop; if(!obj.offsetParent) break; obj = obj.offsetParent; } else if(obj.y) curtop += obj.y; return curtop; } function tdAction(act){ console.log('TD: '+act); var jetzt = new Date(); clearTimeout(mytimer); mytimer = setTimeout ( function () { triggerAction(act); }, 800 ); } function triggerAction(act){ console.log('TA: '+act); var jetzt = new Date(); if (triggerAction.arguments.length>1) { if (triggerAction.arguments.length==1) { //document.getElementById('loadingdiv').className = 'loadingdivactive'; //document.getElementById('loadingdiv').style.left = (findPosX(document.getElementById(triggerAction.arguments[1]))+5) + "px"; //document.getElementById('loadingdiv').style.top = (findPosY(document.getElementById(triggerAction.arguments[1]))+5) + "px"; //off document.getElementById(triggerAction.arguments[1]).innerHTML=document.getElementById('loadingdiv').innerHTML+document.getElementById(triggerAction.arguments[1]).innerHTML; } else { //document.getElementById(triggerAction.arguments[1]).innerHTML=document.getElementById('loadingdiv').innerHTML; } } tisendRequest("POST","/appdata/ajax.php",act+'&dum='+jetzt.getTime()+'¤turl='+encodeURIComponent(document.location)); // if (jQuery.inArray(act.split('&')[0], hideSlider) != -1){ // removeSlider(); // scrollToTop(); // } } function onEnterKey() { if(event.keyCode == 13) { return true; } } function doec(string) { return encodeURIComponent(string); } function stopError() { return true; } var smartsign = (function () { var empty = true; return { //public functions capture: function (){ var parent = document.getElementById("canvas"); parent.childNodes[0].nodeValue = ""; var canvasArea = document.createElement("canvas"); canvasArea.setAttribute("id", "newSignature"); parent.appendChild(canvasArea); var canvas = document.getElementById("newSignature"); var context = canvas.getContext("2d"); if (!context) { throw new Error("Failed to get canvas' 2d context"); } screenwidth = screen.width; if (screenwidth < 480) { canvas.width = screenwidth - 8; canvas.height = (screenwidth * 0.63); } else { canvas.width = 464; canvas.height = 150; } context.fillStyle = "#fff"; context.strokeStyle = "#444"; context.lineWidth = 1.2; context.lineCap = "round"; // context.fillRect(0, 0, canvas.width, canvas.height); context.fillStyle = "#3a87ad"; context.strokeStyle = "#3a87ad"; context.lineWidth = 1; context.moveTo((canvas.width * 0.042), (canvas.height * 0.7)); //context.lineTo((canvas.width * 0.958), (canvas.height * 0.7)); context.stroke(); context.fillStyle = "#fff"; context.strokeStyle = "#444"; var disableSave = true; var pixels = []; var cpixels = []; var xyLast = {}; var xyAddLast = {}; var calculate = false; //functions { function remove_event_listeners() { canvas.removeEventListener('mousemove', on_mousemove, false); canvas.removeEventListener('mouseup', on_mouseup, false); canvas.removeEventListener('touchmove', on_mousemove, false); canvas.removeEventListener('touchend', on_mouseup, false); document.body.removeEventListener('mouseup', on_mouseup, false); document.body.removeEventListener('touchend', on_mouseup, false); } function get_board_coords(e) { var x, y; if (e.changedTouches && e.changedTouches[0]) { var offsety = canvas.offsetTop || 0; var offsetx = canvas.offsetLeft || 0; x = e.changedTouches[0].pageX - offsetx; y = e.changedTouches[0].pageY - offsety; } else if (e.layerX || 0 == e.layerX) { x = e.layerX; y = e.layerY; } else if (e.offsetX || 0 == e.offsetX) { x = e.offsetX; y = e.offsetY; } return { x : x, y : y }; }; function on_mousedown(e) { e.preventDefault(); e.stopPropagation(); canvas.addEventListener('mousemove', on_mousemove, false); canvas.addEventListener('mouseup', on_mouseup, false); canvas.addEventListener('touchmove', on_mousemove, false); canvas.addEventListener('touchend', on_mouseup, false); document.body.addEventListener('mouseup', on_mouseup, false); document.body.addEventListener('touchend', on_mouseup, false); empty = false; var xy = get_board_coords(e); context.beginPath(); pixels.push('moveStart'); context.moveTo(xy.x, xy.y); pixels.push(xy.x, xy.y); xyLast = xy; }; function on_mousemove(e, finish) { e.preventDefault(); e.stopPropagation(); var xy = get_board_coords(e); var xyAdd = { x : (xyLast.x + xy.x) / 2, y : (xyLast.y + xy.y) / 2 }; if (calculate) { var xLast = (xyAddLast.x + xyLast.x + xyAdd.x) / 3; var yLast = (xyAddLast.y + xyLast.y + xyAdd.y) / 3; pixels.push(xLast, yLast); } else { calculate = true; } context.quadraticCurveTo(xyLast.x, xyLast.y, xyAdd.x, xyAdd.y); pixels.push(xyAdd.x, xyAdd.y); context.stroke(); context.beginPath(); context.moveTo(xyAdd.x, xyAdd.y); xyAddLast = xyAdd; xyLast = xy; }; function on_mouseup(e) { remove_event_listeners(); disableSave = false; context.stroke(); pixels.push('e'); calculate = false; }; } canvas.addEventListener('mousedown', on_mousedown, false); canvas.addEventListener('touchstart', on_mousedown, false); } , save : function(typid,field){ var canvas = document.getElementById("newSignature"); // save canvas image as data url (png format by default) var dataURL = canvas.toDataURL("image/png"); triggerAction('savesmart&typid='+typid+'&field='+field+'&value='+doec(dataURL)); } , clear : function(){ var parent = document.getElementById("canvas"); var child = document.getElementById("newSignature"); parent.removeChild(child); empty = true; this.capture(); } , send : function(){ if (empty == false){ var canvas = document.getElementById("newSignature"); var dataURL = canvas.toDataURL("image/png"); document.getElementById("saveSignature").src = dataURL; var sendemail = document.getElementById('sendemail').value; var replyemail = document.getElementById('replyemail').value; var dataform = document.createElement("form"); document.body.appendChild(dataform); dataform.setAttribute("action","sign.php"); dataform.setAttribute("enctype","multipart/form-data"); dataform.setAttribute("method","POST"); dataform.setAttribute("target","_self"); dataform.innerHTML = '' + '' + ''+''; dataform.submit(); } } } })() var smartsign; //window.onerror = stopError;