PageSourceSearch

https://login.efleets.com/fleetweb/include/2.39.0.614/javascript/angular-utils/directives/gadgetBuilder.js

js efleets.com collected 2026-09-28 08:47:43 UTC 2,702 bytes, 57 lines download raw bytes

1angular.module('gadgetBuilderDirectives',[]).directive('gadgetBuilder', function($compile) {	
2	  return {
3		    compile : function(element, attr, linker){
4		    	var myElement = element.clone();
5		    	
6		    	 return function($scope, $element, $attr){
7			  	          var myLoop = $attr.gadgetBuilder,
8			              match = myLoop.match(/^\s*(.+)\s+in\s+(.*?)\s*(\s+track\s+by\s+(.+)\s*)?$/),
9			              indexString = match[1],
10			              collectionString = match[2],
11			              parent = $element.parent();
12			  	          
13			          // $watchCollection is called everytime the collection is modified
14			          $scope.$watchCollection(collectionString, function(collection){
15			            var i, block, childScope;
16			            parent.empty();
17			            for (i = 0; i < collection.length; i++) {
18			              var template = myElement.html();
19
20			              // create a new scope for every element in the collection.
21			              childScope = $scope.$new();
22			              // pass the current element of the collection into that scope
23			              childScope[indexString] = collection[i];
24			              childScope.$index = i;
25			              childScope.$first = (i === 0);
26			              childScope.$last = (i === (collection.length - 1));
27			              
28			              if (childScope.userGadget.gadget.shortDescription != 'empty') {
29			            	  template = template.replace('$controller$',"ng-controller='" + childScope.userGadget.gadget.controllerName + "'");
30			            	  template = template.replace('$directive$',childScope.userGadget.gadget.directiveName);
31			            	  
32			            	  if (childScope.userGadget.gadget.chartType) {
33			            		  template = template.replace('$google-chart$',"google-chart='" + childScope.userGadget.gadget.chartType + "'" +
34			            				  " ng-model='dataModel' trigger='activateChart'");
35			            	  } else {
36			            		  template = template.replace('$google-chart$',""); 
37			            	  }
38			              } else {
39			            	  template = template.replace('$controller$',"");
40			            	  template = template.replace('$directive$',"");	
41			            	  template = template.replace('$google-chart$',"");
42			              }
43
44			              var linkFn = $compile(template);
45			              var content = linkFn(childScope);
46			              
47			              if (childScope.userGadget.gadget.shortDescription != 'empty') {
48			            	  content.removeClass("empty");
49			              }
50			              
51			              parent.append(content); // add to DOM
52			            };
53			          });        		
54		        	}
55		        }
56		  }
57	});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.