// 台長後台 javascript function test_time(){ if ($('content_time').checked == true){ //user_day = $('YYYY').value + '-' + $('MM').value + '-' + $('DD').value + ' ' + $('HH').value + ':' + $('ii').value + ':' + $('ss').value; user_day = $('YYYY').value + '-' + $('MM').value + '-' + $('DD').value + ' ' + $('HH').value + ':' + '00' + ':' + '00'; alert(user_day); today = new Date(); today_year = today.getFullYear(); today_month = today.getMonth() + 1; today_date = today.getDate(); today_hour = today.getHours(); today_minute = today.getMinutes(); today_second = today.getSeconds(); now_day = today_year + '-' + today_month + '-' + today_date + ' ' + today_hour + ':' + today_minute + ':' + today_second; alert(now_day); } } // 預上稿時間檢查 function time_check(){ var result = ''; user_day = jQuery('#YYYY').val() + '-' + jQuery('#MM').val() + '-' + jQuery('#DD').val() + ' ' + jQuery('#HH').val() + ':' + '00' + ':' + '00'; jQuery.ajax({ type: "POST", url: "/public_file/panel_time_check.php", async: false, // 強制 同步 data: { time : user_day } }).done(function(msg) { if (msg != 'ok'){ alert(msg); } result = msg; }); return result; } // 新增文章頁 ########################################################################################## //// 自動文章讀取 //function auto_save_load(mypaper_id){ // var f=document.ttimes; // // // 非編輯舊文才去讀取 auto_save檔 // if ( f.act.value == 'new'){ // // new Ajax.Request("/panel/action/content_auto_save_load.php", { // parameters: $H({mypaper_id: mypaper_id // }), // // asynchronous:false, // onSuccess: function(transport) { // load_data = transport.responseText.split(""); // // if (transport.responseText == 'empty'){ // // 無 auto_save // }else{ // if(confirm('您有一篇未完成的暫存檔,是否要繼續編輯?\n按「確定」載入草稿繼續編輯,\n按「取消」刪除草稿重寫新文章。')){ // load_data = transport.responseText.split(""); // // $('d_title').value = load_data[0]; // $(Article_Editor_Field_Name).value =load_data[1]; // }else{ // new Ajax.Request("/panel/action/content_auto_save_del.php", { // parameters: $H({mypaper_id: mypaper_id // }), // // asynchronous:false, // onSuccess: function(transport) { // $('d_title') = ''; // } // }); // } // } // } // });// ajax end // }// if new end //} //// 自動文章讀取_tiny //function auto_save_load_tiny(mypaper_id){ // var f=document.ttimes; // // // 非編輯舊文才去讀取 auto_save檔 // if ( f.act.value == 'new'){ // // new Ajax.Request("/panel/action/content_auto_save_load.php", { // parameters: $H({mypaper_id: mypaper_id // }), // // asynchronous:false, // onSuccess: function(transport) { // // load_data = transport.responseText.split(""); // // if (transport.responseText == 'empty'){ // // 無 auto_save // }else{ // if(confirm('您有一篇未完成的暫存檔,是否要繼續編輯?\n按「確定」載入草稿繼續編輯,\n按「取消」刪除草稿重寫新文章。')){ // load_data = transport.responseText.split(""); // // $('d_title').value = load_data[0]; // tinyMCE.execCommand('mceSetContent',false,''); // tinyMCE.execCommand('mceInsertContent',false,load_data[1]); // // }else{ // new Ajax.Request("/panel/action/content_auto_save_del.php", { // parameters: $H({mypaper_id: mypaper_id // }), // // asynchronous:false, // onSuccess: function(transport) { // $('d_title') = ''; // } // }); // } // } // } // });// ajax end // }// if new end //} // // 離開編輯頁面確認 //function check_exit(mypaper_id){ // if ($('pubButton').disabled != true){ // if(confirm('您將離開編輯畫面,是否儲存草稿?\n按「確定」儲存草稿,按「取消」放棄草稿。')){ // draft_add(mypaper_id); // }else{ // // alert('什麼都不做'); // } // } //} // 離開編輯頁面確認_tiny //function check_exit_tiny(mypaper_id){ // if ($('pubButton').disabled != true){ // if(confirm('您將離開編輯畫面,是否儲存草稿?\n按「確定」儲存草稿,按「取消」放棄草稿。')){ // draft_add_tiny(mypaper_id); // }else{ // // alert('什麼都不做'); // } // } //} // onload 每分鐘呼叫 x自動儲存 o草稿 function auto_save(mypaper_id){ setInterval('draft_add(\'' + mypaper_id + '\')',60000); } //// onload 每分鐘呼叫自動儲存_tiny //function auto_save_tiny(mypaper_id){ // setInterval('draft_add_tiny(\'' + mypaper_id + '\')',60000); //} //// 自動儲存ajax_tiny //function auto_save_add_tiny(mypaper_id){ // tar_string = tinyMCE.get('area_content').getContent(); // // jQuery.ajax({ // type: "POST", // url: "/panel/action/content_auto_save.php", // data: { // mypaper_id: mypaper_id, // title : jQuery('#d_title').val(), // content : tar_string // } // }).done(function() { // // }); //} // 儲存草稿 function draft_add(mypaper_id){ //編輯器2008.12.3{{ if(typeof(tinyMCE)=='object') { tar_string = tinyMCE.get('area_content').getContent(); }else{ if(editor._editMode == "text"){ tar_string = jQuery('#'+Article_Editor_Field_Name).val(); }else { if(HTMLArea.is_ie){ tar_string = editor_iframe.document.body.innerHTML; }else{ tar_string = jQuery('#editor_iframe').contents().find('body').html(); } } } // title var title = jQuery('#d_title').val(); // content var content = tar_string; if (trim(title) == '' && trim(content) == ''){ return; } // content_time if( jQuery('#content_time').length >0 && jQuery('#content_time').prop('checked') == true) { var content_time = jQuery('#YYYY').val() + '-' + jQuery('#MM').val() + '-' + jQuery('#DD').val() + ' ' + jQuery('#HH').val() + ':' + '00' + ':' + '00'; }else{ var content_time = ''; } // pub_cid var pub_cid =jQuery('#pub_cid').val(); // cid var cid =jQuery('#class_no').val(); // tag var tag =jQuery('#s_tag').val(); // security //var security = $('d_stat').options[$('d_stat').selectedIndex].value; // 改用 jQuery 取值 var security = jQuery("input[name=d_stat]:radio:checked").val(); var pwd = jQuery('#pwd').val() ? jQuery('#pwd').val() : ''; var reminder = jQuery('#reminder').val() ? jQuery('#reminder').val() : ''; // reply_status for(i=0; i 0){ if(jQuery('#smallPicSrc').val()!="") { var cover_img = jQuery('#smallPicSrc').val(); } }else{ var cover_img = ''; } } // lat、lng var lat = jQuery('#LatSet').val(); var lng = jQuery('#LngSet').val(); // top_status var top_status = jQuery('#top_value_new').prop('checked')? 1 : 0; // uniqid var uniqid = jQuery('#uniqid').val(); jQuery.ajax({ url: "/panel/action/content_draft_add.php", type: "POST", data: { mypaper_id: mypaper_id, title : title, content : content, content_time : content_time, pub_cid : pub_cid, cid : cid, tag : tag, security : security, pwd : pwd, reminder : reminder, reply_status : reply_status, cover_img : cover_img, lat : lat, lng : lng, top_status : top_status, uniqid : uniqid }, dataType: "html" }) .done(function( msg ) { if (msg.length == 5) { jQuery('#autosave_button').val('草稿自動儲存於 ' + msg); jQuery('#autosave_button').css("width",180); } }); } //// 儲存草稿_tiny //function draft_add_tiny(mypaper_id){ // tar_string = tinyMCE.get('area_content').getContent(); // // // title // var title = $('d_title').value; // // // content // var content = tar_string; // // if (trim(title) == '' && trim(content) == ''){ // return; // } // // // content_time // if($('content_time') != null && $('content_time').checked == true){ // var content_time = $('YYYY').value + '-' + $('MM').value + '-' + $('DD').value + ' ' + $('HH').value + ':' + '00' + ':' + '00'; // }else{ // var content_time = ''; // } // // // pub_cid // var pub_cid = $('pub_cid').options[$('pub_cid').selectedIndex].value; // // // cid // var cid = $('class_no').options[$('class_no').selectedIndex].value ? $('class_no').options[$('class_no').selectedIndex].value : ''; // // // tag // var tag = $('s_tag').value; // // // security // //var security = $('d_stat').options[$('d_stat').selectedIndex].value; // var security = jQuery("input[name=d_stat]:radio:checked").val(); // // var pwd = $('pwd').value ? $('pwd').value : ''; // var reminder = $('reminder').value ? $('reminder').value : ''; // // // reply_status // for(i=0; i0) && jQuery('#content_time').prop("checked") ){ jQuery('#YYYY').prop("disabled",false); jQuery('#MM').prop("disabled",false); jQuery('#DD').prop("disabled",false); jQuery('#HH').prop("disabled",false); ( (jQuery('#solicit').length >0 ) ? jQuery('#solicit').css("display","none") : ''); //( jQuery('#c_category') != null ? jQuery('#c_category').css("display","none") : ''); //document.ttimes.class_no.value=''; } else{ jQuery('#YYYY').prop("disabled",true); jQuery('#MM').prop("disabled",true); jQuery('#DD').prop("disabled",true); jQuery('#HH').prop("disabled",true); ( jQuery('#solicit') != null ? jQuery('#solicit').css("display","table-row") : ''); //( jQuery('#c_category') != null ? jQuery('#c_category').css("display","table-row") : ''); } } // // 新增文章後檢查與送出 // function check_data(is_pre){ // if ($('content_time') != null && $('content_time').checked == true ){ // var temp = time_check(); // if (temp != 'ok'){ // return false; // } // } // // /* // // if (document.getElementById("gcode_div").style.display != "none"){ // // gcode 驗證 // if(gcode_test("Gcode_Space") == 0){ // return false; // } // } // // */ // // // //發表按鈕 disable,避免重複按 // // $('pubButton').disabled = true; // // // 最少輸入字數(新、舊版共用) // var Article_String_Min_Limit = 10; // var f=document.ttimes; // // // tag 檢查 // if(typeof f.s_tag != "undefined"){ // if ( check_tags(f.s_tag.value) == false) { // $('pubButton').disabled = false; // return false; // } // } // // if(!checkInput('ttimes','d_title')){ // //if(trim(f.d_title.value) == ""){ // alert("請填寫標題"); // f.d_title.focus(); // $('pubButton').disabled = false; // return false; // } // // if(getLength(f.d_title.value) > 60){ // alert("標題請用中文30個字或英文60個字以內"); // f.d_title.focus(); // $('pubButton').disabled = false; // return false; // } // // // 新編輯器才有發佈到forum檢查 // //if (f.from_side.value != 'edit_old'){ // // if( f.d_forum[0].checked == true && (f.fid.value == "" || f.special_no.value == "") ){ // // alert("請選擇分類"); // // f.fid.focus(); // // $('pubButton').disabled = false; // // return false; // // } // //} // // // 舊編輯器的文章字數檢查 // if (f.from_side.value == 'edit_old'){ // f.p_pic0.value=f.s_pic0.value; // f.p_pic1.value=f.s_pic1.value; // f.p_pic2.value=f.s_pic2.value; // f.p_pic3.value=f.s_pic3.value; // f.p_pic4.value=f.s_pic4.value; // f.p_pic5.value=f.s_pic5.value; // f.p_pic6.value=f.s_pic6.value; // f.p_pic7.value=f.s_pic7.value; // f.p_pic8.value=f.s_pic8.value; // f.p_pic9.value=f.s_pic9.value; // // old_total_length = ( trim(f.s_content0.value).length // + trim(f.s_content1.value).length // + trim(f.s_content2.value).length // + trim(f.s_content3.value).length // + trim(f.s_content4.value).length // + trim(f.s_content5.value).length // + trim(f.s_content6.value).length // + trim(f.s_content7.value).length // + trim(f.s_content8.value).length // + trim(f.s_content9.value).length // ); // // if (old_total_length < Article_String_Min_Limit){ // alert('至少需輸入 '+ Article_String_Min_Limit +' 個字'); // $('pubButton').disabled = false; // return false; // } // // if (trim(f.s_content0.value).length > 12000){ // alert("內文一請用12000個字以內"); // f.s_content0.focus(); // $('pubButton').disabled = false; // return false; // } // // if (trim(f.s_content1.value).length > 12000){ // alert("內文二請用12000個字以內"); // f.s_content1.focus(); // $('pubButton').disabled = false; // return false; // } // // if (trim(f.s_content2.value).length > 12000){ // alert("內文三請用12000個字以內"); // f.s_content2.focus(); // $('pubButton').disabled = false; // return false; // } // // if (trim(f.s_content3.value).length > 12000){ // alert("內文四請用12000個字以內"); // f.s_content3.focus(); // $('pubButton').disabled = false; // return false; // } // // if (trim(f.s_content4.value).length > 12000){ // alert("內文五請用12000個字以內"); // f.s_content4.focus(); // $('pubButton').disabled = false; // return false; // } // // if (trim(f.s_content5.value).length > 12000){ // alert("內文六請用12000個字以內"); // f.s_content5.focus(); // $('pubButton').disabled = false; // return false; // } // // if (trim(f.s_content6.value).length > 12000){ // alert("內文七請用12000個字以內"); // f.s_content6.focus(); // $('pubButton').disabled = false; // return false; // } // // if (trim(f.s_content7.value).length > 12000){ // alert("內文八請用12000個字以內"); // f.s_content7.focus(); // $('pubButton').disabled = false; // return false; // } // // if (trim(f.s_content8.value).length > 12000){ // alert("內文九請用12000個字以內"); // f.s_content8.focus(); // $('pubButton').disabled = false; // return false; // } // // if (trim(f.s_content9.value).length > 12000){ // alert("內文十請用12000個字以內"); // f.s_content9.focus(); // $('pubButton').disabled = false; // return false; // } // } // // if(document.getElementById("pub_cid").value == 0 || document.getElementById("pub_cid").value==""){ // alert("請選擇一種官方分類"); // document.getElementById("pub_cid").focus(); // $('pubButton').disabled = false; // return false; // } // // var optionNum=f.d_stat.options[f.d_stat.selectedIndex].value; // if (optionNum==2){ // if(!checkInput('ttimes','pwd')){ // alert("您的 [ 文章密碼 ] 忘了填喔!!不怕被別人看見嗎?"); // f.pwd.focus(); // $('pubButton').disabled = false; // return false; // }else { // for (i = 0;i < document.ttimes.pwd.value.length; i ++) { // str = document.ttimes.pwd.value.charCodeAt(i); // if (!(((str >= 48) && (str <= 57)) || ((str >= 97) && (str <= 122)))) { // alert("[ 文章密碼 ] 請輸入小寫英文,數字"); // document.ttimes.pwd.focus(); // $('pubButton').disabled = false; // return false; // } // } // } // if(!checkInput('ttimes','reminder')){ // document.ttimes.reminder.value="無"; // } // } // // if(document.ttimes.pwd.value.length > 16){ // alert("密碼請設定16個英文數字以內"); // f.pwd.focus(); // $('pubButton').disabled = false; // return false; // } // // if(getLength(document.ttimes.reminder.value)> 40){ // alert("密碼提示請用中文20個字或英文40個字以內"); // f.reminder.focus(); // $('pubButton').disabled = false; // return false; // } // // // 新編輯器才以下這些XXX // if (f.from_side.value != 'edit_old') // { // // //編輯器2008.12.3{{ // if(editor._editMode == "text") // { // tar_string = $(Article_Editor_Field_Name).value; // }else { // if(HTMLArea.is_ie) // { // tar_string = editor_iframe.document.body.innerHTML; // }else{ // tar_string = document.getElementById('editor_iframe').contentDocument.body.innerHTML; // } // } // // if(String_Min_Limit > 0 && tar_string.stripTags().length < String_Min_Limit) // { // alert('至少需輸入 '+ Article_String_Min_Limit +' 個字'); // $('pubButton').disabled = false; // return false; // } // // var flag = true; // //編輯器2008.12.3}} // // //LatLng // if ($F('LatSet').length != 0 && $F('LatSet') != Number($F('LatSet'))) { // alert('緯度格式錯誤!'); // $('LatSet').focus(); // $('pubButton').disabled = false; // return; // }//end if // // if ($F('LngSet').length != 0 && $F('LngSet') != Number($F('LngSet'))) { // alert('經度格式錯誤!'); // $('LngSet').focus(); // $('pubButton').disabled = false; // return; // }//end if // // if( isNaN($('solicit_article')) == true ) // { // if($('solicit_article').checked == true){ // var solicit_already_no = $('solicit_already_no').value; // if( solicit_already_no.indexOf($('solicit_no').value) != -1 && $('solicit_already_no').value != "" && $('solicit_no').value != 0 ){ // alert('這篇文章已經投過同樣的主題過了,請重新選擇!'); // $('solicit_no').focus(); // $('pubButton').disabled = false; // return; // } // }else{ // $('solicit_no').value = 0; // } // } // // //編輯器2008.12.3{{ // new Ajax.Request("/extend/html_area/check_html.php", { // parameters: $H({html: tar_string}), // asynchronous:false, // onSuccess: function(transport) { // if(transport.responseText.substr(0,1) == 0){ // alert(transport.responseText.substr(1,transport.responseText.length)); // $('pubButton').disabled = false; // flag = false; // } else if(transport.responseText.substr(0,1) == 1) { // $(Article_Editor_Field_Name).value = transport.responseText.substr(1,transport.responseText.length); // } else { // alert('發生未知錯誤! 請稍後再嘗試, 如果持續發生, 請聯絡客服人員'); // $('pubButton').disabled = false; // flag = false; // } // } // // }); // // }else{ // var flag = true; // } // // if(is_pre=='submit' && ( flag == true)){ // // 似乎是封面圖 // // 新編輯器才有 // if (f.from_side.value != 'edit_old'){ // if(document.getElementById("smallPicSrc") != null){ // if(document.getElementById("smallPicSrc").value!=""){ // document.ttimes.d_img.value=document.getElementById("smallPicSrc").value; // } // } // } // f.action = "/panel/action/content_add.php"; // document.ttimes.submit(); // } // return flag; // } /////////////////////////////////////////////// // 新增文章後檢查與送出 function check_data_2015(is_pre) { if (jQuery("#content_time").length >0 && jQuery("#content_time").prop("checked") == true ) { var temp = time_check(); if (temp != 'ok') { return false; } } //var content_link_obj = jQuery('iframe').eq(0).contents().find('a'); var content_link_obj = jQuery('#area_content_ifr').eq(0).contents().find('a'); if(content_link_obj.length >0) { var out_side_link =false; content_link_obj.each(function( index ) { if( typeof(jQuery(this).attr('href')) !='undefined' ) { var link_href = jQuery(this).attr('href'); if( link_href.match(/^https?/) && !link_href.match(/https?:\/\/[\w]+.pchome.com.tw\//)) { out_side_link =true; } } }); if(out_side_link && jQuery("#gcode_div").css('display') == "none" ) { jQuery('#gcode_div').show(); alert('請輸入認證碼完成發文'); jQuery('#authRandnum').focus(); return false; } } /////////// //發表按鈕 disable,避免重複按 // $('pubButton').disabled = true; // 最少輸入字數(新、舊版共用) var Article_String_Min_Limit = 10; //var f = jQuery('#ttimes'); var f = document.ttimes; // tag 檢查 if(jQuery("#s_tag").length >0) { //if ( check_tags(f.s_tag.value) == false) if ( check_tags( jQuery("#s_tag").val() ) == false) { jQuery('#pubButton').attr("disabled", false); return false; } } if(!checkInput('ttimes','d_title')) { alert("請填寫標題"); //f.d_title.focus(); jQuery('#d_title').focus(); jQuery('#pubButton').attr("disabled", false); return false; } if(getLength(jQuery("#d_title").val()) > 60) { alert("標題請用中文30個字或英文60個字以內"); //f.d_title.focus(); jQuery('#d_title').focus(); jQuery('#pubButton').attr("disabled", false); return false; } if(document.getElementById("pub_cid").value == 0 || document.getElementById("pub_cid").value=="") { alert("請選擇一種官方分類"); //document.getElementById("pub_cid").focus(); jQuery('#pub_cid').focus(); jQuery('#pubButton').attr("disabled", false); return false; } if( typeof(f.d_stat != "undefined") ) { if (jQuery("input[name=d_stat]:radio:checked").val() == 2) { if(!checkInput('ttimes','pwd')) { alert("您的 [ 文章密碼 ] 忘了填喔!!不怕被別人看見嗎?"); //f.pwd.focus(); jQuery('#pwd').focus(); jQuery('#pubButton').attr("disabled", false); return false; }else { for (i = 0;i < document.ttimes.pwd.value.length; i ++) { str = document.ttimes.pwd.value.charCodeAt(i); if (!(((str >= 48) && (str <= 57)) || ((str >= 97) && (str <= 122)))) { alert("[ 文章密碼 ] 請輸入小寫英文,數字"); //document.ttimes.pwd.focus(); jQuery('#pwd').focus(); jQuery('#pubButton').attr("disabled", false); return false; } } } if(!checkInput('ttimes','reminder')) { document.ttimes.reminder.value="無"; } } } if(document.ttimes.pwd.value.length > 16) { alert("密碼請設定16個英文數字以內"); //f.pwd.focus(); jQuery('#pwd').focus(); jQuery('#pubButton').attr("disabled", false); return false; } if(getLength(document.ttimes.reminder.value)> 40) { alert("密碼提示請用中文20個字或英文40個字以內"); jQuery('#reminder').focus(); jQuery('#pubButton').attr("disabled", false); return false; } // 新編輯器才以下這些XXX if (f.from_side.value != 'edit_old') { if( typeof(tinyMCE) != 'object' ) { //編輯器2008.12.3{{ if(typeof(editor)== "undefined"){ tar_string = jQuery('#area_content').val(); String_Min_Limit =10; }else if(editor._editMode == "text"){ tar_string = jQuery('#'+Article_Editor_Field_Name).val(); }else { if(HTMLArea.is_ie){ tar_string = editor_iframe.document.body.innerHTML; }else{ tar_string = document.getElementById('editor_iframe').contentDocument.body.innerHTML; } } if(String_Min_Limit > 0 && tar_string.stripTags().length < String_Min_Limit) { alert('至少需輸入 '+ Article_String_Min_Limit +' 個字'); jQuery('#pubButton').attr("disabled", false); return false; } var flag = true; //編輯器2008.12.3}} }else{ tar_string = tinyMCE.get(Article_Editor_Field_Name).getContent(); var flag = true; if(Article_String_Min_Limit > 0 && tar_string.stripTags().length < Article_String_Min_Limit) { alert('至少需輸入 '+ Article_String_Min_Limit +' 個字'); jQuery('#pubButton').attr("disabled", false); return false; } } //LatLng // if (jQuery('#LngSet').val().length != 0 && jQuery('#LngSet').val() != Number(jQuery('#LngSet').val())) // { // alert('緯度格式錯誤!'); // jQuery('#LngSet').focus(); // jQuery('#pubButton').attr("disabled", false); // return; // }//end if // if (jQuery('#LngSet').val().length != 0 && jQuery('#LngSet').val() != Number(jQuery('#LngSet').val())) // { // alert('經度格式錯誤!'); // jQuery('#LngSet').focus(); // jQuery('#pubButton').attr("disabled", false); // return; // }//end if if( jQuery('#solicit_article').length >0 ) { if(jQuery('#solicit_article').prop("checked") == true) { var solicit_already_no = jQuery('#solicit_already_no').val(); if( solicit_already_no.indexOf(jQuery('#solicit_no').val()) != -1 && jQuery('#solicit_already_no').val() != "" && jQuery('#solicit_no').val() != 0 ) { alert('這篇文章已經投過同樣的主題過了,請重新選擇!'); jQuery('#solicit_no').focus(); jQuery('#pubButton').attr("disabled", false); return; } }else{ jQuery('#solicit_no').val(0) } } //編輯器2008.12.3 prototype -> jQuery jQuery.ajax({ type: "POST", url: "/extend/html_area/check_html.php", async: false, data: { html : tar_string } }).done(function(msg) { //console.log(msg); //console.log(Article_Editor_Field_Name); if(msg.substr(0,1) == 0) { alert(msg.substr(1,msg.length)); jQuery('#pubButton').disabled = false; flag = false; } else if(msg.substr(0,1) == 1) { jQuery("#"+Article_Editor_Field_Name).val(msg.substr(1,msg.length)); } else { alert('發生未知錯誤! 請稍後再嘗試, 如果持續發生, 請聯絡客服人員'); jQuery('#pubButton').disabled = false; flag = false; } }); }else{ var flag = true; } if(is_pre=='submit' && ( flag == true)) { // 似乎是封面圖 // 新編輯器才有 if (f.from_side.value != 'edit_old') { if(document.getElementById("smallPicSrc") != null) { if(document.getElementById("smallPicSrc").value!="") { document.ttimes.d_img.value=document.getElementById("smallPicSrc").value; } } } ///////////////////////////////// /* jQuery.ajax({ method: "POST", url: "/panel/action/content_add.php", data: { name: "John", location: "Boston" } }) .done(function( msg ) { alert( "Data Saved: " + msg ); }); */ ///////////////////////////////// if ( jQuery("#gcode_div").css('display') != "none") { // gcode 驗證 if(gcode_test("Gcode_Space") == 0) { return false; } } var time_str = ( jQuery("#time_str").length>0 )?jQuery("#time_str").val():0; jQuery.ajax({ type: "POST", url: "/panel/action/make_secreat_20150605.php", data: { mypaper_id : jQuery("input[name=mypaper_id]").val(), time_str : time_str, } }).done(function(msg) { //console.log(msg); if(msg=="System ERR") { alert("系統忙碌中 請稍後~"); flag = false; return false; }else{ eval('var return_arr = '+ msg +';'); if( jQuery("input[name=SN]").length > 0 ) { jQuery("input[name=SN]").val(return_arr.SN); }else{ jQuery( "#ttimes" ).append( '' ); // COOKIE 過期 var d = new Date(); d.setTime(d.getTime() + ( 2 * 60 * 1000)); var expires = "expires=" + d.toGMTString(); document.cookie = "SN="+ return_arr.SN + "; " + expires + '; domain=pchome.com.tw; path=/'; // alert(document.cookie) } if( jQuery("input[name=md5str]").length > 0 ) { jQuery("input[name=md5str]").val(return_arr.md5str); }else{ jQuery( "#ttimes" ).append( '' ); } post_content_ajax(); } }); } return flag; } function show_fancybox(content){ //console.log( "show_fancybox" +content ); show_msg = '
'+ content +'
'; jQuery('#from_side').fancybox({ 'padding' : 30, 'width' : 500, 'height' : 500, 'transitionIn' : 'elastic', 'transitionOut' : 'elastic', 'content' : show_msg, 'showCloseButton': false }); jQuery('#from_side').trigger('click'); } function post_content_ajax() { //show_fancybox("資料處理中,請稍等~"); /// jQuery.ajax({ type: "POST", url: "/panel/action/content_add.php", dataType: "html", beforeSend : show_fancybox("資料處理中,請稍等~"), data: jQuery( "#ttimes" ).serialize() }).done(function(msg) { //console.log(msg); eval("var rs="+msg); if(!rs.status) { //alert(rs.msg); jQuery("#show_fancybox_msg").html(rs.msg); }else{ //alert(rs.msg); jQuery("#show_fancybox_msg").html(rs.msg); if(rs.debug_msg!=''){ //console.log( rs.debug_msg ); } if( typeof(rs.return_path)!='undefined' ){ window.location.href = rs.return_path; } } }); } /////////////////////////////////////////////// // 新增文章封面圖相關 var CurrentStatus = { Overlay: '', ImgPicker: '', //method ShowOverlay: function() { var PageSizeArray = getPageSize(); var PageScroll = getPageScroll(); CurrentStatus.Overlay.style.height = PageSizeArray[1] + 'px'; CurrentStatus.Overlay.style.display = 'block'; CurrentStatus.ImgPicker.style.left = Math.floor(PageSizeArray[0]/2 - 320) + 'px'; CurrentStatus.ImgPicker.style.top = Math.floor(PageSizeArray[3]/2 - 200) + PageScroll[1] + 'px'; CurrentStatus.ImgPicker.style.display = 'block'; var GetOSelect = document.getElementsByTagName('select'); for (var i=0; i","ig"); var re = //i srcArray = content.match(patt1); var htmlformat = "
選擇文章封面
 "; if(srcArray != null ){ for(i=0; i "; } } document.getElementById("ImgPicker").innerHTML = htmlformat; init(); CurrentStatus.ShowOverlay(); } // (新增文章頁面)新增文章分類 function disp_prompt(ss){ var cast_num=0 ; var name = prompt("新增分類","請輸入分類"); if (trim(name) == "" || trim(name) == null ){ alert('請輸入分類'); }else{ b = document.ttimes.class_no; var opt = new Option(name,"new_"+name,true,true); b.options[ss] = opt; } } // 新增文章封面圖相關 function init() { //Overlay if(!document.getElementById('Overlay_Pic')){ var Overlay = document.createElement("div"); Overlay.id = 'Overlay_Pic'; Overlay.style.display = 'none'; Overlay.onclick = function() { CurrentStatus.HideO(); }; document.getElementsByTagName('body')[0].appendChild(Overlay); CurrentStatus.Overlay = Overlay; }else{ var Overlay = document.getElementById("Overlay_Pic"); Overlay.style.display = ''; } //ImgPicker var ImgPicker = document.getElementById('ImgPicker'); var GetOImg = ImgPicker.getElementsByTagName('img'); for (var i=0; i 60){ alert("標題請用60個字以內"); f.class_name.focus(); return false; } f.action = "/panel/action/content_category_add.php"; f.act.value ="new"; f.class_sort.value = no; document.ttimes.submit(); return true; } // 文章回應管理頁 ########################################################################################## // 台長後台 回應管理頁 刪除單篇回應 function reply_single_del(mypaper_id,aid,rid){ if(confirm('確定要刪除嗎?\n刪除之後無法救了喔!')){ url = '/station/action/reply_del.php?mypaper_id=' + mypaper_id + '&aid=' + aid + '&rid=' + rid ; location.href= url; } } // 批次刪除回應 function reply_multi_del(){ jQuery('#multi_del_button').attr("disabled", true); var j = 0; for(i=0;i < document.ttimes.length;i++){ if(document.ttimes.elements[i].checked){ j++; } } if(j == 0 ){ alert('您沒有勾選任何文章'); jQuery('#multi_del_button').attr("disabled", false); return false; } document.ttimes.action = '/station/action/reply_del.php'; document.ttimes.submit(); } // 好站連結 編輯功能 function edit(){ var title = document.getElementById('name_data'); var url = document.getElementById('id_url'); if(title.value == ""){ alert("請填寫標題"); title.focus(); return false; } if(getLength(title.value) > 60){ alert("標題請用中文30個字或英文60個字以內"); title.focus(); return false; } var url_pattern = /^http[s]*:\/\/.+/i if(! url.value.match(url_pattern)){ alert("請填寫正確網頁連結"); url.focus(); return false; } document.ttimes.target = ""; document.ttimes.action = "/panel/action/palweb_action.php"; document.ttimes.act.value = "edit"; document.ttimes.friend_title.value = document.getElementById('name_data').value; document.ttimes.friend_url.value = document.getElementById('id_url').value; document.ttimes.submit(); } // 文章分類 編輯名稱 function category_edit(cid){ var title = document.getElementById('name_data'); if(trim(title.value) == ""){ alert("請填寫標題"); title.focus(); return false; } if(getLength(title.value) > 60){ alert("標題請用60個字以內"); url.focus(); return false; } //document.ttimes.target = ""; document.ttimes.act.value = "edit"; document.ttimes.class_name.value = title.value; document.ttimes.cid.value = cid; document.ttimes.action = "/panel/action/content_category_edit.php"; document.ttimes.submit(); } // 好站連結 新增功能 function add_url(){ var f=document.ttimes; if(document.ttimes.friend_title.value == ""){ alert("請填寫標題"); f.friend_title.focus(); return false; } if(getLength(document.ttimes.friend_title.value) > 60){ alert("標題請用中文30個字或英文60個字以內"); f.friend_url.focus(); return false; } s=document.ttimes.friend_url.value; for ( var i = 0; i < web_path.length; i++) { if (web_path[i] == s ) { alert("網址重覆"); f.friend_url.focus(); return false; } } var url = /^http[s]*:\/\/.+/i if(! s.match(url)){ alert("請填寫正確網頁連結"); f.friend_url.focus(); return false; } f.target = ""; f.action = "/panel/action/palweb_action.php"; f.act.value = "new"; document.ttimes.submit(); return true; } // 好站連結 刪除功能 function del_url(type, index, title, url){ if(confirm('確定要刪除 "'+title+' ('+url+')" 嗎?\n刪除之後無法救了喔!')){ document.ttimes.target = ""; document.ttimes.action = "/panel/action/palweb_action.php"; document.ttimes.act.value = "del"; document.ttimes.friend_type.value = type; document.ttimes.friend_index.value = index; document.ttimes.submit(); } } // 好友管理 加入好友 function firend(mypaper_id){ location.href='/panel/pal_web/' + mypaper_id; } // mypage相關 // 用ajax刪除mypage 好友 function del_mypage_friend(member_id,target_member_id){ if(confirm('確認要刪除好友?')) { jQuery.ajax({ type: "POST", url: "/station/action/mypage_del_friend.php", data: { o_member_id : member_id, f_member_id : target_member_id } }).done(function(msg) { //console.log(msg); if ( msg == 'ok'){ alert('好友刪除成功'); location.reload(); }else{ alert('伺服器忙碌中,請稍後再試'); } }); } } // 用ajax 訂閱 function add_mypage_subscribe(target_sid){ jQuery.ajax({ type: "POST", url: "/panel/pal_subscribe", data: { "f_sid":target_sid } }) .done(function( msg ) { window.location="/panel/pal_subscribe"; }); } // 用ajax 取消訂閱 function del_mypage_subscribe(target_sid){ if(confirm('確認要取消訂閱?')){ jQuery.ajax({ type: "POST", url: "/station/action/mypage_del_subscribe.php", data: { "f_sid":target_sid } }) .done(function( msg ) { if ( msg == 'ok'){ location.reload(); }else{ alert(msg); } }); } } // 用 Ajax 訂閱 NEW For NEW Mobile Code function add_mypage_subscribe_JQ(json_str_arg) { var target_sid = json_str_arg.target_sid; var success_url = json_str_arg.success_url; jQuery.ajax({ type: "POST", url: "/website/panel/pal_subscribe", data: { "f_sid":target_sid } }) .done(function( msg ) { window.location = success_url; }); } // 用ajax 取消訂閱 NEW function del_mypage_subscribe_JQ(json_str_arg){ if(confirm('確認要取消訂閱?')){ var target_sid = json_str_arg.target_sid; var success_url = json_str_arg.success_url; jQuery.ajax({ type: "POST", url: "/website/station/action/mypage_del_subscribe.php", data: { "f_sid":target_sid } }) .done(function( msg ) { alert(msg); window.location = success_url; }); } } // 其他 ########################################################################################## function my_replace(find_key,replace_value,str){ while(str.indexOf(find_key)>0){ str = str.replace(find_key,replace_value); } return str; } function in_array(find_key,source_arr) { for(var i = 0;i30){ alert('每個 tag 不能大於 30 個字\n\n'+tag_buff+'\n\n共有 ' + tag_buff.length + ' 個字\n\n已經超過限制'); return false; } if(tag_buff != "") { if(!in_array(tag_buff,new_tag_arr)){ new_tag_arr.push(tag_buff); } } } if(new_tag_arr.length>15) { alert('最多輸入 15 組 tag\n\n您輸入了 '+new_tag_arr.length+' 組'); return false; } return true; } //去除字串左邊的空白 function ltrim(instr){ return instr.replace(/^[\s]*/gi,""); } //去除字串右邊的空白 function rtrim(instr){ return instr.replace(/[\s]*$/gi,""); } //去除字串前後的空白 function trim(instr){ instr = ltrim(instr); instr = rtrim(instr); return instr; } function getLength(for_check){ var I, cnt=0; for(I=0;I=4){ // cnt +=2; // }else{ cnt++; // } } return cnt; } ///長度檢查(文章標籤用 ,,、三種符號不計算字數 ) function getLength_tag(for_check){ var I, cnt=0; for(I=0;I21){ alert("暱稱請用中文10個字或英文20個字以內"); f.nick.focus(); return false; } if(f.person_intro.value==''){ alert("自我介紹請勿空白"); f.person_intro.focus(); return false; }else if(getLength(f.person_intro.value)>2000){ alert("自我介紹請用中文1000個字或英文2000個字以內"); f.person_intro.focus(); return false; } f.target = ""; f.action = "/panel/panel_set.php"; f.submit(); } //好時光貼曆設定 function HiiirSet(status){ document.ttimes.action = "action/theme_set_hiiir.php"; /* FlagParameter = document.createElement('input'); FlagParameter.type = 'hidden'; FlagParameter.name = 'act'; FlagParameter.id = 'act'; FlagParameter.value = status; Form = document.getElementById("ttimes"); Form.appendChild(FlagParameter); */ document.ttimes.submit(); } //####自訂底圖 var form_input,color_block; var adm_path = ''; //得到該元素的父元素的高與寬 function getOffset(target,id,input,block){ var x=0,y=0; y+=target.offsetHeight; while(target.tagName!='BODY'){ x+=target.offsetLeft; y+=target.offsetTop; target=target.offsetParent; } setColorTable(id,x,y); form_input=input; color_block=block; } //設定十六進位值 function setHexValue(hex,div){ form_input.value=hex; document.getElementById(color_block).style.background=hex; close(div); } //調色版關閉 function close(id){ document.getElementById(id).style.display='none'; } //設定調色版的位置 function setColorTable(id,x,y){ var ctable=document.getElementById(id); ctable.style.display='block'; ctable.style.position='absolute'; ctable.style.top=y+'px'; ctable.style.left=x+'px'; } //設定顏色與十六進位值 function showColorAndHex(color,hex,colorHex){ setColor(color,colorHex); document.getElementById(hex).innerHTML=colorHex; } //設定顏色 function setColor(color,colorHex){ document.getElementById(color).style.backgroundColor=colorHex; } //表單處理 function form_action(src,tar){ document.ttimes.action=src; document.ttimes.target=tar; document.ttimes.submit(); } function disableConfirmBT(id){ //alert(id); document.getElementById(id).style.background="#CCCCCC"; document.getElementById(id).style.border="#CCCCCC"; document.getElementById(id).disabled=true; document.getElementById(id).alt="先按套用,下次進來才可以投稿喔"; document.getElementById(id).title="先按套用,下次進來才可以投稿喔"; } //表單送出檢查 function check_td(form,preview){ form.action=''; form.target='_self'; if(form['body_color'].value==''){ alert('全站文字顏色未填'); form['body_color'].focus(); return false; }else if(form['body_a_color'].value==''){ alert('全站連結文字顏色未填'); form['body_a_color'].focus(); return false; }else if(form['back_img'].value=='' && form['body_background-color'].value==''){ alert('背景顏色未填'); form['back_color'].focus(); return false; }else if(form['banner_img'].value=='' && form['banner_background-color'].value==''){ alert('刊頭背景顏色未填'); form['banner_color'].focus(); return false; }else if(form['banner_height'].value==''){ alert('刊頭高度未填'); form['banner_height'].focus(); return false; }else if(form['banner_height'].value<100 || form['banner_height'].value>1000){ alert('刊頭高度請輸入100~1000以內的數字'); form['banner_height'].focus(); return false; }else if(form['pageheader_h1_a_color'].value==''){ alert('站台名稱文字顏色未填'); form['header_text_color'].focus(); return false; }else if(form['pageheader_description_color'].value==''){ alert('站台簡介文字顏色未填'); form['intro_color'].focus(); return false; }else if(form['serviceList_a_color'].value==''){ alert('導覽列文字顏色未填'); form['title_color'].focus(); return false; }else if(form['side_title_img'].value=='' && form['sidetitle_background-color'].value==''){ alert('標題背景顏色未填'); form['sidetitle_background-color'].focus(); return false; }else if(form['sidetitle_color'].value==''){ alert('標題文字顏色未填'); form['sidetitle_color'].focus(); return false; }else if(form['theme_title'].value==''){ alert('底圖標題未填'); form['theme_title'].focus(); return false; } var tar = preview == 1 ? '_blank' : '_self'; form_action("/panel/panel_set.php?preview="+preview,tar); //form_action(adm_path, tar); } function theme_del(evenForm,lid){ if(confirm('您確定要刪除底圖?')){ var url= '/panel/panel_set.php'; evenForm.act.value = 'theme_del'; evenForm.del_lid.value = lid; evenForm.action = url; evenForm.submit(); }else{ target.checked=false; } } function checkDelete(target,img_id,name,app){ if(target.checked){ if(confirm('您確定要刪除此圖?')){ //var url= '/panel/panel_set.php'; //var params=Form.serialize(target.form)+'&del_img='+name+'&img_type='+app; //var request=new Ajax.Request(url,{method:'post',parameters:params,onComplete:show(target,img_id)}); ///// var params = jQuery("#ttimes").serialize() +'&del_img='+name+'&img_type='+app; jQuery.ajax({ type: "POST", url: '/panel/panel_set.php', data: params }) .done(function( msg ) { show(target,img_id); }); }else{ target.checked=false; } } } function show(target,img_id){ alert('刪除完成'); target.disabled=true; var img=document.getElementById(img_id); img.parentNode.removeChild(img); document.ttimes[img_id+'_type'].value=''; } function findObj(n, d){ var p,i,x; if(!d)d=document; if((p=n.indexOf("?"))>0 && parent.frames.length){ d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p); } if(!(x=d[n]) && d.all)x=d.all[n]; for(i=0; !x && i'); } var cnum=new Array(1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0); function colortabl(){ for(i=0;i<=15;i++){ document.write(''); document.write('') //this.style.backgroundImage=\'url(justify/color_bg.gif)\'; 不知為何要更變底色? for(j=0; j < 30; j ++){ n1=j % 5; n2=Math.floor(j / 5)*3; n3=n2+3; wc((cnum[n3]*n1+cnum[n2]*(5 - n1)),(cnum[n3+1]*n1+cnum[n2+1]*(5 - n1)),(cnum[n3+2]*n1+cnum[n2+2]*(5 - n1)), i); } document.writeln('
'); } } //=================底圖投稿============================= function theme_post_check(evenForm, Param){ if(Param == "click"){ if(evenForm.rule_confirm.checked==true){ evenForm.confirmBT.disabled=false; evenForm.confirmBT.style.background='url(/img/btbg_03.gif)'; evenForm.confirmBT.style.border='#FFBA0C'; }else{ evenForm.confirmBT.disabled=true; evenForm.confirmBT.style.background='#CCCCCC'; evenForm.confirmBT.style.border='#CCCCCC'; } } if(Param == 'post'){ if(evenForm.layout_cid.value == ""){ alert("底圖分類沒有選喔!你忘了幫他找個分類放了啦 XD"); return false; } evenForm.act.value='theme_post'; evenForm.submit(); return true; } } //=================底圖投稿結束============================= // left menu function left_menu(x){ var target_div = getElementsByName_iefix("div",x); var target_img = getElementsByName_iefix("img",x + "_img"); if (target_div[0].style.display ==''){ target_div[0].style.display='none'; target_img[0].src="/img/close.gif"; }else{ target_div[0].style.display=''; target_img[0].src="/img/open.gif"; } } function getElementsByName_iefix(tag, name){ var elem = document.getElementsByTagName(tag); var arr = new Array(); for(i = 0,iarr = 0;i