aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc/html.inc.php
diff options
context:
space:
mode:
authorPeter Wu2014-08-02 16:26:17 +0200
committerPeter Wu2014-08-02 16:30:29 +0200
commitc4d31153e76caf0dbccdfe108574afc4b030c926 (patch)
tree7fdb35c051432d055697b54c94833b01ce0d226d /inc/html.inc.php
parentjsrrdgraph: Fix error functions. Error prototype. (diff)
downloadapt-panopticon_cgp-c4d31153e76caf0dbccdfe108574afc4b030c926.zip
apt-panopticon_cgp-c4d31153e76caf0dbccdfe108574afc4b030c926.tar.gz
apt-panopticon_cgp-c4d31153e76caf0dbccdfe108574afc4b030c926.tar.bz2
apt-panopticon_cgp-c4d31153e76caf0dbccdfe108574afc4b030c926.tar.xz
Merge (a)sync code, reformat CGP.js
Best viewed with `git diff -w`. Since CGP-sync.js and CGP-async.js are almost equal except for one function call, merge them into a single function. While at it, reformat CGP.js to expose a single namespace (`CGP`) which exports the symbol `drawAll`. Remove `alert()` and add a `console.error()` call instead. This is less intrustive to users (who will notice a broken graph anyway) and be more helpful for developers (who can examine the call trace in the Developer Console. Add `"use strict"` and use the standard four spaces as indent. Process the script through `js-beautify` which re-indented the code and added some spaces between operators. Replace double by single quotes for consistency. Rename `catch(e)` to `catch(ex)` to supress a jshint warning about IE8.
Diffstat (limited to '')
-rw-r--r--inc/html.inc.php17
1 files changed, 7 insertions, 10 deletions
diff --git a/inc/html.inc.php b/inc/html.inc.php
index c8cfbaf..117d61d 100644
--- a/inc/html.inc.php
+++ b/inc/html.inc.php
@@ -99,21 +99,18 @@ function html_end() {
99EOT; 99EOT;
100 100
101 if ($CONFIG['graph_type'] == 'canvas') { 101 if ($CONFIG['graph_type'] == 'canvas') {
102 echo <<<EOT
103<script type="text/javascript" src="{$html_weburl}js/CGP.js"></script>
104
105EOT;
106 if ($CONFIG['rrd_fetch_method'] == 'async') { 102 if ($CONFIG['rrd_fetch_method'] == 'async') {
107 echo <<<EOT 103 $js_async = 'true';
108<script type="text/javascript" src="{$html_weburl}js/CGP-async.js"></script>
109
110EOT;
111 } else { 104 } else {
105 $js_async = 'false';
106 }
112 echo <<<EOT 107 echo <<<EOT
113<script type="text/javascript" src="{$html_weburl}js/CGP-sync.js"></script> 108<script src="{$html_weburl}js/CGP.js"></script>
109<script>
110CGP.drawAll($js_async);
111</script>
114 112
115EOT; 113EOT;
116 }
117 } 114 }
118 115
119echo <<<EOT 116echo <<<EOT