Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gualter
matrix-sustrares-blog
Commits
23fb8363
Commit
23fb8363
authored
Sep 01, 2016
by
jon r
Browse files
merge: master
parent
90d8bff3
Changes
2
Hide whitespace changes
Inline
Side-by-side
index.html
View file @
23fb8363
...
...
@@ -97,7 +97,7 @@ time {
<body>
<div
id=
"chat"
>
Loading...
</div>
<script
type=
"text/javascript"
>
var
blog
=
new
MatrixBlog
({
var
chat
=
new
MatrixBlog
({
selector
:
'
#chat
'
,
room
:
'
#degrowth2016:matrix.org
'
,
homeServer
:
'
https://matrix.org
'
...
...
matrix-blog.js
View file @
23fb8363
...
...
@@ -10,7 +10,7 @@ var MatrixBlog = function(settings) {
this
.
client
=
matrixcs
.
createClient
({
baseUrl
:
settings
.
homeServer
});
console
.
log
(
this
.
client
);
this
.
roomId
=
null
;
this
.
endKey
=
null
;
this
.
$posts
=
$
(
'
<ul class="posts">
'
);
...
...
@@ -20,7 +20,7 @@ var MatrixBlog = function(settings) {
this
.
client
.
getRoomIdForAlias
(
this
.
settings
.
room
,
function
(
err
,
data
)
{
var
$root
=
$
(
self
.
settings
.
selector
);
self
.
roomId
=
data
.
room_id
;
console
.
log
(
data
);
// client.sendTyping(roomId, true, 5000, function (err, data) {})
// fetch the last 50 events from our room as inital state
...
...
@@ -39,6 +39,15 @@ var MatrixBlog = function(settings) {
// self.processPresence(evt, user);
// });
// http://stackoverflow.com/a/5347882/1959568
// this.$posts.children().each(function(i,li){this.$posts.prepend(li)});
/*
var $posts = $("ul.posts");
var i = $posts.childNodes.length;
while (i--)
$posts.appendChild($posts.childNodes[i]);
*/
self
.
client
.
registerGuest
({},
function
(
err
,
data
)
{
self
.
client
.
_http
.
opts
.
accessToken
=
data
.
access_token
;
self
.
client
.
credentials
.
userId
=
data
.
user_id
;
...
...
@@ -117,16 +126,22 @@ MatrixBlog.prototype.processChunk = function(message) {
var
info
=
this
.
getUserInfo
(
message
.
getSender
());
$user
.
append
(
$
(
'
<span class="nick">
'
).
text
(
info
.
nick
));
$user
.
append
(
$
(
"
<time>
"
).
text
(
this
.
makeTimeString
(
message
.
getTs
())));
// TODO: x
}
else
{
var
$item
=
$
(
"
ul.posts li:first
"
);
// TODO: y
}
if
(
message
.
event
.
content
.
msgtype
==
'
m.text
'
)
{
$item
.
addClass
(
'
text
'
);
var
$body
=
$
(
'
<div class="body">
'
).
text
(
message
.
event
.
content
.
body
);
$item
.
p
re
pend
(
$user
);
$item
.
p
re
pend
(
$body
);
$item
.
a
ppend
(
$user
);
$item
.
a
ppend
(
$body
);
}
else
if
(
message
.
event
.
content
.
msgtype
==
'
m.image
'
)
{
$item
.
addClass
(
'
image
'
);
...
...
@@ -142,7 +157,9 @@ MatrixBlog.prototype.processChunk = function(message) {
var
body
=
$
(
'
<div class="body">
'
).
text
(
message
.
getSender
()
+
"
"
+
message
.
event
.
content
.
body
);
$item
.
append
(
body
);
}
this
.
$posts
.
prepend
(
$item
);
this
.
last
=
{
userId
:
message
.
getSender
(),
ts
:
message
.
getTs
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment