var Comment = new Object();
var $C = function(tagName)
{
return document.createElement(tagName);
};
String.prototype.trim = function()
{
return this.replace(/^s*|s*$/g,"");
};
String.prototype.realLength = function()
{
return this.replace(/[^x00-xff]/g,"**").length;
};
String.prototype.left = function(n)
{
if (this.length > n)
{
return this.substr(0, n) '...' ;
}
else
{
이것을 반환하세요.
}
};
Array.prototype.remove = function(n)
{
if (n < 0)
{
이것을 반환합니다.
}
else
{
return this.slice(0, n).concat(this.slice(n 1, this.length));
}
};
함수 findPosX(obj)
{
var curleft = 0;
if (obj && obj.offsetParent)
{
while (obj.offsetParent)
{
curleft = obj.offsetLeft;
obj = obj.offsetParent;
}
}
else if (obj && obj.x) curleft = obj.x;
반환 curleft;
}
함수 findPosY(obj)
{
var curtop = 0;
if (obj && obj.offsetParent)
{
while (obj.offsetParent)
{
curtop = obj.offsetTop;
obj = obj.offsetParent;
}
}
else if (obj && obj.y) curtop = obj.y;
커탑 반환;
}
var input_domain = 'http://input.comment.qq.com';
var index_domain = 'http://comment1.qq.com';
var pinglun_domain = 'http://pinglun.qq.com';
var js_domain = 'http://pinglun.qq.com';
var img_domain = 'http://mat1.qq.com/pinglun';
Comment.Configure = {
버전: '1.0',
줄바꿈: 'n',
site_length:
key_ 길이: 20,
id_length: 10,
index_line_sum: 10000,
index_width: 5,
default_mode: 'origin_count',
default_order: 1, default_reply_per_page: 10,
quote_str_len: 60,
intro_len: 150,
> ,
request_delay: 100,
login_frame_delay: 2000,
reply_type_def: {
'1': '
[精] ',
'2': '
[荐] ',
'3': '
[专] '
},
postUrl: input_domain '/post.cmt',
logoutUrl: input_domain '/cgi-bin/qqlogout'
댓글 색인: 'http://pinglun.qq.com/ ',
loginIframeUrl: index_domain '/i_login.htm',
defaultLogoUrl: img_domain '/images/defpic.jpg'
Comment.Define = {
getReplyType: 함수 (유형)
{
if (Comment.Configure.reply_type_def[유형])
{
return Comment.Configure.reply_type_def[유형];
}
else
{
반환 '';
}
}
}
Comment.PGV_Count = 함수(옵션)
{
if (typeof(pgvMain) == 'function')
{
pvRepeatCount = 1;
pvCurDomain = sDomain;
if (옵션)
{
if (option.domain)
{
pvCurDomain = option.domain;
}
if (option.path)
{
pvCurUrl = option.path;
}
}
pgvMain();
//Debug.log('pgv 함수 호출');
}
}
Comment.UrlFactory = {
get3LevelDir: function(id)
{
var path = parseInt(id / 1000000) '/';
경로 = parseInt(id / 1000) '/';
경로 = id / 1;
반환 경로;
},
getCommentUrl: function(id)
{
return (this.get3LevelDir(id) '/');
},
getDebateUrl: function(id)
{
return this.get3LevelDir(id);
},
getUserUrl: function(id)
{
return this.get3LevelDir(id);
},
getReplyUrl: function(key)
{
var path = key.substr(0, 8);
경로 = '/' (key.substr(8, 4));
경로 = '/' (key.substr(12, 2));
경로 = '/' 키;
반환 경로;
},
getIndexUrl: function(id)
{
var length = id.toString().length;
if (length
{
for(var i = 0; i < Comment.Configure.index_width - length; i)
{
id = '0' id;
}
}
반품 ID;
},
getIndexDir: function(mode)
{
var modes = {
'origin_count': 'originindex'
'total_ 개수': 'allindex',
'top_count': 'topindex'
};
반환 모드[mode];
},
getRangeHeader: function(start, length, line_len)
{
var range_start = start * line_len;
var range_length = 길이 * line_len;
return ['Range','bytes=' range_start '-' (parseInt(range_start) parseInt(range_length) - 1 - Comment.Configure.newline.length)];
},
getCommentNormalUrl: function(site, id)
{
return 'comment.htm?site=' site '&id=' id;
},
getCommentGroupUrl: function(site, id)
{
return 'comment_group.htm?site=' site '&id=' id;
},
getCommentDebateUrl: function(site, id)
{
return 'comment_debate.htm?site=' site '&id=' id;
},
getCommentUserUrl: function(uin)
{
return 'comment_user.htm?uin=' uin;
},
getCommentUserLink: function(uin, nick)
{
return '' (nick ? nick : uin) '';
},
getCommentListLink: function(site_en, site_cn, sort_en, sort_cn, className)
{
if (className)
{ = 'class="' 클래스이름 '" ';
}
else
{
className = '';
}
반환 '评论首页 >> '
'' site_cn ' >> '
'' sort_cn '';
}
}
Comment.ContentFormat = {
디코드: function(content)
{
return content.split(Comment.Configure.newline);
}
}
Comment.DataObjectFactory = function(content, model)
{
content = Comment.ContentFormat.decode(content);
var dataModel = Comment.DataObject[모델];
if (content.length - 1 != dataModel.length)
{
if (model != 'commentinfo' && model != 'listsum')
{
//alert( '[DEBUG 信息] O/R 映射失败 ,远程数据와本地模型数weight는 불변!请检查!');
}
}
var dataObject = new Object();
for (var i = 0; i < dataModel.length; i)
{
dataObject[dataModel[i]] = content[i];
}
return dataObject;
}
Comment.DataObject = {
'commentinfo':
[
'site_cn',
'sort_en',
'sort_cn', '출처',
'source_url',
'제목',
'url',
'소개',
'intro_img',
'group_id', 'intro_show', <
'URL',
'소개',
'intro_img',
'comment_id',
'intro_show',
'create_time'
], 'debateinfo':
[ <
'disagree_id',
'middle_id',
'intro_show',
'create_time'
],
'sum':
[
'origin_count'
'total_count',
'top_count'
],
'답글':
[
'comment_id',
'uin',
'닉네임', 'pub_time',
'pass_time',
'ip',
'title',
'content',
'reply_key',
'is_del', '응답_유형',
'reply_kind',
'팁'
],
'pksum':
[
'동의',
'동의',
'중간'
] ,
'listsum':
[
'모두'
],
'usersum':
[
'total_count',
'top_count ',
'전문가'
],
'userinfo':
[
'user_img',
'user_intro'
]
}
/* 控system器类 */
Comment.Control = new Object();
/* 分页控 제어 */
Comment.Control.Pagination = Class.create();
Comment.Control.Pagination.prototype = {
초기화: 함수(옵션)
{
this.totalPage = option.totalPage;
this.currPage = 1;
this.zoom_start = 3;
this.zoom_end = 613;
this.bindControl();
},
재설정: 기능(옵션)
{
this.totalPage = option.totalPage;
this.currPage = 1;
this.movePageControl(this.currPage);
},
updateOrder: function()
{
},
countCurrPage: function(offset)
{
var page = parseInt(offset * 이. totalPage / this.zoom_end) 1;
if (페이지 > this.totalPage)
{
페이지 = this.totalPage;
}
반환 페이지;
},
movePageControl: function(toPage)
{
if (toPage < 1 || toPage > this.totalPage)
{
return;
}
var offset = 0;
if (toPage == 1)
{
offset = this.zoom_start;
}
else if (toPage == this.totalPage)
{
offset = this.zoom_end;
}
else
{
offset = this.zoom_start (toPage - 1) * (this.zoom_end / (this.totalPage - 1));
}
$('scrfloat').style.left = 오프셋 'px';
//$('scrfloat_2').style.left = 오프셋 'px';
},
bindControl: function()
{
var self = this;
var tooltip = $('Page_tip');
var offsetX = 10;
var offsetY = -10;
function getSite(o)
{
var obj = o;
var objS = obj.offsetLeft;
동안(obj != obj.offsetParent && obj.offsetParent)
{
obj = obj.offsetParent;
if (obj.tagName == 'span')
{
objS = obj.offsetLeft;
}
}
객체 반환;
}
Event.observe($('scr'), 'mousedown', mDown, false);
//Event.observe($('scr_2'), 'mousedown', mDown, false);
var 플래그 = false;
함수 mDown()
{
플래그 = true;
if(window.event.srcElement.id != 'scr'
&& window.event.srcElement.id != 'scr_2')
$('scrfloat').style. 왼쪽 = $('scrfloat').offsetLeft;
//$('scrfloat_2').style.left = $('scrfloat').style.left;
}
else
{
$('scrfloat').style.left = (window.event.x - 5);
//$('scrfloat_2').style.left = $('scrfloat').style.left;
}
tooltip.style.display = '차단';
t = $('scrfloat').offsetLeft;
tooltip.innerHTML = self.countCurrPage(t);
tooltip.style.left = window.event.clientX offsetX 'px';
tooltip.style.top = window.event.clientY offsetY document.documentElement.scrollTop 'px';
}
기능 mMove()
{
if(플래그)
{
$('scrfloat').style.left = window.event.client X - getSite($('scr') ) - 5 'px';
//$('scrfloat_2').style.left = window.event.clientX - getSite($('scr')) - 5 'px';
}
if (parseInt($('scrfloat').style.left.replace('px', '')) > self.zoom_end)
{ $('scrfloat' ).style.left = self.zoom_end 'px';
//$('scrfloat_2').style.left = $('scrfloat').style.left;
}
if (parseInt($("scrfloat").style.left.replace('px', '')) < self.zoom_start)
{ $('scrfloat' ).style.left = self.zoom_start 'px';
//$('scrfloat_2').style.left = $('scrfloat').style.left;
}
if (플래그)
{
t = $('scrfloat').offsetLeft;
tooltip.innerHTML = self.countCurrPage(t);
tooltip.style.left = window.event.clientX offsetX 'px';
tooltip.style.top = window.event.clientY offsetY document.documentElement.scrollTop 'px';
}
}
기능 mUp()
{
if (플래그)
{ t = $('scrfloat').offsetLeft;
self.setCurrPage(self.countCurrPage(t));
}
플래그 = false;
tooltip.style.display = '없음';
}
함수 mEnd()
{
window.event.returnValue = false;
}
window.document.onmousemove = mMove;
window.document.ondragstart = mEnd;
window.document.onmouseup = mUp;
Event.observe($('up'), 'click', mUpBtn, false);
Event.observe($('down'), 'click', mDownBtn, false);
함수 mUpBtn()
{
self.setCurrPage(self.currPage - 1, 1);
}
함수 mDownBtn()
{
self.setCurrPage(self.currPage 1, 1);
}
},
nextPage: function()
{
if (this.currPage < this.totalPage)
{
현재페이지;
this.onPageChange();
}
},
previousPage: function()
{
if (this.currPage > 0)
{
-this.curr 페이지;
this.onPageChange();
}
},
setCurrPage: function(page, move)
{
if (page > 0 && page <= this.totalPage && page != this.currPage)
{
this.currPage = 페이지;
this.onPageChange();
if (move != null)
{
this.movePageControl(page);
}
}
},
onPageChange: function()
{
},
getCurrPage: function()
{ > this.currPage를 반환합니다.
}
}
Comment.Iterator = {
getIndex: function(objComment)
{
var rangeList = new Array();
function getIndexId(reply_id)
{
return parseInt(reply_id / Comment.Configure.index_line_sum);
}
함수 getReplyPos(reply_id)
{
return(reply_id % Comment.Configure.index_line_sum);
}
if (objComment.order == 0)
{
var reply_start = (objComment.currPage - 1) * objComment.replyPerPage;
var start_index_id = getIndexId(reply_start);
var start_reply_id = getReplyPos(reply_start);
var currReply = 1;
var replySum = 0; <” 🎜> rangeList.push({
url: Comment.UrlFactory.getIndexUrl(start_index_id),
범위: Comment.UrlFactory.getRangeHeader(start_reply_id, currReply - replySum - 1, objComment.index_line_len)
});
휴식;
}
if (currReply == objComment.replyPerPage)
{
rangeList.push({
URL: Comment.UrlFactory.getIndexUrl(start_index_id),
범위: Comment.UrlFactory .getRangeHeader(start_reply_id, currReply - replySum, objComment.index_line_len)
});
휴식;
}
if (start_reply_id currReply > Comment.Configure.index_line_sum)
rangeList.push({
url: Comment.UrlFactory.getIndexUrl(start_index_id),
범위: Comment.UrlFactory.getRangeHeader(start_reply_id, currReply, objComment.index_line_len)
});
start_index_id ;
start_reply_id = 0;
replySum = currReply - 1;
}
}
}
else
{ 답장 - 1 - (objComment.currPage - 1) * objComment.replyPerPage;
var start_index_id = getIndexId(reply_start);
var start_reply_id = getReplyPos(reply_start);
var currReply = 1;
var replySum = 0;
동안(currReply)
{
if (reply_start - currReply < 0)
{ rangeList.push({
url: Comment.UrlFactory.getIndexUrl(start_index_id),
범위: Comment.UrlFactory.getRangeHeader(0, start_reply_id 1, objComment.index_line_len)
});
휴식;
}
if (currReply == objComment.replyPerPage)
{
rangeList.push({
URL: Comment.UrlFactory.getIndexUrl(start_index_id),
범위: Comment.UrlFactory .getRangeHeader(start_reply_id - currReply replySum 1, currReply - replySum, objComment.index_line_len)
});
휴식;
}
if (start_reply_id - currReply < 0)
{
rangeList.push({
url: Comment.UrlFactory.getIndexUrl(start_index_id),
범위: Comment.UrlFactory.getRangeHeader(0 , start_reply_id 1, objComment.index_line_len)
});
start_index_id--;
start_reply_id = Comment.Configure.index_line_sum - 1;
replySum = currReply;
}
}
}
return rangeList;
}
}
/* 显示样式控system器 */
Comment.Control.Display = Class.create();
Comment.Control.Display.prototype = {
초기화: function()
{
}
}
/* 页face显示类 */
댓글. 페이지 = 새 객체();
/* 评论页控system接口 */
Comment.Page.Base = {
changeMode: function(mode)
{
this.mode = mode;
this.totalReply = this.data_sum[mode];
this.totalPage = parseInt(this.totalReply / this.replyPerPage)
(this.totalReply % this.replyPerPage != 0 ? 1 : 0);
},
changeOrder: function(order)
{
if (this.order == order)
return;
this.order = 주문;
this.currPage = 1;
this.resetPageControl();
this.bindPageNav();
this.bindReplyList();
this.bindOrderControl();
},
bindOrderControl: function()
{
var self = this;
if (self.order == 0)
{
$('order_front').style.cursor = '없음';
$('order_front').style.color = '#000';
$('order_front').onclick = function(e)
{
반환 false;
}
$('order_desc').style.cursor = '포인터';
$('order_desc').style.color = '#3B78AF';
$('order_desc').onclick = function()
{
self.changeOrder(1);
false를 반환합니다.
}
}
else if (self.order == 1)
{
$('order_front').style.cursor = '포인터';
$('order_front').style.color = '#3B78AF';
$('order_front').onclick = function(e)
{
self.changeOrder(0);
false를 반환합니다.
}
$('order_desc').style.cursor = '없음';
$('order_desc').style.color = '#000';
$('order_desc').onclick = function()
{
반환 false;
}
}
},
bindRowsPerPage: function()
{
var self = this;
$A($('rows_page').getElementsByTagName('a')).each(function(button)
{
button.onclick = function()
{ 자신. replyPerPage = button.value;
self.currPage = 1; self.bindReplyList();
return false; > }
});
},
selectTab: function(mode)
{
var self = this;
$A($('mode_tab').getElementsByTagName('p')).each(function(tab)
{
if (tab.value == mode)
{
$A($('mode_tab').getElementsByTagName('p')).each(function(t)
{
if (t.value != '') {
t. className = '없음';
}
})
tab.className =
}
});
},
appendTab: 함수(옵션)
{
var pTab = $C('p');
pTab.innerHTML = option.title;
pTab.value = '';
$('mode_tab').appendChild(pTab);
pTab.onclick = function()
{
window.open(option.url);
}
false를 반환합니다.
},
bindTabControl: function()
{
var self = this;
$A($('mode_tab').getElementsByTagName('p')).each(function(tab)
{
var mode = tab.value;
if (mode != ' ')
{
tab.onclick = function()
{
$A($('mode_tab').getElementsByT agName('p')).each(함수(t)
{
t.className = '없음' });
this.className = 'c';
self.currPage = 1;
self.changeMode(모드)
self.resetPageControl();
self.bindPageNav();
self.bindReplyList();
false를 반환합니다.
}
}
});
},
bindPageRandom: function()
{
var self = this; > if (self.totalPage == 1)
{
self.currPage = 1; {
self.currPage = Math.floor(Math.random() * (self.totalPage 1))); }
}
self.bindPageNav()
self; .bindReplyList();
반환 false;