Преглед на файлове

Switched to own live timestamp system, since the meteor package only had 1 live timestamp at a time.

KrisVos130 преди 9 години
родител
ревизия
cc43bf99cc
променени са 4 файла, в които са добавени 16 реда и са изтрити 3 реда
  1. 0 1
      app/.meteor/packages
  2. 0 1
      app/.meteor/versions
  3. 15 0
      app/client/client.js
  4. 1 1
      app/client/templates/room.html

+ 0 - 1
app/.meteor/packages

@@ -28,5 +28,4 @@ altapp:recaptcha
 http
 zimme:iron-router-active
 momentjs:moment
-copleykj:livestamp
 emojione:emojione

+ 0 - 1
app/.meteor/versions

@@ -17,7 +17,6 @@ caching-html-compiler@1.0.2
 callback-hook@1.0.4
 check@1.1.0
 coffeescript@1.0.11
-copleykj:livestamp@1.1.7
 ddp@1.2.2
 ddp-client@1.2.1
 ddp-common@1.2.2

+ 15 - 0
app/client/client.js

@@ -637,7 +637,22 @@ Template.room.events({
     }
 });
 
+Template.registerHelper("rtime", function(date) {
+    Session.get("time");
+    if (date) {
+        return moment(date).fromNow();
+    }
+});
+
+var chatTimeInterval = undefined;
+
 Template.room.onRendered(function() {
+    if (chatTimeInterval !== undefined) {
+        Meteor.clearInterval(chatTimeInterval)
+    }
+    chatTimeInterval = Meteor.setInterval(function() {
+        Session.set("time", new Date().getTime());
+    }, 10000);
     $(document).ready(function() {
         function makeSlider(){
             var slider = $("#volume-slider").slider();

+ 1 - 1
app/client/templates/room.html

@@ -113,7 +113,7 @@
                             <ul id="chat-ul">
                                 {{#each chat}}
                                     {{#emojione}}
-                                        <li class="chat-message"><small class="rank-{{this.rawrank}}">{{this.rank}}</small> <a style="text-decoration: none" href="/u/{{this.username}}" target="_blank"><b class="bold">{{this.username}}</b></a> <span data-livestamp="{{time}}" title="{{time}}" style="float: right;"></span> <br/>{{this.message}}</li>
+                                        <li class="chat-message"><small class="rank-{{this.rawrank}}">{{this.rank}}</small> <a style="text-decoration: none" href="/u/{{this.username}}" target="_blank"><b class="bold">{{this.username}}</b></a> <span title="{{time}}" style="float: right;">{{rtime time}}</span> <br/>{{this.message}}</li>
                                     {{/emojione}}
                                     <hr>
                                 {{/each}}