//==============提交js开始========================
var type_blog=4;
var type_log=0;
var type_logclass=10;
var type_photo=1;
var type_photoclass=11;
var type_video=2;
var type_videoclass=12;
var type_audio=3;
var type_audioclass=13;
function doSubmit(id,paramstr){
var contentObj=document.getElementById("message_content");
var content;
if(contentObj){//如果有内容参数
content=contentObj.value;
}
var titleObj=document.getElementById("message_title");
var title;
if(titleObj){
title=document.getElementById("message_title").value;
}
var checknumObj =document.getElementById("checknum");
var checknum;
if(checknumObj){
checknum=document.getElementById("checknum").value;
}
var type;
var typeObj=document.getElementById("message_type");
if(typeObj){
type=typeObj.value;
}
var objectid;
var objectidObj=document.getElementById("message_id");
if(objectidObj){
objectid=objectidObj.value;
}
if(id!='1002' && id!='1001' && id!='09'){//这个是登录和登出
if( content == null || content == "") {
alert('内容必须输入!!');
return;
}
}
var url = _contextPath+"/ebfn?_fn="+id+"&ebuser_id="+_ebuser_id;
if(id=='0201'){
if(_needlogin){
_error_msg_show('请您先登陆再留言。','','sorry','');
return;
}
if(_leaveforbit){
_error_msg_show('对不起,您没有留言的权限。','','sorry','');
return;
}
if(getLength(content) < _leavewordminlen){
_error_msg_show('请填入至少'+_leavewordminlen+'字长度的留言。','','sorry','');
return;
}
if(getLength(content) > _leavewordmaxlen){
_error_msg_show('你的留言字数太长了,必须小于'+_leavewordmaxlen+'字节!',"",'sorry','');
contentObj.value = contentObj.value.substr(0,_leavewordmaxlen);
return;
}
if(document.getElementById('isprivate')&&document.getElementById('isprivate').checked){
url+="&isprivate=1";
}else{
url+="&isprivate=0";
}
}else if(id=='0501'){
if(_needlogin){
_error_msg_show('请您先登陆再发送短消息。','','sorry','');
return;
}
if(_messageforbit){
_error_msg_show('对不起,您没有发送短消息的权限。','','sorry','');
return;
}
if(getLength(content) > _messagemaxlen){
_error_msg_show('你的短消息字数太长!',"",'sorry','');
return;
}
}else if(id=='0801'){
if(_needlogin){
_error_msg_show('请您先登陆后再试。','','sorry','');
return;
}
if(paramstr==undefined||paramstr==null)
paramstr = '';
var favoritePicObj=document.getElementById("pic");
if(favoritePicObj){
paramstr+="&pic="+encodeURIComponent(favoritePicObj.value);
}
}
if(paramstr){
url+=paramstr;
}
httpReqeustObject = getHttpRequestObject();
httpReqeustObject.onreadystatechange = function() {
if (httpReqeustObject.readyState == 4) {
var result = new ajaxresult();
result.set(httpReqeustObject);
var status = result.status;
var msg = result.msg;
if(status == "0"){
if( msg=="NULL" ){
msg="操作成功。";
}
if(id=='1002'){
var tempurl=window.location.href;
window.location.href = "/eblog";
/**
if(tempurl.indexOf("/eb")>=0){
parent._error_msg_show(msg,"'"+_contextPath+"/eblogin.do?tf=index'",5,"");
}else{
parent._error_msg_show(msg,"window.location",1,"");
}*/
}else{
parent._error_msg_show(msg,"window.location",1,"");
}
} else {
if( msg=="NULL" ) {
msg="操作失败,请重试。" ;
}
parent._error_msg_show(msg,"",5,"");
}
}
}//function结束
var formValueStr ="title="+encodeURIComponent(title);
formValueStr += "&content=" + encodeURIComponent(content);
formValueStr +="&checknum="+checknum;
formValueStr +="&id="+objectid;
formValueStr +="&type="+type;
httpReqeustObject.open('POST', url, true);
httpReqeustObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
httpReqeustObject.send(formValueStr);
}
function doEvalue(id,paramstr){
var url = _contextPath+"/ebfn?_fn="+id+"&ebuser_id="+_ebuser_id;
if(paramstr){
url+=paramstr;
}
httpReqeustObject = getHttpRequestObject();
httpReqeustObject.onreadystatechange = function() {
if (httpReqeustObject.readyState == 4) {
var result = new ajaxresult();
result.set(httpReqeustObject);
var status = result.status;
var msg = result.msg;
if(status == "0"){
if( msg=="NULL" ){
msg="操作成功。";
}
} else {
if( msg=="NULL" ) {
msg="操作失败,请重试。";
}
parent._error_msg_show(msg,"",5,"");
}
}
} //function结束
httpReqeustObject.open('POST', url, true);
httpReqeustObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
}
function getFriendList(){
var url=_contextPath+"/ebfn?_fn=1201&ebuser_id="+_ebuser_id;
httpReqeustObject = getHttpRequestObject();
httpReqeustObject.onreadystatechange = function() {
if (httpReqeustObject.readyState == 4) {
var xmldoc = httpReqeustObject.responseXML;
var result = new ajaxresult();
result.set(httpReqeustObject);
var status = result.status;
var msg = result.msg;
if(status == "0"){
showfriend(msg);
} else {
msg="操作失败,请重试。" ;
parent._error_msg_show(msg,"",5,"");
}
}
} //function结束
var formValueStr ="";
httpReqeustObject.open('POST', url, true);
httpReqeustObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
httpReqeustObject.send(formValueStr);
}
//==============评论JS开始======================
function doCommentSubmit(id) {
if(_needlogin&&_commentforbit){
_error_msg_show('请您先登陆再发表评论。','','sorry','');
return;
}
var content = document.getElementById("comment.content").value;
if( content == null || content == "") {
alert("内容必须输入!!");
return;
}
var checknumObj =document.getElementById("checknum");
var checknum;
if(checknumObj){
checknum=document.getElementById("checknum").value;
}
if(getLength(content) < _commentminlen){
_error_msg_show('请填入至少'+_commentminlen+'字长度的评论。','','sorry','');
return;
}
if(getLength(content) > _commentmaxlen*2){
_error_msg_show('你发表的评论字数太长',"",'sorry','');
return;
}
var title = document.getElementById("comment.title");
if(title){
if( title.value == null || title.value == "" ) {
title.value = "无标题";
}
}
var url =_contextPath+"/ebfn?_fn=0101&ebuser_id="+_ebuser_id;
httpReqeustObject = getHttpRequestObject();
httpReqeustObject.onreadystatechange = function() {
if (httpReqeustObject.readyState == 4) {
var result = new ajaxresult();
result.set(httpReqeustObject);
var status = result.status;
var msg = result.msg;
if(status == "0"){
if( msg=="NULL" )
_error_msg_show("评论发表成功,谢谢你的支持。","window.location",1,"");
else
_error_msg_show(msg,"window.location+'#comment'",1,"");
} else {
if( msg=="NULL" )
msg="抱歉,评论失败,请重试。";
else
msg="抱歉,评论失败,请重试。
" + msg;
_error_msg_show(msg,"",5,"");
}
}
}//function结束
var formValueStr ="";//"comment.title="+encodeURIComponent(document.getElementById("comment.title").value);
formValueStr += "comment_author=" + _ebuser_id;
formValueStr += "&comment_objectid=" +id;
formValueStr += "&comment_content=" + encodeURIComponent(content);
formValueStr +="&checknum="+checknum;
httpReqeustObject.open('POST', url, true);
httpReqeustObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
httpReqeustObject.send(formValueStr);
}
function logout(){
doSubmit('1002');
}
function doLeaveword(){
doSubmit('0201');
}
function doSupport(id){
doCommentValueSubmit("0102" , id);
}
function doDisagree(id) {
doCommentValueSubmit("0103" , id);
}
function doNoCare(id) {
doCommentValueSubmit("0104" , id);
}
function sendmessage(){
showWindow(_contextPath+"/Base?tf=submitdialog&_fn=message&ebuser_id="+_ebuser_id,300,280,"发送短消息","no");
}
function login(){
//showWindow(_contextPath+"/Base?tf=loginshow",300,220,"登录","no");
}
function reguser(){
//window.location=_contextPath+"/ebreg.do?tf=regedit&_fn=BeforeReg";
}
function addfriend(){
showWindow(_contextPath+"/Base?tf=submitdialog&_fn=friend&ebuser_id="+_ebuser_id,300,280,"增加好友","no");
}
function addblack(){
showWindow(_contextPath+"/Base?tf=submitdialog&_fn=black&ebuser_id="+_ebuser_id,300,280,"加入黑名单","no");
}
function addattention(){
showWindow(_contextPath+"/Base?tf=submitdialog&_fn=attention&ebuser_id="+_ebuser_id,300,280,"加入关注","no");
}
function leaveword(){
window.location=_contextPath+"/User?tf=leaveword&ebuser_id="+_ebuser_id;
}
function recommend(){
showWindow(_contextPath+"/Base?tf=submitdialog&_fn=recommend&ebuser_id="+_ebuser_id,300,280,"推荐给好友","no");
}
function complain(id){
showWindow(_contextPath+"/Base?tf=submitdialog&_fn=complain&ebuser_id="+_ebuser_id+"&id="+id,300,280,"向系统管理员投诉","no",true);
}
function evalue(id){
showWindow(_contextPath+"/Base?tf=evalue&ebuser_id="+_ebuser_id+"&ebcontent_id="+id,300,280,"给他评分","no",true);
}
function doCommentValueSubmit(fn, id){
var url = _contextPath + "/cfn?cmsfn="+fn +"&umID="+id ;
var httpReqeustObject = getHttpRequestObject();
httpReqeustObject.onreadystatechange = function() {
if (httpReqeustObject.readyState == 4) {
var result = new ajaxresult();
result.set(httpReqeustObject);
var status = result.status;
var msg = result.msg;
if(status == "0"){
_error_msg_show("评价成功,谢谢你的支持","window.location.href",5,"");
} else {
_error_msg_show("抱歉,评价失败,请重试","",3,"");
}
}
} //function结束
httpReqeustObject.open('GET', url, true);
httpReqeustObject.send(null);
}
function doClearCookie() {
var url =_contextPath+"/ebfn?_fn=1301&ebuser_id="+_ebuser_id;
httpReqeustObject = getHttpRequestObject();
httpReqeustObject.onreadystatechange = function() {
if (httpReqeustObject.readyState == 4) {
var result = new ajaxresult();
result.set(httpReqeustObject);
var status = result.status;
var msg = result.msg;
if(status == "0"){
if( msg=="NULL" )
_error_msg_show("Cookie 清除成功!","",1,"");
else
_error_msg_show(msg,"",1,"");
} else {
if( msg=="NULL" )
msg="Cookie 清除失败!";
_error_msg_show(msg,"",3,"");
}
}
}//function结束
httpReqeustObject.open('POST', url, true);
httpReqeustObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
httpReqeustObject.send(null);
}
function doAddFavoriteContent(id){
var url =_contextPath+"/ebfn?_fn=1301&ebuser_id="+_ebuser_id;
}
function addFavorite(id,title,pic,type){
var formValueStr ="&title="+encodeURIComponent(title);
formValueStr +="&id="+id;
formValueStr +="&pic="+encodeURIComponent(pic);
formValueStr +="&type="+type;
showWindow(_contextPath+"/Base?tf=submitdialog&_fn=favorite&ebuser_id="+_ebuser_id+formValueStr,300,280,"添加到收藏","no");
}
function doCommon(url,formStr) {
httpReqeustObject = getHttpRequestObject();
httpReqeustObject.onreadystatechange = function() {
if (httpReqeustObject.readyState == 4) {
var result = new ajaxresult();
result.set(httpReqeustObject);
var status = result.status;
var msg = result.msg;
if(status == "0"){
if( msg=="NULL" )
_error_msg_show("Cookie 处理成功!","",1,"");
else
_error_msg_show(msg,"",1,"");
} else {
if( msg=="NULL" )
msg="Cookie 处理失败!";
_error_msg_show(msg,"",3,"");
}
}
}//function结束
httpReqeustObject.open('POST', url, true);
httpReqeustObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
httpReqeustObject.send(formStr);
}
function getTemplateModelStr(id,modelname){
var url =_contextPath + "/ebfn?_fn=1501&ebuser_id="+_ebuser_id;
url += "&own_id=" + id+"&extend_filename="+modelname;
httpReqeustObject = getHttpRequestObject();
httpReqeustObject.onreadystatechange = function() {
if (httpReqeustObject.readyState == 4) {
var result = new sourceresult();
result.set(httpReqeustObject);
var tmpHtml = result.text;//getTemplateModelStr('${own_id}','${extend_filename}');
//document.getElementById('${extend_filename}').value;
tmpHtml = tmpHtml.replace('','');
// document.getElementById('${extend_filename}').value = tmpHtml;
document.getElementById(modelname).value=tmpHtml;
}
} //function结束
httpReqeustObject.open('POST', url, true);
httpReqeustObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
httpReqeustObject.send(null);
}
function getPhotoList(classid){
var url=_contextPath+"/ebfn?_fn=1602&ebuser_id="+_ebuser_id+"&userclass_id="+classid;
httpReqeustObject = getHttpRequestObject();
httpReqeustObject.onreadystatechange = function() {
if (httpReqeustObject.readyState == 4) {
var result = new ajaxresult();
result.set(httpReqeustObject);
var status = result.status;
var msg = result.msg;
if(status == "0"){
onselectphotoclass(msg);
} else {
if(msg=="NULL")
msg="操作失败,请重试。" ;
parent._error_msg_show(msg,"",5,"");
}
}
} //function结束
var formValueStr ="";
httpReqeustObject.open('POST', url, true);
httpReqeustObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
httpReqeustObject.send(formValueStr);
}
function getContentNumsByDay(yyyyMM,type){
var url=_contextPath+"/ebfn?_fn=1703&ebuser_id="+_ebuser_id+"&yyyyMM="+yyyyMM+"&type="+type;
httpReqeustObject = getHttpRequestObject();
httpReqeustObject.onreadystatechange = function() {
if (httpReqeustObject.readyState == 4) {
var result = new ajaxresult();
result.set(httpReqeustObject);
var status = result.status;
var msg = result.msg;
if(status == "0"){
return onGetLogNumsByDay(msg);
} else {
msg="操作失败,请重试。" ;
parent._error_msg_show(msg,"",5,"");
}
}
} //function结束
var formValueStr ="";
httpReqeustObject.open('POST', url, true);
httpReqeustObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
httpReqeustObject.send(formValueStr);
}
//======================= votebox start ==================
function doVote(xId){
var cs = document.getElementsByName("vote." + xId);
if(!cs || cs == null || cs == "" ){
_error_msg_show( "投票项不存在。","",3,"");
return true;
}
var ps = "";
var count = 0;
if(cs && cs.length){
for(var i=0;i0){
ps = ps + "&";
}
ps =ps + "vote." + xId + "=" + cs[i].value;
count++;
}
}
}else if(cs){
if(cs.checked){
ps = ps + "vote." + xId + "=" + cs.value;
count++;
}
}
if(count==0){
_error_msg_show( "必须选择后才能提交.","",3,"");
return true;
}
var url =_contextPath + "/ebfn?_fn=0301&ebuser_id="+_ebuser_id;
httpReqeustObject = getHttpRequestObject();
httpReqeustObject.onreadystatechange = function() {
if (httpReqeustObject.readyState == 4) {
var result = new ajaxresult();
result.set(httpReqeustObject);
var status = result.status;
var msg = result.msg;
if(status == "0"){
if( msg=="NULL" ){
msg="投票成功,谢谢你的支持。";
}else {
msg="投票成功,谢谢你的支持。
" + msg;
}
_error_msg_show(msg,"window.location=window.location",5,"");
} else {
if( msg=="NULL" )
msg="抱歉,投票失败,请重试。" ;
else
msg="抱歉,投票失败,请重试。
" + msg;
_error_msg_show(msg,"",3,"");
}
}
} //function结束
ps += "&vote.votebox_id=" + xId;
var nextUrl = _contextPath + "/Base?tf=_voteResult&vote.votebox_id=" + xId;
url = _contextPath + "/Base?tf=_checkNum&checknum.forward=" + encodeURIComponent(nextUrl) + "&checknum.action=" + encodeURIComponent(url + "&" + ps);
openWindow(url,400,300,"resizable=yes");
}
function doViewVote(xId){
openWindow(_contextPath + "/Base?tf=_voteResult&vote.votebox_id=" + xId,800,600,"resizable=yes,scrollbars=yes");
}
//======================= votebox end ===================
//======================= check Num start ================
function chgAuthImg(){
var authImg = document.getElementById('auth_img');
authImg.src = _contextPath + "/ebfn?_fn=0401" + '&' + Math.random() ;
var cNum = document.getElementById('checkNum.inputNum');
cNum.value = "";
}
function doCheckNum(){
var url =_contextPath + "/ebfn?_fn=0402&ebuser_id="+_ebuser_id;
var inputNum = document.getElementById("checkNum.inputNum");
url += "&checkNum.inputNum=" + inputNum.value;
httpReqeustObject = getHttpRequestObject();
httpReqeustObject.onreadystatechange = function() {
if (httpReqeustObject.readyState == 4) {
var result = new ajaxresult();
result.set(httpReqeustObject);
var status = result.status;
var msg = result.msg;
if(status == "0"){
var sa = document.getElementById("successAction");
var forward = document.getElementById("forward");
if(sa.value != ""){
httpReqeustObject = getHttpRequestObject();
httpReqeustObject.onreadystatechange = function() {
if (httpReqeustObject.readyState == 4) {
window.location=forward.value;
}
}
httpReqeustObject.open('POST', sa.value, true);
httpReqeustObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
httpReqeustObject.send(null);
}else{
window.location=forward.value;
}
} else {
chgAuthImg();
inputNum = document.getElementById("checkNum.inputNum");
inputNum.value="";
inputNum.focus();
_error_msg_show(msg,"",3,"");
}
}
} //function结束
var formValueStr ="";
httpReqeustObject.open('POST', url, true);
httpReqeustObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
httpReqeustObject.send(formValueStr);
}
//======================= check Num end ================
//==============AJAX公用JS开始 ======================
function getHttpRequestObject() {
var http_request = false ;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}else{
alert('??')
}
if (!http_request) {
alert('不支持HTTP的协议。');
return false;
}
return http_request;
}
function getAjaxSubmitStr(name , firstFlag ) {
var value = document.getElementById(name).value;
if( !value || value ==null || value == "" ) {
return "";
}
if(firstFlag )
return name + "=" + value;
else
return "&"+name + "=" + value;
}
function isNullValue(name , chineseName) {
var value = document.getElementById(name).value;
if ( !value || value==null || value=="") {
_error_msg_show( chineseName + "必须输入,请填写。","",3,"");
return true;
}
return false;
}
function ajaxresult(){
var status;
var msg;
this.set = function(httpReqeustObject){
var xmldoc;
if (window.ActiveXObject) { // IE
xmldoc = httpReqeustObject.responseXML;
} else if (window.XMLHttpRequest) { // Mozilla, Safari,...
var parser = new DOMParser();
xmldoc = parser.parseFromString(httpReqeustObject.responseText, "text/xml");
}
var root_node = xmldoc.getElementsByTagName('status').item(0);
this.status = root_node.firstChild.data;
var msg_node = xmldoc.getElementsByTagName('message').item(0);
this.msg = msg_node.firstChild.data;
}
}
function sourceresult(){
var text;
this.set = function(httpReqeustObject){
var xmldoc;
if (window.ActiveXObject) { // IE
xmldoc = httpReqeustObject.responseXML;
} else if (window.XMLHttpRequest) { // Mozilla, Safari,...
var parser = new DOMParser();
xmldoc = parser.parseFromString(httpReqeustObject.responseText, "text/xml");
}
this.text=httpReqeustObject.responseText;
}
}
//=======================AJAX公用JS end ===================
//================= forward start==============
function prenextlocation(url){
if(url!='')
window.location = url;
else
_error_msg_show("对不起,没有了!",'','','');
}
function doSearch(){
if($("searchtype"))
openFormPostWindow($("searchtype").value+"&searchvalue="+$("searchvalue").value);
else
openFormPostWindow(_contextPath+"/System?tf=logindex&searchtype=logtitle&searchvalue="+$("searchvalue").value);
}
function gotoSearchTag(tag,type){
doFormPostSearch(_contextPath+"/System?tf=logindex","tag",tag);
}
function doFormPostSearch(url,pname,pvalue){
if(pname==null||pname==undefined||pname=="") pname = "tag";
var body = document.getElementsByTagName("body");
var form = document.createElement("form");
var tagbox = document.createElement("input");
form.method = "post";
form.action = url;
form.id = "ebsearchform";
form.name = "ebsearchform";
form.style.display = "none";
tagbox.type = "hidden";
tagbox.id = pname;
tagbox.name = pname;
tagbox.value = pvalue;
body[0].appendChild(form);
form.appendChild(tagbox);
form.submit();
}
function openFormPostWindow(targeturl,thisobj){
function getParamNode(paramname,paramvalue){
var paramnode = document.createElement("input");
paramnode.type = "hidden";
paramnode.id = paramname;
paramnode.name = paramname;
paramnode.value = paramvalue;
return paramnode;
}
var body = document.getElementsByTagName("body");
var form = document.createElement("form");
if(thisobj && thisobj.target){
form.target = thisobj.target;
}else{
form.target = "_self";
}
form.method = "post";
form.id = "ebpostform";
form.name = "ebpostform";
form.style.display = "none";
if(targeturl.indexOf('?')>0){
form.action = targeturl.substring(0,targeturl.indexOf('?'));
var params = targeturl.substring(targeturl.indexOf('?')+1);
var pname,pvalue;
while(params.length>0){
if(params.indexOf('=')>0){
pname = params.substring(0,params.indexOf('='));
params = params.substring(params.indexOf('=')+1);
}else{
pname = params;
params = "";
}
if(params.indexOf('&')>0){
pvalue = params.substring(0,params.indexOf('&'));
params = params.substring(params.indexOf('&')+1);
}else{
pvalue = params;
params = "";
}
form.appendChild(getParamNode(pname,pvalue));
}
}else{
form.action = targeturl;
}
body[0].appendChild(form);
form.submit();
}
function openWindow( link , width , height , windowParam){
var widthvalue = (window.screen.width-width)/2;
var heightvalue = (window.screen.height-height)/2;
var PopWindow;
PopWindow = window.open(link,"","width="+ width + ",height=" + height+ "," + windowParam +",left="+widthvalue+",top="+heightvalue,true);
PopWindow.focus();
}
//================= forward end ===============