Simon Hunt
Committed by Gerrit Code Review

GUI -- Cleaned up user agent data injection

- function closure to prevent polluting global namespace
- d3 selection for cleaner setting of touch class

Change-Id: I2711ae32c2a32f051674024d7349e8de6f378d7c
...@@ -148,10 +148,13 @@ ...@@ -148,10 +148,13 @@
148 148
149 <script> 149 <script>
150 <!-- Inject user agent info into html element to allow CSS sensitivity. --> 150 <!-- Inject user agent info into html element to allow CSS sensitivity. -->
151 - var b = document.documentElement; 151 + (function () {
152 - b.setAttribute('data-useragent', navigator.userAgent); 152 + var t = !!('ontouchstart' in window) || !!('onmsgesturechange' in window);
153 - b.setAttribute('data-platform', navigator.platform ); 153 + d3.select(document.documentElement)
154 - b.className += ((!!('ontouchstart' in window) || !!('onmsgesturechange' in window))?' touch':''); 154 + .attr('data-useragent', navigator.userAgent)
155 + .attr('data-platform', navigator.platform)
156 + .classed('touch', t);
157 + }());
155 </script> 158 </script>
156 </body> 159 </body>
157 </html> 160 </html>
......