Page MenuHomeSealhub

konwersacja.html
No OneTemporary

konwersacja.html

<!DOCTYPE html>
<html>
<head>
<script src="/jquery.js"></script>
<script src="/authorization.js"></script>
<meta charset="utf-8">
<title>Konwersacja</title>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<a href="/">Menu główne</a> > <a href="/konwersacje.html">Konwersacje</a>
<center><h1>Konwersacja: <span class="insert-conversation-name"></span></h1></center>
<ul id="lista-wiadomosci">
</ul>
<input type="text" id="message-box" placeholder="Nowa wiadomość">
<button id="confirm" onclick="sendMessage()">Wyślij</button>
</body>
<script>
Auth.redirect_if_not_logged_in();
var conversation_id = document.location.hash.slice(1);
var base_url = "/api/v1/chat/conversation/" + conversation_id + "/messages";
function getTitle() {
$.get("/api/v1/chat/conversation/"+conversation_id, function(data) {
$(".insert-conversation-name").text(data.title);
});
}
function readMessages(){
var message_list = $("#lista-wiadomosci");
message_list.html("");
$.get(base_url, function(data) {
console.log(data);
for(var i in data) {
var entry = data[i];
var node = $("<li>"+entry.message+"</li>");
message_list.append(node);
}
});
}
function sendMessage(){
var message = $("#message-box").val();
$.post("/api/v1/chat/message", {message: message, conversation_id: conversation_id}, function() {
readMessages();
});
$("#message-box").val("");
}
$("#message-box").keydown(function(e){
if(e.which==13){
sendMessage();
}
});
getTitle();
readMessages();
</script>
</html>

File Metadata

Mime Type
text/html
Expires
Sat, Sep 20, 14:43 (1 d, 4 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
949290
Default Alt Text
konwersacja.html (1 KB)

Event Timeline