window.clientId = null; window.iframe = null; var launched = false; function createAnIframe(divToLoadIframe){ divToLoadIframe.innerHTML = ''; cont(); log('Iframe launched. Running SeniorMatics...'); } function cont(){ launchSeniorMaticsWebApp(document.getElementById("testDiv")); // Listen for messages from the iframe window.addEventListener("message", function(event) { // if (event.data.webAppLoaded) { // loginToSeniorMatics("ss", "+86111222333", callbackAfterLogin); // } }); } function onLoginPageLoaded(client) { window.clientId = client; window.iframe = window.parent.document.getElementById("seniormaticsapilauncher"); if(window.iframe!=null){ window.parent.clientId = clientId; onWebAppLoaded(); } } function launchSeniorMaticsWebApp(divContainerElement){ if(launched==false){ launched = true; } } function loginToSeniorMatics(username, phoneOrEmail){ window.parent.document.getElementById("seniormaticsapilauncher").contentWindow.postMessage({ username: username, phoneOrEmail: phoneOrEmail }, "*"); } function onWebAppLoaded(){ window.parent.log('Client id: ' + window.parent.clientId + '. Fill Login data'); } function onRegisterApplied(result){ if(result == true){ window.parent.log("Login information sent, result: " + result); window.parent.log("Get passcode using Phone or Email login data, fill it in Passcode field"); } } function callbackAfterLogin(clientId){ console.log(clientId); window.parent.log("Login information sent, result: " + result); } function callBackAfterSuccessfulLogin(pageName){ console.log("pageName " + pageName); window.parent.log("SeniorMatics page loaded, name: " + pageName); if(pageName == "disclaimer"){ window.parent.log("Read and accept disclaimer"); } else{ window.parent.log("Fill home ID to be navigated to home"); } } function callBackAfterHomeId(homeName){ window.parent.log("You are navigated to Home: " + homeName); } function loginWithPasscodeToSeniorMatics(passcode ){ window.parent.document.getElementById("seniormaticsapilauncher").contentWindow.postMessage({passcode: passcode }, "*"); } function navigateToHome(homeId){ window.parent.document.getElementById("seniormaticsapilauncher").contentWindow.postMessage({ navigateHomeId: homeId }, "*"); }