Changeset:
        f7ad408ef420
        
https://sourceforge.net/p/mrbs/hg-code/ci/f7ad408ef420b725915c044091a43d030f83e579
Author:
        Campbell Morrison <[email protected]>
Date:
        Thu Feb 11 14:02:32 2016 +0000
Log message:

Converted functions.js.php to be an include file

diffstat:

 web/js.inc              |   15 +++++-
 web/js/functions.js.inc |  105 +++++++++++++++++++++++++++++++++++++++++++
 web/js/functions.js.php |  115 ------------------------------------------------
 3 files changed, 119 insertions(+), 116 deletions(-)

diffs (272 lines):

diff -r d7cab9d04a94 -r f7ad408ef420 web/js.inc
--- a/web/js.inc        Thu Feb 11 13:06:16 2016 +0000
+++ b/web/js.inc        Thu Feb 11 14:02:32 2016 +0000
@@ -2,6 +2,8 @@
 
 // $Id$
 
+global $use_strict;
+
 
 // We need to construct a standard query string that can be passed to the 
*.js.php
 // pages.  That's because some of the settings they use are area dependent.
@@ -122,17 +124,28 @@
   <?php
   // Create an empty init() function.   This will get "extended" if necessary
   // by the page specific JavaScript files in the js directory
+  
+  if ($use_strict)
+  {
+    echo "'use strict';\n";
+  }
+  
   ?>
   function init(params)
   {
   }
+  
+  <?php
+  // All pages
+  require 'js/functions.js.inc';
+  ?>
   //]]>
 </script>
 
 <?php
 // All pages
 ?>
-<script type="text/javascript" src="js/functions.js.php?<?php echo 
$standard_query_string ?>"></script>
+
 <script type="text/javascript" src="js/datepicker.js.php?<?php echo 
$standard_query_string ?>"></script>
 <script type="text/javascript" src="js/general.js.php?<?php echo 
$standard_query_string ?>"></script>
 
diff -r d7cab9d04a94 -r f7ad408ef420 web/js/functions.js.inc
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/web/js/functions.js.inc   Thu Feb 11 14:02:32 2016 +0000
@@ -0,0 +1,105 @@
+<?php
+
+// $Id$
+
+?>
+
+$.fn.reverse = [].reverse;
+
+function getErrorList(errors)
+{
+  var result = {html: '', text: ''};
+  var patternSpan = /<span[\s\S]*span>/gi;
+  var patternTags = /<\S[^><]*>/g;
+  result.html += "<ul>";
+  for (var i=0; i<errors.length; i++)
+  {
+    result.html += "<li>" + errors[i] + "<\/li>";
+    result.text += '(' + (i+1).toString() + ') ';
+    <?php // strip out the <span> and its contents and then all other tags ?>
+    result.text += errors[i].replace(patternSpan, '').replace(patternTags, '') 
+ "  \n";
+  }
+  result.html += "<\/ul>";
+  return result;
+}
+
+
+<?php
+// Gets the correct prefix to use (if any) with the page visibility API.
+// Returns null if not supported.
+?>
+var visibilityPrefix = function visibilityPrefix() {
+    var prefixes = ['', 'webkit', 'moz', 'ms', 'o'];
+    var testProperty;
+    
+    if (typeof visibilityPrefix.prefix === 'undefined')
+    {
+      visibilityPrefix.prefix = null;
+      for (var i=0; i<prefixes.length; i++)
+      {
+        testProperty = prefixes[i];
+        testProperty += (prefixes[i] === '') ? 'hidden' : 'Hidden';
+        if (testProperty in document)
+        {
+          visibilityPrefix.prefix = prefixes[i];
+          break;
+        }
+      }
+    }
+
+    return visibilityPrefix.prefix;
+  };
+
+<?php
+// Determine if the page is hidden from the user (eg if it has been minimised
+// or the tab is not visible).    Returns true, false or null (if not known).
+?>
+var isHidden = function isHidden() {
+    var prefix;
+    prefix = visibilityPrefix();
+    switch (prefix)
+    {
+      case null:
+        return null;
+        break;
+      case '':
+        return document.hidden;
+        break;
+      default:
+        return document[prefix + 'Hidden'];
+        break;
+    }
+  };
+
+
+<?php
+// Thanks to Remy Sharp 
https://remysharp.com/2010/07/21/throttling-function-calls
+?>
+function throttle(fn, threshold, scope) {
+
+  var last,
+      deferTimer;
+      
+  threshold || (threshold = 250);
+  
+  return function () {
+    var context = scope || this,
+        now = +new Date,
+        args = arguments;
+        
+    if (last && now < last + threshold)
+    {
+      // hold on to it
+      clearTimeout(deferTimer);
+      deferTimer = setTimeout(function () {
+          last = now;
+          fn.apply(context, args);
+        }, threshold);
+    }
+    else 
+    {
+      last = now;
+      fn.apply(context, args);
+    }
+  };
+}
\ No newline at end of file
diff -r d7cab9d04a94 -r f7ad408ef420 web/js/functions.js.php
--- a/web/js/functions.js.php   Thu Feb 11 13:06:16 2016 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-<?php
-
-// $Id$
-
-require "../defaultincludes.inc";
-
-header("Content-type: application/x-javascript");
-expires_header(60*30); // 30 minute expiry
-
-if ($use_strict)
-{
-  echo "'use strict';\n";
-}
-
-?>
-
-$.fn.reverse = [].reverse;
-
-function getErrorList(errors)
-{
-  var result = {html: '', text: ''};
-  var patternSpan = /<span[\s\S]*span>/gi;
-  var patternTags = /<\S[^><]*>/g;
-  result.html += "<ul>";
-  for (var i=0; i<errors.length; i++)
-  {
-    result.html += "<li>" + errors[i] + "<\/li>";
-    result.text += '(' + (i+1).toString() + ') ';
-    <?php // strip out the <span> and its contents and then all other tags ?>
-    result.text += errors[i].replace(patternSpan, '').replace(patternTags, '') 
+ "  \n";
-  }
-  result.html += "<\/ul>";
-  return result;
-}
-
-
-<?php
-// Gets the correct prefix to use (if any) with the page visibility API.
-// Returns null if not supported.
-?>
-var visibilityPrefix = function visibilityPrefix() {
-    var prefixes = ['', 'webkit', 'moz', 'ms', 'o'];
-    var testProperty;
-    
-    if (typeof visibilityPrefix.prefix === 'undefined')
-    {
-      visibilityPrefix.prefix = null;
-      for (var i=0; i<prefixes.length; i++)
-      {
-        testProperty = prefixes[i];
-        testProperty += (prefixes[i] === '') ? 'hidden' : 'Hidden';
-        if (testProperty in document)
-        {
-          visibilityPrefix.prefix = prefixes[i];
-          break;
-        }
-      }
-    }
-
-    return visibilityPrefix.prefix;
-  };
-
-<?php
-// Determine if the page is hidden from the user (eg if it has been minimised
-// or the tab is not visible).    Returns true, false or null (if not known).
-?>
-var isHidden = function isHidden() {
-    var prefix;
-    prefix = visibilityPrefix();
-    switch (prefix)
-    {
-      case null:
-        return null;
-        break;
-      case '':
-        return document.hidden;
-        break;
-      default:
-        return document[prefix + 'Hidden'];
-        break;
-    }
-  };
-
-
-<?php
-// Thanks to Remy Sharp 
https://remysharp.com/2010/07/21/throttling-function-calls
-?>
-function throttle(fn, threshold, scope) {
-
-  var last,
-      deferTimer;
-      
-  threshold || (threshold = 250);
-  
-  return function () {
-    var context = scope || this,
-        now = +new Date,
-        args = arguments;
-        
-    if (last && now < last + threshold)
-    {
-      // hold on to it
-      clearTimeout(deferTimer);
-      deferTimer = setTimeout(function () {
-          last = now;
-          fn.apply(context, args);
-        }, threshold);
-    }
-    else 
-    {
-      last = now;
-      fn.apply(context, args);
-    }
-  };
-}
\ No newline at end of file

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to