📄 timerules.html.svn-base
字号:
updateselect(_$('startdom'),1,32); updateselect(_$('enddom'),1,32); update_select_menus(_$('dest_match') ); update_select_menus(_$('dest_nomatch') );}function add_trule(){ isNewRule = 1; reset_fields(); _$('create_rule').disabled = 1; _$('form_caption').innerHTML = "<B>" + "Add new Time Rule" + "</B>"; _$('timerule_editdiv').style.display = ""; _$('id_rulename').focus();}function cancel_rule(){ _$('create_rule').disabled = 0; _$('timerule_editdiv').style.display = "none";}function reset_fields(){// id_rulename, startime_hour, startime_minute, endtime_hour, endtime_minute, wday_start// wday_end, startdom, enddom, month_start, month_end, dest_match, dest_nomatch _$('id_rulename').value = ""; var slectboxes = ['startime_hour', 'startime_minute','endtime_hour','endtime_minute','wday_start','wday_end','startdom','enddom','month_start','month_end','dest_match','dest_nomatch']; for (var r=0; r < slectboxes.length; r++){ _$(slectboxes[r]).selectedIndex = -1; }}function check_allfields(){ if(!_$('id_rulename').value){ alert("Please Enter a Rule Name"); _$('id_rulename').focus(); return false; } var slectboxes = ['startime_hour', 'startime_minute','endtime_hour','endtime_minute','wday_start','wday_end','startdom','enddom','month_start','month_end','dest_match','dest_nomatch']; for (var r=0; r < slectboxes.length; r++){ if(!_$(slectboxes[r]).value){ alert("Please select a value"); _$(slectboxes[r]).focus(); return false; } } return true;}function save_rule(){ if(!check_allfields()){return false;} if(isNewRule){ var getnewruleextension = function(){ var t=1; while(timebasedrules[t]){ t++; } return t; } var s = getnewruleextension(); add_newrule(s); }else{ update_rule(); }}function add_newrule(nre){ var added_newrule = function(f){ timebasedrules[nre] = {}; timebasedrules[nre].rulename = _$('id_rulename').value ; timebasedrules[nre].ruleconditons = {} ; timebasedrules[nre].ruleconditons.fromhour = _$('startime_hour').value ; timebasedrules[nre].ruleconditons.fromminutes = _$('startime_minute').value ; timebasedrules[nre].ruleconditons.tohour = _$('endtime_hour').value ; timebasedrules[nre].ruleconditons.tominutes = _$('endtime_minute').value ; timebasedrules[nre].ruleconditons.from_wday = _$('wday_start').value ; timebasedrules[nre].ruleconditons.to_wday = _$('wday_end').value ; timebasedrules[nre].ruleconditons.from_mday = _$('startdom').value ; timebasedrules[nre].ruleconditons.to_mday = _$('enddom').value ; timebasedrules[nre].ruleconditons.from_month = _$('month_start').value ; timebasedrules[nre].ruleconditons.to_month = _$('month_end').value ; timebasedrules[nre].ifmatch_goto = _$('dest_match').value ; timebasedrules[nre].ifnomatch_goto = _$('dest_nomatch').value ; cancel_rule(); clear_table(); showlist_of_rules(); } var tc = _$('startime_hour').value + ':' + _$('startime_minute').value + '-' + _$('endtime_hour').value + ':' + _$('endtime_minute').value + '|' + _$('wday_start').value + '-' + _$('wday_end').value + '|' + _$('startdom').value + '-'+ _$('enddom').value + '|' + _$('month_start').value + '-' + _$('month_end').value ; var line1 = nre + ',1,NoOp(' + _$('id_rulename').value + ')'; var line2 = nre + ',n,GotoIfTime(' + tc + '?' + _$('dest_match').value + ')' ; var line3 = nre + ',n,Goto('+ _$('dest_nomatch').value + ')' ; var as = build_action('append', 0, TIMERULES_CATEGORY, "exten", line1 ) ; as += build_action('append', 1, TIMERULES_CATEGORY, "exten", line2 ) ; as += build_action('append', 2, TIMERULES_CATEGORY, "exten", line3 ) ; makerequest( 'u','extensions.conf',as, added_newrule );}function update_rule(){ // delete existing and add new delete_rule(NOW_EDITING, function(){ add_newrule(NOW_EDITING);} ); }function edit_form(f){ isNewRule = 0; reset_fields(); form_updatevalues(f); NOW_EDITING = f; _$('form_caption').innerHTML = "<B>" + "Edit Time Rule" + "</B>"; _$('create_rule').disabled = 1; _$('timerule_editdiv').style.display = ""; _$('id_rulename').focus();}function delete_rule(f,y){ // prepare and make ajax request // onSuccess update timebasedrules object, and also update table var g = timebasedrules[f]; var h = g.ruleconditons; var tc = h.fromhour + ':' + h.fromminutes + '-' + h.tohour + ':' + h.tominutes + '|' + h.from_wday + '-' + h.to_wday + '|' + h.from_mday + '-'+ h.to_mday + '|' + h.from_month + '-' + h.to_month ; var line1 = f + ',1,NoOp(' + g.rulename + ')'; var line2 = f + ',n,GotoIfTime(' + tc + '?' + g.ifmatch_goto + ')' ; var line3 = f + ',n,Goto('+ g.ifnomatch_goto + ')' ; var as = build_action('delete', 0, TIMERULES_CATEGORY, "exten",'',line1 ) ; as += build_action('delete', 1, TIMERULES_CATEGORY, "exten",'', line2 ) ; as += build_action('delete', 2, TIMERULES_CATEGORY, "exten",'', line3 ) ; makerequest( 'u','extensions.conf',as, function(){ delete timebasedrules[f]; clear_table(); showlist_of_rules(); if(y){y();} } );}function form_updatevalues(f){ _$('id_rulename').value = timebasedrules[f].rulename; var fh = timebasedrules[f].ruleconditons.fromhour; var fm = timebasedrules[f].ruleconditons.fromminutes; var th = timebasedrules[f].ruleconditons.tohour; var tm = timebasedrules[f].ruleconditons.tominutes; _$('startime_hour').selectedIndex = fh; _$('startime_minute').selectedIndex = fm; _$('endtime_hour').selectedIndex = th; _$('endtime_minute').selectedIndex = tm; var find_index = function(el,val){ for(var t=0; t< el.options.length; t++){ if( el.options[t].value == val){ el.selectedIndex = t; return; } } } find_index(_$('wday_start'), timebasedrules[f].ruleconditons.from_wday); find_index(_$('wday_end'), timebasedrules[f].ruleconditons.to_wday); _$('startdom').selectedIndex = parseInt(timebasedrules[f].ruleconditons.from_mday -1); _$('enddom').selectedIndex = parseInt(timebasedrules[f].ruleconditons.to_mday -1); find_index(_$('month_start'), timebasedrules[f].ruleconditons.from_month); find_index(_$('month_end'), timebasedrules[f].ruleconditons.to_month); find_index(_$('dest_match'), timebasedrules[f].ifmatch_goto); find_index(_$('dest_nomatch'), timebasedrules[f].ifnomatch_goto);}</script><body onload="localajaxinit()" bgcolor="FFFFFF"><div style="font-size : 12px; padding : 4px 6px 4px 6px; border-style : solid none solid none; border-top-color : #BDC7E7; border-bottom-color : #182052; border-width : 1px 0px 1px 0px; background-color : #ef8700; color : #ffffff;"> <span style="margin-left: 4px;font-weight:bold;">Time Based Rules</span> <span style="cursor: pointer; cursor: hand;" onclick="window.location.href=window.location.href;" > <img src="images/refresh.png" title=" Refresh " border=0 > </span> <input id="create_rule" type=button value="New Time Rule" class="input8" onclick="add_trule();"></div><div id="maintable1"> <table class="table_blacksm" cellpadding=2 cellspacing=2 border=0 align=center width=500 id="table_one"> <tr> <td width=35>S.No</td> <td align=left>RuleName</td> <td align="center" width=115>Options</td> </tr> </table> <div id="tbrulesTable_div" style="height:430px;width=100%; overflow :auto; padding : 0px 0px 0px 0px;"> <table id="tbrulesTable" cellpadding=2 cellspacing=1 border=0 align=center width=500 bgcolor="#DEDEDE"></table> </div> <BR></div><div id="timerule_editdiv" STYLE="display:none; position: absolute; left: 20; top: 40; width:480; height:320; background-color:#F4EFE5; border-width: 1px; border-color: #7E5538; border-style: solid; z-index:5"> <table width="100%" cellpadding=0 cellspacing=0 onmousedown="ASTGUI.startDrag(event , 'timerule_editdiv');"> <TR bgcolor="#7E5538" style="background-image:url('images/title_gradient.gif');"> <TD><font color="#FFFFFF"> <span id="form_caption"></span></FONT></TD> <TD Height="20" align="right" style="cursor: move"> <A href="#" onclick="$('cancel').click();" style="color:#FFFFFF; font-size: 12px; font-weight:bold;">X</A> </TD> <TD width=4></TD> </TR> </table> <table cellpadding=2 cellspacing=2 border=0 width="100%" align="center"> <tr><td align=center colspan=2> Rule Name : <input id="id_rulename" size=20 class="input9"> (Ex: July4)</td> </tr> <tr><td align=center colspan=2 height=30 valign=bottom><B>Time & Date Conditions</B></td> </tr> <tr> <td align=right>Start Time: <select id="startime_hour" class="input9"></select> : <select id="startime_minute" class="input9"></select></td> <td align=left>End Time: <select id="endtime_hour" class="input9"></select> : <select id="endtime_minute" class="input9"></select></td> </tr> <tr> <td align=right>Start Day: <select id="wday_start" class="input9"> <option value="sun">Sun</option><option value="mon">Mon</option><option value="tue">Tue</option><option value="wed">Wed</option> <option value="thu">Thu</option><option value="fri">Fri</option><option value="sat">Sat</option> </select> </td> <td align=left>End Day: <select id="wday_end" class="input9"> <option value="sun">Sun</option><option value="mon">Mon</option><option value="tue">Tue</option><option value="wed">Wed</option> <option value="thu">Thu</option><option value="fri">Fri</option><option value="sat">Sat</option> </select> </td> </tr> <tr> <td align=right>Start Date: <select id="startdom" class="input9"></select></td> <td align=left>End Date: <select id="enddom" class="input9"></select></td> </tr> <tr> <td align=right>Start Month: <select id="month_start" class="input9"> <option value="jan">January</option><option value="feb">February</option><option value="mar">March</option><option value="apr">April</option> <option value="may">May</option><option value="jun">June</option><option value="jul">July</option><option value="aug">August</option> <option value="sep">September</option><option value="oct">October</option><option value="nov">November</option><option value="dec">December</option> </select> </td> <td align=left>End Month: <select id="month_end" class="input9"> <option value="jan">January</option><option value="feb">February</option><option value="mar">March</option><option value="apr">April</option> <option value="may">May</option><option value="jun">June</option><option value="jul">July</option><option value="aug">August</option> <option value="sep">September</option><option value="oct">October</option><option value="nov">November</option><option value="dec">December</option> </select> </td> </tr> <tr><td align=center colspan=2 height=40 valign=bottom><B>Destination</B></td> </tr> <tr> <td align=right>if time matches:</td> <td align=left><select id="dest_match" class="input9"></select></td> </tr> <tr> <td align=right>if time did not match:</td> <td align=left><select id="dest_nomatch" class="input9"></select></td> </tr> <tr> <td align=center colspan=2 height=30 valign=bottom> <input id="save" type=button value="Save" class="input9" onclick="save_rule();"> <input id="cancel" type=button value="Cancel" class="input9" onclick="cancel_rule();"> </td> </tr> </table></div></body>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -