Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!-- | 1 <!-- |
| 2 Copyright 2016 The LUCI Authors. All rights reserved. | 2 Copyright 2016 The LUCI Authors. All rights reserved. |
| 3 Use of this source code is governed under the Apache License, Version 2.0 | 3 Use of this source code is governed under the Apache License, Version 2.0 |
| 4 that can be found in the LICENSE file. | 4 that can be found in the LICENSE file. |
| 5 | 5 |
| 6 It contains the definition of the following Behaviors: | 6 It contains the definition of the following Behaviors: |
| 7 | 7 |
| 8 SwarmingBehaviors.CommonBehavior | 8 SwarmingBehaviors.CommonBehavior |
| 9 | 9 |
| 10 To use it, include | 10 To use it, include |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 }, | 61 }, |
| 62 | 62 |
| 63 _or: function() { | 63 _or: function() { |
| 64 var result = false; | 64 var result = false; |
| 65 // can't use .foreach, as arguments isn't really an Array. | 65 // can't use .foreach, as arguments isn't really an Array. |
| 66 for (var i = 0; i < arguments.length; i++) { | 66 for (var i = 0; i < arguments.length; i++) { |
| 67 result = result || arguments[i]; | 67 result = result || arguments[i]; |
| 68 } | 68 } |
| 69 return result; | 69 return result; |
| 70 }, | 70 }, |
| 71 | |
| 72 // _postWithToast makes a post request and updates the provided paper-toas t | |
| 73 // element with the response, regardless of failure. | |
| 74 _postWithToast: function(url, msg, auth_headers) { | |
|
jcgregorio
2016/09/06 20:40:56
Now that you are using errorMessage and the error-
kjlubick
2016/09/07 12:00:20
Done.
| |
| 75 // Keep toast displayed until we hear back from the request. | |
| 76 sk.errorMessage(msg, 0); | |
| 77 | |
| 78 sk.request("POST", url, undefined, auth_headers).then(function(response) { | |
| 79 sk.errorMessage("Request sent. Response: "+response, 3000); | |
| 80 }.bind(this)).catch(function(reason) { | |
| 81 console.log("Request failed", reason); | |
| 82 sk.errorMessage("Request failed. Reason: "+reason, 5000); | |
| 83 }.bind(this)); | |
| 84 } | |
| 71 }; | 85 }; |
| 72 })(); | 86 })(); |
| 73 </script> | 87 </script> |
| OLD | NEW |