var sendMode='';
var googleSheetsPortalScript='https://script.google.com/macros/s/AKfycbwXymNpBgHpIhV6oxwLQ6lBBRRCXPAL-K9DhWC7XooXcP4ytGWQ2zB84PiMLjGBrZsB/exec';
var popupPanel='';
var firstName='';
var lastName='';
var email='';
var password='';
var conversationId='';
var conversation='';
var months=['January','February','March','April','May','June','July','August','September','October','November','December'];
var role='patient';
var chatNumbers=[];
var array=[];
var chatArray=[];
var patientToMatch='';
var therapistToMatch='';
var profilePicture='';
var description='';
var myProfilePic='';
var myName='';
var myProfileDescription='';
var partnerProfilePic='';
var partnerName='';
var partnerProfileDescription='';
var conversationDataAsString='';
var profilesArray=[];
var resourcesArray=[];
var meetingTimesArray=[];
var conversationData=[];
var currentProfile='';
var currentResources='';
var currentMeetingTimes='';
var waitForConversationToUpdate=false;
var profileArrayData='';
var autoCheckRunning=false;
function setMode(modeToSend){
role=modeToSend;
}
function getLive(array){
return "<div id='meetingTimeToDisplay'></div>";
}
function showMeetingTimes(array){
var liveUi='';
var meetingIcon="<i class=\'fa fa-video-camera\'></i>";
var addMeeting= "<div style='margin-top:10px;margin-bottom:10px; width:100%;font: 18px Calibri;padding:5px 5px;text-align:center;background-color:lightgray;cursor:pointer;' onclick='javascript:toggle('editMeetingTimes')'><i class='fas fa-edit' ></i> Edit</div><div id='editMeetingTimes' style='padding:15px 12px;font:20px Calibri;height:200px;border:1px solid lightgray;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;display:none;' onclick='javascript:removeMeetingTimesWarning()'><input id='zoomLink' placeholder='✆ Enter zoom link' style='width:100%;margin-bottom:20px;margin-right:5px;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;padding:10px 10px;border:none;box-shadow: 0px 1px 1px 0px rgba(0,0,0,0.2);' ></input><div>"+"<div style='width:520px;height:50px;margin-bottom:20px;position:relative;left:50%;transform:translate(-50%,0%);'>"+getDay()+getDuration()+getHour()+getMinutes()+getAMPM()+"</div><div style='width:100%;text-align:center;-moz-border-radius:50px;-webkit-border-radius:50px;border-radius:50px;padding:5px 5px;float:left;cursor:pointer;' class='onHover' onclick='javascript:setTimeout(function(){saveMeetingTimes();},100)' id='addNewSessionButton'>⊕ Add new session</div></div></div>";
if(role=='patient'){
for(var i=0;i<array.length&&array[i]!='';i=i+2){
liveUi=liveUi+"<div class='onHover' style='font:20px Calibri;padding:15px 12px;'><div onclick='javascript:{window.open('"+array[i]+"','_blank');}' style='cursor:pointer;' class='onHover'>"+meetingIcon+" "+array[i+1]+"</div></div>";
}
document.getElementById('meetingTimeToDisplay').innerHTML="<h3 style='background-color:#00C0FF;color:white;margin-left:10px;padding:5px 5px;cursor:pointer;' onclick=javascript:toggle(\'live\')>Video conference</h3><div id='live' style='display:none;padding:15px 12px;font:20px Calibri;' >"+liveUi+"</div></div>";
}
if(role=='therapist'){
for(var i=0;i<array.length&&array[i]!='';i=i+2){
liveUi=liveUi+"<div class='onHover' style='font:20px Calibri;padding:15px 12px;'><div onclick='javascript:{window.open('"+array[i]+"','_blank');}' class='onHover' style='cursor:pointer;display:inline-block;'>"+meetingIcon+" "+array[i+1]+"</div><span style='float:right'><div onclick='javascript:removeMeeting('"+array[i]+"','"+array[i+1]+"')' style='display:inline-block;color:lightgray;cursor:pointer;' >remove</div></span></div>";
}
document.getElementById('meetingTimeToDisplay').innerHTML="<h3 style='background-color:#00C0FF;color:white;margin-left:10px;padding:5px 5px;cursor:pointer;' onclick=javascript:toggle(\'live\')>Video conference</h3><div id='live' style='display:none;padding:15px 12px;font:20px Calibri;' >"+liveUi+addMeeting+"</div></div>"
}
}
function removeMeeting(url,meetingTime){
sendDataToGoogleSheets(['removeMeeting',firstName,lastName,url,meetingTime,conversationId],googleSheetsPortalScript);
setUpdating();
}
function getWorksheets(array){
var resourcesUi='';
return "<div id='resourcesToDisplay'></div>";
}
function showResources(array){
var resourcesToShow='';
var resourceIcon='';
var addWorksheet="<div style='margin-top:10px;margin-bottom:10px; width:100%;font: 18px Calibri;padding:5px 5px;text-align:center;background-color:lightgray;cursor:pointer;' onclick='javascript:toggle('editResources')'><i class='fas fa-edit' ></i> Edit</div><div id='editResources' style='font:20px Calibri;padding:15px 12px;height:320px;border:1px solid lightgray;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;display:none;' onclick='javascript:removeResourcesWarning()'><div style='margin-bottom:40px;position:relative;left=0px;'><select id='resourceType' onchange='javascript:setResourceType(this.value)'><option onclick='javascript:setEnabled('resourceUploader',false),setEnabled('websiteUrl',false),setEnabled('resourceTitle',false);' value='fileType'>File Type</option><option value='document' onClick='javascript:setEnabled('resourceUploader',true),setEnabled('websiteUrl',false),setEnabled('resourceTitle',true);'>Document</option><option value='video' onclick='javascript:setEnabled('resourceUploader',true),setEnabled('websiteUrl',false),setEnabled('resourceTitle',true);'>Video</option><option value='url' onclick='javascript:setEnabled('websiteUrl',true);setEnabled('resourceUploader',false),setEnabled('resourceTitle',true);' id='URL'>URL</option></select></div><div style='height:80px'><input id='resourceUploader' type='file' style='float:left;margin-right:5px;margin-bottom:20px;' disabled=true></input><input id='websiteUrl' placeholder='Website URL' style='width:100%; margin-bottom:40px; float:left;margin-right:5px;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;padding:10px 10px;border:none;box-shadow: 0px 1px 1px 0px rgba(0,0,0,0.2);' disabled=true></input></div><div style='height:80px'><input placeholder='Title of file' id='resourceTitle' disabled=false style='width:100%;float:left;margin-bottom:10px;margin-right:5px;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;padding:10px 10px;border:none;box-shadow: 0px 1px 1px 0px rgba(0,0,0,0.2);'></input><div style='width:100%;text-align:center;-moz-border-radius:50px;-webkit-border-radius:50px;border-radius:50px;padding:5px 5px;float:left;cursor:pointer;' class='onHover' id='addNewResourceButton' onclick='javascript:setTimeout(function(){saveResource();},100)' >⊕ Add new resource</div></div></div>";
if(role=='patient'){
for(var i=0;i<array.length;i=i+3){
if(array[i]=='document'){
resourceIcon="<i class=\'fa fa-book\'></i>";}
if(array[i]=='video'){
resourceIcon="<i class='fa fa-film'></i>";}
if(array[i]=='url'){
resourceIcon="<i class='far fa-window-restore'></i>";}
if(resourceIcon!=''){
resourcesToShow=resourcesToShow+"<div class='onHover' style='font:20px Calibri;padding:15px 12px;'><div onclick='javascript:{window.open('"+array[i+2]+"','_blank');}' style='cursor:pointer;' class='onHover'>"+resourceIcon+" "+array[i+1]+"</div></div>";}
}
document.getElementById('resourcesToDisplay').innerHTML="<h3 style='background-color:#00C0FF;color:white;margin-left:10px;padding:5px 5px;cursor:pointer;' onclick=javascript:toggle(\'resources\')>Resources</h3><div id='resources' style='display:none;margin-left:10px;margin-bottom:10px;' >"+resourcesToShow+"</div>";
}
if(role=='therapist'){
for(var i=0;i<array.length;i=i+3){
if(array[i]=='document'){
resourceIcon="<i class=\'fa fa-book\'></i>";}
if(array[i]=='video'){
resourceIcon="<i class='fa fa-film'></i>";}
if(array[i]=='url'){
resourceIcon="<i class='far fa-window-restore'></i>";}
if(resourceIcon!=''){
resourcesToShow=resourcesToShow+"<div class='onHover' style='font:20px Calibri;padding:15px 12px;'><div onclick='javascript:{window.open('"+array[i+2]+"','_blank');}' style='cursor:pointer;display:inline-block;' class='onHover'>"+resourceIcon+" "+"<xmp style='font:20px Calibri;display:inline-block;margin:0px;'>"+array[i+1]+"</xmp>"+"</div><span style='float:right'><div onclick='javascript:removeResource('"+array[i+1]+"','"+array[i+2]+"')' style='cursor:pointer;display:inline-block;color:lightgray;' >remove</div></span></div>";}
}
document.getElementById('resourcesToDisplay').innerHTML="<h3 style='background-color:#00C0FF;color:white;margin-left:10px;padding:5px 5px;cursor:pointer;' onclick=javascript:toggle(\'resources\')>Resources</h3><div id='resources' style='display:none;margin-left:10px;margin-bottom:10px;' >"+resourcesToShow+addWorksheet+"</div>";
}
}
function setResourceType(resourceType){
if(resourceType=='fileType'){
setEnabled('resourceUploader',false);
setEnabled('websiteUrl',false);
setEnabled('resourceTitle',false);}
if(resourceType=='document'){
setEnabled('resourceUploader',true);
setEnabled('websiteUrl',false);
setEnabled('resourceTitle',true);}
if(resourceType=='video'){
setEnabled('resourceUploader',true);
setEnabled('websiteUrl',false);
setEnabled('resourceTitle',true);}
if(resourceType=='url'){
setEnabled('resourceUploader',false);
setEnabled('websiteUrl',true);
setEnabled('resourceTitle',true);}
}
function removeResource(title,url){
sendDataToGoogleSheets(['removeResource',firstName,lastName,title,url,conversationId],googleSheetsPortalScript);
setUpdating();
}
function getContacts(){
return "<h3 style='background-color:#00C0FF;color:white;margin-left:10px;padding:5px 5px;cursor:pointer;' onclick=javascript:toggle(\'contacts\')>My contacts</h3><div id='contacts' style='display:none;margin-left:10px;margin-bottom:10px;' >"+getSearchBarUi(true)+"</div>";
}
function getPatients(){
return "<h3 style='background-color:#00C0FF;color:white;margin-left:10px;padding:5px 5px;'>Patients</h3><div id='patients' style='display:block;margin-left:10px;margin-bottom:10px;' ><div id='patientsBody' ></div></div>";
}
function getMyProfile(){
return "<h3 style='background-color:#00C0FF;color:white;margin-left:10px;padding:5px 5px;cursor:pointer;' onclick=javascript:toggle(\'myProfile\')>My profile</h3><div id='myProfile' style='display:none;margin-left:10px;margin-bottom:10px;' ><div style='background-color:lightgray;height:20vh;width:100%;'><div style='background-color:white;width:16vh;height:16vh;position:relative;top:2vh;left:50%;transform:translate(-50%,0%);-moz-border-radius:8vh;-webkit-border-radius:8vh;border-radius:8vh;overflow:hidden;'><div id='myProfilePic' style='position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font: 8vh Arial;'></div></div></div><h3 style='text-align:center;color:tomato;'><div id='myProfileName'></div></h3><div id='myProfileDescription' style='padding:20px 20px;width:28vw;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;position:relative;left:50%;transform:translate(-50%,0%);border:1px solid lightgray;'></div><div onclick='javascript:toggle('editProfile')' style='cursor:pointer'><div style='margin-top:10px;margin-bottom:10px; width:100%;font: 18px Calibri;padding:5px 5px;text-align:center;background-color:lightgray;'><i class='fas fa-edit' ></i> Edit</div></div><div id='editProfile' style='display:none;'><div style='width:28vw;padding:10px 10px;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;border:1px solid lightgray;font: 18px Calibri'>Upload picture<input type='file' id='profilePictureUploader' style='margin-bottom:20px;margin-top:20px;'></input></div><div><textarea id='myProfileDescriptionToSave' placeholder='Write something about yourself.' style='margin-top:20px;width:28vw;box-shadow: 0px 1px 1px 0px rgba(0, 0, 0, 0.2);background-color:white;z-index:2;padding:10px 10px;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;border:none;margin-bottom:20px' ></textarea><div onclick='javascript:saveMyProfile()' style='cursor:pointer;' ><div style='margin-bottom:20px; width:100%;font: 18px Calibri;padding:5px 5px;text-align:center;background-color:lightgray' ><i class='fas fa-save' ></i> Save</div></div></div></div></div>";
}
function saveMyProfile(){
var profilePictureToSave=document.getElementById('profilePictureUploader').files[0];
var profilePictureDimensions='';
var myProfileDescriptionToSave=getFieldText('myProfileDescriptionToSave');
var fileReader=new FileReader();
var rawFile='';
fileReader.onload=function(){
rawFile=fileReader.result;
var myProfilePictureData=rawFile.substring(rawFile.indexOf('base64,')+7,rawFile.length);
sendDataToGoogleSheets(['saveMyProfile',role,myProfilePictureData,profilePictureToSave.type,profilePictureDimensions,firstName,lastName,myProfileDescriptionToSave,conversationId],googleSheetsPortalScript);
setUpdating();
}
if(profilePictureToSave==undefined){
sendDataToGoogleSheets(['saveMyProfile',role,'','',profilePictureDimensions,firstName,lastName,myProfileDescriptionToSave,conversationId],googleSheetsPortalScript);
setUpdating();
}else{
fileReader.readAsDataURL(profilePictureToSave);}
}
function saveResource(){
var resourceToSave=document.getElementById('resourceUploader').files[0];
var websiteUrlToSave=getFieldText('websiteUrl');
var resourceTitleToSave=getFieldText('resourceTitle');
var resourceIndexToSave=0;
var fileReader=new FileReader();
var rawFile='';
var resourceType=document.getElementById('resourceType').value;
var allFieldsCompleted=true;
if(resourceType=='fileType'){
allFieldsCompleted=false;
document.getElementById('addNewResourceButton').innerHTML="<i class='fas fa-exclamation-triangle' style='color:orange'></i> File type not selected";
}
if((resourceType=='document'||resourceType=='video')&&(resourceTitleToSave==''||typeof resourceToSave=='undefined')){
allFieldsCompleted=false;
if(resourceTitleToSave==''){
document.getElementById('addNewResourceButton').innerHTML="<i class='fas fa-exclamation-triangle' style='color:orange'></i> Resource title missing";}
if(typeof resourceToSave=='undefined'){
document.getElementById('addNewResourceButton').innerHTML="<i class='fas fa-exclamation-triangle' style='color:orange'></i> No file selected";}
}
if(resourceType=='url'&&(resourceTitleToSave==''||websiteUrlToSave=='')){
allFieldsCompleted=false;
if(resourceTitleToSave==''){
document.getElementById('addNewResourceButton').innerHTML="<i class='fas fa-exclamation-triangle' style='color:orange'></i> Resource title missing";}
if(websiteUrlToSave==''){
document.getElementById('addNewResourceButton').innerHTML="<i class='fas fa-exclamation-triangle' style='color:orange'></i> Website URL missing";}
}
if(allFieldsCompleted){
fileReader.onload=function(){
rawFile=fileReader.result;
var resourceData=rawFile.substring(rawFile.indexOf('base64,')+7,rawFile.length);
sendDataToGoogleSheets(['saveResource',role,resourceType,resourceData,resourceToSave.type,websiteUrlToSave,resourceTitleToSave,firstName,lastName,conversationId],googleSheetsPortalScript);
}
if(websiteUrlToSave!=''){
sendDataToGoogleSheets(['saveResource',role,resourceType,'','',websiteUrlToSave,resourceTitleToSave,firstName,lastName,conversationId],googleSheetsPortalScript);
}else{
fileReader.readAsDataURL(resourceToSave);}
setUpdating();
}
}
function removeResourcesWarning(){
document.getElementById('addNewResourceButton').innerHTML="⊕ Add new resource";
}
function saveMeetingTimes(){
var zoomLink=document.getElementById('zoomLink').value;
var meetingTime=document.getElementById('getDay').value+' '+document.getElementById('getHour').value+':'+document.getElementById('getMinute').value+' '+document.getElementById('getAMPM').value+' ('+document.getElementById('getDuration').value+')';
var allFieldsCompleted=true;
if(document.getElementById('getAMPM').value=='AM/PM'){
allFieldsCompleted=false;
document.getElementById('addNewSessionButton').innerHTML="<i class='fas fa-exclamation-triangle' style='color:orange'></i> AM/PM not selected";
}
if(document.getElementById('getMinute').value=='Minute'){
allFieldsCompleted=false;
document.getElementById('addNewSessionButton').innerHTML="<i class='fas fa-exclamation-triangle' style='color:orange'></i> Minute not selected";
}
if(document.getElementById('getHour').value=='Hour'){
allFieldsCompleted=false;
document.getElementById('addNewSessionButton').innerHTML="<i class='fas fa-exclamation-triangle' style='color:orange'></i> Hour not selected";
}
if(document.getElementById('getDuration').value=='Duration'){
allFieldsCompleted=false;
document.getElementById('addNewSessionButton').innerHTML="<i class='fas fa-exclamation-triangle' style='color:orange'></i> Duration not selected";
}
if(document.getElementById('getDay').value=='Day'){
allFieldsCompleted=false;
document.getElementById('addNewSessionButton').innerHTML="<i class='fas fa-exclamation-triangle' style='color:orange'></i> Day not selected";
}
if(document.getElementById('zoomLink').value==''){
allFieldsCompleted=false;
document.getElementById('addNewSessionButton').innerHTML="<i class='fas fa-exclamation-triangle' style='color:orange'></i> Link missing";
}
if(allFieldsCompleted){
sendDataToGoogleSheets(['saveMeeting',zoomLink,meetingTime,firstName,lastName,conversationId],googleSheetsPortalScript);
setUpdating();}
}
function removeMeetingTimesWarning(){
document.getElementById('addNewSessionButton').innerHTML="⊕ Add new session";
}
function getPatientsProfile(){
return "<h3 style='background-color:#00C0FF;color:white;margin-left:10px;padding:5px 5px;cursor:pointer;' onclick=javascript:toggle(\'patientsProfile\')>Patient's profile</h3><div id='patientsProfile' style='display:none;margin-left:10px;margin-bottom:10px;' ><div id='patientsProfileDescription' style='padding:20px 20px;width:28vw;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;position:relative;left:50%;transform:translate(-50%,0%);border:1px solid lightgray;'></div></div>";
}
function getPartnerProfile(){
return "<h3 style='background-color:#00C0FF;color:white;margin-left:10px;padding:5px 5px;cursor:pointer;' onclick=javascript:toggle(\'partnerProfile\')>Partner profile</h3><div id='partnerProfile' style='display:none;margin-left:10px;margin-bottom:10px;' ><div style='background-color:lightgray;height:20vh;width:100%;'><div style='background-color:white;width:16vh;height:16vh;position:relative;top:2vh;left:50%;transform:translate(-50%,0%);-moz-border-radius:8vh;-webkit-border-radius:8vh;border-radius:8vh;overflow:hidden;'><div id='partnerProfilePic' style='position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font: 8vh Arial;'></div></div></div><h3 style='text-align:center;color:tomato;'><div id='partnerProfileName'></div></h3><div id='partnerProfileDescription' style='padding:20px 20px;width:28vw;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;position:relative;left:50%;transform:translate(-50%,0%);border:1px solid lightgray;'></div></div>";
}
function getTherapists(){
var therapistList="<h3 style='background-color:#00C0FF;color:white;margin-left:10px;padding:5px 5px;' >Provider</h3><div class='autoScroll' id='therapists' style='display:block;margin-left:10px;margin-bottom:10px;height:90vh;' ><div onclick='javascript:toggle('patientProfilePrompt')' style='cursor:pointer'><div style='width:30vw;position:fixed;left:60vw;transform:translate(-50%,0%);box-shadow: 0px 4px 4px 4px rgba(0, 0, 0, 0.2);background-color:white;z-index:2;padding:10px 20px;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;float:left;font: 20px Arial;display: grid;grid-template-columns: 10% 90%;' ><div>⛶</div><div><div style='text-align:center' id='patientTherapistMatchingPrompt'>Select a patient</div></div></div></div><textarea style='width:30vw;height:300px;position:fixed;left:60vw;top:130px;transform:translate(-50%,0%);box-shadow: 0px 4px 4px 4px rgba(0, 0, 0, 0.2);background-color:white;z-index:2;padding:10px 10px;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;border:none;display:none;' id='patientProfilePrompt' readonly></textarea><div id='therapistsBody' ></div></div>";
return therapistList;
}
function getChat(array){
var chat='';
chat="<h3 style='background-color:#00C0FF;color:white;margin-left:10px;padding:5px 5px;'>Chat</h3>";
chat=chat+"<div style='height:90vh;margin-left:10px;display: grid;grid-template-rows: auto 160px;' >";///
chat=chat+"<div style='width:100%;height:100%;display:flex;flex-direction:column-reverse;' class='autoScroll' ><div id='conversationBody' ></div></div>";
chat=chat+"<div style='position:absolute;bottom:0px;width:60vw;padding-right:10px;'>";//
chat=chat+"";
//chat=chat+"<div style='position:absolute;left:50%;transform:translate(-50%,0%);width:200px;text-align:center;box-shadow: 0px 4px 4px 4px rgba(0, 0, 0, 0.2);background-color:white;z-index:2'>21 September 2009</div>";
chat=chat+ "<form action='javascript:sendText()' autocomplete='off'><textarea id='textToSend' style='padding:10px 10px;width:100%;height:100px;resize:none;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;margin-bottom:10px;' placeholder='Write something...'></textarea><div style='float:right;margin-bottom:10px;' ><input id='sendButton' type='submit' value='Send'></div></form>";
chat=chat+"</div>";//
chat=chat+"</div>";///
return chat;
}
function getCalendar(){
var calendar='';
var namesOfDays=['So','Mo','Tu','We','Th','Fr','Sa'];
calendar="<div style='margin-bottom:5px;overflow:auto;'><div style='-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;background-color:darkgray;color:white;padding:5px 5px;float:left'><</div><div style='padding:5px 5px;float:left;background-color:white;'>September</div><div style='-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;background-color:darkgray;color:white;padding:5px 5px;float:left';>></div></div><div style='clear:left'></div>";
for(var i=0;i<7;i++){
calendar=calendar+"<div style='float:left;width:50px;padding:10px 10px;background-color:gray;color:white;text-align:center;'>"+namesOfDays[i]+"</div>";}
for(var week=0;week<5;week++){
calendar=calendar+"<div style='clear:left'></div>";
for(var day=0;day<7;day++){
calendar=calendar+"<div style='float:left;width:50px;padding:10px 10px;background-color:lightgray;color:black;text-align:center;'>"+day+"</div>";
}
}
//calendar=calendar+"<div style='clear:left'><h5 style='padding:20px 5px;'>Appointment: 12 September 2021| 3:30 p.m.</h5></div>";
return "<h3 style='background-color:black;color:white;margin-left:10px;padding:5px 5px;' onclick=javascript:toggle(\'calendar\')>Schedule appointment</h3><div id='calendar' style='display:none;margin-left:10px;margin-bottom:10px;overflow:auto;'>"+calendar+"</div>";
}
function getBody(myProfile,partnerProfile,contacts,worksheets,chats,patients,therapists,live,patientProfile){
return "<div class='autoScroll' style='float:left;width:30vw;height:100vh;'><div id='myProfileUi'>"+myProfile+"</div><div id='partnerProfileUi'>"+partnerProfile+"</div><div id='patientsProfileUi'>"+patientProfile+"</div><div id='contactsUi'>"+contacts+"</div><div id='worksheetsUi'>"+worksheets+"</div><div id='liveUi'>"+live+"</div><div id='patientsUi'>"+patients+"</div></div><div style='float:left;width:60vw;'><div id='chatsUi'>"+chats+"</div><div id='therapistsUi'>"+therapists+"</div></div>";
}
function displayCorrectBlocks(){
if(role=='patient'){
document.getElementById('myProfileUi').style.display='block';
document.getElementById('partnerProfileUi').style.display='block';
document.getElementById('worksheetsUi').style.display='block';
document.getElementById('patientsUi').style.display='none';
document.getElementById('contactsUi').style.display='block';
document.getElementById('chatsUi').style.display='block';
document.getElementById('therapistsUi').style.display='none';
document.getElementById('liveUi').style.display='block';
document.getElementById('patientsProfileUi').style.display='none';
}
if(role=='therapist'){
document.getElementById('myProfileUi').style.display='block';
document.getElementById('partnerProfileUi').style.display='block';
document.getElementById('worksheetsUi').style.display='block';
document.getElementById('patientsUi').style.display='none';
document.getElementById('contactsUi').style.display='block';
document.getElementById('chatsUi').style.display='block';
document.getElementById('therapistsUi').style.display='none';
document.getElementById('liveUi').style.display='block';
document.getElementById('patientsProfileUi').style.display='block';
}
if(role=='admin'){
document.getElementById('myProfileUi').style.display='none';
document.getElementById('partnerProfileUi').style.display='none';
document.getElementById('worksheetsUi').style.display='none';
document.getElementById('patientsUi').style.display='block';
document.getElementById('contactsUi').style.display='none';
document.getElementById('chatsUi').style.display='none';
document.getElementById('therapistsUi').style.display='block';
document.getElementById('liveUi').style.display='none';
document.getElementById('patientsProfileUi').style.display='none';
}
}
function toggle(item){
if(document.getElementById(item).style.display=='block'){
document.getElementById(item).style.display='none';
}else{
document.getElementById(item).style.display='block';}
}
function getLogin(elementId){
popupPanel=elementId;
resetUi();
makePicture('saceSpaceHighContrastTransparency.png');
makeTitle('Login');
makeField('Email address');
makePasswordField('Password');
var loginUi="<div style='height:580px;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;box-shadow: 0px 4px 8px 4px rgba(0,0,0,0.2);width:400px;position:fixed;left:50%;top:50px;transform:translate(-50%,0%);z-index:2;background-color:white;margin-bottom:0px;' onclick='javascript:clearPopupStatus()'>"+getFormUiAsString()+"<div style='margin-top:0px;margin-left:25px;margin-right:25px;'><button onclick='javascript:getSignup('"+elementId+"')' style='font:22px Calibri;width:100%;background-color:white;padding:6px 6px;box-shadow: 0px 1px 1px 0px rgba(0,0,0,0.2);color:black;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;border:none;'>Register</button><div style='text-align:center;position:relative;left:50%;transform:translate(-50%,0%);font:14px Calibri;margin-top:50px;font:18px Calibri;' id='popupStatus'> </div><div style='margin-top:30px;font:22px Calibri;'><div onclick='javascript:getForgotPassword('"+elementId+"')' style='color:dodgerblue;cursor:pointer;'>Forgot password?</div></div></div></div>";
document.getElementById('popupPanel').style.display='block';
document.getElementById(elementId).innerHTML=loginUi;
sendMode='login';
}
function getSignup(elementId){
resetUi();
makePicture('saceSpaceHighContrastTransparency.png');
makeTitle('Signup');
makeField('First name');
makeField('Last name');
makeField('Enter email address');
makePasswordField('Password (atleast 8 characters)');
makePasswordField('Re-enter password');
var signupUi="<div style='height:580px;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;box-shadow: 0px 4px 8px 4px rgba(0,0,0,0.2);width:400px;position:fixed;left:50%;top:50px;transform:translate(-50%,0%);z-index:2;background-color:white;'>"+getFormUiAsString()+"</div>";
document.getElementById(elementId).innerHTML=signupUi;
sendMode='signup';
}
function getForgotPassword(elementId){
resetUi();
makePicture('saceSpaceHighContrastTransparency.png');
makeTitle('Password recovery');
makeField('Enter email address');
var passwordRecoveryUi="<div style='height:580px;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;box-shadow: 0px 4px 8px 4px rgba(0,0,0,0.2);width:400px;position:fixed;left:50%;top:50px;transform:translate(-50%,0%);z-index:2;background-color:white;' onclick='javascript:clearPopupStatus()'>"+getFormUiAsString()+"<div style='margin:25px'><hr><div id='emailStatus' style='text-align:center;position:relative;left:50%;transform:translate(-50%,0%);font:14px Calibri;margin-top:50px;font:18px Calibri;' ></div></div></div>";
document.getElementById(elementId).innerHTML=passwordRecoveryUi;
sendMode='passwordRecovery';
}
function clearPopupStatus(){
try{
document.getElementById('popupStatus').innerHTML=" ";}catch(err){}
try{
document.getElementById('emailStatus').innerHTML='';}catch(err){}
}
function send(){
if(sendMode=='login'){
document.getElementById('submitButtonGuiForm').disabled=true;
sendDataToGoogleSheets([sendMode,role,getFieldText('Email address'),getFieldText('Password')],googleSheetsPortalScript);
sendDataToGoogleSheets(['getContacts',role,getFieldText('Email address'),getFieldText('Password')],googleSheetsPortalScript);
sendDataToGoogleSheets(['getPatients'],googleSheetsPortalScript);
sendDataToGoogleSheets(['getTherapists'],googleSheetsPortalScript);
document.getElementById('popupStatus').innerHTML="<span style='animation-name:popupStatus;animation-duration:8s;animation-iteration-count:infinite'>🔎 Searching . . .</span> ";
}
if(sendMode=='signup'){
var formCompleted=true;
if(getFieldText('First name')==''){
formCompleted=false;
document.getElementById('First name').style.boxShadow= "0px 0px 1px 0px rgba(255,0,0,1)";}else{
document.getElementById('First name').style.boxShadow= "0px 0px 1px 0px rgba(0,0,0,0.2)";}
if(getFieldText('Last name')==''){
formCompleted=false;
document.getElementById('Last name').style.boxShadow= "0px 0px 1px 0px rgba(255,0,0,1)";}else{
document.getElementById('Last name').style.boxShadow= "0px 0px 1px 0px rgba(0,0,0,0.2)";}
if(getFieldText('Enter email address')==''){
formCompleted=false;
document.getElementById('Enter email address').style.boxShadow= "0px 0px 1px 0px rgba(255,0,0,1)";}else{
document.getElementById('Enter email address').style.boxShadow= "0px 0px 1px 0px rgba(0,0,0,0.2)";}
if(getFieldText('Password (atleast 8 characters)')==''){
formCompleted=false;
document.getElementById('Password (atleast 8 characters)').style.boxShadow= "0px 0px 1px 0px rgba(255,0,0,1)";}else{
document.getElementById('Password (atleast 8 characters)').style.boxShadow= "0px 0px 1px 0px rgba(0,0,0,0.2)";}
if(getFieldText('Re-enter password')==''){
formCompleted=false;
document.getElementById('Re-enter password').style.boxShadow= "0px 0px 1px 0px rgba(255,0,0,1)";}else{
document.getElementById('Re-enter password').style.boxShadow= "0px 0px 1px 0px rgba(0,0,0,0.2)";}
if(getFieldText('Password (atleast 8 characters)')==getFieldText('Re-enter password')&&getFieldText('Password (atleast 8 characters)').length>7&&getFieldText('Re-enter password').length>7){
document.getElementById('Password (atleast 8 characters)').style.boxShadow= "0px 0px 1px 0px rgba(0,0,0,0.2)";
document.getElementById('Re-enter password').style.boxShadow= "0px 0px 1px 0px rgba(0,0,0,0.2)";
}else{
formCompleted=false;
document.getElementById('Password (atleast 8 characters)').style.boxShadow= "0px 0px 1px 0px rgba(255,0,0,1)";
document.getElementById('Re-enter password').style.boxShadow= "0px 0px 1px 0px rgba(255,0,0,1)";
}
if(formCompleted){
firstName=getFieldText('First name');
lastName=getFieldText('Last name');
email=getFieldText('Enter email address');
password=getFieldText('Password (atleast 8 characters)');
if(role=='patient'){
renderPopup(popupPanel);}
if(role=='therapist'){
renderTherapistPopup(popupPanel);}
if(role=='admin'){
sendDataToGoogleSheets([sendMode,role,firstName,lastName,email,password],googleSheetsPortalScript);
sendDataToGoogleSheets(['getPatients'],googleSheetsPortalScript);
sendDataToGoogleSheets(['getTherapists'],googleSheetsPortalScript);
setUpdating();}
}
}
if(sendMode=='passwordRecovery'){
sendDataToGoogleSheets([sendMode,role,getFieldText('Enter email address')],googleSheetsPortalScript);
document.getElementById('emailStatus').innerHTML="<span style='animation-name:popupStatus;animation-duration:8s;animation-iteration-count:infinite'>🔎 Searching . . .</span> ";}
}
function sendText(){
document.getElementById('sendButton').disabled=true;
var dataToSendArray=[];
var date=new Date();
var minute=date.getMinutes();
dataToSendArray[0]=firstName;
dataToSendArray[1]=lastName;
dataToSendArray[2]=myProfilePic;
dataToSendArray[3]=date.getDate()+' '+months[date.getMonth()]+' '+date.getFullYear();
if(minute<10){
minute="0"+minute;}
if(date.getHours()<13){
dataToSendArray[4]=date.getHours()+":"+minute+" am";}else{
dataToSendArray[4]=(date.getHours()-12)+":"+minute+" pm";}
dataToSendArray[5]=getFieldText('textToSend');
if(dataToSendArray[5]!=''){
sendDataToGoogleSheets(['sendingText',conversationId,dataToSendArray.join('*^*')],googleSheetsPortalScript);
}
setFieldText('textToSend','');
}
function autoCheck(){
if(!autoCheckRunning){
setInterval(function(){
sendDataToGoogleSheets(['autoCheck',conversationId],googleSheetsPortalScript);
},3000);
autoCheckRunning=true;}
}
function receiveDataFromGoogleSheets(){
waitForGoogleThenExecute();
if(getDataFromGoogleSheetsAsArray()[0]=='loginFailed'){
document.getElementById('popupStatus').innerHTML="<span style='animation-name:popupStatus;animation-duration:8s;animation-iteration-count:infinite'><i class='fas fa-exclamation-triangle' style='color:orange'></i> Invalid email address / password</span> ";
document.getElementById('submitButtonGuiForm').disabled=false;
}
if(getDataFromGoogleSheetsAsArray()[0]=='loginSuccessful'){
try{
document.getElementById('popupStatus').innerHTML=" ";}catch(err){}
firstName=getDataFromGoogleSheetsAsArray()[1];
lastName=getDataFromGoogleSheetsAsArray()[2];
conversationId=getDataFromGoogleSheetsAsArray()[3];
conversationDataAsString=getDataFromGoogleSheetsAsArray()[4];
var conversationData=[];
conversationData=conversationDataAsString.split('~*data*~');
var profilesArray=[];
try{
currentProfile=conversationData[0];
profilesArray=currentProfile.split('~*profilesArray*~');}catch(err){}
var resourcesArray=[];
try{
currentResources=conversationData[1].split('~*resourcesArray*~');
resourcesArray=currentResources;}catch(err){}
var meetingTimesArray=[];
try{
currentMeetingTimes=conversationData[2].split('~*meetingTimesArray*~');
meetingTimesArray=currentMeetingTimes;}catch(err){}
conversation=conversationData[3];
for(var i=0;i<profilesArray.length;i++){
let profile=profilesArray[i].split('~*profile*~');
let firstNameToSave=profile[0];
let lastNameToSave =profile[1];
let myProfileDescriptionToSave=profile[2];
let profilePictureDimensions=profile[3];
let profilePictureFileUrl=profile[4];
if(firstName==firstNameToSave&&lastName==lastNameToSave){
profileArrayData=profile;
document.getElementById('myProfileName').innerHTML=firstNameToSave+' '+lastNameToSave;
document.getElementById('myProfileDescription').innerHTML="<xmp style='font:18px Calibri'>"+myProfileDescriptionToSave+"</xmp>";
setFieldText('myProfileDescriptionToSave',myProfileDescriptionToSave);
if(profilePictureFileUrl==''){
myProfilePic=(firstNameToSave.substring(0,1)).toUpperCase()+(lastNameToSave.substring(0,1)).toUpperCase();
document.getElementById('myProfilePic').innerHTML=myProfilePic;}else{
myProfilePic=profilePictureFileUrl;
document.getElementById('myProfilePic').innerHTML="<img style='width:16vh' src='"+myProfilePic+"'>";}
}else{
if(profile!=''){
document.getElementById('patientsProfileDescription').innerHTML="<xmp style='font:18px Calibri'>"+profilePictureDimensions+"</xmp>";
document.getElementById('partnerProfileName').innerHTML=firstNameToSave+' '+lastNameToSave;
document.getElementById('partnerProfileDescription').innerHTML="<xmp style='font:18px Calibri'>"+myProfileDescriptionToSave+"</xmp>";
if(profilePictureFileUrl==''){
partnerProfilePic=(firstNameToSave.substring(0,1)).toUpperCase()+(lastNameToSave.substring(0,1)).toUpperCase();
document.getElementById('partnerProfilePic').innerHTML=partnerProfilePic;}else{
partnerProfilePic=profilePictureFileUrl;
document.getElementById('partnerProfilePic').innerHTML="<img style='width:16vh' src='"+partnerProfilePic+"'>";}}
}
}
var resourcesToShowArray=[];
for(var i=0;i<resourcesArray.length;i++){
let resource=resourcesArray[i].split('~*resource*~');
resourcesToShowArray[i*3]=resource[0];
resourcesToShowArray[i*3+1]=resource[1];
resourcesToShowArray[i*3+2]=resource[2];
}
showResources(resourcesToShowArray);
var meetingsToShowArray=[];
for(var i=0;i<meetingTimesArray.length;i++){
let meeting=meetingTimesArray[i].split('~*meeting*~');
meetingsToShowArray[i*2]=meeting[0];
meetingsToShowArray[i*2+1]=meeting[1];
}
showMeetingTimes(meetingsToShowArray);
removePopupPanel();
if(role!='admin'){
autoCheck();
setUpdating();
removeUpdatingOnConversationUpdate();}
displayDashboard();
if(role=='therapist'){
}
if(document.getElementById('myProfileName').innerHTML==''&&role!='admin'){
saveMyProfile();}
}
if(getDataFromGoogleSheetsAsArray()[0]=='noConversationId'){
removePopupPanel();
removeUpdating();
document.getElementById('loginRejectionPanel').innerHTML="<div onclick='javascript:{document.getElementById('loginRejectionPanel').innerHTML='';}' style='cursor:pointer;position:absolute;top:0px;left:0px;z-index:2;width:100vw;height:100vh;background-color:rgba(0,0,0,.5);'><div style='position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);color:white;font:44px Calibri;'>"+getDataFromGoogleSheetsAsArray()[1]+"</div></div>";
}
if(getDataFromGoogleSheetsAsArray()[0]=='updateConversation'){
if(waitForConversationToUpdate){
waitForConversationToUpdate=false;
removeUpdating();}
var conversationDataAsString=getDataFromGoogleSheetsAsArray()[1];
let conversation
let conversationData=[];
conversationData=conversationDataAsString.split('~*data*~');
var profilesArray=[];
try{
if(currentProfile!=conversationData[0]){
currentProfile=conversationData[0];
profilesArray=currentProfile.split('~*profilesArray*~');
updateProfile(profilesArray);
}
}catch(err){}
var resourcesArray=[];
try{
if(currentResources!=conversationData[1]){
currentResources=conversationData[1];
let resourcesToShowArray=[];
resourcesArray=currentResources.split('~*resourcesArray*~');
for(var i=0;i<resourcesArray.length;i++){
let resource=resourcesArray[i].split('~*resource*~');
resourcesToShowArray[i*3]=resource[0];
resourcesToShowArray[i*3+1]=resource[1];
resourcesToShowArray[i*3+2]=resource[2];
}
showResources(resourcesToShowArray);
}
}catch(err){}
var meetingTimesArray=[];
try{
if(currentMeetingTimes!=conversationData[2]){
currentMeetingTimes=conversationData[2];
meetingTimesArray=currentMeetingTimes.split('~*meetingTimesArray*~');
let meetingsToShowArray=[];
for(var i=0;i<meetingTimesArray.length;i++){
let meeting=meetingTimesArray[i].split('~*meeting*~');
meetingsToShowArray[i*2]=meeting[0];
meetingsToShowArray[i*2+1]=meeting[1];
}
showMeetingTimes(meetingsToShowArray);}
}catch(err){}
conversation=conversationData[3];
setConversationBody(conversation);
removeUpdating();
}
if(getDataFromGoogleSheetsAsArray()[0]=='signupSuccessful'){
}
if(getDataFromGoogleSheetsAsArray()[0]=='patientRequestSuccessful'){
}
if(getDataFromGoogleSheetsAsArray()[0]=='emailSent'){
document.getElementById('emailStatus').innerHTML="<span style='animation-name:popupStatus;animation-duration:8s;animation-iteration-count:infinite'><i class='fas fa-envelope' style='color:green'></i> Check your email for further instructions</span> ";
}
if(getDataFromGoogleSheetsAsArray()[0]=='emailNotFound'){
document.getElementById('emailStatus').innerHTML="<span style='animation-name:popupStatus;animation-duration:8s;animation-iteration-count:infinite'><i class='fas fa-exclamation-triangle' style='color:orange'></i> Invalid email address</span> ";
}
if(getDataFromGoogleSheetsAsArray()[0]=='contactsFound'){
var contactsArray=getDataFromGoogleSheetsAsArray()[1];
var contactList=contactsArray.split('*^*');
var contactNamesToDisplay=[];
for(var i=0;i<contactList.length;i++){
contactNamesToDisplay[i]=(contactList[i].split('*^^^*'))[0];
chatNumbers[contactNamesToDisplay[i]]=(contactList[i].split('*^^^*'))[1];
}
contactNamesToDisplay.join('^*^');
setRecordToSearch(contactNamesToDisplay);
}
if(getDataFromGoogleSheetsAsArray()[0]=='patientsFound'){
var tempPatientTherapistList=getDataFromGoogleSheetsAsArray()[1].split('*^*');
var patientTherapistList=[];
var patientTherapistPatientProfile=[];
for(var i=0;i<tempPatientTherapistList.length;i++){
var patientTherapistInfo=tempPatientTherapistList[i].split('*^^^*');
if(patientTherapistInfo[1]==''){
patientTherapistList[i]=patientTherapistInfo[0];
patientTherapistPatientProfile[i]=patientTherapistInfo[3];
}
else{
patientTherapistList[i]=patientTherapistInfo[0]+ " ( "+patientTherapistInfo[1]+" )";
patientTherapistPatientProfile[i]=patientTherapistInfo[3];
}
}
setPatientsList(patientTherapistList,patientTherapistPatientProfile);
}
if(getDataFromGoogleSheetsAsArray()[0]=='therapistsFound'){
var tempTherapistList=getDataFromGoogleSheetsAsArray()[1].split('*^*');
setTherapistList(tempTherapistList);
}
if(getDataFromGoogleSheetsAsArray()[0]=='therapistAssignedSuccessful'){
document.getElementById('patientTherapistMatchingPrompt').innerHTML='Select a patient';
document.getElementById('patientProfilePrompt').innerHTML='';
sendDataToGoogleSheets(['getPatients'],googleSheetsPortalScript);
}
}
function removeUpdatingOnConversationUpdate(){
waitForConversationToUpdate=true;}
function searchBarItemSelected(chatSelected){
conversationId=chatNumbers[chatSelected];
}
function setPatientsList(patientNames,patientProfile){
removeUpdating();
var patientsNameUi='';
for(var i=0;i<patientNames.length;i++){
if(patientNames[i].indexOf('(')==-1){
patientsNameUi=patientsNameUi+"<div onclick='javascript:setPatientTherapistMatchingPrompt('"+patientNames[i]+"');setPatientTherapistMatchingProfile('"+patientProfile[i].replaceAll("\n",'~~~')+"')' style='cursor:pointer;'><div class='onHoverAdmin' style='-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;padding:15px 12px;' >"+patientNames[i]+"</div></div>";
}else{
patientsNameUi=patientsNameUi+"<div style='padding:15px 12px;'><div style='-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;display:inline-block;' disabled=true>"+patientNames[i]+"</div><span style='float:right'><div onclick='javascript:removeTherapist('"+patientNames[i]+"')' style='display:inline-block;color:#00C0FF;cursor:pointer;' >remove</div></span></div>";}
}
document.getElementById('patientsBody').innerHTML=patientsNameUi;
}
function setPatientTherapistMatchingPrompt(patientNameToMatch){
patientToMatch=patientNameToMatch;
document.getElementById('patientTherapistMatchingPrompt').innerHTML='Assign '+patientNameToMatch+' a therapist';
}
function setPatientTherapistMatchingProfile(patientProfile){
document.getElementById('patientProfilePrompt').innerHTML=patientProfile.replaceAll('~~~','\r\n');
}
function setTherapistList(therapistsNames){
var therapistsNameUi='';
therapistsNameUi="<div style='width:100%;height:70px;'></div>";
for(var i=0;i<therapistsNames.length;i++){
var therapistInfo=therapistsNames[i].split('*^^^*');
therapistsNameUi=therapistsNameUi+"<div onclick='javascript:setTherapist('"+therapistInfo[0]+' '+therapistInfo[1]+"')' style='cursor:pointer;'><div class='onHoverTherapist' style='-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;'><div style='width:100%;'><div style='background-color:white;width:8vh;height:8vh;position:relative;top:2vh;left:50%;transform:translate(-50%,0%);-moz-border-radius:4vh;-webkit-border-radius:4vh;border-radius:4vh;overflow:hidden;'><div style='position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font: 4vh Arial;'><img style='width:8vh' src='"+therapistInfo[3]+"' >"+"</div></div></div><h3 style='text-align:center;color:tomato;'><div >"+therapistInfo[0]+' '+therapistInfo[1]+"</div></h3><h4 style='text-align:center;color:dimgrey'><div><textarea style='padding:10px 10px;width:90%;resize:none;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;margin-bottom:10px;border:none;overflow:none;' placeholder='Write something short...' readonly>"+therapistInfo[2]+"</textarea></div></h4></div></div>";
}
document.getElementById('therapistsBody').innerHTML=therapistsNameUi;
}
function setTherapist(therapistToMatchWithPatient){
therapistToMatch=therapistToMatchWithPatient;
if(patientToMatch!=''&&therapistToMatch!=''){
sendDataToGoogleSheets(['assignTherapist',patientToMatch,therapistToMatch],googleSheetsPortalScript);
setUpdating();
patientToMatch='';
therapistToMatch='';
}
}
function removeTherapist(patientAndTherapist){
var patientToUnassign=patientAndTherapist.substring(0,patientAndTherapist.indexOf('(')-1);
var therapistToUnassign=patientAndTherapist.substring(patientAndTherapist.indexOf('(')+2,patientAndTherapist.indexOf(')')-1);
sendDataToGoogleSheets(['unassignTherapist',patientToUnassign,therapistToUnassign],googleSheetsPortalScript);
setUpdating();
}
function setUpdating(){
document.getElementById('adminPatientRejectionPanel').innerHTML="<div style='cursor:pointer;position:absolute;top:0px;left:0px;z-index:2;width:100vw;height:100vh;'><div style='width:100%;height:100%;background-color:rgba(0,0,0,.5);animation-name:popupStatus;animation-duration:8s;animation-iteration-count:infinite'><div style='position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font:44px Calibri;'><i class='fas fa-cloud-upload-alt' style='color:orange'></i> Updating...</div></div></div>";
}
function removeUpdating(){
document.getElementById('adminPatientRejectionPanel').innerHTML='';
}
function setConversationBody(conversationBodyToSet){
var conversationArray=[];
try{
conversationArray=conversationBodyToSet.split('*^^^*');}catch(err){
document.getElementById('conversationBody').innerHTML='';}
var chat='';
for(var i=0;i<conversationArray.length;i++){
try{
var messageArray=[];
messageArray=conversationArray[i].split('*^*');
if(messageArray.length>1){
if(firstName==messageArray[0]&&lastName==messageArray[1]){
if(myProfilePic.length>2){
chat=chat+"<div style='display:block;margin-bottom:10px;' ><div style='width:60px;height:60px;-moz-border-radius:30px;-webkit-border-radius:30px;border-radius:30px;overflow:hidden;'><img style='width:60px' src='"+myProfilePic+"'></div> </div> ";}else{
chat=chat+"<div style='display:block;margin-bottom:10px;' ><div style='width:60px;height:60px;-moz-border-radius:30px;-webkit-border-radius:30px;border-radius:30px;overflow:hidden;background-color:whitesmoke'><div style='text-align:center;font:30px Calibri;position:relative;top:50%;transform:translate(0%,-50%)'>"+myProfilePic+"</div></div> </div> ";
}
chat=chat+"<div style='padding:10px 10px; overflow:hidden;display:block;background-color:lightgray;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;margin-bottom:10px;'><xmp>"+messageArray[5]+"</xmp><div style='margin-top:10px;color:gray;text-align:right;'>"+messageArray[3]+" | "+messageArray[4]+"</div></div>";}
else{
if(partnerProfilePic.length>2){
chat=chat+"<div style='display:block;margin-bottom:10px;' ><div style='width:60px;height:60px;-moz-border-radius:30px;-webkit-border-radius:30px;border-radius:30px;overflow:hidden;'><img style='width:60px' src='"+partnerProfilePic+"'></div> </div>";}else{
chat=chat+"<div style='display:block;margin-bottom:10px;' ><div style='width:60px;height:60px;-moz-border-radius:30px;-webkit-border-radius:30px;border-radius:30px;overflow:hidden;background-color:wheat'><div style='text-align:center;font:30px Calibri;position:relative;top:50%;transform:translate(0%,-50%)'>"+partnerProfilePic+"</div></div> </div> ";}
chat=chat+"<div style='padding:10px 10px; overflow:hidden;display:block;background-color:lightgray;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;margin-bottom:10px;'><xmp>"+messageArray[5]+"</xmp><div style='margin-top:10px;color:gray;text-align:right;'>"+messageArray[3]+" | "+messageArray[4]+"</div></div>";}
}
}catch(err){}
}
document.getElementById('conversationBody').innerHTML=chat;
document.getElementById('sendButton').disabled=false;
}
function waitForGoogleThenExecute(){}
function waitForPatientInfo(patientProfileInfo){
sendDataToGoogleSheets([sendMode,role,firstName,lastName,email,password,patientProfileInfo],googleSheetsPortalScript);
setUpdating();
}
function waitForTherapistInfo(therapistPic,therapistPicType,therapistDescription){
sendDataToGoogleSheets([sendMode,role,firstName,lastName,email,password,therapistPic,therapistPicType,therapistDescription],googleSheetsPortalScript);
setUpdating();
}
function removePopupPanel(){
document.getElementById('popupPanel').style.display='none';
}
function getDay(){
return "<span><select style='float:left;padding:2px 2px;margin:2px;' id='getDay'><option>Day</option><option value='Monday'>Monday</option><option value='Tuesday'>Tuesday</option><option value='Wednesday'>Wednesday</option><option value='Thursday'>Thursday</option><option value='Friday'>Friday</option><option value='Saturday'>Saturday</option><option value='Sunday'>Sunday</option></select></span>";
}
function getDuration(){
return "<span><select style='float:left;padding:2px 2px;margin:2px;' id='getDuration'><option>Duration</option><option value='00h 15m'>00h 15m</option><option value='00h 30'>00h 30m</option><option value='00h 45m'>00h 45m</option><option value='01h 00m'>01h 00m</option><option value='01h 15m'>01h 15m</option><option value='01h 30m'>01h 30m</option><option value='01h 45m'>01h 45m</option><option value='02h 00m'>02h 00m</option></select></span>";
}
function getHour(){
return "<span><select style='float:left;padding:2px 2px;margin:2px;' id='getHour'><option>Hour</option><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option><option value='9'>9</option><option value='10'>10</option><option value='11'>11</option><option value='12'>12</option></select></span>";
}
function getMinutes(){
return "<span><select style='float:left;padding:2px 2px;margin:2px;' id='getMinute'><option>Minute</option><option value='05'>5</option><option value='10'>10</option><option value='15'>15</option><option value='20'>20</option><option value='25'>25</option><option value='30'>30</option><option value='35'>35</option><option value='40'>40</option><option value='45'>45</option><option value='50'>50</option><option value='55'>55</option></select></span>";
}
function getAMPM(){
return "<span><select style='float:left;padding:2px 2px;margin:2px;' id='getAMPM'><option>AM/PM</option><option value='AM'>AM</option><option value='PM'>PM</option></select></span>";
}
function updateProfile(profileArraysToUpdate){
for(var i=0;i<profileArraysToUpdate.length;i++){
let profile=profileArraysToUpdate[i].split('~*profile*~');
let firstNameToSave=profile[0];
let lastNameToSave =profile[1];
let myProfileDescriptionToSave=profile[2];
let profilePictureDimensions=profile[3];
let profilePictureFileUrl=profile[4];
if(firstName==firstNameToSave&&lastName==lastNameToSave){
}else{
if(profile!=''){
document.getElementById('patientsProfileDescription').innerHTML="<xmp style='font:18px Calibri'>"+profilePictureDimensions+"</xmp>";
document.getElementById('partnerProfileName').innerHTML=firstNameToSave+' '+lastNameToSave;
document.getElementById('partnerProfileDescription').innerHTML="<xmp style='font:18px Calibri'>"+myProfileDescriptionToSave+"</xmp>";
if(profilePictureFileUrl==''){
partnerProfilePic=(firstNameToSave.substring(0,1)).toUpperCase()+(lastNameToSave.substring(0,1)).toUpperCase();
document.getElementById('partnerProfilePic').innerHTML=partnerProfilePic;}else{
partnerProfilePic=profilePictureFileUrl;
document.getElementById('partnerProfilePic').innerHTML="<img style='width:16vh' src='"+partnerProfilePic+"'>";}}}
}
}