aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/java/com/juick/http/www/PageTemplates.java2
-rw-r--r--src/java/com/juick/http/www/User.java6
-rw-r--r--web/scripts3.js37
3 files changed, 28 insertions, 17 deletions
diff --git a/src/java/com/juick/http/www/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java
index 1c958bd1..768406d9 100644
--- a/src/java/com/juick/http/www/PageTemplates.java
+++ b/src/java/com/juick/http/www/PageTemplates.java
@@ -52,7 +52,7 @@ public class PageTemplates {
out.print("<head>");
out.print("<link rel=\"stylesheet\" href=\"/style.2013120400.css\"/>");
out.print("<script type=\"text/javascript\" src=\"//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js\" defer=\"defer\"></script>");
- out.print("<script type=\"text/javascript\" src=\"/scripts.2013120400.js\" defer=\"defer\"></script>");
+ out.print("<script type=\"text/javascript\" src=\"/scripts.2013120801.js\" defer=\"defer\"></script>");
if (headers != null) {
out.print(headers);
}
diff --git a/src/java/com/juick/http/www/User.java b/src/java/com/juick/http/www/User.java
index 5de54341..38910b01 100644
--- a/src/java/com/juick/http/www/User.java
+++ b/src/java/com/juick/http/www/User.java
@@ -304,9 +304,9 @@ public class User {
} else {
out.println(" <li><a href=\"/post?body=BL+%40" + user.UName + "\" title=\"" + rb.getString("(UToolbar) Block") + "\"><div style=\"background-position: -80px 0\"></div></a></li>");
}
-// if (!UserQueries.isInBL(sql, user.UID, visitor.UID) && !UserQueries.isInBL(sql, visitor.UID, user.UID)) {
-// out.println(" <li><a href=\"/post?body=PM+%40" + user.UName + "\" title=\"" + rb.getString("(UToolbar) Private") + "\"><div style=\"background-position: -112px 0\"></div></a></li>");
-// }
+ if (!UserQueries.isInBLAny(sql, user.UID, visitor.UID)) {
+ out.println(" <li><a href=\"/#chat/" + user.UName + "\" title=\"" + rb.getString("(UToolbar) Private") + "\"><div style=\"background-position: -112px 0\"></div></a></li>");
+ }
out.println(" </ul>");
} else {
out.println(" <hr/>");
diff --git a/web/scripts3.js b/web/scripts3.js
index dc2cc330..a8630b7e 100644
--- a/web/scripts3.js
+++ b/web/scripts3.js
@@ -4,6 +4,16 @@ var currentMID=0;
/******************************************************************************/
+function initPage() {
+ var url=window.location.hash.substring(1);
+ if(url.substr(0,5)==="chat/") {
+ var uname=url.substr(5);
+ showPM(uname);
+ }
+}
+
+/******************************************************************************/
+
function initWS() {
ws = new WebSocket("wss://ws.juick.com/?hash="+hash);
ws.onopen = function() {
@@ -48,7 +58,7 @@ function initPMUList() {
ul.empty();
$.each(lastConversations,function(i,item) {
var img=$("<img/>").attr("src","https://i.juick.com/as/"+item.uid+".png");
- var a=$("<a/>").attr("href","#").attr("onclick","return showPM('"+item.uname+"')");
+ var a=$("<a/>").attr("href","#chat/"+item.uname);
a.append(img).append(item.uname);
if(item.MessagesCount) {
a.append($("<div/>").attr("class","unreadcnt").text(item.MessagesCount));
@@ -323,9 +333,17 @@ function showPM(uname) {
initPMUList();
}
+ currentPMUser=uname;
+
+ var content=$('#content');
+ content.empty();
+ content.append($('<ul id="pmlist"/>'));
+ var sendform=$('<div id="pmreplyform"><input type="text" name="reply" id="pmreplytext" onkeypress="sendPMformListener(this.form,event)"/><input type="button" value=">" id="pmreplybutton" onclick="return sendPM()"/>');
+ content.append(sendform);
+ $('#pmreplytext').focus();
+
$.getJSON('https://api.juick.com/pm?hash='+hash+'&uname='+uname+'&callback=?').done(function(data) {
- var ul=$('<ul/>');
- ul.attr("id","pmlist");
+ var ul=$('#pmlist');
$.each(data,function(i,item) {
var li=$("<li/>");
if(item.user.uid==user_id) {
@@ -336,17 +354,7 @@ function showPM(uname) {
li.text(item.body);
ul.append(li);
});
-
- currentPMUser=uname;
-
- var sendform=$('<div id="pmreplyform"><input type="text" name="reply" id="pmreplytext" onkeypress="sendPMformListener(this.form,event)"/><input type="button" value=">" id="pmreplybutton" onclick="return sendPM()"/>');
-
- var content=$('#content');
- content.empty();
- content.append(ul);
- content.append(sendform);
$(window).scrollTop($(document).height());
- $('#pmreplytext').focus();
});
return false;
}
@@ -838,4 +846,7 @@ $(document).ready(function() {
unfoldReply();
$(window).bind('hashchange',unfoldReply);
+
+ initPage();
+ $(window).bind('hashchange',initPage);
});