diff --git a/awx/ui/static/js/app.js b/awx/ui/static/js/app.js index a3ef0a3242..d8c1177230 100644 --- a/awx/ui/static/js/app.js +++ b/awx/ui/static/js/app.js @@ -426,7 +426,32 @@ angular.module('Tower', [ $rootScope.crumbCache = []; $rootScope.sessionTimer = Timer.init(); + function detectBrowser() { + var ua = window.navigator.userAgent, + browser; + if (ua.search("MSIE") >= 0) { + browser = "MSIE"; + } + else if (navigator.userAgent.search("Chrome") >= 0) { + browser = "CHROME"; + } + else if (navigator.userAgent.search("Firefox") >= 0) { + browser = "FF"; + } + else if (navigator.userAgent.search("Safari") >= 0 && navigator.userAgent.search("Chrome") < 0) { + browser = "SAFARI"; + } + else if (navigator.userAgent.search("Opera") >= 0) { + browser = "OPERA"; + } + return browser; + } + + $rootScope.browser = detectBrowser(); + $rootScope.$on("$routeChangeStart", function (event, next) { + var base; + // Before navigating away from current tab, make sure the primary view is visible if ($('#stream-container').is(':visible')) { HideStream(); @@ -456,7 +481,7 @@ angular.module('Tower', [ } // Make the correct tab active - var base = $location.path().replace(/^\//, '').split('/')[0]; + base = $location.path().replace(/^\//, '').split('/')[0]; if (base === '') { base = 'home'; } else { @@ -464,6 +489,7 @@ angular.module('Tower', [ base = (base === 'job_events' || base === 'job_host_summaries') ? 'jobs' : base; } $('.nav-tabs a[href="#' + base + '"]').tab('show'); + }); if (!Authorization.getToken()) { @@ -515,7 +541,6 @@ angular.module('Tower', [ setTimeout(function() { $rootScope.$apply(function() { sock.checkStatus(); - //$rootScope.$emit('SocketErrorEncountered'); $log.debug('socket status: ' + $rootScope.socketStatus); }); },2000); diff --git a/awx/ui/static/js/controllers/JobStdout.js b/awx/ui/static/js/controllers/JobStdout.js index 47bc044004..9dec929fed 100644 --- a/awx/ui/static/js/controllers/JobStdout.js +++ b/awx/ui/static/js/controllers/JobStdout.js @@ -7,7 +7,7 @@ 'use strict'; -function JobStdoutController ($scope, $compile, $routeParams, ClearScope, GetBasePath, Wait, Rest, ProcessErrors, Socket) { +function JobStdoutController ($rootScope, $scope, $compile, $routeParams, ClearScope, GetBasePath, Wait, Rest, ProcessErrors, Socket) { ClearScope(); @@ -36,14 +36,50 @@ function JobStdoutController ($scope, $compile, $routeParams, ClearScope, GetBas Rest.setUrl(stdout_url + '?format=html'); Rest.get() .success(function(data) { + var lines, styles=[], html=[], found=false, doc, style, pre, parser; api_complete = true; Wait('stop'); - var doc, style, pre, parser = new DOMParser(); - doc = parser.parseFromString(data, "text/html"); - pre = doc.getElementsByTagName('pre'); - style = doc.getElementsByTagName('style'); - $('#style-sheet-container').empty().html(style[0]); - $('#pre-container-content').empty().html($(pre[0]).html()); + if ($rootScope.browser === "SAFARI") { + // Safari's DOMParser will not parse HTML, so we have to do our best to extract the + // parts we want. + + lines = data.split("\n"); + // Get the style sheet + lines.forEach(function(line) { + if (//.test(line)) { + found = false; + } + }); + found = false; + // Get all the bits between
 and  
+ lines.forEach(function(line) { + if (/
/.test(line)) {
+                            found = true;
+                        }
+                        else if (/<\/pre>/.test(line)) {
+                            found = false;
+                        }
+                        else if (found) {
+                            html.push(line);
+                        }
+                    });
+                    $('#style-sheet-container').empty().html(styles.join("\n"));
+                    $('#pre-container-content').empty().html(html.join("\n"));
+                }
+                else {
+                    parser = new DOMParser();
+                    doc = parser.parseFromString(data, "text/html");
+                    pre = doc.getElementsByTagName('pre');
+                    style = doc.getElementsByTagName('style');
+                    $('#style-sheet-container').empty().html(style[0]);
+                    $('#pre-container-content').empty().html($(pre[0]).html());
+                }
                 setTimeout(function() { $('#pre-container').mCustomScrollbar("scrollTo", 'bottom'); }, 1000);
             })
             .error(function(data, status) {
@@ -83,4 +119,5 @@ function JobStdoutController ($scope, $compile, $routeParams, ClearScope, GetBas
         });
 }
 
-JobStdoutController.$inject = [ '$scope', '$compile', '$routeParams', 'ClearScope', 'GetBasePath', 'Wait', 'Rest', 'ProcessErrors', 'Socket' ];
\ No newline at end of file
+JobStdoutController.$inject = [ '$rootScope', '$scope', '$compile', '$routeParams', 'ClearScope', 'GetBasePath', 'Wait', 'Rest', 'ProcessErrors', 'Socket' ];
+