aboutsummaryrefslogtreecommitdiff
path: root/web/scripts3.js
diff options
context:
space:
mode:
authorGravatar Ugnich Anton2013-12-10 00:16:54 +0700
committerGravatar Ugnich Anton2013-12-10 00:16:54 +0700
commit522dc220a02c36e208935e9f6789c547616269e4 (patch)
tree6922262c7876b1e2e44f4a549200cca6ccdaaff2 /web/scripts3.js
parent3184680827e2a611e71c57dd2a74c4e7e754b8a6 (diff)
#chat/username links
Diffstat (limited to 'web/scripts3.js')
-rw-r--r--web/scripts3.js37
1 files changed, 24 insertions, 13 deletions
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);
});