Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22393819
konwersacje.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
3 KB
Referenced Files
None
Subscribers
None
konwersacje.html
View Options
<!DOCTYPE html>
<
html
>
<
head
>
<
script
src
=
"/jquery.js"
></
script
>
<
meta
charset
=
"utf-8"
>
<
title
>
Lista konwersacji
</
title
>
<
style
>
html
{
background-color
:
gray
;
}
body
{
padding
:
20
px
;
background-color
:
white
;
font-family
:
sans-serif
;
max-width
:
50
rem
;
margin
:
0
auto
;
}
.
email
{
color
:
gray
;
font-size
:
0.8
em
;
}
</
style
>
</
head
>
<
body
>
<
nav
>
<
a
href
=
"/"
>
Menu główne
</
a
>
</
nav
>
<
center
><
h1
>
Lista konwersacji
</
h1
></
center
>
<
ul
id
=
"lista-konwersacji"
>
</
ul
>
<
input
type
=
"text"
placeholder
=
"Tytuł konwersacji"
id
=
"title"
>
<
select
id
=
"user2"
></
select
>
<
button
id
=
"confirm"
onclick
=
"addNewConversation()"
>
Dodaj
</
button
>
</
body
>
<
script
>
//function getAllUsers(){
var
users
;
$
.
get
(
"/api/v1/users"
,
function
(
data
){
for
(
var
i
in
data
){
users
=
data
;
var
entry
=
data
[
i
];
$
(
"#user2"
).
append
(
$
(
"<option value='"
+
entry
.
user_id
+
"'>"
+
entry
.
username
+
"</option>"
));
}
});
var
me
;
$
get
(
"api/v1/users/me"
,
function
(
user_data
){
me
=
user_data
.
user_id
;
})
function
findById
(
users
,
id
){
for
(
var
i
in
users
){
if
(
users
[
i
].
user_id
==
id
){
return
users
[
i
].
username
;
}
}
}
function
readConversations
(){
$
(
"#lista-konwersacji"
).
html
(
""
);
$
.
get
(
"/api/v1/chat/conversation"
,
function
(
data
)
{
console
.
log
(
data
);
for
(
var
i
in
data
)
{
var
entry
=
data
[
i
];
console
.
log
(
entry
);
var
node
=
$
(
"<li id='"
+
entry
.
id
+
"'><a href='konwersacja.html#"
+
entry
.
id
+
"'>"
+
entry
.
title
+
"</a><i> rozmowa z użytkownikiem: "
+
findById
(
users
,
entry
.
user2
)
+
" </i> <button onclick='deleteCoversation("
+
entry
.
id
+
")'>Usuń</button>"
);
var
selectMode
=
$
(
"<select class='access_mode'><option value='private' >Prywatna</option><option value='public'>Publiczna</option></select>"
);
node
.
append
(
selectMode
);
selectMode
.
val
(
entry
.
access_mode
);
$
(
"#lista-konwersacji"
).
append
(
node
);
}
});
}
function
addNewConversation
(){
var
title
=
$
(
"#title"
).
val
();
var
user2
=
$
(
"#user2"
).
val
();
$
.
post
(
"/api/v1/chat/conversation"
,
{
title
:
title
,
user2
:
user2
},
function
(
result
)
{
if
(
result
){
readConversations
();
}
else
{
document
.
location
.
href
=
"/login.html"
;
}
});
}
function
deleteCoversation
(
conversation_id
){
$
.
ajax
({
url
:
'/api/v1/chat/conversation'
,
data
:
{
id
:
conversation_id
},
type
:
'DELETE'
,
success
:
function
(
result
)
{
readConversations
();
}
});
}
function
editAccessMode
(
conversation_id
,
new_access_mode
){
$
.
ajax
({
url
:
'/api/v1/chat/conversation/'
+
conversation_id
+
'/access_mode'
,
data
:
{
access_mode
:
new_access_mode
},
type
:
'PUT'
,
success
:
function
(
result
){
readConversations
();
}
})
}
function
getAccessMode
(
conversation_id
,
callback
){
$
.
get
(
"/api/v1/chat/conversation/"
+
conversation_id
+
"/access_mode"
,
function
(
data
)
{
callback
(
data
);
});
}
$
(
document
).
ready
(
function
(){
$
(
document
).
on
(
"change"
,
"select.access_mode"
,
function
(
e
){
console
.
log
(
"dupa"
);
var
id
=
$
(
this
).
parent
().
attr
(
"id"
);
var
access_mode
=
$
(
this
).
val
();
editAccessMode
(
id
,
access_mode
);
});
});
readConversations
();
</
script
>
</
html
>
File Metadata
Details
Attached
Mime Type
text/html
Expires
Fri, Nov 27, 16:10 (1 d, 16 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1227648
Default Alt Text
konwersacje.html (3 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline