poll added
[brisk.git] / web / room.js
index 0e0aed9..27093bb 100644 (file)
@@ -580,6 +580,40 @@ function mesgtoadmbox(w, h)
     $('mesgtoadm_form').elements['subj'].focus();
 }
 
+function j_pollbox(form)
+{
+    var no, i, choose; 
+
+    do {
+        // submit the request
+        
+        for (i = 0 ; i < form.elements.length ; i++) {
+            if (form.elements[i].checked == true)
+                break;
+        }
+        if (i == form.elements.length) {
+            no = new notify(gst, "<br>Non hai espresso nessuna preferenza;</br> correggi per favore.", 1, "chiudi", 280, 100); 
+            return false;
+        }
+        else
+            choose = form.elements[i].value;
+
+        token = server_request('mesg', 'poll', 
+                               'cli_choose', encodeURIComponent(choose) );
+
+        if (token == "1") {
+            // TODO: mesg to user
+            // $('mesgtoadmbox').style.visibility = "hidden";
+            break;
+        }
+    } while (0);
+
+    return (false);
+}
+
+
+
+
 function list_set(what, setco, info)
 {
     if (what == 'auth') {
@@ -595,3 +629,66 @@ function list_set(what, setco, info)
         createCookie("CO_list", what, 24*365, cookiepath);
     }
 }
+
+function sideslide(domobj, height, step)
+{
+    this.st = 'wait';
+    this.twait = 5000;
+
+    this.domobj = domobj;
+    this.height = height;
+    this.step = step;
+
+    this.start();
+}
+
+sideslide.prototype = {
+    id: null,
+    st: 'wait',
+    twait: 0,
+    scroll: 0,
+    countdown: 0,
+
+    domobj: null,
+    height: 0,
+    step: 0,
+
+    start: function() {
+        var instant = this;
+        
+        this.st = 'wait';
+        this.id = setTimeout(function () { instant.sideslide_cb(); }, this.twait);
+    },
+
+    sideslide_cb: function() {
+        var instant = this;
+
+        if (this.st == 'wait') {
+            this.st = 'scroll';
+            this.countdown = 10;
+            this.id = setInterval(function () { instant.sideslide_cb(); }, 100);
+        }
+        else if (this.st == 'scroll') {
+            this.scroll += (this.step / 10);
+            if (this.scroll >= this.height - this.step) {
+                this.scroll = 0;
+            }
+            this.domobj.scrollTop = this.scroll;
+            this.countdown--;
+            if (this.countdown == 0) {
+                this.stop();
+                this.st = 'wait';
+                this.id = setTimeout(function () { instant.sideslide_cb(); }, this.twait);
+            }
+        }
+    },
+
+
+    stop: function() {
+        if (this.id != null) {
+            clearInterval(this.id);
+            this.id = null;
+        }
+    }
+
+}