Changeset 16456 for util

Show
Ignore:
Timestamp:
05/19/07 10:33:17 (18 months ago)
Author:
Aankhen
Message:

util/smartlinks.pl (JS):
* combined a couple conditionals.
* moved the location.hash bit outside the loop.
* fixed the line anchors!

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • util/smartlinks.pl

    r16455 r16456  
    165165  for (var i = 0, j = divs.length; i < j; i++) { 
    166166    var curr = divs[i]; 
    167     if (!curr.id) { continue; } 
    168     if (curr.id.match(/smartlink_(\d+)/)) { 
     167    if (curr.id && curr.id.match(/smartlink_(\d+)/)) { 
    169168      var num = RegExp.$1; 
    170169 
     
    202201      curr.parentNode.insertBefore(p, curr); 
    203202      curr.style.display = 'none'; 
    204  
    205       // explicitly jump to the page anchor (if any) since the code above messes it up 
    206       if (location.hash.match(/#.+/)) location.hash = RegExp.lastMatch; 
    207     } 
     203    } 
     204 
     205    // explicitly jump to the page anchor (if any) since the code above messes it up 
     206    if (location.hash && location.hash.match(/#.+/)) location.hash = RegExp.lastMatch; 
    208207  } 
    209208}); 
     
    454453    my $html = ''; 
    455454    for ($curr .. $list->[0] - 1) { 
    456         $html .= qq{<a id"_line_$_"></a>\n}; 
     455        $html .= qq{<a id="_line_$_"></a>\n}; 
    457456    } 
    458457    $html;