+ render_room_view(0, 9999999999);
+}
+
+
+// Goto next room with unread messages
+// which_oper is 0=ungoto, 1=skip, 2=goto
+//
+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
+ }
+ else {
+ next_room = march_list[0].name;
+ march_list.splice(0, 1);
+ console.log("going to " + next_room + " , " + march_list.length + " rooms remaining in march list");
+ gotoroom(next_room);
+ }
+}
+
+
+// Called by gotonext() when the march list is empty.
+//
+function load_new_march_list() {
+ var request = new XMLHttpRequest();
+ request.open("GET", "/ctdl/r/", true);
+ request.onreadystatechange = function() {
+ if ((this.readyState === 4) && ((this.status / 100) == 2)) {
+ march_list = (JSON.parse(this.responseText));
+ march_list = march_list.filter(function(room) {
+ return room.hasnewmsgs;
+ });
+ march_list = march_list.sort(function(a,b) {
+ if (a.floor != b.floor) {
+ return(a.floor - b.floor);
+ }
+ if (a.rorder != b.rorder) {
+ return(a.rorder - b.rorder);
+ }
+ return(a.name < b.name);
+ });
+ march_list.push({name:"_BASEROOM_",known:true,hasnewmsgs:true,floor:0});
+ gotonext();
+ }
+ };
+ request.send();
+ request = null;