Commit 5932eb57 authored by Aral Balkan's avatar Aral Balkan

Fixed the message timestamp keys.

parent b39d26bb
......@@ -316,7 +316,7 @@ app.get '/', require('./routes/public/public.coffee')(app)
#
# Ajax updates
# Ajax updates
#
app.get '/posts-after/:key', require('./routes/public/posts-after.coffee')(app)
......
......@@ -62,6 +62,23 @@ module.exports = (app) ->
# This should never happen and probably shows that some sort of corrupted date got through somehow.
return 'No date.'
# Format the post date
timestampFormatter = (messageID) ->
messageIDParserRegExp = /^(\d{9})?-?(\d{4}-\d{2}-\d{2}T\d{2}_\d{2}_\d{2}\.\d{3}Z)-?(.*)?/
matches = messageID.match messageIDParserRegExp
if matches != null
timestamp = matches[2]
# Desearialise the timestamp.
timestamp = timestamp.replace /_/g, ':'
return timestamp
else
# This should never happen and probably shows that some sort of corrupted ID got through somehow.
return (new Date())
# Format the person’s name
personFormatter = (messageID) ->
......
......@@ -75,6 +75,24 @@ window.addEventListener('load', function(){
return profileImagePath;
}
set.format['timestampFormatter'] = function (messageID) {
var messageIDParserRegExp = /^(\d{9})?-?(\d{4}-\d{2}-\d{2}T\d{2}_\d{2}_\d{2}\.\d{3}Z)-?(.*)?/;
var matches = messageID.match(messageIDParserRegExp);
if (matches != null) {
var timestamp = matches[2];
// Deserialise the timestamp.
timestamp = timestamp.replace(/_/g, ':');
return timestamp;
} else {
// This should never happen and probably shows that some sort of corrupted ID got through somehow.
return (new Date());
}
}
// Update the repeater node
set(repeaterNode, {messages: posts})
});
......
......@@ -25,7 +25,7 @@
<div class="image-and-body">
<img class="profileImage" data-set-attribute='src message.key profileImagePathFormatter'>
<div class="bodyText" data-set-text='html message.value'>Message body HTML</div>
<div class="meta"><span class='postDate' data-set-attribute='data-timestamp message.key' data-set-text='message.key postDateFormatter'></span><span data-set-text='message.key personFormatter'></span> <a data-set-attribute='href message.key addFriendLinkFormatter' data-set-text='html message.key addFriendTextFormatter'></a></div>
<div class="meta"><span class='postDate' data-set-attribute='data-timestamp message.key timestampFormatter' data-set-text='message.key postDateFormatter'></span><span data-set-text='message.key personFormatter'></span> <a data-set-attribute='href message.key addFriendLinkFormatter' data-set-text='html message.key addFriendTextFormatter'></a></div>
</div>
</div>
<!-- <div class='messageStatus' data-set-attribute='id message.key messageStatusIDFormatter'></div>-->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment