##// END OF EJS Templates
Add reflink map
ritsufag -
r118:ab4d79db ritsufag/add-refl...
parent child Browse files
Show More
@@ -91,6 +91,47 b' function addQuickReply(postId) {'
91 $("html, body").animate({ scrollTop: $(textAreaId).offset().top }, "slow");
91 $("html, body").animate({ scrollTop: $(textAreaId).offset().top }, "slow");
92 }
92 }
93
93
94 function addRefLinkMap() {
95 var postByNum = [], refMap = [];
96
97 $('.post').each(function() {
98 var self = $(this);
99
100 var postNum = self.attr('id');
101 //add post by id
102 postByNum[postNum] = self;
103 //add ref link
104 self.find('p').children('a').each(function() {
105 if($(this).text().indexOf('>>') == 0) {
106 var refNum = $(this).text().match(/\d+/);
107
108 if(postByNum[refNum]) {
109 if(!refMap[refNum])
110 refMap[refNum] = [];
111
112 //if !exist
113 if((',' + refMap[refNum].toString() + ',').indexOf(',' + postNum + ',') < 0) {
114 refMap[refNum].push(postNum);
115 };
116 }
117 }
118 });
119 });
120
121 for(var pNum in refMap) {
122 if(typeof refMap[pNum] === 'object') {
123 var data = 'Ответы:' + refMap[pNum].toString().replace(/(\d+)/g, ' <a href="/jump/$1/">>>$1</a>');
124
125 //append refmap panel
126 if(!$("#refmap_"+pNum).length) {
127 $('#'+pNum+'').find('.message').after($('<div class="refmap" id="refmap_'+pNum+'">'+data+'</div>'));
128 }
129 }
130 }
131 }
132
133
94 $(document).ready(function(){
134 $(document).ready(function(){
95 add_panel('.navigation_panel');
135 add_panel('.navigation_panel');
136 addRefLinkMap();
96 });
137 });
General Comments 0
You need to be logged in to leave comments. Login now