| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 _or: function() { | 102 _or: function() { |
| 103 var result = false; | 103 var result = false; |
| 104 // can't use .foreach, as arguments isn't really an Array. | 104 // can't use .foreach, as arguments isn't really an Array. |
| 105 for (var i = 0; i < arguments.length; i++) { | 105 for (var i = 0; i < arguments.length; i++) { |
| 106 result = result || arguments[i]; | 106 result = result || arguments[i]; |
| 107 } | 107 } |
| 108 return result; | 108 return result; |
| 109 }, | 109 }, |
| 110 | 110 |
| 111 _taskLink: function(task_id) { | 111 _taskLink: function(taskId, disableCanonicalID) { |
| 112 if (!task_id) { | 112 if (!taskId) { |
| 113 return undefined; | 113 return undefined; |
| 114 } | 114 } |
| 115 return "/newui/task?id=" + task_id; | 115 if (!disableCanonicalID) { |
| 116 // task abcefgh0 is the "canonical" task id. The first try has the id |
| 117 // abcefgh1. If there is a second (transparent retry), it will be |
| 118 // abcefgh2. We almost always want to link to the canonical one, |
| 119 // because the milo output (if any) will only be generated for |
| 120 // abcefgh0, not abcefgh1 or abcefgh2. |
| 121 taskId = taskId.substring(0, taskId.length - 1) + "0"; |
| 122 } |
| 123 return "/newui/task?id=" + taskId; |
| 116 }, | 124 }, |
| 117 | 125 |
| 118 // _timeDiffApprox returns the approximate difference between now and | 126 // _timeDiffApprox returns the approximate difference between now and |
| 119 // the specified date. | 127 // the specified date. |
| 120 _timeDiffApprox: function(date){ | 128 _timeDiffApprox: function(date){ |
| 121 if (!date) { | 129 if (!date) { |
| 122 return "eons"; | 130 return "eons"; |
| 123 } | 131 } |
| 124 return sk.human.diffDate(date.getTime()); | 132 return sk.human.diffDate(date.getTime()); |
| 125 }, | 133 }, |
| 126 | 134 |
| 127 // timeDiffExact returns the exact difference between the two specified | 135 // timeDiffExact returns the exact difference between the two specified |
| 128 // dates. E.g. 2d 22h 22m 28s ago If a second date is not provided, | 136 // dates. E.g. 2d 22h 22m 28s ago If a second date is not provided, |
| 129 // now is used. | 137 // now is used. |
| 130 _timeDiffExact: function(first, second){ | 138 _timeDiffExact: function(first, second){ |
| 131 if (!first) { | 139 if (!first) { |
| 132 return "eons"; | 140 return "eons"; |
| 133 } | 141 } |
| 134 if (!second) { | 142 if (!second) { |
| 135 second = new Date(); | 143 second = new Date(); |
| 136 } | 144 } |
| 137 return this._humanDuration((second.getTime() - first.getTime())/1000); | 145 return this._humanDuration((second.getTime() - first.getTime())/1000); |
| 138 }, | 146 }, |
| 139 }; | 147 }; |
| 140 })(); | 148 })(); |
| 141 </script> | 149 </script> |
| OLD | NEW |