##// END OF EJS Templates
frontend: use splitDelimitedHash when dealing with hash parsing
ergo -
r789:1deb9d88 default
parent child Browse files
Show More
@@ -366,15 +366,9 b' function offsetScroll(element, offset){'
366 // At the time of development, Chrome didn't seem to support jquery's :target
366 // At the time of development, Chrome didn't seem to support jquery's :target
367 // element, so I had to scroll manually
367 // element, so I had to scroll manually
368 if (location.hash) {
368 if (location.hash) {
369 var splitIx = location.hash.indexOf('/?/');
369 var result = splitDelimitedHash(location.hash);
370 if (splitIx !== -1){
370 var loc = result.loc;
371 var loc = location.hash.slice(0, splitIx);
371 var remainder = result.remainder;
372 var remainder = location.hash.slice(splitIx + 2);
373 }
374 else{
375 var loc = location.hash;
376 var remainder = null;
377 }
378 if (loc.length > 1){
372 if (loc.length > 1){
379 var lineno = $(loc+'.lineno');
373 var lineno = $(loc+'.lineno');
380 if (lineno.length > 0){
374 if (lineno.length > 0){
@@ -74,6 +74,29 b' String.prototype.capitalizeFirstLetter ='
74
74
75
75
76 /**
76 /**
77 * Splits remainder
78 *
79 * @param input
80 */
81 function splitDelimitedHash(input){
82 var splitIx = input.indexOf('/?/');
83 if (splitIx !== -1){
84 var loc = input.slice(0, splitIx);
85 var remainder = input.slice(splitIx + 2);
86 }
87 else{
88 var loc = input;
89 var remainder = null;
90 }
91 //fixes for some urls generated incorrectly
92 var result = loc.match('#+(.*)');
93 if (result !== null){
94 loc = '#' + result[1];
95 }
96 return {loc:loc, remainder: remainder}
97 }
98
99 /**
77 * Escape html characters in string
100 * Escape html characters in string
78 */
101 */
79 var entityMap = {
102 var entityMap = {
@@ -372,9 +372,9 b''
372 }
372 }
373 });
373 });
374
374
375 if (location.href.indexOf('#') != -1) {
375 if (location.hash) {
376 var id = '#'+location.href.substring(location.href.indexOf('#') + 1).split('#');
376 var result = splitDelimitedHash(location.hash);
377 var line = $('html').find(id);
377 var line = $('html').find(result.loc);
378 offsetScroll(line, 70);
378 offsetScroll(line, 70);
379 }
379 }
380
380
@@ -412,9 +412,9 b''
412 %endif
412 %endif
413
413
414 <script type="text/javascript">
414 <script type="text/javascript">
415 if (location.href.indexOf('#') != -1) {
415 if (location.hash) {
416 var id = '#'+location.href.substring(location.href.indexOf('#') + 1).split('#');
416 var result = splitDelimitedHash(location.hash);
417 var line = $('html').find(id);
417 var line = $('html').find(result.loc);
418 offsetScroll(line, 70);
418 offsetScroll(line, 70);
419 }
419 }
420 $(function(){
420 $(function(){
General Comments 0
You need to be logged in to leave comments. Login now