This is an amazing addition, thank you ! Taken for submission,
Alex On Tue, Mar 3, 2015 at 4:18 PM, Michael Wood <[email protected]> wrote: > Fix warnings and items that do not conform to strict. > Also add a fairly lenient jshintrc. usage: jshint js_file > > Signed-off-by: Michael Wood <[email protected]> > --- > bitbake/lib/toaster/toastergui/static/js/.jshintrc | 11 +++ > .../lib/toaster/toastergui/static/js/libtoaster.js | 79 > +++++++++++----------- > 2 files changed, 51 insertions(+), 39 deletions(-) > create mode 100644 bitbake/lib/toaster/toastergui/static/js/.jshintrc > > diff --git a/bitbake/lib/toaster/toastergui/static/js/.jshintrc > b/bitbake/lib/toaster/toastergui/static/js/.jshintrc > new file mode 100644 > index 0000000..b02f3ef > --- /dev/null > +++ b/bitbake/lib/toaster/toastergui/static/js/.jshintrc > @@ -0,0 +1,11 @@ > +{ > + "curly" : false, > + "predef" : [ "$","libtoaster", "prettyPrint" ], > + "eqnull": true, > + "plusplus" : false, > + "browser" : true, > + "jquery" : true, > + "devel" : true, > + "unused" : true, > + "maxerr" : 60 > +} > diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js > b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js > index ea1522f..3832066 100644 > --- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js > +++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js > @@ -1,3 +1,4 @@ > +"use strict"; > /* All shared functionality to go in libtoaster object. > * This object really just helps readability since we can then have > * a traceable namespace. > @@ -19,7 +20,7 @@ var libtoaster = (function (){ > source: function(query, process){ > xhrParams.value = query; > $.getJSON(xhrUrl, this.options.xhrParams, function(data){ > - if (data.error != "ok") { > + if (data.error !== "ok") { > console.log("Error getting data from server "+data.error); > return; > } > @@ -61,7 +62,7 @@ var libtoaster = (function (){ > } > > jQElement.data('typeahead').render = customRenderFunc; > - }; > + } > > /* > * url - the url of the xhr build */ > @@ -79,10 +80,10 @@ var libtoaster = (function (){ > data: data, > headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, > success: function (_data) { > - if (_data.error != "ok") { > + if (_data.error !== "ok") { > console.warn(_data.error); > } else { > - if (onsuccess != undefined) onsuccess(_data); > + if (onsuccess !== undefined) onsuccess(_data); > } > }, > error: function (_data) { > @@ -90,7 +91,7 @@ var libtoaster = (function (){ > console.warn(_data); > if (onfail) onfail(data); > } }); > - }; > + } > > /* Get a project's configuration info */ > function _getProjectInfo(url, projectId, onsuccess, onfail){ > @@ -100,18 +101,18 @@ var libtoaster = (function (){ > data: { project_id : projectId }, > headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, > success: function (_data) { > - if (_data.error != "ok") { > + if (_data.error !== "ok") { > console.warn(_data.error); > } else { > - if (onsuccess != undefined) onsuccess(_data); > + if (onsuccess !== undefined) onsuccess(_data); > } > }, > error: function (_data) { > console.warn(_data); > - if (onfail) onfail(data); > + if (onfail) onfail(_data); > } > }); > - }; > + } > > /* Properties for data can be: > * layerDel (csv) > @@ -129,10 +130,10 @@ var libtoaster = (function (){ > success: function (data) { > if (data.error != "ok") { > console.log(data.error); > - if (onFail != undefined) > + if (onFail !== undefined) > onFail(data); > } else { > - if (onSuccess != undefined) > + if (onSuccess !== undefined) > onSuccess(data); > } > }, > @@ -141,7 +142,7 @@ var libtoaster = (function (){ > console.log(data); > } > }); > - }; > + } > > function _getLayerDepsForProject(xhrDataTypeaheadUrl, projectId, > layerId, onSuccess, onFail){ > /* Check for dependencies not in the current project */ > @@ -150,7 +151,7 @@ var libtoaster = (function (){ > function(data) { > if (data.error != "ok") { > console.log(data.error); > - if (onFail != undefined) > + if (onFail !== undefined) > onFail(data); > } else { > onSuccess(data); > @@ -158,22 +159,22 @@ var libtoaster = (function (){ > }, function() { > console.log("E: Failed to make request"); > }); > - }; > + } > > /* parses the query string of the current window.location to an object > */ > function _parseUrlParams() { > - string = window.location.search > + var string = window.location.search; > string = string.substr(1); > - stringArray = string.split ("&"); > - obj = {}; > + var stringArray = string.split ("&"); > + var obj = {}; > > - for (i in stringArray) { > - keyVal = stringArray[i].split ("="); > + for (var i in stringArray) { > + var keyVal = stringArray[i].split ("="); > obj[keyVal[0]] = keyVal[1]; > } > > return obj; > - }; > + } > > /* takes a flat object and outputs it as a query string > * e.g. the output of dumpsUrlParams > @@ -181,7 +182,7 @@ var libtoaster = (function (){ > function _dumpsUrlParams(obj) { > var str = "?"; > > - for (key in obj){ > + for (var key in obj){ > if (!obj[key]) > continue; > > @@ -190,7 +191,7 @@ var libtoaster = (function (){ > } > > return str; > - }; > + } > > > return { > @@ -203,23 +204,23 @@ var libtoaster = (function (){ > debug: false, > parseUrlParams : _parseUrlParams, > dumpsUrlParams : _dumpsUrlParams, > - } > + }; > })(); > > /* keep this in the global scope for compatability */ > function reload_params(params) { > - uri = window.location.href; > - splitlist = uri.split("?"); > - url = splitlist[0], parameters=splitlist[1]; > + var uri = window.location.href; > + var splitlist = uri.split("?"); > + var url = splitlist[0]; > + var parameters = splitlist[1]; > // deserialize the call parameters > - if(parameters){ > - cparams = parameters.split("&"); > - }else{ > - cparams = [] > - } > - nparams = {} > - for (i = 0; i < cparams.length; i++) { > - temp = cparams[i].split("="); > + var cparams = []; > + if(parameters) > + cparams = parameters.split("&"); > + > + var nparams = {}; > + for (var i = 0; i < cparams.length; i++) { > + var temp = cparams[i].split("="); > nparams[temp[0]] = temp[1]; > } > // update parameter values > @@ -227,7 +228,7 @@ function reload_params(params) { > nparams[encodeURIComponent(i)] = encodeURIComponent(params[i]); > } > // serialize the structure > - callparams = [] > + var callparams = []; > for (i in nparams) { > callparams.push(i+"="+nparams[i]); > } > @@ -238,7 +239,7 @@ function reload_params(params) { > /* Things that happen for all pages */ > $(document).ready(function() { > > - /* If we don't have a console object which might be the case in some > + /* If we don't have a console object which might be the case in some > * browsers, no-op it to avoid undefined errors. > */ > if (!window.console) { > @@ -271,7 +272,7 @@ $(document).ready(function() { > // .btn class applied, and make sure popovers work on click, are > mutually > // exclusive and they close when your click outside their area > > - $('html').click(function(e){ > + $('html').click(function(){ > $('td > a.btn').popover('hide'); > }); > > @@ -323,9 +324,9 @@ $(document).ready(function() { > // linking directly to tabs > $(function(){ > var hash = window.location.hash; > - hash && $('ul.nav a[href="' + hash + '"]').tab('show'); > + $('ul.nav a[href="' + hash + '"]').tab('show'); > > - $('.nav-tabs a').click(function (e) { > + $('.nav-tabs a').click(function () { > $(this).tab('show'); > $('body').scrollTop(); > }); > -- > 2.1.0 > > -- > _______________________________________________ > toaster mailing list > [email protected] > https://lists.yoctoproject.org/listinfo/toaster > -- Alex Damian Yocto Project SSG / OTC
-- _______________________________________________ toaster mailing list [email protected] https://lists.yoctoproject.org/listinfo/toaster
