bitbake: toaster: base.js minor jshint fixes

Fixing errors identified by jshint, some missing semicolons and
preference for === operator. Also pass the urldata in libtoaster as an
object rather than constructing a query string.

(Bitbake rev: 8652fbaf5e8c56d9d28b7da57432f37313a19b4a)

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Michael Wood
2015-03-27 15:49:55 +00:00
committed by Richard Purdie
parent 65e9859769
commit fab29bd737
2 changed files with 13 additions and 15 deletions

View File

@@ -6,7 +6,7 @@ function basePageInit (ctx) {
/* Hide the button if we're on the project,newproject or importlyaer page /* Hide the button if we're on the project,newproject or importlyaer page
* or if there are no projects yet defined * or if there are no projects yet defined
*/ */
if (ctx.numProjects == 0 || ctx.currentUrl.search('newproject|project/\\d/$|importlayer/$') > 0){ if (ctx.numProjects === 0 || ctx.currentUrl.search('newproject|project/\\d/$|importlayer/$') > 0){
newBuildButton.hide(); newBuildButton.hide();
return; return;
} }
@@ -18,17 +18,17 @@ function basePageInit (ctx) {
newBuildButton.show().removeAttr("disabled"); newBuildButton.show().removeAttr("disabled");
_checkProjectBuildable() _checkProjectBuildable();
_setupNewBuildButton(); _setupNewBuildButton();
function _checkProjectBuildable(){ function _checkProjectBuildable(){
if (ctx.projectId == undefined) if (ctx.projectId === undefined)
return; return;
libtoaster.getProjectInfo(ctx.projectInfoUrl, ctx.projectId, libtoaster.getProjectInfo(ctx.projectInfoUrl, ctx.projectId,
function(data){ function(data){
if (data.machine.name == undefined || data.layers.length == 0) { if (data.machine.name === undefined || data.layers.length === 0) {
/* we can't build anything with out a machine and some layers */ /* we can't build anything with out a machine and some layers */
$("#new-build-button #targets-form").hide(); $("#new-build-button #targets-form").hide();
$("#new-build-button .alert").show(); $("#new-build-button .alert").show();
@@ -51,7 +51,7 @@ function basePageInit (ctx) {
/* If we don't have a current project then present the set project /* If we don't have a current project then present the set project
* form. * form.
*/ */
if (ctx.projectId == undefined) { if (ctx.projectId === undefined) {
$('#change-project-form').show(); $('#change-project-form').show();
$('#project .icon-pencil').hide(); $('#project .icon-pencil').hide();
} }
@@ -72,13 +72,13 @@ function basePageInit (ctx) {
* the value that has been set by selecting a suggestion from the typeahead * the value that has been set by selecting a suggestion from the typeahead
*/ */
newBuildProjectInput.on('input', function(event) { newBuildProjectInput.on('input', function(event) {
if (event.keyCode == 13) if (event.keyCode === 13)
return; return;
newBuildProjectSaveBtn.attr("disabled", "disabled"); newBuildProjectSaveBtn.attr("disabled", "disabled");
}); });
newBuildTargetInput.on('input', function() { newBuildTargetInput.on('input', function() {
if ($(this).val().length == 0) if ($(this).val().length === 0)
newBuildTargetBuildBtn.attr("disabled", "disabled"); newBuildTargetBuildBtn.attr("disabled", "disabled");
else else
newBuildTargetBuildBtn.removeAttr("disabled"); newBuildTargetBuildBtn.removeAttr("disabled");
@@ -96,7 +96,7 @@ function basePageInit (ctx) {
}); });
newBuildProjectSaveBtn.click(function() { newBuildProjectSaveBtn.click(function() {
ctx.projectId = selectedProject.id ctx.projectId = selectedProject.id;
/* Update the typeahead project_id paramater */ /* Update the typeahead project_id paramater */
_checkProjectBuildable(); _checkProjectBuildable();
newBuildTargetInput.data('typeahead').options.xhrParams.project_id = ctx.projectId; newBuildTargetInput.data('typeahead').options.xhrParams.project_id = ctx.projectId;
@@ -131,6 +131,5 @@ function basePageInit (ctx) {
$(".new-build").click (function(event) { $(".new-build").click (function(event) {
event.stopPropagation(); event.stopPropagation();
}); });
}; }
} }

View File

@@ -67,12 +67,11 @@ var libtoaster = (function (){
/* /*
* url - the url of the xhr build */ * url - the url of the xhr build */
function _startABuild (url, project_id, targets, onsuccess, onfail) { function _startABuild (url, project_id, targets, onsuccess, onfail) {
var data;
if (project_id) var data = {
data = 'project_id='+project_id+'&targets='+targets; project_id : project_id,
else targets : targets,
data = 'targets='+targets; }
$.ajax( { $.ajax( {
type: "POST", type: "POST",