]> arthur.barton.de Git - netdata.git/blobdiff - web/dashboard.js
older browsers compatibility fix; fixed a bug introduced with #290 due to #286 that...
[netdata.git] / web / dashboard.js
index a2089d412521321c9bd2b1af6de9748805c32c30..96f2c23faa2fceb044a71a6d682a5d3cad3437aa 100644 (file)
 // var netdataServer = "http://yourhost:19999"; // set your NetData server
 
 //(function(window, document, undefined) {
+
+       // ------------------------------------------------------------------------
+       // compatibility fixes
+
        // fix IE issue with console
-       if(!window.console){ window.console = {log: function(){} }; }
+       if(!window.console) { window.console = { log: function(){} }; }
+
+       // if string.endsWith is not defined, define it
+       if(typeof String.prototype.endsWith !== 'function') {
+               String.prototype.endsWith = function(s) {
+                       if(s.length > this.length) return false;
+                       return this.slice(-s.length) === s;
+               };
+       }
+
+       // if string.startsWith is not defined, define it
+       if(typeof String.prototype.startsWith !== 'function') {
+               String.prototype.startsWith = function(s) {
+                       if(s.length > this.length) return false;
+                       return this.slice(s.length) === s;
+               };
+       }
 
        // global namespace
        var NETDATA = window.NETDATA || {};
                NETDATA.serverDefault = netdataServer;
        else {
                var s = NETDATA._scriptSource();
-               NETDATA.serverDefault = s.replace(/\/dashboard.js(\?.*)*$/g, "");
+               if(s) NETDATA.serverDefault = s.replace(/\/dashboard.js(\?.*)*$/g, "");
+               else {
+                       console.log('WARNING: Cannot detect the URL of the netdata server.');
+                       NETDATA.serverDefault = null;
+               }
        }
 
        if(NETDATA.serverDefault === null)
        NETDATA.google_js               = 'https://www.google.com/jsapi';
 
        NETDATA.themes = {
-               default: {
+               white: {
                        bootstrap_css: NETDATA.serverDefault + 'css/bootstrap.min.css',
                        dashboard_css: NETDATA.serverDefault + 'dashboard.css',
                        background: '#FFFFFF',
        if(typeof netdataTheme !== 'undefined' && typeof NETDATA.themes[netdataTheme] !== 'undefined')
                NETDATA.themes.current = NETDATA.themes[netdataTheme];
        else
-               NETDATA.themes.current = NETDATA.themes.default;
+               NETDATA.themes.current = NETDATA.themes.white;
 
        NETDATA.colors = NETDATA.themes.current.colors;
 
 
        NETDATA._loadjQuery(function() {
                NETDATA.loadRequiredJs(0, function() {
-                       if(typeof $().emulateTransitionEnd == 'function') {
+                       if(typeof $().emulateTransitionEnd !== 'function') {
                                // bootstrap is not available
                                NETDATA.options.current.show_help = false;
                        }