| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 (function() { | |
| 6 | |
| 7 function init() { | |
| 8 var branchChooser = document.getElementById('branch-chooser-popup'); | |
| 9 Array.prototype.forEach.call(branchChooser.getElementsByTagName('button'), | |
| 10 function(button) { | |
| 11 button.addEventListener('click', function(event) { | |
| 12 choose(button.className); | |
| 13 event.stopPropagation(); | |
| 14 }); | |
| 15 }); | |
| 16 } | |
| 17 | |
| 18 function choose(branch) { | |
| 19 var currentBranch = window.bootstrap.branchInfo.current; | |
| 20 var path = window.location.pathname.split('/'); | |
| 21 if (path[0] == '') | |
| 22 path = path.slice(1); | |
| 23 var index = path.indexOf(currentBranch); | |
| 24 if (index != -1) | |
| 25 path[index] = branch; | |
| 26 else | |
| 27 path.splice(0, 0, branch); | |
| 28 window.location.pathname = '/' + path.join('/'); | |
| 29 } | |
| 30 | |
| 31 init(); | |
| 32 | |
| 33 })() | |
| OLD | NEW |