summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2015-03-09 13:03:39 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-03-09 14:33:54 +0000
commitf5edfce70d089f47ce440701266122f814b4a94e (patch)
treefd0361fd91fdd9fc7989bc134a780d03b4d94bee /bitbake/lib/toaster
parent0fa38bb8e17f4b56ad25a92123c5ce9894ffa85a (diff)
downloadpoky-f5edfce70d089f47ce440701266122f814b4a94e.tar.gz
bitbake: toaster: projectapp.js - clear up jslint warnings
This patch clears up jslint warnings for the project app, and improves file readability. (Bitbake rev: 10e58867a0231c8039f6d2523b885b9ca7c7dff6) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster')
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/projectapp.js181
1 files changed, 100 insertions, 81 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/projectapp.js b/bitbake/lib/toaster/toastergui/static/js/projectapp.js
index df811fb4a3..82db10781c 100644
--- a/bitbake/lib/toaster/toastergui/static/js/projectapp.js
+++ b/bitbake/lib/toaster/toastergui/static/js/projectapp.js
@@ -61,7 +61,7 @@ angular_formpost = function($httpProvider) {
61 $httpProvider.defaults.transformRequest = [function(data) { 61 $httpProvider.defaults.transformRequest = [function(data) {
62 return angular.isObject(data) && String(data) !== '[object File]' ? param(data) : data; 62 return angular.isObject(data) && String(data) !== '[object File]' ? param(data) : data;
63 }]; 63 }];
64} 64};
65 65
66 66
67/** 67/**
@@ -77,14 +77,14 @@ angular_formpost = function($httpProvider) {
77function _diffArrays(existingArray, newArray, compareElements, onAdded, onDeleted ) { 77function _diffArrays(existingArray, newArray, compareElements, onAdded, onDeleted ) {
78 var added = []; 78 var added = [];
79 var removed = []; 79 var removed = [];
80 newArray.forEach( function( newElement, newIndex, _newArray) { 80 newArray.forEach( function( newElement ) {
81 var existingIndex = existingArray.findIndex(function ( existingElement, _existingIndex, _existingArray ) { 81 var existingIndex = existingArray.findIndex(function ( existingElement ) {
82 return compareElements(newElement, existingElement); 82 return compareElements(newElement, existingElement);
83 }); 83 });
84 if (existingIndex < 0 && onAdded) { added.push(newElement); } 84 if (existingIndex < 0 && onAdded) { added.push(newElement); }
85 }); 85 });
86 existingArray.forEach( function( existingElement, existingIndex, _existingArray) { 86 existingArray.forEach( function( existingElement ) {
87 var newIndex = newArray.findIndex(function ( newElement, _newIndex, _newArray ) { 87 var newIndex = newArray.findIndex(function ( newElement ) {
88 return compareElements(newElement, existingElement); 88 return compareElements(newElement, existingElement);
89 }); 89 });
90 if (newIndex < 0 && onDeleted) { removed.push(existingElement); } 90 if (newIndex < 0 && onDeleted) { removed.push(existingElement); }
@@ -108,7 +108,7 @@ if (Array.prototype.findIndex === undefined) {
108 for ( i = 0; i < this.length; i++ ) 108 for ( i = 0; i < this.length; i++ )
109 if (callback(this[i], i, this)) return i; 109 if (callback(this[i], i, this)) return i;
110 return -1; 110 return -1;
111 } 111 };
112} 112}
113 113
114var projectApp = angular.module('project', ['ngCookies', 'ngAnimate', 'ui.bootstrap', 'ngRoute', 'ngSanitize'], angular_formpost); 114var projectApp = angular.module('project', ['ngCookies', 'ngAnimate', 'ui.bootstrap', 'ngRoute', 'ngSanitize'], angular_formpost);
@@ -124,7 +124,7 @@ projectApp.config(function($interpolateProvider) {
124projectApp.filter('timediff', function() { 124projectApp.filter('timediff', function() {
125 return function(input) { 125 return function(input) {
126 function pad(j) { 126 function pad(j) {
127 if (parseInt(j) < 10) {return "0" + j} 127 if (parseInt(j) < 10) {return "0" + j;}
128 return j; 128 return j;
129 } 129 }
130 seconds = parseInt(input); 130 seconds = parseInt(input);
@@ -133,7 +133,7 @@ projectApp.filter('timediff', function() {
133 hours = Math.floor(seconds / 3600); 133 hours = Math.floor(seconds / 3600);
134 seconds = seconds - hours * 3600; 134 seconds = seconds - hours * 3600;
135 return pad(hours) + ":" + pad(minutes) + ":" + pad(seconds); 135 return pad(hours) + ":" + pad(minutes) + ":" + pad(seconds);
136 } 136 };
137}); 137});
138 138
139// add "time to future" eta that computes time from now to a point in the future 139// add "time to future" eta that computes time from now to a point in the future
@@ -143,7 +143,7 @@ projectApp.filter('toeta', function() {
143 diff = (parseInt(input) - crtmiliseconds ) / 1000; 143 diff = (parseInt(input) - crtmiliseconds ) / 1000;
144 console.log("Debug: future time ", input, "crt time", crtmiliseconds, ":", diff); 144 console.log("Debug: future time ", input, "crt time", crtmiliseconds, ":", diff);
145 return diff < 0 ? 300 : diff; 145 return diff < 0 ? 300 : diff;
146 } 146 };
147}); 147});
148 148
149/** 149/**
@@ -169,7 +169,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
169 }); 169 });
170 170
171 return deffered.promise; 171 return deffered.promise;
172 } 172 };
173 173
174 var inXHRcall = false; 174 var inXHRcall = false;
175 175
@@ -194,7 +194,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
194 } 194 }
195 var deffered = $q.defer(); 195 var deffered = $q.defer();
196 196
197 if (undefined === callparams.headers) { callparams.headers = {} }; 197 if (undefined === callparams.headers) { callparams.headers = {}; }
198 callparams.headers['X-CSRFToken'] = $cookies.csrftoken; 198 callparams.headers['X-CSRFToken'] = $cookies.csrftoken;
199 199
200 $http(callparams).success(function(_data, _status, _headers, _config) { 200 $http(callparams).success(function(_data, _status, _headers, _config) {
@@ -239,12 +239,14 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
239 239
240 // step 3 - display alerts. 240 // step 3 - display alerts.
241 if (addedLayers.length > 0) { 241 if (addedLayers.length > 0) {
242 $scope.displayAlert($scope.zone2alerts, "You have added <b>"+addedLayers.length+"</b> layer" + ((addedLayers.length>1)?"s: ":": ") + addedLayers.map(function (e) { return "<a href=\""+e.layerdetailurl+"\">"+e.name+"</a>" }).join(", "), "alert-info"); 242 $scope.displayAlert($scope.zone2alerts,
243 "You have added <b>"+addedLayers.length+"</b> layer" + ((addedLayers.length>1)?"s: ":": ") + addedLayers.map(function (e) { return "<a href=\""+e.layerdetailurl+"\">"+e.name+"</a>"; }).join(", "),
244 "alert-info");
243 // invalidate error layer data based on current layers 245 // invalidate error layer data based on current layers
244 $scope.layersForTargets = {}; 246 $scope.layersForTargets = {};
245 } 247 }
246 if (deletedLayers.length > 0) { 248 if (deletedLayers.length > 0) {
247 $scope.displayAlert($scope.zone2alerts, "You have deleted <b>"+deletedLayers.length+"</b> layer" + ((deletedLayers.length>1)?"s: ":": ") + deletedLayers.map(function (e) { return "<a href=\""+e.layerdetailurl+"\">"+e.name+"</a>" }).join(", "), "alert-info"); 249 $scope.displayAlert($scope.zone2alerts, "You have deleted <b>"+deletedLayers.length+"</b> layer" + ((deletedLayers.length>1)?"s: ":": ") + deletedLayers.map(function (e) { return "<a href=\""+e.layerdetailurl+"\">"+e.name+"</a>"; }).join(", "), "alert-info");
248 // invalidate error layer data based on current layers 250 // invalidate error layer data based on current layers
249 $scope.layersForTargets = {}; 251 $scope.layersForTargets = {};
250 } 252 }
@@ -323,9 +325,9 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
323 deffered.resolve(_data); 325 deffered.resolve(_data);
324 } 326 }
325 }).error(function(_data, _status, _headers, _config) { 327 }).error(function(_data, _status, _headers, _config) {
326 if (_status == 0) { 328 if (_status === 0) {
327 // the server has gone away 329 // the server has gone away
328 alert("The server is not responding. The application will terminate now") 330 alert("The server is not responding. The application will terminate now");
329 $interval.cancel($scope.pollHandle); 331 $interval.cancel($scope.pollHandle);
330 } 332 }
331 else { 333 else {
@@ -336,7 +338,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
336 }); 338 });
337 339
338 return deffered.promise; 340 return deffered.promise;
339 } 341 };
340 342
341 $scope.layeralert = undefined; 343 $scope.layeralert = undefined;
342 /** 344 /**
@@ -344,33 +346,34 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
344 */ 346 */
345 347
346 $scope.validateData = function () { 348 $scope.validateData = function () {
347 if ($scope.layers.length == 0) { 349 if ($scope.layers.length === 0) {
348 $scope.layeralert = $scope.displayAlert($scope.zone1alerts, "You need to add some layers to this project. <a href=\""+$scope.urls.layers+"\">View all layers available in Toaster</a> or <a href=\""+$scope.urls.importlayer+"\">import a layer</a>"); 350 $scope.layeralert = $scope.displayAlert($scope.zone1alerts, "You need to add some layers to this project. <a href=\""+$scope.urls.layers+"\">View all layers available in Toaster</a> or <a href=\""+$scope.urls.importlayer+"\">import a layer</a>");
349 } else { 351 } else {
350 if ($scope.layeralert != undefined) { 352 if ($scope.layeralert !== undefined) {
351 $scope.layeralert.close(); 353 $scope.layeralert.close();
352 $scope.layeralert = undefined; 354 $scope.layeralert = undefined;
353 } 355 }
354 } 356 }
355 } 357 };
356 358
357 $scope.buildExistingTarget = function(targets) { 359 $scope.buildExistingTarget = function(targets) {
358 $scope.buildTargetList(targets.map(function(v,i,a){return v.target})); 360 $scope.buildTargetList(targets.map(function(v){return v.target;}));
359 } 361 };
360 362
361 $scope.buildTargetList = function(targetlist) { 363 $scope.buildTargetList = function(targetlist) {
362 var oldTargetName = $scope.targetName; 364 var oldTargetName = $scope.targetName;
363 $scope.targetName = targetlist.join(' '); 365 $scope.targetName = targetlist.join(' ');
364 $scope.buildNamedTarget(); 366 $scope.buildNamedTarget();
365 $scope.targetName = oldTargetName; 367 $scope.targetName = oldTargetName;
366 } 368 };
367 369
368 $scope.buildNamedTarget = function(target) { 370 $scope.buildNamedTarget = function() {
369 if ($scope.targetName === undefined && $scope.targetName1 === undefined){ 371 if ($scope.targetName === undefined && $scope.targetName1 === undefined){
370 console.warn("No target defined, please type in a target name"); 372 console.warn("No target defined, please type in a target name");
371 return; 373 return;
372 } 374 }
373 375
376 // this writes the $scope.safeTargetName variable
374 $scope.sanitizeTargetName(); 377 $scope.sanitizeTargetName();
375 378
376 $scope._makeXHRCall({ 379 $scope._makeXHRCall({
@@ -379,6 +382,8 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
379 targets: $scope.safeTargetName, 382 targets: $scope.safeTargetName,
380 } 383 }
381 }).then(function (data) { 384 }).then(function (data) {
385 // make sure nobody re-uses the current $safeTargetName
386 delete $scope.safeTargetName;
382 console.warn("TRC3: received ", data); 387 console.warn("TRC3: received ", data);
383 $scope.targetName = undefined; 388 $scope.targetName = undefined;
384 $scope.targetName1 = undefined; 389 $scope.targetName1 = undefined;
@@ -386,7 +391,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
386 // call $anchorScroll() 391 // call $anchorScroll()
387 $anchorScroll(); 392 $anchorScroll();
388 }); 393 });
389 } 394 };
390 395
391 $scope.sanitizeTargetName = function() { 396 $scope.sanitizeTargetName = function() {
392 $scope.safeTargetName = undefined; 397 $scope.safeTargetName = undefined;
@@ -396,7 +401,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
396 if (undefined === $scope.safeTargetName) return; 401 if (undefined === $scope.safeTargetName) return;
397 402
398 $scope.safeTargetName = $scope.safeTargetName.replace(/\[.*\]/, '').trim(); 403 $scope.safeTargetName = $scope.safeTargetName.replace(/\[.*\]/, '').trim();
399 } 404 };
400 405
401 $scope.buildCancel = function(build) { 406 $scope.buildCancel = function(build) {
402 $scope._makeXHRCall({ 407 $scope._makeXHRCall({
@@ -405,25 +410,25 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
405 buildCancel: build.id, 410 buildCancel: build.id,
406 } 411 }
407 }).then( function () { 412 }).then( function () {
408 build['status'] = "deleted"; 413 build.status = "deleted";
409 $scope.canceledBuilds.push(build); 414 $scope.canceledBuilds.push(build);
410 }); 415 });
411 } 416 };
412 417
413 $scope.buildDelete = function(build) { 418 $scope.buildDelete = function(build) {
414 $scope.canceledBuilds.splice($scope.canceledBuilds.indexOf(build), 1); 419 $scope.canceledBuilds.splice($scope.canceledBuilds.indexOf(build), 1);
415 } 420 };
416 421
417 422
418 $scope.onLayerSelect = function (item, model, label) { 423 $scope.onLayerSelect = function (item) {
419 $scope.layerAddId = item.id; 424 $scope.layerAddId = item.id;
420 } 425 };
421 426
422 427
423 $scope.layerAddById = function (id) { 428 $scope.layerAddById = function (id) {
424 $scope.layerAddId = id; 429 $scope.layerAddId = id;
425 $scope.layerAdd(); 430 $scope.layerAdd();
426 } 431 };
427 432
428 $scope.layerAdd = function() { 433 $scope.layerAdd = function() {
429 434
@@ -439,7 +444,12 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
439 controller: function ($scope, $modalInstance, items, layerAddName) { 444 controller: function ($scope, $modalInstance, items, layerAddName) {
440 $scope.items = items; 445 $scope.items = items;
441 $scope.layerAddName = layerAddName; 446 $scope.layerAddName = layerAddName;
442 $scope.selectedItems = (function () { s = {}; for (var i = 0; i < items.length; i++) { s[items[i].id] = true; };return s; })(); 447 $scope.selectedItems = (function () {
448 s = {};
449 for (var i = 0; i < items.length; i++)
450 { s[items[i].id] = true; }
451 return s;
452 })();
443 453
444 $scope.ok = function() { 454 $scope.ok = function() {
445 console.warn("TRC4: scope selected is ", $scope.selectedItems); 455 console.warn("TRC4: scope selected is ", $scope.selectedItems);
@@ -490,7 +500,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
490 } 500 }
491 } 501 }
492 }); 502 });
493 } 503 };
494 504
495 $scope.layerDel = function(id) { 505 $scope.layerDel = function(id) {
496 $scope._makeXHRCall({ 506 $scope._makeXHRCall({
@@ -499,7 +509,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
499 layerDel: id, 509 layerDel: id,
500 } 510 }
501 }); 511 });
502 } 512 };
503 513
504 514
505 /** 515 /**
@@ -545,13 +555,13 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
545 } 555 }
546 }); 556 });
547 557
548 modalInstance.result.then(function () { $scope.editProjectSettings(elementid)}); 558 modalInstance.result.then(function () { $scope.editProjectSettings(elementid); });
549 } else { 559 } else {
550 $scope.editProjectSettings(elementid); 560 $scope.editProjectSettings(elementid);
551 } 561 }
552 } 562 }
553 }); 563 });
554 } 564 };
555 565
556 /** 566 /**
557 * Performs changes to project settings, and updates the user interface accordingly. 567 * Performs changes to project settings, and updates the user interface accordingly.
@@ -560,23 +570,23 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
560 $scope.editProjectSettings = function(elementid) { 570 $scope.editProjectSettings = function(elementid) {
561 var data = {}; 571 var data = {};
562 console.warn("TRC7: editProjectSettings with ", elementid); 572 console.warn("TRC7: editProjectSettings with ", elementid);
563 var alertText = undefined; 573 var alertText;
564 var alertZone = undefined; 574 var alertZone;
565 var oldLayers = []; 575 var oldLayers = [];
566 576
567 switch(elementid) { 577 switch(elementid) {
568 case '#select-machine': 578 case '#select-machine':
569 alertText = "You have changed the machine to: <strong>" + $scope.machineName + "</strong>"; 579 alertText = "You have changed the machine to: <strong>" + $scope.machineName + "</strong>";
570 alertZone = $scope.zone2alerts; 580 alertZone = $scope.zone2alerts;
571 data['machineName'] = $scope.machineName; 581 data.machineName = $scope.machineName;
572 break; 582 break;
573 case '#change-project-name': 583 case '#change-project-name':
574 data['projectName'] = $scope.projectName; 584 data.projectName = $scope.projectName;
575 alertText = "You have changed the project name to: <strong>" + $scope.projectName + "</strong>"; 585 alertText = "You have changed the project name to: <strong>" + $scope.projectName + "</strong>";
576 alertZone = $scope.zone3alerts; 586 alertZone = $scope.zone3alerts;
577 break; 587 break;
578 case '#change-project-version': 588 case '#change-project-version':
579 data['projectVersion'] = $scope.projectVersion; 589 data.projectVersion = $scope.projectVersion;
580 alertText = "You have changed the release to: "; 590 alertText = "You have changed the release to: ";
581 alertZone = $scope.zone3alerts; 591 alertZone = $scope.zone3alerts;
582 // save old layers 592 // save old layers
@@ -590,15 +600,15 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
590 method: "POST", url: $scope.urls.xhr_edit, data: data, 600 method: "POST", url: $scope.urls.xhr_edit, data: data,
591 }).then( function (_data) { 601 }).then( function (_data) {
592 $scope.toggle(elementid); 602 $scope.toggle(elementid);
593 if (data['projectVersion'] != undefined) { 603 if (data.projectVersion !== undefined) {
594 alertText += "<strong>" + $scope.project.release.desc + "</strong>. "; 604 alertText += "<strong>" + $scope.project.release.desc + "</strong>. ";
595 } 605 }
596 if (elementid == '#change-project-version') { 606 if (elementid == '#change-project-version') {
597 $scope.layersForTargets = {}; // invalidate error layers for the targets, since layers changed 607 $scope.layersForTargets = {}; // invalidate error layers for the targets, since layers changed
598 608
599 // requirement https://bugzilla.yoctoproject.org/attachment.cgi?id=2229, notification for changed version to include layers 609 // requirement https://bugzilla.yoctoproject.org/attachment.cgi?id=2229, notification for changed version to include layers
600 $scope.zone2alerts.forEach(function (e) { e.close() }); 610 $scope.zone2alerts.forEach(function (e) { e.close(); });
601 alertText += "This has caused the following changes in your project layers:<ul>" 611 alertText += "This has caused the following changes in your project layers:<ul>";
602 612
603 613
604 // warnings - this is executed AFTER the generic XHRCall handling is done; at this point, 614 // warnings - this is executed AFTER the generic XHRCall handling is done; at this point,
@@ -606,14 +616,14 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
606 // show added/deleted layer notifications; scope.layers is already updated by this point. 616 // show added/deleted layer notifications; scope.layers is already updated by this point.
607 var addedLayers = []; 617 var addedLayers = [];
608 var deletedLayers = []; 618 var deletedLayers = [];
609 _diffArrays( oldLayers, $scope.layers, function (e, f) { return e.id == f.id }, 619 _diffArrays( oldLayers, $scope.layers, function (e, f) { return e.id == f.id; },
610 function (e) {addedLayers.push(e); }, 620 function (e) {addedLayers.push(e); },
611 function (e) {deletedLayers.push(e); }); 621 function (e) {deletedLayers.push(e); });
612 622
613 // some of the deleted layers are actually replaced (changed) layers 623 // some of the deleted layers are actually replaced (changed) layers
614 var changedLayers = []; 624 var changedLayers = [];
615 deletedLayers.forEach(function (e) { 625 deletedLayers.forEach(function (e) {
616 if ( -1 < addedLayers.findIndex(function (f) { return f.name == e.name })) { 626 if ( -1 < addedLayers.findIndex(function (f) { return f.name == e.name; })) {
617 changedLayers.push(e); 627 changedLayers.push(e);
618 } 628 }
619 }); 629 });
@@ -623,10 +633,10 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
623 }); 633 });
624 634
625 if (addedLayers.length > 0) { 635 if (addedLayers.length > 0) {
626 alertText += "<li><strong>"+addedLayers.length+"</strong> layer" + ((addedLayers.length>1)?"s changed: ":" changed: ") + addedLayers.map(function (e) { return "<a href=\""+e.layerdetailurl+"\">"+e.name+"</a>" }).join(", ") + "</li>"; 636 alertText += "<li><strong>"+addedLayers.length+"</strong> layer" + ((addedLayers.length>1)?"s changed: ":" changed: ") + addedLayers.map(function (e) { return "<a href=\""+e.layerdetailurl+"\">"+e.name+"</a>"; }).join(", ") + "</li>";
627 } 637 }
628 if (deletedLayers.length > 0) { 638 if (deletedLayers.length > 0) {
629 alertText += "<li><strong>"+deletedLayers.length+"</strong> layer" + ((deletedLayers.length>1)?"s deleted: ":"deleted: ") + deletedLayers.map(function (e) { return "<a href=\""+e.layerdetailurl+"\">"+e.name+"</a>" }).join(", ") + "</li>"; 639 alertText += "<li><strong>"+deletedLayers.length+"</strong> layer" + ((deletedLayers.length>1)?"s deleted: ":"deleted: ") + deletedLayers.map(function (e) { return "<a href=\""+e.layerdetailurl+"\">"+e.name+"</a>"; }).join(", ") + "</li>";
630 } 640 }
631 641
632 } 642 }
@@ -634,7 +644,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
634 } 644 }
635 $scope.displayAlert(alertZone, alertText, "alert-info"); 645 $scope.displayAlert(alertZone, alertText, "alert-info");
636 }); 646 });
637 } 647 };
638 648
639 649
640 /** 650 /**
@@ -645,15 +655,15 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
645 cmd = $location.path(); 655 cmd = $location.path();
646 656
647 function _cmdExecuteWithParam(param, f) { 657 function _cmdExecuteWithParam(param, f) {
648 if (cmd.indexOf(param)==0) { 658 if (cmd.indexOf(param) === 0) {
649 if (cmd.indexOf("=") > -1) { 659 if (cmd.indexOf("=") > -1) {
650 var parameter = cmd.split("=", 2)[1]; 660 var parameter = cmd.split("=", 2)[1];
651 if (parameter != undefined && parameter.length > 0) { 661 if (parameter !== undefined && parameter.length > 0) {
652 f(parameter); 662 f(parameter);
653 } 663 }
654 } else { 664 } else {
655 f(); 665 f();
656 }; 666 }
657 } 667 }
658 } 668 }
659 669
@@ -674,14 +684,14 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
674 }); 684 });
675 }); 685 });
676 686
677 _cmdExecuteWithParam("/layerimported", function (layer) { 687 _cmdExecuteWithParam("/layerimported", function () {
678 var imported = $cookieStore.get("layer-imported-alert"); 688 var imported = $cookieStore.get("layer-imported-alert");
679 var text; 689 var text;
680 690
681 if (!imported) 691 if (!imported)
682 return; 692 return;
683 693
684 if (imported.deps_added.length == 0) { 694 if (imported.deps_added.length === 0) {
685 text = "You have imported <strong><a href=\""+$scope.urls.layer+ 695 text = "You have imported <strong><a href=\""+$scope.urls.layer+
686 imported.imported_layer.id+"\">"+imported.imported_layer.name+ 696 imported.imported_layer.id+"\">"+imported.imported_layer.name+
687 "</a></strong> and added it to your project."; 697 "</a></strong> and added it to your project.";
@@ -694,7 +704,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
694 links +="<a href=\""+$scope.urls.layer+item.id+"\" >"+item.name+ 704 links +="<a href=\""+$scope.urls.layer+item.id+"\" >"+item.name+
695 "</a>"; 705 "</a>";
696 /*If we're at the last element we don't want the trailing comma */ 706 /*If we're at the last element we don't want the trailing comma */
697 if (imported.deps_added[index+1] != undefined) 707 if (imported.deps_added[index+1] !== undefined)
698 links += ", "; 708 links += ", ";
699 }); 709 });
700 710
@@ -731,7 +741,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
731 $scope.layerAdd(); 741 $scope.layerAdd();
732 }); 742 });
733 }); 743 });
734 } 744 };
735 745
736 /** 746 /**
737 * Utility function to display an alert to the user 747 * Utility function to display an alert to the user
@@ -740,16 +750,21 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
740 $scope.displayAlert = function(zone, text, type) { 750 $scope.displayAlert = function(zone, text, type) {
741 if (zone.maxid === undefined) { zone.maxid = 0; } 751 if (zone.maxid === undefined) { zone.maxid = 0; }
742 var crtid = zone.maxid ++; 752 var crtid = zone.maxid ++;
743 angular.forEach(zone, function (o) { o.close() }); 753 angular.forEach(zone, function (o) { o.close(); });
744 o = { 754 o = {
745 id: crtid, text: text, type: type, 755 id: crtid, text: text, type: type,
746 close: function() { 756 close: function() {
747 zone.splice((function(id){ for (var i = 0; i < zone.length; i++) if (id == zone[i].id) { return i}; return undefined;})(crtid), 1); 757 zone.splice((function(id) {
758 for (var i = 0; i < zone.length; i++)
759 if (id == zone[i].id)
760 { return i; }
761 return undefined;
762 }) (crtid), 1);
748 }, 763 },
749 } 764 };
750 zone.push(o); 765 zone.push(o);
751 return o; 766 return o;
752 } 767 };
753 768
754 /** 769 /**
755 * Toggles display items between label and input box (the edit pencil icon) on selected settings in project page 770 * Toggles display items between label and input box (the edit pencil icon) on selected settings in project page
@@ -762,7 +777,7 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
762 777
763 angular.element(id).toggle(); 778 angular.element(id).toggle();
764 angular.element(id+"-opposite").toggle(); 779 angular.element(id+"-opposite").toggle();
765 } 780 };
766 781
767 /** 782 /**
768 * Functionality related to "Most build targets" 783 * Functionality related to "Most build targets"
@@ -770,44 +785,48 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
770 785
771 $scope.enableBuildSelectedTargets = function () { 786 $scope.enableBuildSelectedTargets = function () {
772 var keys = Object.keys($scope.mostBuiltTargets); 787 var keys = Object.keys($scope.mostBuiltTargets);
773 keys = keys.filter(function (e) { if ($scope.mostBuiltTargets[e]) return e }); 788 keys = keys.filter(function (e) { if ($scope.mostBuiltTargets[e]) return e; });
774 return keys.length == 0; 789 return keys.length === 0;
775 } 790 };
776 791
777 $scope.buildSelectedTargets = function () { 792 $scope.buildSelectedTargets = function () {
778 var keys = Object.keys($scope.mostBuiltTargets); 793 var keys = Object.keys($scope.mostBuiltTargets);
779 keys = keys.filter(function (e) { if ($scope.mostBuiltTargets[e]) return e }); 794 keys = keys.filter(function (e) { if ($scope.mostBuiltTargets[e]) return e; });
780 795
781 $scope.buildTargetList(keys); 796 $scope.buildTargetList(keys);
782 for (var i = 0; i < keys.length; i++) 797 for (var i = 0; i < keys.length; i++)
783 { 798 {
784 $scope.mostBuiltTargets[keys[i]] = 0; 799 $scope.mostBuiltTargets[keys[i]] = 0;
785 } 800 }
786 } 801 };
787 802
788 /** 803 /**
789 * Helper function to deal with error string recognition and manipulation 804 * Helper function to deal with error string recognition and manipulation
790 */ 805 */
791 806
792 $scope.getTargetNameFromErrorMsg = function (msg) { 807 $scope.getTargetNameFromErrorMsg = function (msg) {
793 targets = msg.split(" ").splice(2).map(function (v) { return v.replace(/'/g, '')}) 808 return msg.split(" ").splice(2).map(function (v) { return v.replace(/'/g, ''); });
794 return targets; 809 };
795 } 810
811 /**
812 * Utility function to retrieve which layers can be added to the project if the target was not
813 * provided by any of the existing project layers
814 */
796 815
797 $scope.fetchLayersForTargets = function () { 816 $scope.fetchLayersForTargets = function () {
798 $scope.builds.forEach(function (buildrequest) { 817 $scope.builds.forEach(function (buildrequest) {
799 buildrequest.errors.forEach(function (error) { 818 buildrequest.errors.forEach(function (error) {
800 if (error.msg.indexOf("Nothin") == 0) { 819 if (error.msg.indexOf("Nothin") === 0) {
801 $scope.getTargetNameFromErrorMsg(error.msg).forEach(function (target) { 820 $scope.getTargetNameFromErrorMsg(error.msg).forEach(function (target) {
802 if ($scope.layersForTargets[target] === undefined) 821 if ($scope.layersForTargets[target] === undefined)
803 $scope.getAutocompleteSuggestions("layers4target", target).then( function (list) { 822 $scope.getAutocompleteSuggestions("layers4target", target).then( function (list) {
804 $scope.layersForTargets[target] = list; 823 $scope.layersForTargets[target] = list;
805 }) 824 });
806 }) 825 });
807 } 826 }
808 }) 827 });
809 }) 828 });
810 } 829 };
811 830
812 831
813 /** 832 /**
@@ -819,16 +838,16 @@ projectApp.controller('prjCtrl', function($scope, $modal, $http, $interval, $loc
819 $scope.layersForTargets = {}; 838 $scope.layersForTargets = {};
820 $scope.fetchLayersForTargets(); 839 $scope.fetchLayersForTargets();
821 $scope.pollHandle = $interval(function () { $scope._makeXHRCall({method: "GET", url: $scope.urls.xhr_edit, data: undefined});}, 2000, 0); 840 $scope.pollHandle = $interval(function () { $scope._makeXHRCall({method: "GET", url: $scope.urls.xhr_edit, data: undefined});}, 2000, 0);
822 } 841 };
823 842
824}); 843});
825 844
826 845
827var s = undefined; 846var _testing_scope;
828 847
829function test_set_alert(text) { 848function test_set_alert(text) {
830 s = angular.element("div#main").scope(); 849 _testing_scope = angular.element("div#main").scope();
831 s.displayAlert(s.zone3alerts, text); 850 _testing_scope.displayAlert(_testing_scope.zone3alerts, text);
832 console.warn("TRC8: zone3alerts", s.zone3alerts); 851 console.warn("TRC8: zone3alerts", _testing_scope.zone3alerts);
833 s.$digest(); 852 _testing_scope.$digest();
834} 853}