]> git.parisson.com Git - django-jqchat.git/commitdiff
add day of the week to message header
authoryomguy <yomguy@parisson.com>
Mon, 19 Nov 2012 08:09:20 +0000 (09:09 +0100)
committeryomguy <yomguy@parisson.com>
Mon, 19 Nov 2012 08:09:20 +0000 (09:09 +0100)
jqchat/models.py
jqchat/static/jqchat/jqchat.js
jqchat/views.py

index 1299eda30f849b44ad5b85b0c4dfb8e745f8847d..fd3ab2a1be174b58c6d86bea36a49b99e09d7f02 100644 (file)
@@ -100,7 +100,7 @@ class messageManager(models.Manager):
         m = Message(user=user,
                     room=room,
                     event=event_id)
-        m.text = "<strong>%s</strong> <em>%s</em><br />" % (user, m.get_event_display())
+        m.text = '<strong>%s</strong> <em>%s</em><br />' % (user, m.get_event_display())
         m.save()
         return m
 
index 03713b04b9057e31f690184486f665855ea33ef1..bd64a34e09d82cd4210133e50ac9f95c80a88671 100644 (file)
@@ -1,3 +1,4 @@
+
 //Handles the csrf_token for ajax posts, taken from:
 // https://docs.djangoproject.com/en/dev/ref/contrib/csrf/
 
@@ -39,6 +40,17 @@ $(document).ajaxSend(function(event, xhr, settings) {
 });
 
 
+jQuery.fn.urlize = function( base ) {
+    var x = this.html();
+    list = x.match( /\b(http:\/\/|www\.|http:\/\/www\.)[^ ]{2,100}\b/g );
+    if ( list ) {
+        for ( i = 0; i < list.length; i++ ) {
+            x = x.replace( list[i], "<a href='" + base + escape( list[i] ) + "'>"+ list[i] + "</a>" );
+        }
+        this.html(x);
+    }
+};
+
 // Chat client code.
 
 
@@ -73,7 +85,7 @@ function processResponse(payload) {
        // Get the timestamp, store it in global variable to be passed to the server on next call.
        timestamp = payload.time;
        for(message in payload.messages) {
-               $("#chatwindow").append(payload.messages[message].text);
+               $("#chatwindow").append(payload.messages[message].text).urlize( "/" );
        }
        // Scroll down if messages fill up the div.
        var objDiv = document.getElementById("chatwindow");
index 0f8a0bda57c6b2bf3c3147df8603ff5fbbefd291..4689f2507f1184a42b1a89b7c07788adb9ebb769 100644 (file)
@@ -14,7 +14,7 @@ try:
     DATE_FORMAT = settings.JQCHAT_DATE_FORMAT
 except:
     # Use default format.
-    DATE_FORMAT = "H:i:s"
+    DATE_FORMAT = "D-H:i:s"
 
 # How many messages to retrieve at most.
 JQCHAT_DISPLAY_COUNT = getattr(settings, 'JQCHAT_DISPLAY_COUNT', 100)