refmaps.js
38 lines
| 1.2 KiB
| application/javascript
|
JavascriptLexer
neko259
|
r126 | function addRefLinkMap() { | |
var postByNum = [], refMap = []; | |||
$('.post').each(function() { | |||
var self = $(this); | |||
var postNum = self.attr('id'); | |||
//add post by id | |||
postByNum[postNum] = self; | |||
//add ref link | |||
self.find('p').children('a').each(function() { | |||
if($(this).text().indexOf('>>') == 0) { | |||
var refNum = $(this).text().match(/\d+/); | |||
if(postByNum[refNum]) { | |||
if(!refMap[refNum]) | |||
refMap[refNum] = []; | |||
//if !exist | |||
if((',' + refMap[refNum].toString() + ',').indexOf(',' + postNum + ',') < 0) { | |||
refMap[refNum].push(postNum); | |||
}; | |||
} | |||
} | |||
}); | |||
}); | |||
var label_replies = gettext('Replies') + ':'; | |||
for(var pNum in refMap) { | |||
if(typeof refMap[pNum] === 'object') { | |||
//append refmap panel | |||
if(!$("#refmap_"+pNum).length) { | |||
ritsufag
|
r225 | $('#'+pNum+'').find('.message').after( | |
$('<div class="refmap" id="refmap_'+pNum+'">'+label_replies + refMap[pNum].toString().replace(/(\d+)/g, ' <a href="/jump/$1/">>>$1</a>')+'</div>') | |||
); | |||
neko259
|
r126 | } | |
} | |||
} | |||
ritsufag
|
r225 | } |