function isAndroidMobile() { return navigator.userAgent.match(/Android/i); } function isIphoneMobile() { return navigator.userAgent.match(/iPhone|iPad|iPod/i); } function isOperaMiniMobile() { return navigator.userAgent.match(/Opera Mini/i); } function isWindowsMobile() { return navigator.userAgent.match(/IEMobile/i) || navigator.userAgent.match(/WPDesktop/i); } function isMobilePhone() { return ( (isAndroidMobile()) || (isIphoneMobile()) || (isWindowsMobile()) || (isOperaMiniMobile()) ); } function fallbackCopyTextToClipboard(text) { var textArea = document.createElement("textarea"); textArea.value = text; // Avoid scrolling to bottom textArea.style.top = "0"; textArea.style.left = "0"; textArea.style.position = "fixed"; document.body.appendChild(textArea); textArea.focus(); textArea.select(); try { var successful = document.execCommand('copy'); var msg = successful ? 'successful' : 'unsuccessful'; console.log('Fallback: Copying text command was ' + msg); } catch (err) { console.error('Fallback: Oops, unable to copy', err); } document.body.removeChild(textArea); } function copyTextToClipboard(text) { if (!navigator.clipboard) { fallbackCopyTextToClipboard(text); return; } navigator.clipboard.writeText(text).then(function() { console.log('Async: Copying to clipboard was successful!'); }, function(err) { console.error('Async: Could not copy text: ', err); }); } function copyToExcel(el) { var urlField = el; var range = document.createRange(); range.selectNode(urlField); window.getSelection().addRange(range); document.execCommand('copy'); } function trimDec(textContent) { textContent = textContent.replace(/[^0-9]/gmi, "").replace(/\s+/g, ""); return textContent; } function trimNonAscii(textContent) { textContent = textContent.replace(/[^A-Za-z0-9]+/, "-").replace(/\s+/g, ""); return textContent; } function trimHex(textContent) { textContent = textContent.replace(/[^a-f0-9]/gmi, "").replace(/\s+/g, ""); return textContent; } function fileToDataUri(field) { return new Promise((resolve) => { const reader = new FileReader(); reader.addEventListener("load", () => { resolve(reader.result); }); reader.readAsDataURL(field); }); } function bytesToSize(bytes) { var sizes = ["Bytes", "KB", "MB", "GB", "TB"]; if (bytes === 0) { return "0 Byte"; } const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); return Math.round(bytes / Math.pow(1024, i), 2) + " " + sizes[i]; } function compressImage(imgToCompress, resizingFactor, quality) { // resizing the image // let resizingFactor = 0.8; // let quality = 0.8; const canvas = document.createElement("canvas"); const context = canvas.getContext("2d"); const originalWidth = imgToCompress.width; const originalHeight = imgToCompress.height; const canvasWidth = originalWidth * resizingFactor; const canvasHeight = originalHeight * resizingFactor; canvas.width = canvasWidth; canvas.height = canvasHeight; context.drawImage( imgToCompress, 0, 0, originalWidth * resizingFactor, originalHeight * resizingFactor ); // reducing the quality of the image canvas.toBlob( (blob) => { if (blob) { // showing the compressed image // alert("No "+blob.size); var reader = new FileReader(); reader.readAsDataURL(blob); reader.onloadend = function() { var base64data = reader.result; document.getElementById("pictureData").value=base64data; } // imgToCompress.src = URL.createObjectURL(blob); } }, "image/jpeg", quality ); } function getPrice(o) { o=document.getElementById('catPay'); var pr=o.options[o.selectedIndex].value; var promo=document.getElementById('promo-input').value; var user2=document.getElementById('userNow').value; if (promo==null) promo=''; // alert(pr+' '+promo+' '+user2); $.ajax({ url: '/ajax/', type: "POST", data: { "getPrice":pr,"codePromo":promo,"user2":user2 }, success: function (response) { eval(response); }, failure: function() { } }); } function changeQRC(o) { var pr=o.value; var user2=document.getElementById('userNow').value; $.ajax({ url: '/ajax/', type: "POST", data: { "changeQRC":pr,"user2":user2 }, success: function (response) { eval(response); }, failure: function() { } }); } function keepmeAlive() { setTimeout(function(){ keepmeAlive(); }, 30000); $.ajax({ url: '/ajax/', type: "POST", data: { "justkeepmeAlive":"1" }, success: function (response) { eval(response); }, failure: function() { } }); } function getLastPictureMan() { // changed with new design $.ajax({ url: '/ajax/', type: "POST", data: { "getLastPicture":"1" }, success: function (response) { eval(response); }, failure: function() { } }); } function getLastPictureWoman() { $.ajax({ url: '/ajax/', type: "POST", data: { "getLastPicture":"2" }, success: function (response) { eval(response); }, failure: function() { } }); } function getLastPictureCollectifs() { $.ajax({ url: '/ajax/', type: "POST", data: { "getLastPicture":"3" }, success: function (response) { eval(response); }, failure: function() { } }); } function changeStatut(id,stat) { var n=""; if (stat==1) n="/images/simpleOk.gif"; else n="/images/err.gif"; document.getElementById("stat"+id.toString()).innerHTML="" ; return true; } function sendAjaxData(u,p,cp,cap,opt,dat) { $.ajax({ url: '/ajax/', type: "POST", data: { "u":u,"p":p,"cp":cp,"cap":cap,"opt":opt,"dat":dat }, success: function (response) { // alert(response); eval(response); }, failure: function() { // alert("failure"); return false; } }); } function changeExpiryDate(u,newDate) { // alert(u+" "+newDate); var p=""; var cp=""; var cap=""; return sendAjaxData(u,p,cp,cap,"9",newDate); } function sendForm() { var u=trimDec($("#username-input").val()); // var p=trimHex($("#passwd-input").val()); var p=trimNonAscii($("#passwd-input").val()); var cap=$("#captcha-input").val(); // alert(cap); // cap=trimNonAscii(cap); // alert(cap); // pour message.. var opt=trimDec($("#opt-input").val()); var cp=""; var dat=""; if (opt=="0") { cp=p; return sendAjaxData(u,p,cp,cap,opt,dat); } else if (opt=="1") { cp=trimNonAscii($("#passwd-confirm-input").val()); return sendAjaxData(u,p,cp,cap,opt,dat); } else if (opt=="2") { cp=trimNonAscii($("#passwd-confirm-input").val()); return sendAjaxData(u,p,cp,cap,opt,dat); } else if (opt=="3") { cp=trimNonAscii($("#passwd-confirm-input").val()); return sendAjaxData(u,p,cp,cap,opt,dat); } else if (opt=="4") { cp=trimNonAscii($("#passwd-confirm-input").val()); return sendAjaxData(u,p,cp,cap,opt,dat); } else if (opt=="5") { cp=trimNonAscii($("#passwd-confirm-input").val()); return sendAjaxData(u,p,cp,cap,opt,dat); } else if (opt=="6") { cp=trimNonAscii($("#passwd-confirm-input").val()); return sendAjaxData(u,p,cp,cap,opt,dat); } else if (opt=="7") { // elogin cp=p; return sendAjaxData(u,p,cp,cap,opt,dat); } else if (opt=="8") { // elogin cp=p; return sendAjaxData(u,p,cp,cap,opt,dat); } else if (opt=="9") { // elogin cp=p; return sendAjaxData(u,p,cp,cap,opt,dat); } else if (opt=="12") { cp=trimNonAscii($("#passwd-confirm-input").val()); return sendAjaxData(u,p,cp,cap,opt,dat); } } function findUser() { var username=trimDec($("#username-input").val()); var passwd=trimNonAscii($("#passwd-input").val()); var captcha=trimNonAscii($("#captcha-input").val()); if (username.length < 10) { $("#username-input").focus(); return false; } // > $("#pay-button").html(''); $("#username-input").hide(); sendAjaxData("","","","","10",username); } function changeQrEvent() { var username=trimDec($("#username-input").val()); var passwd=trimNonAscii($("#passwd-input").val()); var captcha=trimNonAscii($("#captcha-input").val()); if (username.length < 10) { $("#username-input").focus(); return false; } // > $("#pay-button").html(''); $("#username-input").hide(); // alert("OK"); // function sendAjaxData(u,p,cp,cap,opt,dat) sendAjaxData("","","",$("#nqr").val(),"10",username); } function addEventUser() { var username=trimDec($("#username-input").val()); var passwd=trimNonAscii($("#passwd-input").val()); var captcha=trimNonAscii($("#captcha-input").val()); if (username.length < 10) { $("#username-input").focus(); return false; } // > $("#pay-button").html(''); $("#username-input").val(''); sendAjaxData("","","","","11",username); } function addEventUserTarget(t) { var t=trimDec(t); if (t.length==0) return; var username=trimDec($("#username-input").val()); var passwd=trimNonAscii($("#passwd-input").val()); var captcha=trimNonAscii($("#captcha-input").val()); if (username.length < 10) { $("#username-input").focus(); return false; } // > $("#pay-button").html(''); $("#username-input").val(''); // u p cp cap sendAjaxData("","",t,"","11",username); } function checkLogin() { if($("#root").is(":visible")) { // alert("OK"); } else { // alert("KO"); return false; } var username=trimDec($("#username-input").val()); var passwd=trimNonAscii($("#passwd-input").val()); var captcha=trimNonAscii($("#captcha-input").val()); // if (username.length!=10) if (username.length < 10) { $("#username-input").focus(); return false; } else if ( passwd.length < 8 ) { // alert("length "+(passwd.length).toString()); $("#passwd-input").focus(); return false; } else if ( captcha.length < 5 ) { $("#captcha-input").focus(); return false; } $("#root").hide(); $("#wait").show(); sendForm(); // $("#root").show(); // Cookie } function loadUrl(url) { $("#root").hide(); $("#wait").show(); document.location.href=url; } function checkCard() { if($("#root").is(":visible")) { // alert("OK"); } else { // alert("KO"); return false; } var username=trimDec($("#username-input").val()); var passwd=trimNonAscii($("#passwd-input").val()); var captcha=trimNonAscii($("#passwd-confirm-input").val()); if (username.length < 16) { $("#username-input").focus(); return false; } else if ( passwd.length != 5 ) { // alert("length "+(passwd.length).toString()); $("#passwd-input").focus(); return false; } else if ( captcha.length < 3 ) { $("#passwd-confirm-input").focus(); return false; } $("#root").hide(); $("#wait").show(); sendForm(); // $("#root").show(); } function checkProfil() { var nom=trimNonAscii($("#passwd-input").val()); var prenom=trimNonAscii($("#captcha-input").val()); var birthday=trimNonAscii($("#birthday").val()); var poid=trimDec($("#poid").val()); var genre=trimDec($("#genre option:selected").val()); // alert('OK'); // var picture= $('#pictureSize').val(); var picture=$('#pictureData').val(); if (picture=="0") { $("#picture").focus().trigger('click'); return false; } if (genre=="0") { $("#genre").focus(); return false; } if (nom.length < 3) { $("#passwd-input").focus(); return false; } else if (prenom.length < 3) { $("#captcha-input").focus(); return false; } else if (birthday.length < 10) { $("#birthday").focus(); return false; } else if (poid.length < 2) { $("#poid").focus(); return false; } $("#myProfil").submit(); } function checkCcp() { if($("#root").is(":visible")) { } else { return false; } var username=trimDec($("#username-input").val()); var passwd=trimNonAscii($("#passwd-input").val()); var captcha=trimNonAscii($("#captcha-input").val()); if (username.length!=20) { $("#username-input").focus(); return false; } else if ( passwd.length < 3 ) { $("#passwd-input").focus(); return false; } else if ( captcha.length < 3 ) { $("#captcha-input").focus(); return false; } $("#root").hide(); $("#wait").show(); sendForm(); // $("#root").show(); } function checkAccess(code) { if($("#root").is(":visible")) { } else { alert("No root is visible"); return false; } $("#root").hide(); $("#wait").show(); sendAjaxData("","","","","7",code); // $("#root").show(); } function validate(evt,inpt) { var theEvent = evt || window.event; // Handle paste if (theEvent.type === 'paste') { key = event.clipboardData.getData('text/plain'); } else { // Handle key press var key0 = theEvent.keyCode || theEvent.which; var key = String.fromCharCode(key0); } if (inpt.id=="passwd-input") { regex = /[A-Za-z0-9]|\.|\-/; if( !regex.test(key) ) { theEvent.returnValue = false; if(theEvent.preventDefault) theEvent.preventDefault(); } } else if (inpt.id=="passwd-confirm-input") { regex = /[A-Za-z0-9]|\./; if( !regex.test(key) ) { theEvent.returnValue = false; if(theEvent.preventDefault) theEvent.preventDefault(); } } else if (inpt.id=="captcha-input") { regex = /[A-Za-z0-9]|\.|\ /; if( !regex.test(key) ) { theEvent.returnValue = false; if(theEvent.preventDefault) theEvent.preventDefault(); } } else { regex = /[0-9]|\./; if( !regex.test(key) ) { theEvent.returnValue = false; if(theEvent.preventDefault) theEvent.preventDefault(); } } /* var regex = /[0-9]|\./; if( !regex.test(key) ) { theEvent.returnValue = false; if(theEvent.preventDefault) theEvent.preventDefault(); } */ // alert((inpt.value.length)); if (((inpt.value.length)==(inpt.maxlength)) && (inpt.id=="username-input")) { $("#passwd-input").focus(); } else if (((inpt.value.length)==(inpt.maxlength)) && (inpt.id=="passwd-input")) { $("#captcha-input").focus(); } else if (((inpt.value.length)==(inpt.maxlength)) && (inpt.id=="captcha-input")) { $("#pay-button").click(); } if ((key0==13) && (inpt.id=="username-input")) $("#passwd-input").focus(); else if ((key0==13) && (inpt.id=="passwd-input")) $("#captcha-input").focus(); else if ((key0==13) && (inpt.id=="captcha-input")) $("#pay-button").click(); } function validateMessage(evt,inpt) { var theEvent = evt || window.event; // Handle paste if (theEvent.type === 'paste') { key = event.clipboardData.getData('text/plain'); } else { // Handle key press var key0 = theEvent.keyCode || theEvent.which; var key = String.fromCharCode(key0); } if (inpt.id=="passwd-input") { regex = /[A-Za-z0-9]|\./; if( !regex.test(key) ) { theEvent.returnValue = false; if(theEvent.preventDefault) theEvent.preventDefault(); } } else if (inpt.id=="passwd-confirm-input") { regex = /[A-Za-z0-9]|\./; if( !regex.test(key) ) { theEvent.returnValue = false; if(theEvent.preventDefault) theEvent.preventDefault(); } } else if (inpt.id=="captcha-input") { regex = /[A-Za-z0-9 ]|\./; if( !regex.test(key) ) { theEvent.returnValue = false; if(theEvent.preventDefault) theEvent.preventDefault(); } } else { regex = /[0-9]|\./; if( !regex.test(key) ) { theEvent.returnValue = false; if(theEvent.preventDefault) theEvent.preventDefault(); } } /* var regex = /[0-9]|\./; if( !regex.test(key) ) { theEvent.returnValue = false; if(theEvent.preventDefault) theEvent.preventDefault(); } */ // alert((inpt.value.length)); if (((inpt.value.length)==(inpt.maxlength)) && (inpt.id=="username-input")) { $("#passwd-input").focus(); } else if (((inpt.value.length)==(inpt.maxlength)) && (inpt.id=="passwd-input")) { $("#captcha-input").focus(); } else if (((inpt.value.length)==(inpt.maxlength)) && (inpt.id=="captcha-input")) { $("#pay-button").click(); } if ((key0==13) && (inpt.id=="username-input")) $("#passwd-input").focus(); else if ((key0==13) && (inpt.id=="passwd-input")) $("#captcha-input").focus(); else if ((key0==13) && (inpt.id=="captcha-input")) $("#pay-button").click(); } function validateCard(evt,inpt) { var theEvent = evt || window.event; // Handle paste if (theEvent.type === 'paste') { key = event.clipboardData.getData('text/plain'); } else { // Handle key press var key0 = theEvent.keyCode || theEvent.which; var key = String.fromCharCode(key0); } if (inpt.id=="passwd-input") { regex = /[A-Za-z0-9]|\./; if( !regex.test(key) ) { theEvent.returnValue = false; if(theEvent.preventDefault) theEvent.preventDefault(); } } else if (inpt.id=="passwd-confirm-input") { regex = /[0-9]|\./; if( !regex.test(key) ) { theEvent.returnValue = false; if(theEvent.preventDefault) theEvent.preventDefault(); } } else if (inpt.id=="captcha-input") { regex = /[A-Za-z0-9]|\./; if( !regex.test(key) ) { theEvent.returnValue = false; if(theEvent.preventDefault) theEvent.preventDefault(); } } else { regex = /[0-9]|\./; if( !regex.test(key) ) { theEvent.returnValue = false; if(theEvent.preventDefault) theEvent.preventDefault(); } } /* var regex = /[0-9]|\./; if( !regex.test(key) ) { theEvent.returnValue = false; if(theEvent.preventDefault) theEvent.preventDefault(); } */ // alert((inpt.value.length)); if (((inpt.value.length)==(inpt.maxlength)) && (inpt.id=="username-input")) { $("#passwd-input").focus(); } else if (((inpt.value.length)==(inpt.maxlength)) && (inpt.id=="passwd-input")) { $("#captcha-input").focus(); } else if (((inpt.value.length)==(inpt.maxlength)) && (inpt.id=="passwd-confirm-input")) { $("#pay-button").click(); } if ((key0==13) && (inpt.id=="username-input")) $("#passwd-input").focus(); else if ((key0==13) && (inpt.id=="passwd-input")) $("#passwd-confirm-input").focus(); else if ((key0==13) && (inpt.id=="passwd-confirm-input")) $("#pay-button").click(); if (((inpt.value.length) > 1) && (inpt.id=="passwd-input")) { inpt.value=trimNonAscii(inpt.value); var month=inpt.value.substring(0,2); var year=inpt.value.substring(3); inpt.value=month+"/"+year; } } function getInfo(id) { $.ajax({ url: '/ajax/', type: "POST", data: { "u":id,"opt":"4" }, success: function (response) { // alert(response); eval(response); }, failure: function() { // alert("failure"); } }); } function setCookie(cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays*24*60*60*1000)); var expires = "expires="+ d.toUTCString(); document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; } function getCookie(cname) { var name = cname + "="; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); for(var i = 0; i