Revision: 2692
          https://sourceforge.net/p/mrbs/code/2692/
Author:   cimorrison
Date:     2013-02-10 19:06:42 +0000 (Sun, 10 Feb 2013)
Log Message:
-----------
Restructured code

Modified Paths:
--------------
    mrbs/trunk/web/js/refresh.js.php

Modified: mrbs/trunk/web/js/refresh.js.php
===================================================================
--- mrbs/trunk/web/js/refresh.js.php    2013-02-10 18:44:50 UTC (rev 2691)
+++ mrbs/trunk/web/js/refresh.js.php    2013-02-10 19:06:42 UTC (rev 2692)
@@ -18,11 +18,42 @@
 
 var intervalId;
 
-<?php
-// refreshPage will be defined later as a function, once we know
-// the page data, which won't be until init().
-?>
-var refreshPage = {};
+var refreshPage = function refreshPage() {
+    if (!isHidden() && !refreshPage.disabled)
+    {
+      var data = {ajax: 1, 
+                  day: refreshPage.args.day,
+                  month: refreshPage.args.month,
+                  year: refreshPage.args.year,
+                  room: refreshPage.args.room,
+                  area: refreshPage.args.area};
+      if (refreshPage.args.timetohighlight !== undefined)
+      {
+        data.timetohighlight = refreshPage.args.timetohighlight;
+      }
+      var table = $('table.dwm_main');
+      $.post(refreshPage.args.page + '.php',
+             data,
+             function(result){
+                 <?php
+                 // (1) Empty the existing table in order to get rid of events
+                 // and data and prevent memory leaks, (2) insert the updated 
+                 // table HTML, (3) clear the existing interval timer and then
+                 // (4) trigger a window load event so that the resizable
+                 // bookings are re-created and a new timer started.
+                 ?>
+                 if (!isHidden() && !refreshPage.disabled)
+                 {
+                   table.empty();
+                   table.html(result);
+                   window.clearInterval(intervalId);
+                   intervalId = undefined;
+                   $(window).trigger('load');
+                 }
+               },
+             'html');
+    }  <?php // if (!isHidden() && !refreshPage.disabled) ?>
+  };
 
 <?php
 // Functions to turn off and on page refresh.  We don't want the page to be
@@ -79,43 +110,7 @@
   init = function(args) {
     oldInitRefresh.apply(this, [args]);
     
-    refreshPage = function refreshPage() {
-        if (!isHidden() && !refreshPage.disabled)
-        {
-          var data = {ajax: 1, 
-                      day: args.day,
-                      month: args.month,
-                      year: args.year,
-                      room: args.room,
-                      area: args.area};
-          if (args.timetohighlight !== undefined)
-          {
-            data.timetohighlight = args.timetohighlight;
-          }
-          var table = $('table.dwm_main');
-          $.post(args.page + '.php',
-                 data,
-                 function(result){
-                     <?php
-                     // (1) Empty the existing table in order to get rid of 
events
-                     // and data and prevent memory leaks, (2) insert the 
updated 
-                     // table HTML, (3) clear the existing interval timer and 
then
-                     // (4) trigger a window load event so that the resizable
-                     // bookings are re-created and a new timer started.
-                     ?>
-                     if (!isHidden() && !refreshPage.disabled)
-                     {
-                       table.empty();
-                       table.html(result);
-                       window.clearInterval(intervalId);
-                       intervalId = undefined;
-                       $(window).trigger('load');
-                     }
-                   },
-                 'html');
-        }  <?php // if (!isHidden() && !refreshPage.disabled) ?>
-      };
-    
+    refreshPage.args = args;
     <?php
     // Set an interval timer to refresh the page, unless there's already one 
in place
     ?>
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to