Toby Chui 6 роки тому
батько
коміт
f5c57a953a

+ 25 - 14
src/index.php

@@ -33,16 +33,20 @@ $userIcon = getUserIconPath();
 var activeChat = "";
 
 function showChat(id) {
-	
-  var x = document.getElementById("chatPop");
-  if (x.style.visibility === "hidden") {
-    x.style.visibility = "visible";
-  } else if(activeChat == id){
-    x.style.visibility = "hidden";
-  }
-  activeChat = id;
-  refresh();
-  document.getElementById("chatTarget").innerHTML = activeChat;
+	//alert(id + "," + activeChat);
+	if (activeChat == id){
+		$("#chatPop").hide();
+		activeChat = "";
+	}else{
+		$("#chatPop").show();
+		activeChat = id;
+	}
+	refresh();
+	document.getElementById("chatTarget").innerHTML = activeChat;
+	//Scroll to the bottom of the chat record
+    setTimeout(function(){
+		$('#chatHistory').scrollTop($('#chatHistory')[0].scrollHeight);
+	},500);
 } 
 
 function update() {
@@ -60,11 +64,18 @@ function update() {
 	xhttp.open("POST", "getChatHistory.php", true);
 	xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
 	xhttp.send("touser="+touser+"&fromuser="+fromuser+"&message="+myText);
+	//Scroll to the bottom of the chat record
+	setTimeout(function(){
+		$('#chatHistory').scrollTop($('#chatHistory')[0].scrollHeight);
+	},500);
+    
   }
   document.getElementById("message").value = "";
   
   var objDiv = document.getElementById("chatHistory");
   objDiv.scrollTop = objDiv.scrollHeight;
+  
+ 
 }
 
 
@@ -125,7 +136,7 @@ setInterval(refresh,1000);
 }
 
 .chatroomWindow{
-	visibility: hidden;
+	display:none;
 	width:320px !important;
 	height:500px !important;
 	padding:5px !important;
@@ -209,7 +220,7 @@ setInterval(refresh,1000);
 		foreach ($followerResult as $chat){
 			echo '
 			<div class="ts nopadding comments">
-				<div class="comment selectable" id="'.$chat["targetName"].'"onClick="showChat(this.id)">
+				<div class="comment selectable">
 					<a class="avatar">
 						<img src="img/dummy.png">
 					</a>
@@ -219,7 +230,7 @@ setInterval(refresh,1000);
 							現時在線
 						</div>
 						<div class="middoted actions">
-							<a>
+							<a id="'.$chat["targetName"].'" onClick="showChat(this.id);">
 								<i class="comment online icon"></i> 打開聊天室
 							</a>
 						</div>
@@ -289,7 +300,7 @@ setInterval(refresh,1000);
 
 </div>
 
-<div class="chatroomWindow" id="chatPop">
+<div class="chatroomWindow" id="chatPop" style="position:fixed;right:0px;bottom:0px;z-index:999;">
 <script>
 refresh();
 </script>

+ 1 - 0
src/userdata/cookieseeds/1573980966.auth

@@ -0,0 +1 @@
+969d60098405a8eb1ab15498bbdeae29cf321cbcfe5a4149c3db7348f9fd2589de0d73ac2c2bfaa23bb7ba32b3ea6a98c58bb94892dc8adad215bb3b58efadec

+ 1 - 0
src/userdata/cookieseeds/1574863419.auth

@@ -0,0 +1 @@
+ee08f68dd64a34c2ac675d45ac4277bd2f027eb3df0b2edff382f416250d14b795f01fde8519209a27b6116df62a254c04f39da487217e41752d0ed7093c43af