Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: chrome/common/extensions/docs/server2/static/js/branch.js

Issue 10826173: Extensions Docs Server: Proper path handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 (function() { 5 (function() {
6 function redirectToBranch() { 6 function redirectToBranch() {
7 var value = event.target.value; 7 var value = event.target.value;
8 if (!value) 8 if (!value)
9 return; 9 return;
10 var current_branch = window.bootstrap.branchInfo.current; 10 var current_branch = window.bootstrap.branchInfo.current;
11 var path = window.location.pathname.split('/'); 11 var path = window.location.pathname.split('/');
12 if (path[0] == '')
13 path = path.slice(1);
12 var index = path.indexOf(current_branch); 14 var index = path.indexOf(current_branch);
13 if (index != -1) 15 if (index != -1)
14 path[index] = value; 16 path[index] = value;
15 else 17 else
16 path.splice(path.length - 1, 0, value); 18 path.splice(0, 0, value);
17 window.location = path.join('/'); 19 window.location = '/' + path.join('/');
18 } 20 }
19 21
20 document.getElementById('branchChooser').addEventListener( 22 document.getElementById('branchChooser').addEventListener(
21 'change', 23 'change',
22 redirectToBranch); 24 redirectToBranch);
23 })() 25 })()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698