Job stdout refactor

Switching to new stdout endpoint and restyling.
This commit is contained in:
Chris Houseknecht
2014-06-23 13:41:33 -04:00
parent 8d78755ef4
commit 2c0e0324f6
6 changed files with 2880 additions and 50 deletions
+4 -40
View File
@@ -33,52 +33,16 @@ function JobStdoutController ($rootScope, $scope, $compile, $routeParams, ClearS
$scope.removeLoadStdout();
}
$scope.removeLoadStdout = $scope.$on('LoadStdout', function() {
Rest.setUrl(stdout_url + '?format=html');
Rest.setUrl(stdout_url + '?format=json&start_line=-1000');
Rest.get()
.success(function(data) {
var lines, styles=[], html=[], found=false, doc, style, pre, parser;
api_complete = true;
Wait('stop');
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 (/<style.*/.test(line)) {
found = true;
}
if (found) {
styles.push(line);
}
if (/<\/style>/.test(line)) {
found = false;
}
});
found = false;
// Get all the bits between <pre> and </pre>
lines.forEach(function(line) {
if (/<pre>/.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"));
if (data.content) {
$('#pre-container-content').empty().html(data.content);
}
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());
$('#pre-container-content').empty();
}
setTimeout(function() { $('#pre-container').mCustomScrollbar("scrollTo", 'bottom'); }, 1000);
})