MSV FM

dot.antimicrobial@66.96.161.157: ~ $
Path : /hermes/sb_web/b1536/advancedfunctions.co/meridianlms/
File Upload :
Current < : //hermes/sb_web/b1536/advancedfunctions.co/meridianlms/modules.js

var sendMode='';
var googleSheetsPortalScript='https://script.google.com/macros/s/AKfycbwm5f7WCG9HxKvMYp60zkF2xOcqpXX2m01wSwtaPRQsXzOpvPVoDoJT4ulVpRppRCDl/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(&#39;editMeetingTimes&#39;)'><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='&#9990; &nbsp;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'>&#8853;&nbsp;&nbsp;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(&#39;"+array[i]+"&#39;,&#39;_blank&#39;);}' style='cursor:pointer;' class='onHover'>"+meetingIcon+"&nbsp;&nbsp;&nbsp;"+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(&#39;"+array[i]+"&#39;,&#39;_blank&#39;);}'  class='onHover' style='cursor:pointer;display:inline-block;'>"+meetingIcon+"&nbsp;&nbsp;&nbsp;"+array[i+1]+"</div><span style='float:right'><div onclick='javascript:removeMeeting(&#39;"+array[i]+"&#39;,&#39;"+array[i+1]+"&#39;)' 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(&#39;editResources&#39;)'><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(&#39;resourceUploader&#39;,false),setEnabled(&#39;websiteUrl&#39;,false),setEnabled(&#39;resourceTitle&#39;,false);' value='fileType'>File Type</option><option value='document' onClick='javascript:setEnabled(&#39;resourceUploader&#39;,true),setEnabled(&#39;websiteUrl&#39;,false),setEnabled(&#39;resourceTitle&#39;,true);'>Document</option><option value='video' onclick='javascript:setEnabled(&#39;resourceUploader&#39;,true),setEnabled(&#39;websiteUrl&#39;,false),setEnabled(&#39;resourceTitle&#39;,true);'>Video</option><option value='url' onclick='javascript:setEnabled(&#39;websiteUrl&#39;,true);setEnabled(&#39;resourceUploader&#39;,false),setEnabled(&#39;resourceTitle&#39;,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)' >&#8853;&nbsp;&nbsp;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(&#39;"+array[i+2]+"&#39;,&#39;_blank&#39;);}' style='cursor:pointer;' class='onHover'>"+resourceIcon+"&nbsp;&nbsp;&nbsp;"+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\')>Digital 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(&#39;"+array[i+2]+"&#39;,&#39;_blank&#39;);}'  style='cursor:pointer;display:inline-block;' class='onHover'>"+resourceIcon+"&nbsp;&nbsp;&nbsp;"+"<xmp style='font:20px Calibri;display:inline-block;margin:0px;'>"+array[i+1]+"</xmp>"+"</div><span style='float:right'><div onclick='javascript:removeResource(&#39;"+array[i+1]+"&#39;,&#39;"+array[i+2]+"&#39;)' 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\')>Digital 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;'>Select A Student</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(&#39;editProfile&#39;)' 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="&#8853;&nbsp;&nbsp;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="&#8853;&nbsp;&nbsp;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\')>My Teacher's 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;' >Lessons</h3><div class='autoScroll' id='therapists' style='display:block;margin-left:10px;margin-bottom:10px;height:90vh;' ><div 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:none;' ><div><div style='text-align:center' id='patientTherapistMatchingPrompt' ></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 hijackTherapists(){
var therapistList="<h3 style='background-color:#00C0FF;color:white;margin-left:10px;padding:5px 5px;' >Lessons</h3><div class='autoScroll' id='therapists' style='display:block;margin-left:10px;margin-bottom:10px;height:90vh;' ><div 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>&#x26F6;</div><div><div style='text-align:center' id='patientTherapistMatchingPrompt' ></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 getChats(array){
var chat='';
if(false){
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;' onclick=''><div id='a'>"+getPictureTitleDescriptionPanelEdit("My Profile","myProfile","0")+"</div><div id='b'>"+getPictureTitleDescriptionPanel("My Teacher's Profile","myTeachersProfile","1")+"</div><div id='c'>"+getSearchList("My Lessons","myLessons","8")+"</div><div id='d'>"+getPictureTitleDescriptionPanel("My Lesson Overview","StudentLessons","2")+"</div><div id='e'>"+getDigitalResourcesList("Digital Resources","studentsDigitalResources",["url","Tinkercad","","url","Stingray Compiler",""])+"</div><div id='f'>"+getCalendar("Attendance","3")+"</div><div id='g'>"+getTableWithHeadingColumnAndMax4BarGraph("Grades","4")+"</div><div id='h'>"+getPictureTitleDescriptionPanelEdit("Teacher's Profile","teachersProfile","1")+"</div><div id='i'>"+getPictureTitleDescriptionPanelEdit("Lesson Maker","lessonMaker","2")+"</div><div id='j'>"+getSearchList("Teacher's Lessons","teacherLessons","9")+"</div><div id='k'>"+getDigitalResourcesList("Attendance & Gradebook","attendanceAndGradebook",["url","Attendance","","url","Gradebrook",""])+"</div><div id='l'>"+getDigitalResourcesListEdit("Digital Resources","teacherDigitalResource",["url","Tinkercad","","url","Stingray Compiler",""])+"</div><div id='m'>"+getDropDownButton("Class Administration","displayClassAdminPage()")+"</div><div id='n'>"+getSearchList("My Schools","teacherSchools")+"</div><div id='o'>"+getPictureTitleDescriptionPanelEdit("Add A School","teacherSchoolAdded","")+"</div><div id='p'>"+getSearchList("My Classes","teacherClass")+"</div><div id='q'>"+getPictureTitleDescriptionPanelEdit("Add A Class","teacherClassAdded","")+"</div><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 id='r'>"+getDropDownButton("Back To Class","displayClassPage()")+"</div></div><div id='s'>"+getChat("activityMaker",5)+"</div><div id='t'>"+getChat("StudentSubmissions",7)+"</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='none';
document.getElementById('partnerProfileUi').style.display='none';
document.getElementById('worksheetsUi').style.display='none';
document.getElementById('patientsUi').style.display='none';
document.getElementById('contactsUi').style.display='none';
document.getElementById('chatsUi').style.display='none';
document.getElementById('therapistsUi').style.display='none';
document.getElementById('liveUi').style.display='none';
document.getElementById('patientsProfileUi').style.display='none';
document.getElementById('a').style.display='block';
document.getElementById('b').style.display='block';
document.getElementById('c').style.display='block';
document.getElementById('d').style.display='block';
document.getElementById('e').style.display='none';
document.getElementById('f').style.display='block';
document.getElementById('g').style.display='block';
document.getElementById('h').style.display='none';
document.getElementById('i').style.display='none';
document.getElementById('j').style.display='none';
document.getElementById('k').style.display='none';
document.getElementById('l').style.display='none';
document.getElementById('m').style.display='none';
document.getElementById('n').style.display='none';
document.getElementById('o').style.display='none';
document.getElementById('p').style.display='none';
document.getElementById('q').style.display='none';
document.getElementById('r').style.display='none';
document.getElementById('s').style.display='none';
document.getElementById('t').style.display='block';
}
if(role=='therapist'){
displayClassPage();
}

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 displayClassAdminPage(){
document.getElementById('a').style.display='none';
document.getElementById('b').style.display='none';
document.getElementById('c').style.display='none';
document.getElementById('d').style.display='none';
document.getElementById('e').style.display='none';
document.getElementById('f').style.display='none';
document.getElementById('g').style.display='none';
document.getElementById('h').style.display='none';
document.getElementById('i').style.display='none';
document.getElementById('j').style.display='none';
document.getElementById('k').style.display='none';
document.getElementById('l').style.display='none';
document.getElementById('m').style.display='none';
document.getElementById('n').style.display='block';
document.getElementById('o').style.display='block';
document.getElementById('p').style.display='block';
document.getElementById('q').style.display='block';
document.getElementById('r').style.display='block';
document.getElementById('s').style.display='none';
document.getElementById('t').style.display='none';

document.getElementById('chatsUi').style.display='none';
document.getElementById('patientsUi').style.display='block';
document.getElementById('therapistsUi').style.display='block';
}


function displayClassPage(){
document.getElementById('myProfileUi').style.display='none';
document.getElementById('partnerProfileUi').style.display='none';
document.getElementById('worksheetsUi').style.display='none';
document.getElementById('patientsUi').style.display='none';
document.getElementById('contactsUi').style.display='none';
document.getElementById('chatsUi').style.display='none';
document.getElementById('therapistsUi').style.display='none';
document.getElementById('liveUi').style.display='none';
document.getElementById('patientsProfileUi').style.display='none';
document.getElementById('a').style.display='none';
document.getElementById('b').style.display='none';
document.getElementById('c').style.display='none';
document.getElementById('d').style.display='none';
document.getElementById('e').style.display='none';
document.getElementById('f').style.display='none';
document.getElementById('g').style.display='none';
document.getElementById('h').style.display='block';
document.getElementById('i').style.display='block';
document.getElementById('j').style.display='block';
document.getElementById('k').style.display='block';
document.getElementById('l').style.display='block';
document.getElementById('m').style.display='block';
document.getElementById('n').style.display='none';
document.getElementById('o').style.display='none';
document.getElementById('p').style.display='none';
document.getElementById('q').style.display='none';
document.getElementById('r').style.display='none';
document.getElementById('s').style.display='block';
document.getElementById('t').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(&#39;"+elementId+"&#39;)' 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'>&nbsp;</div><div style='margin-top:30px;font:22px Calibri;'><div onclick='javascript:getForgotPassword(&#39;"+elementId+"&#39;)' 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="&nbsp;";}catch(err){}
try{
document.getElementById('emailStatus').innerHTML='';}catch(err){}
}
function send(){
document.getElementById('submitButtonGuiForm').disabled=true;
console.log('roll',role);
let arrayToSend=[];
if(role=='therapist'){
arrayToSend[0]=[100,teacherProfile,1].join("^,^");}
if(role=='patient'){
arrayToSend[0]=[100,studentProfile,1].join("^,^");}

arrayToSend[1]=[getFieldText('Full Name'),getFieldText('Password')].join("*,^");
sendDataToGoogleSheets([arrayToSend.join("*.^")],googleSheetsPortalScriptLMS);
console.log('login in:',arrayToSend);
document.getElementById('popupStatus').innerHTML="<span style='animation-name:popupStatus;animation-duration:8s;animation-iteration-count:infinite'>&#x1F50E; 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();
distribute(getDataFromGoogleSheetsAsArray());
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 username / 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="<xml style='white-space: pre-wrap;font:18px Calibri'>"+myProfileDescriptionToSave+"</xml>";
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="<xml style='white-space: pre-wrap;ont:18px Calibri'>"+myProfileDescriptionToSave+"</xml>";
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(&#39;loginRejectionPanel&#39;).innerHTML=&#39;&#39;;}' 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> &nbsp;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 username</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(&#39;"+patientNames[i]+"&#39;);setPatientTherapistMatchingProfile(&#39;"+patientProfile[i].replaceAll("\n",'~~~')+"&#39;)' 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(&#39;"+patientNames[i]+"&#39;)' 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 Lesson';
}

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(&#39;"+therapistInfo[0]+' '+therapistInfo[1]+"&#39;)' 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 hijackTherapistList(therapistsNames){
var therapistsNameUi='';
therapistsNameUi="<div style='width:100%;height:70px;'></div>";
for(var i=0;i<therapistsNames.length;i++){
var therapistInfo=therapistsNames[i];
therapistsNameUi=therapistsNameUi+"<div onclick='javascript:setTherapist(&#39;"+therapistInfo[0]+' '+therapistInfo[1]+"&#39;)' 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:12vh;height:12vh;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='height:14vh' 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><div style='white-space: pre-wrap;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;'>"+therapistInfo[2]+"</div></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;position:relative;top:50%;left:50%;transform:translate(-50%,-50%);' 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;position:relative;top:50%;left:50%;transform:translate(-50%,-50%);' 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 hijackConversationBody(conversationArray){
var chat='';
for(var i=0;i<conversationArray.length;i++){
try{
var messageArray=[];
messageArray=conversationArray[i];
if(messageArray[1].length>1){
if(messageArray[0]==0){
if(messageArray[1].length>2){
chat=chat+"<div style='display:block;margin-bottom:10px;'  align='right'><div style='margin:20px;width:60px;height:60px;-moz-border-radius:30px;-webkit-border-radius:30px;border-radius:30px;overflow:hidden;'><img style='width:60px;position:relative;top:50%;left:50%;transform:translate(-50%,-50%);' src='"+messageArray[1]+"'></div> </div> ";}else{
chat=chat+"<div style='display:block;margin-bottom:10px;' align='right'><div style='margin:20px;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%)'>"+messageArray[1]+"</div></div> </div> ";
}
chat=chat+"<div style='padding:10px 10px; overflow:hidden;display:block;background-color:whitesmoke;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;margin-bottom:10px;'><div style='white-space: pre-wrap;'>"+messageArray[4]+"</div><div style='margin-top:10px;color:gray;text-align:right;'>"+messageArray[2]+" | "+messageArray[3]+"</div></div>";}
else{

if(messageArray[2].length>2){
chat=chat+"<div style='display:block;margin-bottom:10px;' ><div style='margin:20px;width:60px;height:60px;-moz-border-radius:30px;-webkit-border-radius:30px;border-radius:30px;overflow:hidden;'><img style='width:60px;position:relative;top:50%;left:50%;transform:translate(-50%,-50%);' src='"+messageArray[1]+"'></div> </div>";}else{
chat=chat+"<div style='display:block;margin-bottom:10px;' ><div style='margin:20px;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%)'>"+messageArray[1]+"</div></div> </div> ";}

chat=chat+"<div style='padding:10px 10px; overflow:hidden;display:block;background-color:whitesmoke;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;margin-bottom:10px;'><div style='white-space: pre-wrap;'>"+messageArray[4]+"</div><div style='margin-top:10px;color:gray;text-align:right;'>"+messageArray[2]+" | "+messageArray[3]+"</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="<xml style='white-space: pre-wrap;font:18px Calibri'>"+myProfileDescriptionToSave+"</xml>";
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+"'>";}}}
}
}