regexes are fun and pleasant to work with, in the same way that oranges are purple

This commit is contained in:
Shish
2012-03-14 03:15:35 +00:00
parent b57a3be442
commit e67d679194
2 changed files with 43 additions and 49 deletions

View File

@ -41,14 +41,19 @@ $(document).ready(function() {
$("TABLE.sortable").tablesorter();
$(".comment_link").each(function(idx, elm) {
var target_id = $(elm).text().match(/#c?(\d+)/);
if(target_id && $("#c"+target_id[1])) {
var target_name = $("#c"+target_id[1]+" .username").html();
if(target_name) {
$(elm).attr("href", "#c"+target_id[1]);
$(elm).html("@"+target_name);
}
$(".shm-clink").each(function(idx, elm) {
var target_id = $(elm).data("clink-sel");
if(target_id && $(target_id)) {
// if the target comment is already on this page, don't bother
// switching pages
$(elm).attr("href", target_id);
// highlight it when clicked
$(elm).click(function(e) {
$(target_id).effect('highlight', {}, 5000);
});
// vanilla target name should already be in the URL tag, but this
// will include the anon ID as displayed on screen
$(elm).html("@"+$(target_id+" .username").html());
}
});