Skip to content

Commit

Permalink
Chromium bug
Browse files Browse the repository at this point in the history
Demo.js includes a workaround for Chromium's incorrect initialization of alternate stylesheets.
  • Loading branch information
kloverde committed May 13, 2018
1 parent 435e5bb commit fac2a4d
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 13 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Release 1.1.1 (May 13, 2018)

* Updated the demo to handle a Chromium bug that affects the proper operation of themes. See README.MD and demo.js for more information.


# Release 1.1 (May 9, 2018)

This release improves theme support.
Expand Down
6 changes: 3 additions & 3 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RealtimeMonitor v1.1
====================
RealtimeMonitor v1.1.1
======================

See LICENSE for this software's licensing terms. At first glance, it resembles the BSD-3 license, but it contains a significant difference which prohibits certain use. Read it carefully. Licenses for third-party components used by RealtimeMonitor are in THIRD_PARTY_LICENSES.MD.

Expand Down Expand Up @@ -173,7 +173,7 @@ Chrome only displays notifications if the page is loaded over HTTPS - or so I've

The application includes several alternate color schemes, or themes. Themes are implemented by alternate stylesheets which override portions of the base stylesheet. Some browsers, such as Firefox and IE, place alternate stylesheets in a menu that the user can then select from to switch to a different theme. Chrome does not have built-in support for this functionality. I've read that there are third-party Chrome addons that add this capability, but I haven't looked into it any further than that.

Several different aspects of the panels are changed by theming, but of particular note are the colors used to represent statuses of normal, warning and danger. Some themes use green/yellow/red while others use green/orange/red, depending on the panel's background color.
Chromium (and by extension, all Chromium-based browsers) has a bug where alternate stylesheets aren't correctly initialized upon page load. Chromium initializes the 'disabled' property of every alternate stylesheet to `false`, which is wrong. The workaround for this needs to be made at the page level, not within RealtimeMonitor. If you plan on using themes, you need to forcibly set this property to `true` on all alternate stylesheets before instantiating RealtimeMonitor. See the `fixBrokenBrowsers` function in `demo.js` for code which does this.


## Third-party Attribution
Expand Down
2 changes: 1 addition & 1 deletion css/realtimeMonitor.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* RealtimeMonitor v1.1
* RealtimeMonitor v1.1.1
* https://www.github.com/kloverde/js-RealtimeMonitor
*
* Copyright (c) 2018, Kurtis LoVerde
Expand Down
2 changes: 1 addition & 1 deletion css/themes/burlywood.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* RealtimeMonitor v1.1
* RealtimeMonitor v1.1.1
* https://www.github.com/kloverde/js-RealtimeMonitor
*
* Copyright (c) 2018, Kurtis LoVerde
Expand Down
2 changes: 1 addition & 1 deletion css/themes/dark.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* RealtimeMonitor v1.1
* RealtimeMonitor v1.1.1
* https://www.github.com/kloverde/js-RealtimeMonitor
*
* Copyright (c) 2018, Kurtis LoVerde
Expand Down
2 changes: 1 addition & 1 deletion css/themes/darkslategray.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* RealtimeMonitor v1.1
* RealtimeMonitor v1.1.1
* https://www.github.com/kloverde/js-RealtimeMonitor
*
* Copyright (c) 2018, Kurtis LoVerde
Expand Down
2 changes: 1 addition & 1 deletion css/themes/deeppurple.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* RealtimeMonitor v1.1
* RealtimeMonitor v1.1.1
* https://www.github.com/kloverde/js-RealtimeMonitor
*
* Copyright (c) 2018, Kurtis LoVerde
Expand Down
2 changes: 1 addition & 1 deletion css/themes/dimgray.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* RealtimeMonitor v1.1
* RealtimeMonitor v1.1.1
* https://www.github.com/kloverde/js-RealtimeMonitor
*
* Copyright (c) 2018, Kurtis LoVerde
Expand Down
2 changes: 1 addition & 1 deletion css/themes/lightslategray.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* RealtimeMonitor v1.1
* RealtimeMonitor v1.1.1
* https://www.github.com/kloverde/js-RealtimeMonitor
*
* Copyright (c) 2018, Kurtis LoVerde
Expand Down
2 changes: 1 addition & 1 deletion css/themes/lightsteelblue.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* RealtimeMonitor v1.1
* RealtimeMonitor v1.1.1
* https://www.github.com/kloverde/js-RealtimeMonitor
*
* Copyright (c) 2018, Kurtis LoVerde
Expand Down
15 changes: 15 additions & 0 deletions demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
"use strict";

document.addEventListener( "DOMContentLoaded", function() {
fixBrokenBrowsers(); // You should read the documentation in this function.

const rtm = new RealtimeMonitor();

const panel1 = rtm.newPanel( {
Expand Down Expand Up @@ -127,4 +129,17 @@ document.addEventListener( "DOMContentLoaded", function() {
rtm.loadTheme( theme );
}
}

function fixBrokenBrowsers() {
// Forcibly set all alternate stylesheets to disabled. You MUST do this if you're using RealtimeMonitor's themes in your project.
// There's a bug in Chromium where all alternate stylesheets are initialized with their 'disabled' property set to false, even
// though they all start out disabled. This is incorrect behavior, and it interferes with how RealtimeMonitor detects the active
// theme. This affects all Chromium browsers, so Chrome, Brave, etc. will not function correctly unless you do this.

const sheets = document.querySelectorAll( "link[rel='alternate stylesheet']" );

for( let i = 0; i < sheets.length; i++ ) {
sheets[i].disabled = true;
}
}
} );
2 changes: 1 addition & 1 deletion js/realtimeMonitor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* RealtimeMonitor v1.1
* RealtimeMonitor v1.1.1
* https://www.github.com/kloverde/js-RealtimeMonitor
*
* Copyright (c) 2018, Kurtis LoVerde
Expand Down
2 changes: 1 addition & 1 deletion js/realtimeMonitor.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fac2a4d

Please sign in to comment.