aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/scripts3.js376
1 files changed, 5 insertions, 371 deletions
diff --git a/web/scripts3.js b/web/scripts3.js
index 8445ee198..2b12bfbd6 100644
--- a/web/scripts3.js
+++ b/web/scripts3.js
@@ -1,18 +1,5 @@
+/*
var ws=null;
-var currentPMUser="";
-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);
@@ -31,11 +18,11 @@ function initWS() {
try {
var jsonMsg=$.parseJSON(msg.data);
if(jsonMsg.rid>0) {
- incomingComment(jsonMsg);
+ //incomingComment(jsonMsg);
} else if(jsonMsg.mid>0) {
- incomingPost(jsonMsg);
+ //incomingPost(jsonMsg);
} else {
- incomingPM(jsonMsg);
+ //incomingPM(jsonMsg);
}
} catch(err) {
console.log(err);
@@ -50,353 +37,7 @@ function wsSendKeepAlive() {
ws.send(' ');
}
}
-
-/******************************************************************************/
-
-function initPMUList() {
- var ul=$('#pmulist');
- 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","#chat/"+item.uname);
- a.append(img).append(item.uname);
- if(item.MessagesCount) {
- a.append($("<div/>").attr("class","unreadcnt").text(item.MessagesCount));
- }
- var li=$("<li/>").append(a);
- ul.append(li);
- });
-}
-
-/******************************************************************************/
-
-function incomingPost(msg) {
- console.log(msg);
- if(groups[0].MessagesCount>0) {
- groups[0].MessagesCount++;
- } else {
- groups[0].MessagesCount=1;
- }
- initGroupsList();
-}
-
-function incomingComment(msg) {
- console.log(msg);
-}
-
-function showGroup(gid) {
- currentPMUser="";
- currentMID=0;
- groups[0].MessagesCount=0;
- initGroupsList();
-
- $.getJSON('https://api.juick.com/home?hash='+hash+'&callback=?').done(function(data) {
- var ul=$('<ul/>');
- ul.attr("id","msglist");
- $.each(data,function(i,item) {
- var tags="";
- if(item.tags) {
- $.each(item.tags,function(t,tag) {
- tags+=" *"+tag;
- });
- }
- var photo="";
- if(item.photo) {
- photo="<div class=\"msg-media\"><img src=\""+item.photo.small+"\"/></div>";
- }
- var replies="";
- if(item.replies>0) {
- replies="<div class=\"msg-replies\"><a href=\"#\" onclick=\"return showMessage("+item.mid+")\">"+item.replies+" ";
- if(item.replies%10==1) {
- replies+="reply";
- } else {
- replies+="replies";
- }
- replies+=" </a>";
- if(item.repliesby) {
- replies+=" by "+item.repliesby;
- }
- replies+="</div>";
- }
- var li=$("<li/>").attr("class","msg").html(
- "<div class=\"msg-header\">"+
- "<div class=\"msg-menu\"></div>"+
- "<div class=\"msg-avatar\"><a href=\"#\" onclick=\"return showUser('"+item.user.uname+"')\"><img src=\"//i.juick.com/a/"+item.user.uid+".png\"/></a></div>"+
- "<div class=\"msg-uname\"><a href=\"#\" onclick=\"return showUser('"+item.user.uname+"')\">@"+item.user.uname+"</a>:"+tags+"</div>"+
- "<div class=\"msg-ts\"><a href=\"#\" onclick=\"return showMessage("+item.mid+")\">"+item.timestamp+"</a></div>"+
- "</div>"+
- "<div class=\"msg-txt\">"+item.body+"</div>"+
- photo+
- "<div class=\"msg-comment\"><div class=\"ta-wrapper\"><textarea id=\"tareply-"+item.mid+"\" name=\"body\" rows=\"1\" class=\"reply\" placeholder=\"Add a comment...\" onkeypress=\"postformListener(this.form,event)\"></textarea></div></div>"+
- replies
- );
- ul.append(li);
- });
- $('#toppanel').css("display","none");
- $('#bottompanel').css("display","none");
- var content=$('#content');
- content.attr("class","");
- content.empty();
- content.append(ul);
- $(window).scrollTop(0);
- });
- return false;
-}
-
-function showMessages(param) {
- currentPMUser="";
- currentMID=0;
- $.getJSON('https://api.juick.com/messages?hash='+hash+'&'+param+'&callback=?').done(function(data) {
- var ul=$('<ul/>');
- ul.attr("id","msglist");
- $.each(data,function(i,item) {
- var tags="";
- if(item.tags) {
- $.each(item.tags,function(t,tag) {
- tags+=" *"+tag+"</a>";
- });
- }
- var photo="";
- if(item.photo) {
- photo="<div class=\"msg-media\"><img src=\""+item.photo.small+"\"/></div>";
- }
- var replies="";
- if(item.replies>0) {
- replies="<div class=\"msg-replies\"><a href=\"#\" onclick=\"return showMessage("+item.mid+")\">"+item.replies+" ";
- if(item.replies%10==1) {
- replies+="reply";
- } else {
- replies+="replies";
- }
- replies+=" </a>";
- if(item.repliesby) {
- replies+=" by "+item.repliesby;
- }
- replies+="</div>";
- }
- var li=$("<li/>").attr("class","msg").html(
- "<div class=\"msg-header\">"+
- "<div class=\"msg-menu\"></div>"+
- "<div class=\"msg-avatar\"><a href=\"#\" onclick=\"return showUser('"+item.user.uname+"')\"><img src=\"//i.juick.com/a/"+item.user.uid+".png\"/></a></div>"+
- "<div class=\"msg-uname\"><a href=\"#\" onclick=\"return showUser('"+item.user.uname+"')\">@"+item.user.uname+"</a>:"+tags+"</div>"+
- "<div class=\"msg-ts\"><a href=\"#\" onclick=\"return showMessage("+item.mid+")\">"+item.timestamp+"</a></div>"+
- "</div>"+
- "<div class=\"msg-txt\">"+item.body+"</div>"+
- photo+
- "<div class=\"msg-comment\"><div class=\"ta-wrapper\"><textarea name=\"body\" rows=\"1\" class=\"reply\" placeholder=\"Add a comment...\" onkeypress=\"postformListener(this.form,event)\"></textarea></div></div>"+
- replies
- );
- ul.append(li);
- });
- $('#toppanel').css("display","none");
- $('#bottompanel').css("display","none");
- var content=$('#content');
- content.attr("class","");
- content.empty();
- content.append(ul);
- $(window).scrollTop(0);
- });
- return false;
-}
-
-/******************************************************************************/
-
-function showUser(uname) {
- showMessages('uname='+uname);
- return false;
-}
-
-/******************************************************************************/
-
-function showMessage(mid) {
- currentPMUser="";
- currentMID=mid;
- $.getJSON('https://api.juick.com/thread?mid='+mid+'&hash='+hash+'&callback=?').done(function(data) {
- var ul=$('<ul/>');
- ul.attr("id","thread");
-
- var post=data.shift();
- var tags="";
- if(post.tags) {
- $.each(post.tags,function(t,tag) {
- tags+=" *"+tag+"</a>";
- });
- }
- var photo="";
- if(post.photo) {
- photo="<div class=\"msg-media\"><img src=\""+post.photo.small+"\"/></div>";
- }
- var li=$("<li/>").attr("class","msg").html(
- "<div class=\"msg-header\">"+
- "<div class=\"msg-menu\"></div>"+
- "<div class=\"msg-avatar\"><a href=\"#\" onclick=\"return showUser('"+post.user.uname+"')\"><img src=\"//i.juick.com/a/"+post.user.uid+".png\"/></a></div>"+
- "<div class=\"msg-uname\"><a href=\"#\" onclick=\"return showUser('"+post.user.uname+"')\">@"+post.user.uname+"</a>:"+tags+"</div>"+
- "<div class=\"msg-ts\">"+post.timestamp+"</div>"+
- "</div>"+
- "<div class=\"msg-txt\">"+post.body+"</div>"+
- photo+
- "<div class=\"msg-comment\"><div class=\"ta-wrapper\"><textarea name=\"body\" rows=\"1\" class=\"reply\" placeholder=\"Add a comment...\" onkeypress=\"postformListener(this.form,event)\"></textarea></div></div>"
- );
- ul.append(li);
-
- var content=$('#content');
- var maxmargin=content.width()-li.width()-50;
-
- var start,end;
- start=new Date();
- showThread(ul,data,0,20,maxmargin);
- end=new Date();
- console.log("Execution time: "+(end.getTime()-start.getTime()));
-
- $('#toppanel').css("display","none");
- $('#bottompanel').css("display","none");
- content.attr("class","");
- content.empty();
- content.append($('<div/>').attr("id","threadwrap").append(ul));
- $(window).scrollTop(0);
- });
- return false;
-}
-
-function showThread(ul,data,rid,margin,maxmargin) {
- $.each(data,function(i,item) {
- var replyto=item.replyto || 0;
- if(replyto==rid) {
- var photo="";
- if(item.photo) {
- photo="<div class=\"msg-media\"><img src=\""+item.photo.small+"\"/></div>";
- }
- var li=$("<li/>").attr("class","msg").css("margin-left",margin).html(
- "<div class=\"msg-header\">"+
- "<div class=\"msg-menu\"></div>"+
- "<div class=\"msg-avatar\"><a href=\"#\" onclick=\"return showUser('"+item.user.uname+"')\"><img src=\"//i.juick.com/a/"+item.user.uid+".png\"/></a></div>"+
- "<div class=\"msg-uname\"><a href=\"#\" onclick=\"return showUser('"+item.user.uname+"')\">@"+item.user.uname+"</a>:</div>"+
- "<div class=\"msg-ts\">"+item.timestamp+"</div>"+
- "</div>"+
- "<div class=\"msg-txt\">"+item.body+"</div>"+
- photo//+
- //"<div class=\"msg-comment\"><textarea name=\"body\" rows=\"1\" class=\"reply\" placeholder=\"Add a comment...\" onkeypress=\"postformListener(this.form,event)\"></textarea></div>"
- );
- ul.append(li);
-
- var newmargin=margin+20;
- if(newmargin>maxmargin) {
- newmargin=maxmargin;
- }
- showThread(ul,data.slice(i),item.rid,newmargin,maxmargin);
- }
- });
-}
-
-/******************************************************************************/
-
-function incomingPM(msg) {
- try {
- if(msg.user.uname===currentPMUser) {
- $('#pmlist').append($("<li/>").attr("class","pm-in").text(msg.body));
- $(window).scrollTop($(document).height());
- } else {
- var modified=false;
- $.each(lastConversations,function(i,item) {
- if(item.uname===msg.user.uname) {
- if(item.MessagesCount>0) {
- item.MessagesCount++;
- } else {
- item.MessagesCount=1;
- }
- modified=true;
- }
- });
- if(!modified) {
- lastConversations.unshift({
- uname:msg.user.uname,
- uid:msg.user.uid,
- MessagesCount:"1"
- });
- }
- initPMUList();
- }
- } catch(err) { }
-}
-
-function showPM(uname) {
- currentMID=0;
-
- var modified=false;
- $.each(lastConversations,function(i,item) {
- if(item.uname===uname && item.MessagesCount>0) {
- item.MessagesCount=0;
- modified=true;
- }
- });
- if(modified) {
- 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=$('#pmlist');
- $.each(data,function(i,item) {
- var li=$("<li/>");
- if(item.user.uid==user_id) {
- li.attr("class","pm-out");
- } else {
- li.attr("class","pm-in");
- }
- li.text(item.body);
- ul.append(li);
- });
- $(window).scrollTop($(document).height());
- });
- return false;
-}
-
-function sendPMformListener(formEl,ev) {
- if(ev.ctrlKey && (ev.keyCode==10 || ev.keyCode==13)) {
- sendPM();
- }
-}
-
-function sendPM() {
- var replypmtext=$('#pmreplytext');
- var replypmbutton=$('#pmreplybutton');
- replypmtext.prop('disabled', true);
- replypmbutton.prop('disabled', true);
-
- var body=replypmtext.val();
-
- $.ajax({
- url:"https://api.juick.com/pm",
- type:"POST",
- data:{
- hash:hash,
- uname:currentPMUser,
- body:body
- },
- success:function(data) {
- replypmtext.val("");
- $('#pmlist').append($("<li/>").attr("class","pm-out").text(body));
- $(window).scrollTop($(document).height());
- },
- error:function(jqxhr,status) {
- alert("Error: "+status);
- },
- complete:function() {
- replypmtext.removeAttr("disabled");
- replypmbutton.removeAttr("disabled");
- replypmtext.focus();
- }
- });
- return false;
-}
+*/
/******************************************************************************/
/******************************************************************************/
@@ -819,10 +460,6 @@ jQuery.fn.selectText = function(){
/******************************************************************************/
$(document).ready(function() {
- if(typeof lastConversations != 'undefined') {
- initPMUList();
- }
-
var tareply=$('textarea.reply');
tareply.autoResize({
extraSpace: 0,
@@ -848,7 +485,4 @@ $(document).ready(function() {
unfoldReply();
$(window).bind('hashchange',unfoldReply);
-
- initPage();
- $(window).bind('hashchange',initPage);
});