📄 publish.js
字号:
/****************************************************************
*
* @Purpose: 发表文章相关处理函数
* @File name: publish.js
* @Author: AiGuo Li
* @Create Time: 2006/04/25
* @Email: liaiguo@tomonline-inc.com
* @Modify Time: 2006/05/08
*
*****************************************************************/
function date () {
this.length = date.arguments.length;
for(var i=0;i<this.length;i++) {
this[i+1] = date.arguments[i]
}
}
function getToday () {
var Today = new Date();
var D = new date("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
return Today.getYear()+"年"+(Today.getMonth()+1)+"月"+Today.getDate()+"日 "+D[Today.getDay()+1]
}
function getFrameNode ( pNodeID ) {
return document.frames ? document.frames[pNodeID] : document.getElementById(pNodeID).contentWindow;
}
function insertImg ( pUrl ) {
var oInnerDoc1 = getFrameNode("Content___Frame");
var oImg = oInnerDoc1.FCK.CreateElement('IMG') ;
oImg.src = pUrl;
}
function checkArticleForm () {
var objForm = document.getElementById("formPublish");
if ( objForm.Title.value == '') {
showInfor("文章标题不能为空!");
objForm.Title.focus();
return false;
} else if ( objForm.Title.value.length > 50 ) {
showInfor("文章标题最多为50个字符或25个汉字!");
objForm.Title.focus();
return false;
}
if ( objForm.Directory.value == '0' ) {
showInfor("请选择文章所属的目录!");
objForm.Directory.focus();
return false;
}
return true;
}
function publishArticle () {
var objForm = document.getElementById("formPublish");
var oInnerDoc = getFrameNode("Content___Frame");
var Mood = oInnerDoc.document.getElementById("mood").value;
if ( checkArticleForm() ) {
objForm.Status.value = '2';
objForm.todayMood.value = Mood;
objForm.submit();
}
}
function saveAsDraft () {
var objForm = document.getElementById("formPublish");
var oInnerDoc = getFrameNode("Content___Frame");
var Mood = oInnerDoc.document.getElementById("mood").value;
if ( objForm.Title.value == '' ) {
var Today = new Date();
var D = new date("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
objForm.Title.value = getToday();
}
objForm.Status.value = '1';
objForm.todayMood.value = Mood;
objForm.submit();
}
function publishReset () {
var objForm = document.getElementById("formPublish");
objForm.reset();
}
function checkCommentForm ( pUID , pAID ) {
var uID = pUID;
var aID = pAID;
var User = getElement("replyUser"+aID).value;
var Url = getElement("Url"+aID).value;
var Content = getElement("Content"+aID).value;
if ( User == '' || User.length > 20 ) {
showInfor("“名称”应为0-20个字符!");
} else if ( Content == '' || Content.length > 10000 ) {
showInfor("“评论内容”应为0-10000个字符!");
} else {
var ajax = new myAjax();
var para = "uid="+uID+"&aid="+aID+"&username="+jsUrlEncode(User)+"&url="+jsUrlEncode(Url)+"&content="+jsUrlEncode(Content);
ajax.open("POST","http://blog.tom.com/blog/comment.php",para,"TEXT",done);
}
function done ( retData ) {
if ( retData == "1" ) {
showInfor('对不起,请不要连续发表评论!');
} else if ( retData == "2" ) {
showInfor('评论失败,请重试!');
} else {
showInfor('发表评论成功!','succ',"getHtml('commentlist',"+uID+","+aID+",1,0,0,'CommentList"+aID+"');");
}
}
}
function deleteComment ( pUID , pAID , pCID ) {
var uID = pUID;
var aID = pAID;
var cID = pCID;
var url = 'http://blog.tom.com/manage/article/deleteComment.php';
var para = 'bloggerid='+uID+'&blogid='+aID+'&commentid='+cID;
var ajax = new myAjax();
ajax.open("POST",url,para,"TEXT",thisDone);
initProcessing();
function thisDone ( retData ) {
resetProcessing();
if ( retData == "1" ) {
confirmInfor('评论删除成功!','succ',"getHtml('commentlist',"+uID+","+aID+",1,0,0,'CommentList"+aID+"');");
} else if( retData == "0" ) {
showInfor('评论删除失败,请重试!','failing');
} else {
showInfor('对不起,您无权删除该评论!','failing');
}
}
}
function initProcessing() {
var processingBg = '<div id="processingDiv" style="position:absolute;top:250px;left:400px;width:300px;height:100px;text-align: center;padding-top:45px;border:1px dotted #000000;background-color:#FFFFFF;">数据正在处理中,请稍后 ......</div>';
var oDiv = document.createElement("span");
oDiv.id = "processing";
oDiv.innerHTML = processingBg;
document.body.appendChild(oDiv);
}
function resetProcessing () {
document.getElementById("processing") ? document.getElementById("processing").parentNode.removeChild(document.getElementById("processing")) : function(){};
}
function showImg ( pObj , pID ) {
var oImgContainer = document.getElementById("imgContainer"+pID);
if ( pObj.value != '' ) {
oImgContainer.src = pObj.value;
oImgContainer.width = 250;
oImgContainer.onreadystatechange = function () {
if ( oImgContainer.readyState == "complete" ) {
var maxSize = 2 * 1024 * 1024;
if ( oImgContainer.fileSize > maxSize ) {
oImgContainer.width = 0;
showInfor('您选择的图片大小超过了2M!','failing');
}
}
}
} else {
oImgContainer.width = 0;
showInfor('您没有选择要上传的图片!','failing');
}
}
function uploadImg ( pID ) {
var objForm = document.getElementById("uploadImgs");
var curUploadImg = document.getElementById("curUpload");
curUploadImg.value = "imgFile"+pID;
objForm.submit();
}
function getAlbumList () {
var url = 'http://blog.tom.com/manage/album/albumList.php';
var ajax = new myAjax();
ajax.open("POST",url,null,"TEXT",thisDone2);
function thisDone2 ( pRetData ) {
var albumContainer = document.getElementById("albumContainer");
albumContainer.innerHTML = pRetData;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -