mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 00:49:28 -05:00
webgui: first steps in chat
This commit is contained in:
parent
2fed36a029
commit
f4c68a1016
@ -1,5 +1,5 @@
|
|||||||
.chat
|
.chat
|
||||||
$color: lightblue
|
$color: black
|
||||||
$header_height: 50px
|
$header_height: 50px
|
||||||
$left_width: 200px
|
$left_width: 200px
|
||||||
$right_width: 200px
|
$right_width: 200px
|
||||||
@ -26,7 +26,7 @@
|
|||||||
width: $left_width
|
width: $left_width
|
||||||
border-right: solid 1px gray
|
border-right: solid 1px gray
|
||||||
box-sizing: border-box
|
box-sizing: border-box
|
||||||
background-color: lightgray
|
background-color: black
|
||||||
&.right
|
&.right
|
||||||
position: absolute
|
position: absolute
|
||||||
top: $header_height
|
top: $header_height
|
||||||
@ -59,7 +59,7 @@
|
|||||||
width: $author_width
|
width: $author_width
|
||||||
top: 10px
|
top: 10px
|
||||||
left: 0px
|
left: 0px
|
||||||
color: gray
|
color: white
|
||||||
text-align: right
|
text-align: right
|
||||||
&.when
|
&.when
|
||||||
float: right
|
float: right
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var m = require("mithril");
|
var m = require("mithril");
|
||||||
|
var rs = require("retroshare");
|
||||||
|
|
||||||
function msg(from, when, text){
|
function msg(from, when, text){
|
||||||
return m(".chat.msg.container",[
|
return m(".chat.msg.container",[
|
||||||
@ -10,18 +11,59 @@ function msg(from, when, text){
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function lobbies(){
|
||||||
|
var lobs = rs("chat/lobbies");
|
||||||
|
if (lobs === undefined) {
|
||||||
|
return m("div","loading ...")
|
||||||
|
};
|
||||||
|
var dta = lobs.map(function (lobby){
|
||||||
|
return m("div.btn",{
|
||||||
|
title: "topic: " + lobby.topic + "\n"
|
||||||
|
+ "subscribed: " + lobby.subscribed,
|
||||||
|
onclick: function(){
|
||||||
|
m.route("/chat?lobby=" + lobby.chat_id);
|
||||||
|
}
|
||||||
|
},lobby.name + (lobby.unread_msg_count > 0 ? ("(" + lobby.unread_msg_count + ")") : ""));
|
||||||
|
});
|
||||||
|
return dta;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function lobby(lobbyid){
|
||||||
|
var msgs = rs("chat/messages/" + lobbyid);
|
||||||
|
var info = rs("chat/info/" + lobbyid);
|
||||||
|
if (msgs === undefined || info === undefined) {
|
||||||
|
return m("div","waiting ...");
|
||||||
|
}
|
||||||
|
return msgs.map(function(item){
|
||||||
|
var d = new Date(new Number(item.send_time)*1000);
|
||||||
|
return msg(item.author_name, d.toLocaleDateString() + " " + d.toLocaleTimeString(),item.msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
view: function(){
|
frame: function(content, right){
|
||||||
return m(".chat.container", [
|
return m(".chat.container", [
|
||||||
m(".chat.header", "headerbar"),
|
m(".chat.header", "headerbar"),
|
||||||
m(".chat.left", "left"),
|
m(".chat.left", [
|
||||||
m(".chat.right", "right"),
|
m("div.chat.header","lobbies:"),
|
||||||
m(".chat.middle", [
|
m("hr"),
|
||||||
msg("Andi", "now", "Hallo"),
|
lobbies(),
|
||||||
msg("Test", "now", "Hallo back"),
|
|
||||||
msg("Somebody", "now", "Hallo back, sfjhfu dsjkchsd wehfskf sdjksdf sjdnfkjsf sdjkfhjksdf jksdfjksdnf sjdefhsjkn cesjdfhsjk fskldcjhsklc ksdj"),
|
|
||||||
]),
|
]),
|
||||||
|
m(".chat.right", right),
|
||||||
|
m(".chat.middle", content),
|
||||||
m(".chat.clear", ""),
|
m(".chat.clear", ""),
|
||||||
]);
|
]);
|
||||||
|
},
|
||||||
|
view: function(){
|
||||||
|
var lobbyid = m.route.param("lobby");
|
||||||
|
if (lobbyid != undefined ) {
|
||||||
|
return this.frame(
|
||||||
|
lobby(lobbyid),[]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
return this.frame(
|
||||||
|
m("div", "please select lobby"),
|
||||||
|
m("div","right"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user