//台長前台 javascript // 留言板 ########################################################################################## //訪客新增留言 function gb_add(){ $('set_reply').disabled = true; // 留言內容長度 if ($('content').value.length > 2000){ alert('內容請在2000個字以內,目前' + $('content').value.length + '個字'); $('content').focus(); reset_gcode('Gcode_Space'); $('set_reply').disabled = false; return false; } // 留言禁止空白 if( trim($('content').value) =='') { alert("內容請勿空白"); $('content').focus(); reset_gcode('Gcode_Space'); $('set_reply').disabled = false; return false; } // gcode 驗證 if(gcode_test("Gcode_Space") == 0){ $('set_reply').disabled = false; return false; } document.ttimes.action = '/station/action/gb_add.php'; document.ttimes.submit(); return; } //台長回應留言 function gb_reply(){ $('admin_reply_button').disabled = true; // 回應內容長度 if ($('s_content').value.length > 2000){ alert('內容請在2000個字以內,目前' + $('s_content').value.length + '個字'); $('s_content').focus(); $('admin_reply_button').disabled = false; return false; } // 回應禁止空白 // if( trim($('s_content').value) =='') { // alert("內容請勿空白"); // $('s_content').focus(); // return false; // } document.ttimes.action = '/station/action/gb_reply.php'; document.ttimes.submit(); } //刪除留言 function gb_del(tar_obj){ // 檢查核取 var arr = document.getElementsByName(tar_obj); var sel = 0; for(var i = 0;i 2000){ alert("內容請用中文1000個字或英文2000個字以內"); document.getElementById('s_content').focus(); reset_gcode('Gcode_Space'); $('set_reply').disabled = false; return false; } // gcode 驗證 if(gcode_test("Gcode_Space") == 0){ $('set_reply').disabled = false; return false; } document.ttimes.action="/station/action/reply_add.php"; document.ttimes.submit(); } // 刪除單文回應 function reply_del(tar_obj){ // 檢查核取 var arr = document.getElementsByName(tar_obj); var sel = 0; for(var i = 0;i 2000){ alert('內容請在2000個字以內,目前' + $('s_content').value.length + '個字'); $('s_content').focus(); $('admin_reply_button').disabled = false; return false; } // 回應禁止空白 // if( trim($('s_content').value) =='') { // alert("內容請勿空白"); // $('s_content').focus(); // return false; // } document.ttimes.action = '/station/action/reply_reply.php'; document.ttimes.submit(); } // 文章推薦 ####################################################################################### // 新增推薦 function recommend_add(mypaper_id,aid,mypaper_sid){ if (mypaper_sid == ""){ alert('請先登入新聞台Blog,才能推薦文章。'); }else if(mypaper_id == mypaper_sid){ alert('本人不能自薦'); }else{ // alert('有登入'); new Ajax.Request("/station/action/recommend_add.php",{ parameters: $H({mypaper_id : mypaper_id, aid : aid, mypaper_sid : mypaper_sid }).toQueryString(), onSuccess: function(transport){ //$('recommend_list_data').innerHTML=transport.responseText; //alert(transport.responseText); if ( transport.responseText == 'recommend_ok'){ window.location.reload(); }else if(transport.responseText == 'already_recommend'){ //一篇文章只能推薦一次,不可重覆推薦!! window.location.href='http://fiber.twfirm.com/11/oops.htm?type=station&code=a_04'; }else{ window.location.reload(); //alert(transport.responseText); //alert('囧>'); } } }); } } // 顯示推薦 隱藏回應 function recommend_list(mypaper_id,aid){ if(document.getElementById("reply_list")!= null){ document.getElementById("reply_list").className="tab"; } document.getElementById("recommend_list").className="tab_on"; new Ajax.Request("/station/action/recommend_show.php",{ parameters: $H({mypaper_id : mypaper_id, aid : aid }).toQueryString(), onSuccess: function(transport){ $('recommend_list_data').innerHTML=transport.responseText; //alert(transport.responseText); } }); //$('recommend_list_data').innerHTML= '藍藍路'; //alert(transport.responseText); document.getElementById("reply_list_data").style.display='none'; } // 顯示回應 隱藏推薦 function reply_list(){ document.getElementById("reply_list").className="tab_on"; document.getElementById("recommend_list").className="tab"; document.getElementById("reply_list_data").style.display=''; $('recommend_list_data').innerHTML=""; } // 單文轉寄 ####################################################################################### // 檢查輸入值然後跳轉寄處理頁 function send() { if(!mail_nick()){ return( false ) ;} else if(!mail_receive()){ return( false ) ;} else { document.ttimes.action="/station/action/mail_sent.php"; document.ttimes.submit(); } } // 轉寄相關檢查 function mail_nick(){ if ( document.ttimes.mail_nick.value == "" ){ alert( "請填寫【您的名字】 !" ) ; document.ttimes.mail_s_nick.focus(); return( false ) ; }else if(getLength(document.ttimes.mail_nick.value)>80){ alert('【您的名字】過長'); document.ttimes.mail_s_nick.focus; return( false ) ; } return( true ) ; } // 轉寄相關檢查 function mail_receive(){ if ( document.ttimes.mail_receive.value == ""){ alert( "請填寫【收件人的e-mail】" ) ; document.ttimes.mail_receive.focus(); return( false ) ; }else if(getLength(document.ttimes.mail_receive.value)>1000){ alert('【收件人的e-mail】過長'); document.ttimes.mail_receive.focus; return( false ) ; } var i=0; words = new String(document.ttimes.mail_receive.value) var swords = words.split(";"); while(swords[i]){ var len = swords[i].length; for(var j=0;j="A"&&c<="Z")||(c>="a"&&c<="z")||(c>="0"&&c<="9")||(c=="-")||(c=="_")||(c==".")||(c=="@"))){ alert( "您的『電子郵件地址』只能是數字,英文字母及'-','_'等符號,其他的符號都不能使用 !\n"); return ( false ); } } if((swords[i].indexOf("@")==-1)||(swords[i].indexOf("@")==0)||(swords[i].indexOf("@")==(len-1))){ alert("您的『電子郵件地址』不合法 !\n"); document.ttimes.mail_receive.focus(); return ( false ); } if((swords[i].indexOf("@")!=-1)&&(swords[i].substring(swords[i].indexOf("@")+1,len).indexOf("@")!=-1)){ alert("您的『電子郵件地址』不合法 !\n"); document.ttimes.mail_receive.focus(); return ( false ); } if((swords[i].indexOf(".")==-1)||(swords[i].indexOf(".")==0)||(swords[i].lastIndexOf(".")==(len-1))){ alert("您的『電子郵件地址』不完全 !\n"); document.ttimes.mail_receive.focus(); return ( false ); } i++; } return( true ); } // 轉寄專用取字數 function getLength(for_check){ var I, cnt=0; for(I=0;I=4){ cnt +=2; }else{ cnt++; } } return cnt; } // 站台鼓勵 ########################################################################################### function station_point_add( ){ document.ttimes.action="/station/action/station_point_add.php"; document.ttimes.submit(); } // 其他 ########################################################################################### // 計算字數 function strlens(text){ var len =0,i=0; text = text.replace(/^\s*/,""); text = text.replace(/\s*$/,""); text = text.replace(/\r\n*$/,""); for(var i=0;i< text.length;i++){ len += (text.charCodeAt(i) > 255)?2:1; } return len; } // 全選 function select_all(tar_obj){ var arr = document.getElementsByName(tar_obj); for(var i = 0;i