Code cleanup part #1: move all the services and directive JS code in the app.js file into its own files
This commit is contained in:
parent
3cae6609a7
commit
9b87999c1c
97 changed files with 7076 additions and 6870 deletions
38
static/js/directives/ui/dockerfile-view.js
Normal file
38
static/js/directives/ui/dockerfile-view.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
* An element which displays the contents of a Dockerfile in a nicely formatted way.
|
||||
*/
|
||||
angular.module('quay').directive('dockerfileView', function () {
|
||||
var directiveDefinitionObject = {
|
||||
priority: 0,
|
||||
templateUrl: '/static/directives/dockerfile-view.html',
|
||||
replace: false,
|
||||
transclude: false,
|
||||
restrict: 'C',
|
||||
scope: {
|
||||
'contents': '=contents'
|
||||
},
|
||||
controller: function($scope, $element, UtilService) {
|
||||
$scope.$watch('contents', function(contents) {
|
||||
$scope.lines = [];
|
||||
|
||||
var lines = contents ? contents.split('\n') : [];
|
||||
for (var i = 0; i < lines.length; ++i) {
|
||||
var line = $.trim(lines[i]);
|
||||
var kind = 'text';
|
||||
if (line && line[0] == '#') {
|
||||
kind = 'comment';
|
||||
} else if (line.match(/^([A-Z]+\s)/)) {
|
||||
kind = 'command';
|
||||
}
|
||||
|
||||
var lineInfo = {
|
||||
'text': line,
|
||||
'kind': kind
|
||||
};
|
||||
$scope.lines.push(lineInfo);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
return directiveDefinitionObject;
|
||||
});
|
Reference in a new issue