OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | |
6 * Redirects to the same page on a different branch. | |
7 * | |
8 * @param {String} The path to redirect to. | |
9 */ | |
10 (function() { | 5 (function() { |
11 function redirectToBranch(value) { | 6 function redirectToBranch() { |
12 if (!value) | 7 if (!this.value) |
not at google - send to devlin
2012/07/27 03:30:39
"this" is evil. This method gets called with the e
cduvall
2012/07/27 17:51:10
Done.
| |
13 return; | 8 return; |
14 var path = window.location.pathname.split('/') | 9 var current_branch = window.bootstrap.branchInfo.current; |
15 window.location = value + '/' + path[path.length - 1]; | 10 var path = window.location.pathname.split('/'); |
11 var index = path.indexOf(current_branch); | |
12 if (index != -1) | |
13 path[index] = this.value; | |
not at google - send to devlin
2012/07/27 03:30:39
need to make sure that if value is empty the eleme
cduvall
2012/07/27 17:51:10
Value will never be empty, the branchChooser uses
| |
14 else | |
15 path.splice(path.length - 1, 0, this.value); | |
16 window.location = path.join('/'); | |
16 } | 17 } |
17 | 18 |
18 window.redirectToBranch = redirectToBranch; | 19 document.getElementById('branchChooser').addEventListener( |
20 'change', | |
21 redirectToBranch, | |
22 true); | |
not at google - send to devlin
2012/07/27 03:30:39
hm haven't seen "true" here before. Why do you nee
cduvall
2012/07/27 17:51:10
It was so I could use 'this' in the callback. Now
| |
19 })() | 23 })() |
OLD | NEW |