Update of /var/cvs/contributions/didactor2/src/core/templates/core/js
In directory james.mmbase.org:/tmp/cvs-serv14724

Modified Files:
        Didactor.js 
Log Message:



See also: 
http://cvs.mmbase.org/viewcvs/contributions/didactor2/src/core/templates/core/js


Index: Didactor.js
===================================================================
RCS file: 
/var/cvs/contributions/didactor2/src/core/templates/core/js/Didactor.js,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- Didactor.js 13 Nov 2008 10:48:22 -0000      1.16
+++ Didactor.js 13 Nov 2008 11:17:15 -0000      1.17
@@ -6,7 +6,7 @@
  * One global variable 'didactor' is automaticly created, which can be be 
referenced (as long as the di:head tag is used).
  * @since Didactor 2.3.0
  * @author Michiel Meeuwissen
- * @version $Id: Didactor.js,v 1.16 2008/11/13 10:48:22 michiel Exp $
+ * @version $Id: Didactor.js,v 1.17 2008/11/13 11:17:15 michiel Exp $
  */
 
 
@@ -23,7 +23,9 @@
 
     $.timer(500, function(timer) {
            self.reportOnline();
-      var interval = self.getSetting("Didactor-PageReporterInterval") * 1000;
+        var interval = self.getSetting("Didactor-PageReporterInterval");
+        interval = interval == "" ? 10000 : interval * 1000;
+        if (interval < 10000) interval = 10000;
            timer.reset(self.pageReporter ? interval : 1000 * 60 * 2);
     });
     if (this.pageReporter) {
@@ -113,7 +115,7 @@
                     params[this.name] = this.value;
                 }
             });
-            $.ajax({url: this.href, type: "POST", dataType: "xml", data: 
params,
+            $.ajax({url: this.href, async: false, type: "POST", dataType: 
"xml", data: params,
                     complete: function(res, status) {
                         if (status == "success") {
                             $(div).append(res.responseText);
@@ -149,6 +151,18 @@
 
 }
 
+Didactor.prototype.saveQuestions = function() {
+    var didactor = this;
+    for (key in didactor.questions) {
+        var status = didactor.questions[key];
+        var changed = status[0];
+        var div = status[1];
+        if (changed) {
+            $(div).find(".answerquestion").click();
+            didactor.questions[key][0] = false;
+        }
+    }
+}
 
 
 var didactor;
@@ -165,16 +179,13 @@
     });
 
     $(document).bind("didactorContentBeforeUnload",  function(ev, el) {
-        for (key in didactor.questions) {
-            var status = didactor.questions[key];
-            var changed = status[0];
-            var div = status[1];
-            if (changed) {
-                $(div).find(".answerquestion").click();
-                didactor.questions[key][0] = false;
-            }
-        }
+        didactor.saveQuestions();
+
     });
+    $(window).bind("beforeunload", function() {
+        didactor.saveQuestions();
+    });
+
     // if this is a staticly loaded piece of html, there may be some questions 
already
     didactor.resolveQuestions(document);
 });
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to