|
|
@@ -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>
|