//for iframe where class = axiframe console.log("axscript v4.11"); //13/01/2025 function get_url_parameters(){ var url = window.location.href; var splitted = url.split("?"); if(splitted.length === 1) { return {}; } var paramList = splitted[1].split("&"); var params = {}; for(var i = 0; i < paramList.length; i++){ var paramTuple = paramList[i].split("="); params[decodeURIComponent(paramTuple[0].replace('ax_',''))] = decodeURIComponent(paramTuple[1]); } return params; } function set_url_parameter(key,value){ var url = window.location.href; var splitted = url.split("?"); var new_url = window.location.href.split("?")[0]; if(splitted.length === 1) { new_url = new_url + "?" + encodeURIComponent(key) + "=" + encodeURIComponent(value); }else{ var paramList = splitted[1].split("&"); new_url += "?"; var key_is_add = false; for(var i = 0; i < paramList.length; i++){ var paramTuple = paramList[i].split("="); if(decodeURIComponent(paramTuple[0]) == key){ new_url += "&" + encodeURIComponent(key) + "=" + encodeURIComponent(value); key_is_add = true; }else if(paramTuple[0]){ new_url += "&" + paramTuple[0] + "=" + paramTuple[1]; } } if(!key_is_add){ new_url += "&" + encodeURIComponent(key) + "=" + encodeURIComponent(value); } } new_url = new_url.replace("?&","?"); window.history.replaceState({}, document.title, new_url); //("statedata", "title", "url") return new_url; } //Pour les bug safari qui n'accete pas les cookies //Pour bug ie avec les cookie if(typeof axiframe_already_exist == 'undefined'){ //si module ax_iframe est chargé plusieur fois var safari_pushNotification = (typeof safari != 'undefined') ? safari.pushNotification : false; if( (/Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor) && (Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0 || (function (p){return p.toString() === "[object SafariRemoteNotification]";})(!window['safari']) || safari_pushNotification) ) || ( navigator.userAgent.match(/(iPod|iPhone|iPad)/) && navigator.userAgent.match(/FBAV/i) ) || (/Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor) && /iPad|iPhone|iPod/.test(navigator.platform) ) || ( /MSIE|Trident\//.test(navigator.userAgent) ) || (/MacIntel/.test(navigator.platform) && navigator.maxTouchPoints > 1) ){ var url_parameters = get_url_parameters(); console.log('Is Safari'); if( window.location.href.indexOf("ax_session") == -1 ){ window.location.href = "https://www.apex-timing.com/gokarts/functions/start_session.php?return=" + encodeURIComponent(window.location.href); }else{ window.history.replaceState({}, "vouchers", window.location.href.replace("?&ax_session", "").replace("&ax_session", "").replace("?ax_session", "") ); //("statedata", "title", "url") } } }else{ if(!window.console.countReset){ //window.console.countReset --> ie only (si la console est pas ouverte) console.info('Warning !! For best performance the ax.iframe.js javascript must not be loaded more than once per page.'); }else{ console.info('%cWarning !! For best performance the ax.iframe.js javascript must not be loaded more than once per page.', 'color: blue; font-size: large'); } } var axiframe_already_exist = true; //si module ax_iframe est chargé plusieur fois var addFunctionOnWindowLoad = function(callback){ if(window.addEventListener){ window.addEventListener('DOMContentLoaded',callback,false); }else if(document.attachEvent){ window.attachEvent('onload',callback); } } function init_ax_iframes(){ //pour les div
var all_divs = document.querySelectorAll('div[src*="www.apex-timing.com/gokarts"],div[src*="www.apex-timing.com/live-timing"],div[data-src*="www.apex-timing.com/gokarts"],div[data-src*="www.apex-timing.com/live-timing"]'); for(var i = 0; i < all_divs.length; i++){ all_divs[i].innerHTML = ''; } var url_parameters = get_url_parameters(); var all_iframes = document.querySelectorAll('iframe[src*="www.apex-timing.com/gokarts"],iframe[src*="www.apex-timing.com/live-timing"],iframe[data-src*="www.apex-timing.com/gokarts"],iframe[data-src*="www.apex-timing.com/live-timing"]'); if(all_iframes.length != 0){ //si ils ont oublier de mettre la classe ax.iframe sur les iframes met la class axiframe à la place sur les iframes contenant www.apex-timing.com/gokarts for(var i = 0; i < all_iframes.length; i++){ if(!all_iframes[i].classList.contains('axiframe')){ all_iframes[i].classList.add("axiframe"); all_iframes[i].classList.add("auto_axiframe"); } } } var all_iframe = document.getElementsByClassName("axiframe"); if(document.getElementsByClassName("auto_axiframe").length != 0){ if(!window.console.countReset){ //window.console.countReset --> ie only (si la console est pas ouverte) console.info('Warning !! For best performance add axiframe class to apex-timing iframes. \nRead integration\'s doc on www.apex-timing.com/gokarts/sample.php'); }else{ console.info('%cWarning !! For best performance add axiframe class to apex-timing iframes. \nRead integration\'s doc on www.apex-timing.com/gokarts/sample.php', 'color: blue; font-size: large'); } } /* if(all_iframe.length == 0){ //si ils ont oublier de mettre la classe ax.iframe sur les iframes met la class axiframe à la place sur les iframes contenant www.apex-timing.com/gokarts all_iframes = document.getElementsByTagName('iframe'); if(all_iframes.length != 0){ for (var i = 0; i < all_iframes.length; i++) { if(all_iframes[i].src.indexOf('www.apex-timing.com/gokarts') != -1){ all_iframes[i].classList.add("axiframe"); all_iframes[i].classList.add("auto_axiframe"); } } all_iframe = document.getElementsByClassName("axiframe"); if(all_iframe.length != 0){ if(!window.console.countReset){ //window.console.countReset --> ie only (si la console est pas ouverte) console.info('Warning !! For best performance add axiframe class to apex-timing iframes. \nRead integration\'s doc on www.apex-timing.com/gokarts/sample.php'); }else{ console.info('%cWarning !! For best performance add axiframe class to apex-timing iframes. \nRead integration\'s doc on www.apex-timing.com/gokarts/sample.php', 'color: blue; font-size: large'); } } } } */ if(all_iframe.length == 0){ if(!window.console.countReset){ //window.console.countReset --> ie only (si la console est pas ouverte) console.info('Warning !! No iframe with axiframe class detected !! \nRead integration\'s doc on www.apex-timing.com/gokarts/sample.php'); }else{ console.warn('%cWarning !! No iframe with axiframe class detected !! \nRead integration\'s doc on www.apex-timing.com/gokarts/sample.php', 'color: red; font-size: large'); } } for (var i = 0; i < all_iframe.length; i++) { all_iframe[i].removeAttribute("height"); //pour les bugs ios 10 qui prend le height en priorité --> ex height="100" } for (var i = 0; i < all_iframe.length; i++) { //supprime le border des iframe par default all_iframe[i].style.border = 'none'; } var all_iframe_src = []; for (var i = 0; i < all_iframe.length; i++) { //stock les src all_iframe_src[i] = all_iframe[i].getAttribute('data-src') || all_iframe[i].src; //.src pour le moment pour les anciennes versions if(!all_iframe[i].getAttribute('data-src') && all_iframe[i].src){ if(!window.console.countReset){ //window.console.countReset --> ie only (si la console est pas ouverte) console.info('Warning !! For best performance use data-src instead of src in iframes axiframe !!'); }else{ console.warn('%cWarning !! For best performance use data-src instead of src in iframes axiframe !!', 'color: red; font-size: normal'); } } if(!all_iframe_src[i]){ if(all_iframe[i].src.indexOf('live-timing') !== -1){ all_iframe_src[i] = all_iframe[i].src; //si c'est le live timing et qu'il en en src prend quand même le src }else{ all_iframe_src[i] = '404.php'; //si il utilise src aulieu de data-src --> n'affiche pas la page et le redirige vers 404 } } } var use_results_page = false; var use_leaderboards_page = false; var use_ticketing_page = false; var use_kiosk_page = false; for (var i = 0; i < all_iframe_src.length; i++) { if(all_iframe_src[i].indexOf("results.php") !== -1) use_results_page = true; if(all_iframe_src[i].indexOf("leaderboards.php") !== -1) use_leaderboards_page = true; if(all_iframe_src[i].indexOf("ticketing.php") || all_iframe_src[i].indexOf("vouchers.php") !== -1) use_ticketing_page = true; if(all_iframe_src[i].indexOf("kiosk.php") !== -1) use_kiosk_page = true; } for (var i = 0; i < all_iframe_src.length; i++) { if(all_iframe_src[i].indexOf("mini_leaderboards.php") == -1 /*&& all_iframe_src[i].indexOf("kiosk.php") == -1*/){ //pas besoin de redirection pour kiosk et mini leaderboard //var center = get_url_parameters(all_iframe[i].src)["center"] if("member" in url_parameters){ all_iframe_src[i] = "https://www.apex-timing.com/gokarts/member.php?"; break; //redirige vers la page du membre }else if("leaderboard" in url_parameters){ all_iframe_src[i] = "https://www.apex-timing.com/gokarts/results.php?"; break; //redirige vers la page du leaderboard }else if("unsubscribe" in url_parameters){ all_iframe_src[i] = "https://www.apex-timing.com/gokarts/mail_unsubscribe.php?"; break; //redirige vers la page de désabonement }else if("bookingPayment" in url_parameters){ all_iframe_src[i] = "https://www.apex-timing.com/gokarts/booking_payment.php?"; break; //redirige vers la page de web_cheking pour l'enregistrement des membres dans les résas de session }else if("invoicePayment" in url_parameters){ all_iframe_src[i] = "https://www.apex-timing.com/gokarts/invoice_payment.php?"; break; //redirige vers la page de web_cheking pour l'enregistrement des membres dans les résas de session }else if("quotePayment" in url_parameters){ all_iframe_src[i] = "https://www.apex-timing.com/gokarts/quote_payment.php?"; break; //redirige vers la page de web_cheking pour l'enregistrement des membres dans les résas de session }else if("booking_cancel" in url_parameters){ all_iframe_src[i] = "https://www.apex-timing.com/gokarts/mail_booking_cancel.php?"; break; //redirige vers la page de d'annulation de réservation }else if("booking" in url_parameters){ all_iframe_src[i] = "https://www.apex-timing.com/gokarts/booking.php?"; break; //redirige vers la page de web_cheking pour l'enregistrement des membres dans les résas de session } } if("waivers" in url_parameters){ if(use_kiosk_page){ if(all_iframe_src[i].indexOf("kiosk.php") !== -1){ all_iframe_src[i] = "https://www.apex-timing.com/gokarts/mail_waivers.php?"; break; //redirige vers la page de la waiver } }else if(use_results_page){ if(all_iframe_src[i].indexOf("results.php") !== -1){ all_iframe_src[i] = "https://www.apex-timing.com/gokarts/mail_waivers.php?"; break; //redirige vers la page de la waiver } } } }; for (var i = 0; i < all_iframe_src.length; i++){ if(all_iframe_src[i].indexOf("?") == -1){ all_iframe_src[i] += "?"; } for(var key in url_parameters){ if(url_parameters[key]){ //si parametre undefined all_iframe_src[i] += "&" + key + "=" + url_parameters[key]; }else{ all_iframe_src[i] += "&" + key; } } var page_language = (document.getElementsByTagName('html')[0].getAttribute('lang') || navigator.language || navigator.browserLanguage || '').split('-')[0] //ajout automatique de la langue //TODO --> tester si le 2ème parametre ex 'en-US' --> si US existe dans la liste des langues disponnible if(page_language && all_iframe_src[i].indexOf("language=") == -1){ all_iframe_src[i] += "&language=" + page_language; } // if(all_iframe_src[i].indexOf("mini_leaderboards.php") == -1 && all_iframe_src[i].indexOf("kiosk.php") == -1){ //ajoute l'url de la page // var page_url = window.location.href.split("?")[0] + "?"; // for(var key in url_parameters){ // if(key != "member" && key != "center"){ // page_url = page_url + "&" + key + "=" + url_parameters[key]; // } // } // all_iframe_src[i] += "&url=" + encodeURIComponent(page_url); // } } for(var i = 0; i < all_iframe_src.length; i++){ //change les src if(all_iframe[i].getAttribute('data-loaded') == 'true'){ //l'ignore si déjà chargé continue; } //all_iframe[i].src = all_iframe_src[i] + "&url=" + encodeURIComponent(window.location.href); var iframe_id = (all_iframe[i].id == "") ? "axiframe_" + i : all_iframe[i].id; if(all_iframe_src[i].indexOf("?") == -1){ all_iframe_src[i] += "?"; } all_iframe_src[i] = all_iframe_src[i] + '&iframe_id=' + iframe_id; if(all_iframe_src[i].indexOf("localhost") == -1 && all_iframe_src[i].indexOf("live-timing") == -1){ all_iframe[i].src = all_iframe_src[i].replace("https", "http").replace("http", "https"); }else{ all_iframe[i].src = all_iframe_src[i]; } if(all_iframe[i].id == ""){ //donne un id à l'iframe si il n'en a pas all_iframe[i].id = iframe_id; } all_iframe[i].setAttribute('data-reload', "false"); all_iframe[i].setAttribute('allow','camera;microphone;web-share'); //pour avoir l'accès a la camera et micro pour les photos //web-share pour les partage (mobile surtout) if(window.addEventListener){ //scroll on the top of iframe quand elle change d'url // qu'elle change de page all_iframe[i].addEventListener('load',on_iframe_reload,false); }else if(document.attachEvent){ all_iframe[i].attachEvent('onload',on_iframe_reload); } all_iframe[i].setAttribute('data-loaded', "true"); } //for (var i = 0; i < all_iframe.length; i++) { //$('.axiframe').iFrameResize({heightCalculationMethod: 'documentElementOffset'}); //auto resize iFrameResize( {heightCalculationMethod: 'documentElementOffset', checkOrigin: false}, ".axiframe" ); //si besoin ajouter checkOrigin: false //} } var on_iframe_reload = function(){ //scroll on the top of iframe quand elle change d'url // qu'elle change de page if(this.getAttribute("data-reload") == "false" ){ //pour le premier chargement ne cible pas l'iframe this.setAttribute('data-reload', "true"); }else{ //if( !window.location.origin ){ // window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: ''); //} //window.location = window.location.origin + window.location.pathname + window.location.search + "#" + this.id document.getElementById( this.id ).scrollIntoView(); var body_top = (document.documentElement.scrollTop != 0) ? document.documentElement.scrollTop : document.body.scrollTop; //for ie window.scrollTo(0, body_top - 150); } } // --> j'ai enlever y.resizedCallback et y.initCallback (je ne m'en sert pas) !function(){"use strict";function a(a,b,c){"addEventListener"in window?a.addEventListener(b,c,!1):"attachEvent"in window&&a.attachEvent("on"+b,c)}function b(){var a,b=["moz","webkit","o","ms"];for(a=0;ab)throw new Error("Value for min"+a+" can not be greater than max"+a);c(" Checking "+e+" is in range "+d+"-"+b),d>f&&(f=d,c(" Set "+e+" to min value")),f>b&&(f=b,c(" Set "+e+" to max value")),z[e]=""+f}function k(){var b=a.origin,d=z.iframe.src.split("/").slice(0,3).join("/");if(y.checkOrigin&&(c(" Checking connection is from: "+d),""+b!="null"&&b!==d))throw new Error("Unexpected message received from: "+b+" for "+z.iframe.id+". Message was: "+a.data+". This error can be disabled by adding the checkOrigin: false option.");return!0}function l(){return s===(""+x).substr(0,t)}function m(){var a=z.type in{"true":1,"false":1};return a&&c(" Ignoring init message from meta parent page"),a}function n(){var a=x.substr(x.indexOf(":")+r+6);c(" MessageCallback passed: {iframe: "+z.iframe.id+", message: "+a+"}"),y.messageCallback({iframe:z.iframe,message:a}),c(" --")}function o(){if(null===z.iframe)throw new Error("iFrame ("+z.id+") does not exist on "+u);return!0}function q(){c(" Reposition requested from iFrame"),v={x:z.width,y:z.height},f()}function w(){switch(z.type){case"close":d(z.iframe)/*,y.resizedCallback(z)*/;break;case"message":n();break;case"scrollTo":q();break;case"reset":g(z);break;case"init":b()/*,y.initCallback(z.iframe)*/;break;default:b()}}var x=a.data,z={};l()&&(c(" Received: "+x),z=e(),j("Height"),j("Width"),!m()&&o()&&k()&&(w(),p=!1))}function e(){null===v&&(v={x:void 0!==window.pageXOffset?window.pageXOffset:document.documentElement.scrollLeft,y:void 0!==window.pageYOffset?window.pageYOffset:document.documentElement.scrollTop},c(" Get position: "+v.x+","+v.y))}function f(){null!==v&&(window.scrollTo(v.x,v.y),c(" Set position: "+v.x+","+v.y),v=null)}function g(a){function b(){h(a),j("reset","reset",a.iframe)}c(" Size reset requested by "+("init"===a.type?"host page":"iFrame")),e(),i(b,a,"init")}function h(a){function b(b){a.iframe.style[b]=a[b]+"px",c(" IFrame ("+a.iframe.id+") "+b+" set to "+a[b]+"px")}y.sizeHeight&&b("height"),y.sizeWidth&&b("width")}function i(a,b,d){d!==b.type&&w?(c(" Requesting animation frame"),w(a)):a()}function j(a,b,d){c("["+a+"] Sending msg to iframe ("+b+")"),d.contentWindow.postMessage(s+b,"*")}function k(){function b(){function a(a){1/0!==y[a]&&0!==y[a]&&(k.style[a]=y[a]+"px",c(" Set "+a+" = "+y[a]+"px"))}a("maxHeight"),a("minHeight"),a("maxWidth"),a("minWidth")}function d(a){return""===a&&(k.id=a="iFrameResizer"+o++,c(" Added missing iframe ID: "+a+" ("+k.src+")")),a}function e(){c(" IFrame scrolling "+(y.scrolling?"enabled":"disabled")+" for "+l),k.style.overflow=!1===y.scrolling?"hidden":"auto",k.scrolling=!1===y.scrolling?"no":"yes"}function f(){("number"==typeof y.bodyMargin||"0"===y.bodyMargin)&&(y.bodyMarginV1=y.bodyMargin,y.bodyMargin=""+y.bodyMargin+"px")}function h(){return l+":"+y.bodyMarginV1+":"+y.sizeWidth+":"+y.log+":"+y.interval+":"+y.enablePublicMethods+":"+y.autoResize+":"+y.bodyMargin+":"+y.heightCalculationMethod+":"+y.bodyBackground+":"+y.bodyPadding+":"+y.tolerance}function i(b){a(k,"load",function(){var a=p;j("iFrame.onload",b,k),!a&&y.heightCalculationMethod in x&&g({iframe:k,height:0,width:0,type:"init"})}),j("init",b,k)}var k=this,l=d(k.id);e(),b(),f(),i(h())}function l(a){if("object"!=typeof a)throw new TypeError("Options is not an object.")}function m(){function a(a){if("IFRAME"!==a.tagName.toUpperCase())throw new TypeError("Expected