aboutsummaryrefslogtreecommitdiffstats
path: root/webroot/.static/js/lxrng-funcs.js
diff options
context:
space:
mode:
authorArne Georg Gleditsch <argggh@taniquetil.(none)>2009-08-15 12:27:50 +0200
committerArne Georg Gleditsch <argggh@taniquetil.(none)>2009-08-15 12:27:50 +0200
commitca7960590a140fa516aa3e979ef43b655d7292be (patch)
tree64fe543a54c21038439840256036ed1e85e8a7a4 /webroot/.static/js/lxrng-funcs.js
parent4df686a0aa8ef2f75be6cee2bfa2874f1bbb4437 (diff)
Make hash navigation javascript a bit more robust.
Diffstat (limited to 'webroot/.static/js/lxrng-funcs.js')
-rw-r--r--webroot/.static/js/lxrng-funcs.js17
1 files changed, 13 insertions, 4 deletions
diff --git a/webroot/.static/js/lxrng-funcs.js b/webroot/.static/js/lxrng-funcs.js
index 2df711c..8a6720f 100644
--- a/webroot/.static/js/lxrng-funcs.js
+++ b/webroot/.static/js/lxrng-funcs.js
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 Arne Georg Gleditsch <lxr@linux.no>.
+// Copyright (C) 2008, 2009 Arne Georg Gleditsch <lxr@linux.no>.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -100,7 +100,7 @@ function ajax_nav() {
function ajax_jumpto_line() {
location.hash = location.hash.replace(/\#L\d+$/, '') +
- this.href.replace(/.*(\#L\d+)$/, '$1');
+ this.href.match(/\#L\d+$/);
check_hash_navigation();
return false;
}
@@ -127,9 +127,16 @@ function check_hash_navigation() {
if (location.hash.replace(/\#L\d+$/, '') ==
loaded_hash.replace(/\#L\d+$/, ''))
{
- var l = location.hash.replace(/.*#(L\d+)$/, '$1');
+ var l;
+ if (location.hash.match(/\#(L\d+)/)) {
+ l = RegExp.$1;
+ }
+ else {
+ l = 'L1';
+ }
var a = document.getElementById(l);
if (l && a) {
+ // Need to patch anchor to include file name.
a.name = location.hash.replace(/^\#/, '');
document.location.hash = a.name;
loaded_hash = location.hash;
@@ -345,7 +352,9 @@ function load_content_finalize(content) {
function update_version(verlist, base_url, tree, defversion, path) {
if (use_ajax_navigation) {
var file = location.hash.replace(/^[^\/]*\//, '');
- var line = file.replace(/.*\#L(\d+)/, '$1');
+ var line;
+ file.match(/\#L(\d+)/);
+ line = RegExp.$1;
file = file.replace(/\#L\d*$/, '');
load_file(loaded_tree, file, verlist.value, line);