var plipk; function select_create(){ try{ $_DOM('select_option_edit').className=''; select_disabled(true); document.form1.textfield.value=''; document.form1.textfield.focus(); document.form1.select_action.value='create'; return true; }catch(e){ return false; } } function select_close(){ try{ document.form1.textfield.value=''; document.form1.textfield.blur(); $_DOM('select_option_edit').className='disp'; document.form1.select_action.value=''; select_disabled(false); selectbutton_disabled_update(); return true; }catch(e){ return false; } } function select_disabled(is_open){ try{ document.form1.select.disabled=is_open; document.form1.button2.disabled=is_open; document.form1.button3.disabled=is_open; document.form1.button4.disabled=is_open; document.form1.button5.disabled=is_open; document.form1.button6.disabled=is_open; return true; }catch(e){ return false; } } function select_ok(){ var act=document.form1.select_action.value; var val=document.form1.textfield.value; var sel=document.form1.select; var ind=sel.selectedIndex; if (Trim(val)==""){ alert('选项名称不能为空'); document.form1.textfield.focus(); return false; }else if (val.length>32){ alert('选项名称不能超过32个字'); document.form1.textfield.focus(); return false; }else{ select_disabled(false); if (act=='create'){ var opt=new Option(val,val); sel.options[sel.length]=opt; sel.options[sel.length-1].selected=true; }else{ sel.options[ind].text=val; sel.options[ind].value=val; } document.form1.select_action.value=''; $_DOM('select_option_edit').className='disp'; selectbutton_disabled_update(); select2_update(); return true; } } function select_edit(){ try{ var sel=document.form1.select; var ind=sel.selectedIndex; var val=sel.options[ind].text; $_DOM('select_option_edit').className=''; select_disabled(true); document.form1.textfield.value=val; document.form1.textfield.select(); document.form1.select_action.value='update'; return true; }catch(e){ return false; } } function selectbutton_disabled_update(){ var sel=document.form1.select; var ind=sel.selectedIndex; document.form1.button5.disabled=(ind==0); document.form1.button6.disabled=(ind==sel.length-1); document.form1.button2.disabled=(sel.length>27); document.form1.button4.disabled=(sel.length<2); } function select_delete(){ var sel=document.form1.select; var ind=sel.selectedIndex; var val=sel.options[ind].text; var ret=confirm('您是否要删除选项“'+val+'”?'); if (!ret) return false; else{ sel.remove(ind); if (ind+1>sel.length) ind--; sel[ind].selected=true; selectbutton_disabled_update(); select2_update(); } } function select_up(){ var sel=document.form1.select; var ind=sel.selectedIndex; var val=sel.options[ind].text; if (ind<1) return false; else{ var val2=sel.options[ind-1].text; sel.options[ind].text=val2; sel.options[ind].value=val2; sel.options[ind-1].text=val; sel.options[ind-1].value=val; sel.options[ind-1].selected=true; selectbutton_disabled_update(); return true; } } function select_down(){ var sel=document.form1.select; var ind=sel.selectedIndex; var val=sel.options[ind].text; if (ind==sel.length-1) return false; else{ var val2=sel.options[ind+1].text; sel.options[ind].text=val2; sel.options[ind].value=val2; sel.options[ind+1].text=val; sel.options[ind+1].value=val; sel.options[ind+1].selected=true; selectbutton_disabled_update(); return true; } } function toupiaoform_submit(){ document.form1.button9.disabled=true; if (Trim(document.form1.title.value)==""){ topic_alert('帖子标题不能为空','toupiaoform_alerted_title'); return false; }else if (document.form1.select.length<2){ topic_alert('投票选项必须至少填写两项','toupiaoform_alerted_select'); return false; }else if (!youxiaoqi()){ topic_alert(plipk,'toupiaoform_alerted_riqi'); return false; }else if (!captcha_true('','')){ topic_alert('请输入验证码','topic_alerted_yzms'); return false; }else{ document.form1.actian.value='create_toupiao'; document.form1.action='Ajax/topicdata.php'; document.form1.target='form_area'; document.form1.Content.value=$_DOM('editarea_base').innerHTML; toupiaoform_selectdata_allselect(); editarea_keyup($_DOM('editarea_base')); return true; } } function toupiaoform_selectdata_allselect(){ var f; document.form1.selects.value=''; //防止出错,先清空数据 for (var i=0;i<document.form1.select.length;i++){ f=document.form1.select.options[i].value; if (i>0) f=','+f; document.form1.selects.value+=f; } return true; } function toupiaoform_alerted_title(){ diag_close(); document.form1.button9.disabled=false; document.form1.title.focus(); } function select2_update(){ if (document.form1.select.length<2) return false; var val=(document.form1.select2.length>0)?document.form1.select2.value:2; while (document.form1.select2.length>0) document.form1.select2.remove(0); var len=document.form1.select.length,opt; for (var i=1;i<len;i++){ opt=new Option(i+1,i+1); document.form1.select2.options[i-1]=opt; }try{ if (val>0) document.form1.select2.options[val-2].selected=true; return true; }catch(e){ return false; } } function more_select(){ var span=$_DOM('more'); var val=document.form1.typ[0].checked; if (val) span.className='disp'; else span.className=''; } function toupiaoform_alerted_select(){ diag_close(); document.form1.button9.disabled=false; select_create(); } function toupiaoform_alerted_riqi(){ diag_close(); document.form1.button9.disabled=false; document.form1.textfield2.select(); } function topic_alerted_yzms(){ diag_close(); captcha_update('',''); document.form1.captcha_val.value=''; document.form1.button9.disabled=false; document.form1.captcha_val.focus(); } function formarea_loaded_newtoupiao(){ var msg=window.frames['form_area'].document.getElementById('msg').innerHTML; if (msg=="default"){ return false; }else if (msg=="created"){ var url=$_DOM('board_url').href; document.location=url; }else if (msg=="OK"){ window.frames['form_area'].document.location='Include/default2.php'; }else{ topic_alert(msg,(msg=="验证码输入错误" || msg=="验证码超时,请重新输入")?'topic_alerted_yzms':'topic_alerted_else2'); } } function topic_alerted_else2(){ diag_close(); document.form1.button9.disabled=false; } function youxiaoqi(){ var val=document.form1.textfield2.value; var reg=/^20[0-9][0-9]-(1[012]|[1-9])-([12][0-9]|[1-9]|3[01])$/; var span=$_DOM('riqi_error'); if (reg.test(val)){ val=val.split('-'); var time=$_DOM('rec').innerHTML; //获得服务器时间 time=time.split(','); var afk='请输入“'+time[0]+'年'+time[1]+'月'+time[2]+'日”以后的日期'; for (i=0;i<3;i++){ time[i]=Number(time[i]); val[i]=Number(val[i]); } if (val[0]<time[0]){ span.innerHTML=afk; plipk=afk; return false; }else if (val[0]=time[0]){ if (val[1]<time[1]){ span.innerHTML=afk; plipk=afk; return false; }else if (val[1]==time[1]){ if (val[2]>time[2]){ span.innerHTML=''; plipk='OK'; return true; }else{ span.innerHTML=afk; plipk=afk; return false; } }else{ span.innerHTML=''; plipk='OK'; return true; } }else{ span.innerHTML=''; plipk='OK'; return true; } }else{ span.innerHTML='日期格式错误'; plipk='日期格式错误'; return false; } }
|