ungoto/skip/goto ui taking shape...
[citadel.git] / webcit-ng / static / js / main.js
index cea3df2bde11240d943bb6378e203619aea66025..943d7519fdddc5f987664f3e39015de4fae73c83 100644 (file)
@@ -34,12 +34,11 @@ function _(x) {
 //
 function randomString(length) {
        var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghiklmnopqrstuvwxyz'.split('');
+       var str = '';
 
-       if (! length) {
+       if (!length) {
                length = Math.floor(Math.random() * chars.length);
        }
-
-       var str = '';
        for (var i = 0; i < length; i++) {
                str += chars[Math.floor(Math.random() * chars.length)];
        }
@@ -50,35 +49,35 @@ function randomString(length) {
 // string escape for html display
 //
 function escapeHTML(text) {
-    'use strict';
-    return text.replace(/[\"&<>]/g, function (a) {
-        return {
-               '"': '&quot;',
-               '&': '&amp;',
-               '<': '&lt;',
-               '>': '&gt;'
-       }[a];
-    });
+       'use strict';
+       return text.replace(/[\"&<>]/g, function (a) {
+               return {
+                       '"': '&quot;',
+                       '&': '&amp;',
+                       '<': '&lt;',
+                       '>': '&gt;'
+               }[a];
+       });
 }
 
 
 // string escape for html display
 //
 function escapeHTMLURI(text) {
-    'use strict';
-    return text.replace(/./g, function (a) {
-        return '%' + a.charCodeAt(0).toString(16);
-    });
+       'use strict';
+       return text.replace(/./g, function (a) {
+               return '%' + a.charCodeAt(0).toString(16);
+       });
 }
 
 
 // string escape for JavaScript string
 //
 function escapeJS(text) {
-    'use strict';
-    return text.replace(/[\"\']/g, function (a) {
-        return '\\' + a ;
-    });
+       'use strict';
+       return text.replace(/[\"\']/g, function (a) {
+               return '\\' + a ;
+       });
 }
 
 
@@ -96,6 +95,7 @@ function ctdl_startup() {
        request = null;
 }
 
+
 // Continuation of ctdl_startup() after serv_info is retrieved
 //
 function ctdl_startup_2(data) {
@@ -112,6 +112,7 @@ function ctdl_startup_2(data) {
        display_room_list();
 }
 
+
 // Display a room list in the main div.
 //
 function display_room_list() {
@@ -128,6 +129,7 @@ function display_room_list() {
        request = null;
 }
 
+
 // Renderer for display_room_list()
 //
 function display_room_list_renderer(data) {
@@ -151,8 +153,10 @@ function display_room_list_renderer(data) {
                }
                new_roomlist_text = new_roomlist_text +
                        "<li>"
+                       + (data[i].hasnewmsgs ? "<b>" : "")
                        + "<a href=\"javascript:gotoroom('" + escapeJS(escapeHTML(data[i].name)) + "');\">"
                        + escapeHTML(data[i].name)
+                       + (data[i].hasnewmsgs ? "</b>" : "")
                        + "</a></li>"
                ;
        }
@@ -160,6 +164,7 @@ function display_room_list_renderer(data) {
        document.getElementById("roomlist").innerHTML = new_roomlist_text ;
 }
 
+
 // Update the "banner" div with all relevant info.
 //
 function update_banner() {
@@ -207,8 +212,10 @@ function gotoroom_2(data) {
 
 
 // Goto next room with unread messages
+// which_oper is 0=ungoto, 1=skip, 2=goto
 //
-function gotonext() {
+function gotonext(which_oper) {
+       if (which_oper != 2) return;            // FIXME implement the other two
        if (march_list.length == 0) {
                load_new_march_list();          // we will recurse back here
        }