Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22419164
konwersacja.html
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
konwersacja.html
View Options
<!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
style
=
"width: 25rem;"
>
<
div
class
=
"content"
>
<
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ść"
></
textarea
>
<
button
id
=
"confirm"
onclick
=
"sendMessage()"
>
Wyślij
</
button
>
</
div
>
</
body
>
<
script
>
Auth
.
redirect_if_not_logged_in
();
var
me
;
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
getCurrentUserID
(
callback
){
$
.
get
(
"api/v1/users/me"
,
function
(
user_data
){
me
=
user_data
.
user_id
;
callback
();
});
}
function
readMessages
(){
console
.
log
(
"read messages"
);
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
;
if
(
entry
.
message
.
trim
()
!=
""
){
if
(
entry
.
owner_id
==
me
){
node
=
$
(
"<li class='message incoming'>"
+
entry
.
message
+
"</li>"
);
}
else
{
node
=
$
(
"<li class='message'><div class='poitner'></div>"
+
entry
.
message
+
"</li>"
);
}
message_list
.
append
(
node
);
}
}
});
}
function
sendMessage
(){
var
message
=
$
(
"#message-box"
).
val
();
if
(
message
.
trim
()
!=
""
){
$
.
post
(
"/api/v1/chat/message"
,
{
message
:
message
,
conversation_id
:
conversation_id
},
function
()
{
readMessages
();
});
}
else
{
alert
(
"Może najpierw coś napisz?"
);
}
$
(
"#message-box"
).
val
(
""
);
}
$
(
"#message-box"
).
keydown
(
function
(
e
){
if
(
e
.
which
==
13
){
sendMessage
();
}
});
getCurrentUserID
(
readMessages
);
getTitle
();
//setInterval(readMessages, 500);
</
script
>
</
html
>
File Metadata
Details
Attached
Mime Type
text/html
Expires
Sat, Nov 28, 02:19 (1 d, 16 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1230044
Default Alt Text
konwersacja.html (2 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline