diff options
| -rw-r--r-- | bitbake/lib/toaster/toastergui/static/js/.jshintrc | 11 | ||||
| -rw-r--r-- | bitbake/lib/toaster/toastergui/static/js/libtoaster.js | 79 |
2 files changed, 51 insertions, 39 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/.jshintrc b/bitbake/lib/toaster/toastergui/static/js/.jshintrc new file mode 100644 index 0000000000..b02f3efa1c --- /dev/null +++ b/bitbake/lib/toaster/toastergui/static/js/.jshintrc | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | { | ||
| 2 | "curly" : false, | ||
| 3 | "predef" : [ "$","libtoaster", "prettyPrint" ], | ||
| 4 | "eqnull": true, | ||
| 5 | "plusplus" : false, | ||
| 6 | "browser" : true, | ||
| 7 | "jquery" : true, | ||
| 8 | "devel" : true, | ||
| 9 | "unused" : true, | ||
| 10 | "maxerr" : 60 | ||
| 11 | } | ||
diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js index ea1522f471..38320667dc 100644 --- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js +++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | "use strict"; | ||
| 1 | /* All shared functionality to go in libtoaster object. | 2 | /* All shared functionality to go in libtoaster object. |
| 2 | * This object really just helps readability since we can then have | 3 | * This object really just helps readability since we can then have |
| 3 | * a traceable namespace. | 4 | * a traceable namespace. |
| @@ -19,7 +20,7 @@ var libtoaster = (function (){ | |||
| 19 | source: function(query, process){ | 20 | source: function(query, process){ |
| 20 | xhrParams.value = query; | 21 | xhrParams.value = query; |
| 21 | $.getJSON(xhrUrl, this.options.xhrParams, function(data){ | 22 | $.getJSON(xhrUrl, this.options.xhrParams, function(data){ |
| 22 | if (data.error != "ok") { | 23 | if (data.error !== "ok") { |
| 23 | console.log("Error getting data from server "+data.error); | 24 | console.log("Error getting data from server "+data.error); |
| 24 | return; | 25 | return; |
| 25 | } | 26 | } |
| @@ -61,7 +62,7 @@ var libtoaster = (function (){ | |||
| 61 | } | 62 | } |
| 62 | 63 | ||
| 63 | jQElement.data('typeahead').render = customRenderFunc; | 64 | jQElement.data('typeahead').render = customRenderFunc; |
| 64 | }; | 65 | } |
| 65 | 66 | ||
| 66 | /* | 67 | /* |
| 67 | * url - the url of the xhr build */ | 68 | * url - the url of the xhr build */ |
| @@ -79,10 +80,10 @@ var libtoaster = (function (){ | |||
| 79 | data: data, | 80 | data: data, |
| 80 | headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, | 81 | headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, |
| 81 | success: function (_data) { | 82 | success: function (_data) { |
| 82 | if (_data.error != "ok") { | 83 | if (_data.error !== "ok") { |
| 83 | console.warn(_data.error); | 84 | console.warn(_data.error); |
| 84 | } else { | 85 | } else { |
| 85 | if (onsuccess != undefined) onsuccess(_data); | 86 | if (onsuccess !== undefined) onsuccess(_data); |
| 86 | } | 87 | } |
| 87 | }, | 88 | }, |
| 88 | error: function (_data) { | 89 | error: function (_data) { |
| @@ -90,7 +91,7 @@ var libtoaster = (function (){ | |||
| 90 | console.warn(_data); | 91 | console.warn(_data); |
| 91 | if (onfail) onfail(data); | 92 | if (onfail) onfail(data); |
| 92 | } }); | 93 | } }); |
| 93 | }; | 94 | } |
| 94 | 95 | ||
| 95 | /* Get a project's configuration info */ | 96 | /* Get a project's configuration info */ |
| 96 | function _getProjectInfo(url, projectId, onsuccess, onfail){ | 97 | function _getProjectInfo(url, projectId, onsuccess, onfail){ |
| @@ -100,18 +101,18 @@ var libtoaster = (function (){ | |||
| 100 | data: { project_id : projectId }, | 101 | data: { project_id : projectId }, |
| 101 | headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, | 102 | headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, |
| 102 | success: function (_data) { | 103 | success: function (_data) { |
| 103 | if (_data.error != "ok") { | 104 | if (_data.error !== "ok") { |
| 104 | console.warn(_data.error); | 105 | console.warn(_data.error); |
| 105 | } else { | 106 | } else { |
| 106 | if (onsuccess != undefined) onsuccess(_data); | 107 | if (onsuccess !== undefined) onsuccess(_data); |
| 107 | } | 108 | } |
| 108 | }, | 109 | }, |
| 109 | error: function (_data) { | 110 | error: function (_data) { |
| 110 | console.warn(_data); | 111 | console.warn(_data); |
| 111 | if (onfail) onfail(data); | 112 | if (onfail) onfail(_data); |
| 112 | } | 113 | } |
| 113 | }); | 114 | }); |
| 114 | }; | 115 | } |
| 115 | 116 | ||
| 116 | /* Properties for data can be: | 117 | /* Properties for data can be: |
| 117 | * layerDel (csv) | 118 | * layerDel (csv) |
| @@ -129,10 +130,10 @@ var libtoaster = (function (){ | |||
| 129 | success: function (data) { | 130 | success: function (data) { |
| 130 | if (data.error != "ok") { | 131 | if (data.error != "ok") { |
| 131 | console.log(data.error); | 132 | console.log(data.error); |
| 132 | if (onFail != undefined) | 133 | if (onFail !== undefined) |
| 133 | onFail(data); | 134 | onFail(data); |
| 134 | } else { | 135 | } else { |
| 135 | if (onSuccess != undefined) | 136 | if (onSuccess !== undefined) |
| 136 | onSuccess(data); | 137 | onSuccess(data); |
| 137 | } | 138 | } |
| 138 | }, | 139 | }, |
| @@ -141,7 +142,7 @@ var libtoaster = (function (){ | |||
| 141 | console.log(data); | 142 | console.log(data); |
| 142 | } | 143 | } |
| 143 | }); | 144 | }); |
| 144 | }; | 145 | } |
| 145 | 146 | ||
| 146 | function _getLayerDepsForProject(xhrDataTypeaheadUrl, projectId, layerId, onSuccess, onFail){ | 147 | function _getLayerDepsForProject(xhrDataTypeaheadUrl, projectId, layerId, onSuccess, onFail){ |
| 147 | /* Check for dependencies not in the current project */ | 148 | /* Check for dependencies not in the current project */ |
| @@ -150,7 +151,7 @@ var libtoaster = (function (){ | |||
| 150 | function(data) { | 151 | function(data) { |
| 151 | if (data.error != "ok") { | 152 | if (data.error != "ok") { |
| 152 | console.log(data.error); | 153 | console.log(data.error); |
| 153 | if (onFail != undefined) | 154 | if (onFail !== undefined) |
| 154 | onFail(data); | 155 | onFail(data); |
| 155 | } else { | 156 | } else { |
| 156 | onSuccess(data); | 157 | onSuccess(data); |
| @@ -158,22 +159,22 @@ var libtoaster = (function (){ | |||
| 158 | }, function() { | 159 | }, function() { |
| 159 | console.log("E: Failed to make request"); | 160 | console.log("E: Failed to make request"); |
| 160 | }); | 161 | }); |
| 161 | }; | 162 | } |
| 162 | 163 | ||
| 163 | /* parses the query string of the current window.location to an object */ | 164 | /* parses the query string of the current window.location to an object */ |
| 164 | function _parseUrlParams() { | 165 | function _parseUrlParams() { |
| 165 | string = window.location.search | 166 | var string = window.location.search; |
| 166 | string = string.substr(1); | 167 | string = string.substr(1); |
| 167 | stringArray = string.split ("&"); | 168 | var stringArray = string.split ("&"); |
| 168 | obj = {}; | 169 | var obj = {}; |
| 169 | 170 | ||
| 170 | for (i in stringArray) { | 171 | for (var i in stringArray) { |
| 171 | keyVal = stringArray[i].split ("="); | 172 | var keyVal = stringArray[i].split ("="); |
| 172 | obj[keyVal[0]] = keyVal[1]; | 173 | obj[keyVal[0]] = keyVal[1]; |
| 173 | } | 174 | } |
| 174 | 175 | ||
| 175 | return obj; | 176 | return obj; |
| 176 | }; | 177 | } |
| 177 | 178 | ||
| 178 | /* takes a flat object and outputs it as a query string | 179 | /* takes a flat object and outputs it as a query string |
| 179 | * e.g. the output of dumpsUrlParams | 180 | * e.g. the output of dumpsUrlParams |
| @@ -181,7 +182,7 @@ var libtoaster = (function (){ | |||
| 181 | function _dumpsUrlParams(obj) { | 182 | function _dumpsUrlParams(obj) { |
| 182 | var str = "?"; | 183 | var str = "?"; |
| 183 | 184 | ||
| 184 | for (key in obj){ | 185 | for (var key in obj){ |
| 185 | if (!obj[key]) | 186 | if (!obj[key]) |
| 186 | continue; | 187 | continue; |
| 187 | 188 | ||
| @@ -190,7 +191,7 @@ var libtoaster = (function (){ | |||
| 190 | } | 191 | } |
| 191 | 192 | ||
| 192 | return str; | 193 | return str; |
| 193 | }; | 194 | } |
| 194 | 195 | ||
| 195 | 196 | ||
| 196 | return { | 197 | return { |
| @@ -203,23 +204,23 @@ var libtoaster = (function (){ | |||
| 203 | debug: false, | 204 | debug: false, |
| 204 | parseUrlParams : _parseUrlParams, | 205 | parseUrlParams : _parseUrlParams, |
| 205 | dumpsUrlParams : _dumpsUrlParams, | 206 | dumpsUrlParams : _dumpsUrlParams, |
| 206 | } | 207 | }; |
| 207 | })(); | 208 | })(); |
| 208 | 209 | ||
| 209 | /* keep this in the global scope for compatability */ | 210 | /* keep this in the global scope for compatability */ |
| 210 | function reload_params(params) { | 211 | function reload_params(params) { |
| 211 | uri = window.location.href; | 212 | var uri = window.location.href; |
| 212 | splitlist = uri.split("?"); | 213 | var splitlist = uri.split("?"); |
| 213 | url = splitlist[0], parameters=splitlist[1]; | 214 | var url = splitlist[0]; |
| 215 | var parameters = splitlist[1]; | ||
| 214 | // deserialize the call parameters | 216 | // deserialize the call parameters |
| 215 | if(parameters){ | 217 | var cparams = []; |
| 216 | cparams = parameters.split("&"); | 218 | if(parameters) |
| 217 | }else{ | 219 | cparams = parameters.split("&"); |
| 218 | cparams = [] | 220 | |
| 219 | } | 221 | var nparams = {}; |
| 220 | nparams = {} | 222 | for (var i = 0; i < cparams.length; i++) { |
| 221 | for (i = 0; i < cparams.length; i++) { | 223 | var temp = cparams[i].split("="); |
| 222 | temp = cparams[i].split("="); | ||
| 223 | nparams[temp[0]] = temp[1]; | 224 | nparams[temp[0]] = temp[1]; |
| 224 | } | 225 | } |
| 225 | // update parameter values | 226 | // update parameter values |
| @@ -227,7 +228,7 @@ function reload_params(params) { | |||
| 227 | nparams[encodeURIComponent(i)] = encodeURIComponent(params[i]); | 228 | nparams[encodeURIComponent(i)] = encodeURIComponent(params[i]); |
| 228 | } | 229 | } |
| 229 | // serialize the structure | 230 | // serialize the structure |
| 230 | callparams = [] | 231 | var callparams = []; |
| 231 | for (i in nparams) { | 232 | for (i in nparams) { |
| 232 | callparams.push(i+"="+nparams[i]); | 233 | callparams.push(i+"="+nparams[i]); |
| 233 | } | 234 | } |
| @@ -238,7 +239,7 @@ function reload_params(params) { | |||
| 238 | /* Things that happen for all pages */ | 239 | /* Things that happen for all pages */ |
| 239 | $(document).ready(function() { | 240 | $(document).ready(function() { |
| 240 | 241 | ||
| 241 | /* If we don't have a console object which might be the case in some | 242 | /* If we don't have a console object which might be the case in some |
| 242 | * browsers, no-op it to avoid undefined errors. | 243 | * browsers, no-op it to avoid undefined errors. |
| 243 | */ | 244 | */ |
| 244 | if (!window.console) { | 245 | if (!window.console) { |
| @@ -271,7 +272,7 @@ $(document).ready(function() { | |||
| 271 | // .btn class applied, and make sure popovers work on click, are mutually | 272 | // .btn class applied, and make sure popovers work on click, are mutually |
| 272 | // exclusive and they close when your click outside their area | 273 | // exclusive and they close when your click outside their area |
| 273 | 274 | ||
| 274 | $('html').click(function(e){ | 275 | $('html').click(function(){ |
| 275 | $('td > a.btn').popover('hide'); | 276 | $('td > a.btn').popover('hide'); |
| 276 | }); | 277 | }); |
| 277 | 278 | ||
| @@ -323,9 +324,9 @@ $(document).ready(function() { | |||
| 323 | // linking directly to tabs | 324 | // linking directly to tabs |
| 324 | $(function(){ | 325 | $(function(){ |
| 325 | var hash = window.location.hash; | 326 | var hash = window.location.hash; |
| 326 | hash && $('ul.nav a[href="' + hash + '"]').tab('show'); | 327 | $('ul.nav a[href="' + hash + '"]').tab('show'); |
| 327 | 328 | ||
| 328 | $('.nav-tabs a').click(function (e) { | 329 | $('.nav-tabs a').click(function () { |
| 329 | $(this).tab('show'); | 330 | $(this).tab('show'); |
| 330 | $('body').scrollTop(); | 331 | $('body').scrollTop(); |
| 331 | }); | 332 | }); |
