webui: chat: sending messages

This commit is contained in:
zeners 2016-02-20 19:37:31 +01:00
parent fdb93c3f8d
commit b8a8f34a48
3 changed files with 67 additions and 26 deletions

View File

@ -43,7 +43,7 @@ google material design has nice rules for color, spacing and everything: https:/
should provide forward, backward and follow-list-end
[ ] backend: view/create identities
[ ] backend: chat lobby participants list
[ ] chat: send_message
[X] chat: send_message
[ ] backend: chat typing notifications
[ ] make routines to handle retroshare links
[ ] backend: edit shared folders

View File

@ -45,7 +45,11 @@
padding-top: 0px
padding-left: 0px
padding-right: 0px
&.bottom
position: absolute
bottom: 0px
right: $right_width
left: $left_width
&.msg
padding: 0px
$author_width: 100px

View File

@ -3,7 +3,9 @@
var m = require("mithril");
var rs = require("retroshare");
function msg(from, when, text){
var msg = null;
function dspmsg(from, when, text){
return m(".chat.msg.container",[
m(".chat.msg.from", from),
m(".chat.msg.when", when),
@ -45,6 +47,15 @@ function getLobbyDetails(lobbyid){
return null;
}
function sendmsg(msgid){
var txtmsg = document.getElementById("txtNewMsg");
rs.request("chat/send_message", {
chat_id: msgid,
msg: txtmsg.value
});
txtmsg.value="";
}
function lobby(lobbyid){
var msgs;
var lobby = getLobbyDetails(lobbyid);
@ -100,12 +111,30 @@ function lobby(lobbyid){
},"subscribe as " + item.name);
}),
];
} else {
msg = m(".chat.bottom",[
m("div","enter new message:"),
m("input",{
id:"txtNewMsg",
onkeydown: function(event){
if (event.keyCode == 13){
sendmsg(lobbyid);
}
}
}),
m("div.btn2", {
style: {textAlign:"center"},
onclick: function(){
sendmsg(lobbyid);
}
},"submit")
]);
}
return [
intro,
mem.msg.map(function(item){
var d = new Date(new Number(item.send_time)*1000);
return msg(
return dspmsg(
item.author_name,
d.toLocaleDateString() + " " + d.toLocaleTimeString(),
item.msg
@ -116,7 +145,8 @@ function lobby(lobbyid){
module.exports = {
frame: function(content, right){
return m(".chat.container", [
return m("div", [
m(".chat.container", [
m(".chat.header", [
m(
"h2",
@ -132,13 +162,19 @@ module.exports = {
m(".chat.right", right),
m(".chat.middle", content),
m(".chat.clear", ""),
]),
msg != null
? msg
: [],
]);
},
view: function(){
var lobbyid = m.route.param("lobby");
msg = null;
if (lobbyid != undefined ) {
return this.frame(
lobby(lobbyid),[]
lobby(lobbyid),
[]
);
};
return this.frame(
@ -147,6 +183,7 @@ module.exports = {
{style: {margin:"10px"}},
"please select lobby"
),
m("div","right"));
m("div","right")
);
}
}