//其它域名
var webhost = window.location.host;
var mainHost = webhost.substr((webhost.length - 9), 9);
if (mainHost == ".30dao.cn") {
mainHost = "30dao.cn";
} else {
mainHost = "30edu.com.cn";
}
function mustLogin() {
if (typeof (userNumb) == 'undefined') {
$(".mustLogin").removeAttr("onclick").unbind("click").click(function () {
var html = '
';
$.dialog({
title: "请先登录",
content: html,
lock: true,
padding: 0,
width: 250
});
});
}
}
mustLogin();
var MaxTime = "";
function FeedListDown(count) {
count = count || 10;
webapi("Feed.ListUser", { UserNumb: window.spaceUserNumb, Count: count, MaxTime: MaxTime }, function (json) {
if (MaxTime == "")
$("#feed_list")[0].innerHTML = "";
if (json.length < 10)
$("#loading_more").hide();
else
$("#loading_more").show();
var html = [];
$.each(json, function (i, feed) {
html.push(feedHtml(feed));
MaxTime = feed.AddTime;
});
var el = document.createElement('div');
el.innerHTML = html.join("\r\n");;
$("#feed_list")[0].appendChild(el);
var fcTextarea = $('#feed_list textarea');
fcTextarea.tah({
moreSpace: 0,
maxHeight: 100,
animateDur: 100
});
$("#feed_list div.feed_box").each(function () {
var textBox = $(this).find("textarea")[0];
var weiboNum = $(this).find("div.weibo_num")[0];
TextareaUtils.init(textBox, weiboNum);
});
});
}
//动态列表
if ($("#feed_box").length == 1) {
var fc_textarea = $('#feed_box textarea');
fc_textarea.tah({
moreSpace: 0,
maxHeight: 100,
animateDur: 100
});
var textBox = $("#feed_box textarea")[0];
var weibo_num = $("#feed_box div.weibo_num")[0];
TextareaUtils.init(textBox, weibo_num);
}
//单条动态信息
if (typeof FeedInfo != "undefined") {
$("#oneFeed").html(feedHtml(FeedInfo, true));
showCommentFeed();
showDigg();
var textBox = $("#commentList textarea")[0];
var weibo_num = $("#commentList div.weibo_num")[0];
TextareaUtils.init(textBox, weibo_num);
var fc_textarea = $('#commentList textarea');
fc_textarea.tah({
moreSpace: 0,
maxHeight: 100,
animateDur: 100
});
$("#commentList a.ico_face").on("click", function () {
var box = $(this).parents("#commentList");
var textBox = box.find("textarea")[0];
showFaceContent($(this), textBox);
return false;
});
$("#commentList a.ico_friend").on("click", function () {
var box = $(this).parents("#commentList");
var textBox = box.find("textarea")[0];
showAtContent($(this), textBox);
});
$("#commentList").on("click", "a.delComment", function () {
var id = $(this).attr("commentid");
$.dialog.confirm("操作不可恢复,确定删除该评论吗?", function () {
webapi("FeedComment.DeleteUserFeedCommentByID", { ID: id }, function (feed) {
location.reload();
});
});
});
$("#commentList").on("click", "a.relComment", function () {
var box = $(this).parents("#commentList");
box.find("textarea").val("回复@" + $(this).attr("usernumb") + "||");
});
$("#addComment").on("click", function () {
var box = $(this).parents("#commentList");
var textBox = box.find("textarea")[0];
if (!TextareaUtils.check(textBox)) {
TextareaUtils.showerror(textBox, 3);
return;
}
var info = { FeedID: FeedInfo.ID };
info.IsForward = box.find("input.IsForward")[0].checked;
info.Content = textBox.value;
webapi("FeedComment.AddUserFeedComment", info, function (feed) {
alert("评论成功!");
location.reload();
});
});
$("a.showDiggBt").on("click", function () {
var me = $(this);
if ($(this).text().indexOf("取消") == -1) {
webapi("Digg.AddDigg", { FeedID: FeedInfo.ID }, function (feed) {
FeedInfo.DiggCount = feed.DiggCount;
FeedInfo.Digg = feed.Digg;
me.html("取消赞(" + feed.DiggCount + ")");
location.reload();
});
} else {
webapi("Digg.DeleteDigg", { FeedID: FeedInfo.ID }, function (feed) {
FeedInfo.DiggCount = feed.DiggCount;
FeedInfo.Digg = feed.Digg;
me.html("赞(" + feed.DiggCount + ")");
location.reload();
});
}
});
}
function showCommentFeed() {
var html = [];
$.each(FeedInfo.Comment, function (n, comment) {
if (comment.AtUser) {
$.each(comment.AtUser, function (k, v) {
var reg = new RegExp("@" + k);
comment.Content = comment.Content.replace(reg, "@" + v + "");
});
}
if (faceReg.test(comment.Content))
comment.Content = comment.Content.replace(faceReg, function (a, b) { return faceDic[b]; });
html.push('');
html.push('
');
html.push('
');
html.push('
');
html.push('' + comment.UserName + ' ');
html.push('
' + comment.Content + '
');
html.push('
');
if (typeof userNumb != "undefined" && (comment.UserNumb == userNumb || spaceUserNumb == userNumb))
html.push('');
html.push('
');
html.push('
');
});
$("#commentPageList").html(html.join("\r\n"));
}
function showDigg() {
var html = [];
$.each(FeedInfo.Digg, function (i, digg) {
html.push("");
});
$("ul.goodBox").html(html.join("\r\n"));
}
function AddSpaceGuestBook(userNumb, text) {
if (text == "") {
$.dialog.alert("留言内容不能为空!");
return false;
}
if (text.length > 300) {
$.dialog.alert("留言内容长度不能超过300!");
return false;
}
$.post("/Message.AddGuestBook.data", { userNumb: userNumb, Content: text }, function () {
$.dialog.confirm("留言发布成功!", function () { location.reload(); });
});
}
function DelGuestBook(id) {
$.dialog.confirm("操作不可恢复,确定删除本条留言吗?", function () {
$.post("/Message.DelGuestBook.data", { ID: id }, function() {
$.alert("删除留言成功!", function() { location.reload(); });
});
}, true);
}