~qeef/damn-client.js

f33dba2d130e44a6f1c992b3162dd661ce1aabb0 — Jiri Vlasak 3 months ago c6cd4bd
Filter area in chat
1 files changed, 16 insertions(+), 3 deletions(-)

M static/chat.js
M static/chat.js => static/chat.js +16 -3
@@ 1,10 1,18 @@
function html_message(msg)
{
    const w = document.getElementById("chat_within");
    if (parseInt(w.value) > 0 && parseInt(w.value) != msg["aid"]) {
        return "";
    }
    var d = new Date(msg["tim"]);
    var ih = "";
    ih += "<br />";
    ih += "<small>" + d.toLocaleTimeString() + "</small>";
    ih += " <em>" + msg["usr"] + "</em>:";
    ih += " <em>" + msg["usr"];
    if (msg["aid"] > 0) {
        ih += " to " + msg["aid"];
    }
    ih += "</em>:";
    ih += " " + msg["msg"];
    return ih;
}


@@ 72,11 80,16 @@ function send_msg(e)
        var user = api.user()["display_name"];
        var token = api.token();
        const t = msg.value;
        ws.send(JSON.stringify({
        const w = document.getElementById("chat_within");
        var msg_to_send = {
            "usr": user,
            "msg": t,
            "jwt": token,
        }));
        };
        if (parseInt(w.value) > 0) {
            msg_to_send["aid"] = parseInt(w.value);
        }
        ws.send(JSON.stringify(msg_to_send));
        msg.value = "";
    }
}