//台長前台 javascript // 留言板 ########################################################################################## // 訪客新增留言 function gb_add(){ jQuery('#set_reply').attr("disabled", true); // 留言內容長度 if (jQuery('#content').val().length > 2000){ alert('內容請在2000個字以內,目前' + jQuery('#content').val().length + '個字'); jQuery('#content').focus(); reset_gcode('Gcode_Space'); jQuery('#set_reply').attr("disabled", false); return false; } // 留言人禁止空白 if( trim(jQuery('#nickname').val()) =='') { alert("留言人請勿空白"); jQuery('#nickname').focus(); reset_gcode('Gcode_Space'); jQuery('#set_reply').attr("disabled", false); return false; } // 留言禁止空白 if( trim(jQuery('#content').val()) =='') { alert("內容請勿空白"); jQuery('#content').focus(); reset_gcode('Gcode_Space'); jQuery('#set_reply').attr("disabled", false); return false; } // gcode 驗證 if(gcode_test("Gcode_Space") == 0){ jQuery('#set_reply').attr("disabled", false); return false; } document.ttimes.action = '/station/action/gb_add.php'; document.ttimes.submit(); return; } //台長回應留言 function gb_reply(){ jQuery('#admin_reply_button').attr("disabled", true); // 回應內容長度 if (jQuery('#s_content').val().length > 2000){ alert('內容請在2000個字以內,目前' + jQuery('#s_content').val().length + '個字'); jQuery('#s_content').focus(); jQuery('#admin_reply_button').attr("disabled", false); return false; } document.ttimes.action = '/station/action/gb_reply.php'; document.ttimes.submit(); } //刪除留言 function gb_del_single(mid, no){ if(confirm('確定要刪除嗎?\n刪除之後無法救了喔!')) { jQuery.ajax({ type: "POST", url: "/station/action/gb_del.php", data: { mypaper_id : mid, time : no } }).done(function(msg) { //console.log(msg); if ( msg == 'done'){ window.location.reload(); }else if(msg == 'no_power'){ window.location.href='/oops.htm?type=station&code=no_power'; }else if(msg == 'failure'){ window.location.href='/oops.htm?type=api&code=a_01'; }else{ window.location.reload(); } }); } } //刪除留言 function gb_del(tar_obj){ // 檢查核取 var arr = document.getElementsByName(tar_obj); var sel = 0; for(var i = 0;i 2000){ alert("內容請用中文1000個字或英文2000個字以內"); jQuery('#s_content').focus(); reset_gcode('Gcode_Space'); jQuery('#set_reply').attr("disabled", false); return false; } // gcode 驗證 if(gcode_test("Gcode_Space") == 0){ jQuery('#set_reply').attr("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個字以內,目前' + jQuery('#s_content').val().length + '個字'); jQuery('#s_content').focus(); jQuery('#admin_reply_button').attr("disabled", false); return false; } document.ttimes.action = '/station/action/reply_reply.php'; document.ttimes.submit(); } // 台長回應訪客的回應 function content_reply_2015(_PRE_STR){ var _THIS_Obj = jQuery( "[name*='"+ _PRE_STR +"']" ); //return; // 回應內容長度 if (_THIS_Obj.filter('#s_content').val().length > 2000) { alert('內容請在2000個字以內,目前' + _THIS_Obj.filter('#s_content').val().length + '個字'); _THIS_Obj.filter('#s_content').focus(); return false; } // 懶的惡搞了 var form_HTML ="\r\n" + '
'+ "\r\n" + ''+ "\r\n" + ''+ "\r\n" + ''+ "\r\n" + ''+ "\r\n" + ''+ "\r\n" + ''+ "\r\n" //+ ''+ "\r\n" + '
'; if(jQuery("#ttimes2").length <1) { jQuery("body").append(form_HTML); } jQuery("#ttimes2").submit(); } // 文章推薦 ####################################################################################### // 新增推薦 function recommend_add(mypaper_id,aid,mypaper_sid,host_type){ if (mypaper_sid == ""){ if(confirm('請先登入個人新聞台,才能推薦文章。')){ location.href= 'https://member.pchome.com.tw/login.html?ref=' + encodeURIComponent(location); } }else if(mypaper_id == mypaper_sid){ alert('本人不能自薦'); }else{ var collect_add_url = ( host_type =='mobile')?'/website/station/action/recommend_add.php':'/station/action/recommend_add.php'; jQuery.ajax({ type: "POST", url: collect_add_url, async: false, // 強制 同步 data: { mypaper_id : mypaper_id, aid : aid, mypaper_sid : mypaper_sid } }).done(function(msg) { //console.log(msg); if ( msg == 'recommend_ok'){ alert('感謝您的推薦!'); // PM說上面人要看報表所以要重整 window.location.reload(); return; //$A($$('span.recmd_num')).each(function(s) {s.innerHTML = parseInt(s.innerHTML)+1;}); }else if(msg == 'already_recommend'){ //一篇文章只能推薦一次,不可重覆推薦!! if( location.pathname.match('/m/post/') ){ alert('你已經推薦過。'); // PM說上面人要看報表所以要重整 window.location.reload(); return; }else{ //window.location.href='/oops.htm?type=station&code=a_04'; alert('你已經推薦過。'); return; } //window.location.href='/oops.htm?type=station&code=a_04'; }else{ window.location.reload(); } }); } } // 顯示回應 隱藏推薦、收藏 function reply_list(){ jQuery("#reply_list").attr('class',"tab_on"); jQuery("#recommend_list").attr('class',"tab"); jQuery("#collect_list").attr('class',"tab"); jQuery('#reply_list_data').css("display",""); jQuery('#recommend_list_data').html(''); jQuery('#collect_list_data').html(''); } // 顯示推薦 隱藏回應、收藏 function recommend_list(mypaper_id,aid){ jQuery("#recommend_list").attr('class',"tab_on"); if(jQuery("#reply_list").length >0 ){ jQuery("#reply_list").attr('class',"tab"); jQuery("#collect_list").attr('class',"tab"); } jQuery('#reply_list_data').css("display","none"); jQuery('#collect_list_data').html(""); jQuery.ajax({ type: "POST", url: "/station/action/recommend_show.php", data: { mypaper_id : mypaper_id, aid : aid, } }).done(function(msg) { //console.log(msg); jQuery('#recommend_list_data').html(msg); }); } // 顯示單文收藏 隱藏回應、推薦 function collect_list(mypaper_id,aid){ jQuery("#collect_list").attr('class',"tab_on"); jQuery("#recommend_list").attr('class',"tab"); jQuery("#reply_list").attr('class',"tab"); jQuery("#reply_list_data").css("display","none"); jQuery('#recommend_list_data').html(""); jQuery.ajax({ type: "POST", url: "/station/action/collect_show.php", data: { mypaper_id : mypaper_id, aid : aid, } }).done(function(msg) { //console.log(msg); jQuery('#collect_list_data').html(msg); }); } // 新增收藏 // 2014-09-01 ADD [ host_type ] for 手機裝置用 function collect_add(mypaper_id,aid,mypaper_sid,host_type){ if (mypaper_sid == ""){ if(confirm('請先登入個人新聞台,才能收藏文章。')){ location.href= 'https://member.pchome.com.tw/login.html?ref=' + encodeURIComponent(location); } }else{ var collect_add_url = ( host_type =='mobile')?'/website/station/action/collect_add.php':'/station/action/collect_add.php'; jQuery.ajax({ type: "POST", url: collect_add_url, async: false, // 強制 同步 data: { mypaper_id : mypaper_id, aid : aid, mypaper_sid : mypaper_sid } }).done(function(msg) { //console.log(msg); if ( msg == 'collect_ok') { alert('感謝您的收藏!'); // PM說上面人要報表好看所以要重整 window.location.reload(); return; }else if(msg == 'duplicate'){ alert('此篇文章已收藏過!'); }else if(msg == 'article_not_exists'){ alert('此篇文章不存在!!'); }else if(msg == 'collect_full'){ alert('收藏數已達上限!'); }else{ alert('不明錯誤!請稍後再試'); } }); } } // 單文轉寄 ####################################################################################### // 檢查輸入值然後跳轉寄處理頁 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 station_zongzi_point_add( ){ // document.ttimes.action="/station/action/station_zongzi_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資料讀取中'); jQuery('#friend_data_area').data( "dataflag", 0 ); jQuery.ajax({ type: "POST", url: "/station/action/mypage_friend_list_show.php", data: { member_id : member_id } }).done(function(msg) { if ( msg == 'api error'){ jQuery('#friend_data_area').html('
  • 伺服器忙碌中,請稍後再試
  • '); jQuery('#friend_data_area').data( "dataflag", 2 ); }else{ jQuery('#friend_data_area').html(msg); jQuery('#friend_data_area').data( "dataflag", 1 ); } }); } function setFocus() { document.search.q.focus(); }