I am vb.net programmer i don't have background about this programming lang.
I think my issue is by replacing some variables , if that easy for you please help and make it for me.
Code: Select all
/*
* This program is copyright © 2008,2009-2013 Eric Bishop and is distributed under the terms of the GNU GPL
* version 2.0 with a special clarification/exception that permits adapting the program to
* configure proprietary "back end" software provided that all modifications to the web interface
* itself remain covered by the GPL.
* See http://gargoyle-router.com/faq.html#qfoss for more information
echo "var hostData = new Array();"
if [ -e /etc/hosts ] ; then
awk ' $0 ~ /^[\t ]*[0-9]/ {print "hostData.push([\""$1"\",\""$2"\"]);"};' /etc/hosts
fi
var ipHostHash = new Array();
for (hostIndex in hostData)
{
host=hostData[hostIndex];
ipHostHash[ host[0] ] = host[1];
}
*/function saveChanges(){setControlsEnabled(!1,!0);var e=[],t=uciOriginal.getAllSectionsOfType(pkg,"quota");while(t.length>0){var n=t.shift();uciOriginal.removeSection(pkg,n),e.push("uci del "+pkg+"."+n)}e.push("uci commit");var r=uci.getAllSectionsOfType(pkg,"quota"),i="\nuci del gargoyle.status.quotause ; uci commit ;\n",s=[];while(r.length>0){var n=r.shift(),o=uci.get(pkg,n,"id");s[o]=n,changedIds[o]==1&&uci.set(pkg,n,"ignore_backup_at_next_restore","1")}var u=document.getElementById("quota_table_container").firstChild,a=getTableDataArray(u,!0,!1),f=0;for(f=0;f<a.length;f++){var l=a[f][rowCheckIndex],c=s[l.id];c!=null&&(uci.set(pkg,c,"enabled",l.checked?"1":"0"),l.checked&&(i='\nuci set gargoyle.status.quotause="225" ; uci commit ;\n'))}var h=[];h.push("sh /usr/lib/gargoyle/restart_firewall.sh"),h.push('if [ -d "/usr/data/quotas/" ] ; then rm -rf /usr/data/quotas/* ; fi ;'),h.push("backup_quotas");var p=e.join("\n")+"\n"+uci.getScriptCommands(uciOriginal)+"\n"+i+"\n"+h.join("\n"),d=getParameterDefinition("commands",p)+"&"+getParameterDefinition("hash",document.cookie.replace(/^.*hash=/,"").replace(/[\t ;]+.*$/,"")),v=function(e){e.readyState==4&&(setControlsEnabled(!0),window.location.href=window.location.href)};runAjax("POST","utility/run_commands.sh",d,v)}
function resetData(){var e=0;upQosClasses=[],upQosMarks=[],downQosClasses=[],downQosMarks=[];for(e=0;e<qosMarkList.length;e++){var t=qosMarkList[e][1],n=uciOriginal.get("qos_gargoyle",t,"name");t=n==""?t:n,qosMarkList[e][0]=="upload"?(upQosClasses.push(t),upQosMarks.push(qosMarkList[e][2])):(downQosClasses.push(t),downQosMarks.push(qosMarkList[e][2]))}var r=uciOriginal.getAllSectionsOfType(pkg,"quota"),i=[],s=[],o=[];changedIds=[];for(sectionIndex=0;sectionIndex<r.length;sectionIndex++){var u=uciOriginal.get(pkg,r[sectionIndex],"ip").toUpperCase(),a=uciOriginal.get(pkg,r[sectionIndex],"id");a==""&&(a=getIdFromIp(u),uci.set(pkg,r[sectionIndex],"id",a));var f=getTimeParametersFromUci(uci,r[sectionIndex],1),l=getLimitStrFromUci(uci,r[sectionIndex]),c=uciOriginal.get(pkg,r[sectionIndex],"enabled");c=c!="0"?!0:!1; var h=createEnabledCheckbox(c);
/////////////////////////////////////
h.id=a,s.push(h),o.push(c),i.push([ipToTableSpan(u), timeParamsToTableSpan(f),l,h,createEditButton(c)])}columnNames=[quotasStr.IPs,quotasStr.Active,textListToSpanElement([quotasStr.Limits,quotasStr.Totals],!1),UI.Enabled,""],quotaTable=createTable(columnNames,i,"quota_table",!0,!1,removeQuotaCallback),tableContainer=document.getElementById("quota_table_container"),tableContainer.firstChild!=null&&tableContainer.removeChild(tableContainer.firstChild),tableContainer.appendChild(quotaTable);while(s.length>0){var p=s.shift(),d=o.shift();p.checked=d}setDocumentFromUci(document,new UCIContainer,""),setVisibility(document)}
function ipToTableSpan(e){var t=e;if(t=="ALL_OTHERS_INDIVIDUAL")t=quotasStr.OthersOne;else if(t=="ALL_OTHERS")t=quotasStr.OthersAll;else if(t=="ALL"||t=="")t=quotasStr.All;return textListToSpanElement(t.split(/[\t ]*,[\t ]*/),!0,document)}
function timeParamsToTableSpan(e){var t=e[0],n=e[1],r=e[2],i=e[3],s=[];return i=="always"?s.unshift(UI.Always):(r!=""?s=r.match(",")?r.split(/[\t ]*,[\t ]*/):[r]:(t!=""&&(s=t.match(",")?t.split(/[\t ]*,[\t ]*/):[t]),n!=""&&s.unshift(n)),s.unshift(i=="only"?quotasStr.Only+":":quotasStr.AllExcept+":")),textListToSpanElement(s,!1,document)}
function getLimitStrFromUci(e,t){var n=uci.get(pkg,t,"combined_limit"),r=uci.get(pkg,t,"ingress_limit"),i=uci.get(pkg,t,"egress_limit");return (n/880000).toFixed(2) +"/"+r/880000+"/"+i/880000}
function getIdFromIp(e){id=e==""?"ALL":e.replace(/[\t, ]+.*$/,""),id=id.replace(/\//,"_");
var t=id,n=!0,r=0,i=uci.getAllSectionsOfType(pkg,"quota");
while(n){n=!1;var s;for(s=0;s<i.length&&!n;s++)n=n||uci.get(pkg,i[s],"id")==id;if(n){var o="ABCDEFGHIJKLMNOPQRSTUVWXYZ",u=r<26?"_"+o.substr(r,1):"_Z"+(r-25);id=t+u}r++}
return id}
function getIpFromDocument(e){e=e==null?document:e;var t="ALL";if(getSelectedValue("applies_to_type",e)=="all")t="ALL";else if(getSelectedValue("applies_to_type",e)=="others_combined")t="ALL_OTHERS_COMBINED";else if(getSelectedValue("applies_to_type",e)=="others_individual")t="ALL_OTHERS_INDIVIDUAL";else if(getSelectedValue("applies_to_type",e)=="only"){var n=e.getElementById("quota_ip_table_container").firstChild,r=n!=null?getTableDataArray(n,!0,!1):[],i=[],s;for(s=0;s<r.length;s++)i.push(r[s][0]);t=i.join(",")}return t}
function setDocumentIp(e,t){e=e==""?"ALL":e,t=t==null?document:t,t.getElementById("add_ip").value="";var n=t.getElementById("quota_ip_table_container");while(n.firstChild!=null)n.removeChild(n.firstChild);if(e=="ALL")setSelectedValue("applies_to_type","all",t);else if(e=="ALL_OTHERS_COMBINED")setSelectedValue("applies_to_type","others_combined",t);else if(e=="ALL_OTHERS_INDIVIDUAL")setSelectedValue("applies_to_type","others_individual",t);else{setSelectedValue("applies_to_type","only",t),t.getElementById("add_ip").value=e;var r=addAddressesToTable(t,"add_ip","quota_ip_table_container","quota_ip_table",!1,3,!1,250);r||(t.getElementById("add_ip").value="")}}
function addNewQuota(){var e=validateQuota(document,"","none");if(e.length>0)alert(e.join("\n")+"\n"+quotasStr.AddError);else{var t=1;while(uci.get(pkg,"quota_"+t,"")!="")t++;setUciFromDocument(document,"");var n=createEnabledCheckbox(!0);n.id=uci.get(pkg,"quota_"+t,"id");var r=document.getElementById("quota_table_container"),i=r.firstChild,s=getIpFromDocument(document),o=getTimeParametersFromUci(uci,"quota_"+t),u=getLimitStrFromUci(pkg,"quota_"+t);addTableRow(i,[ipToTableSpan(s),timeParamsToTableSpan(o),u,n,createEditButton(!0)],!0,!1,removeQuotaCallback),setDocumentFromUci(document,new UCIContainer,""),n.checked=!0}}
function setVisibility(e){e=e==null?document:e,setInvisibleIfIdMatches("applies_to_type",["all","others_combined","others_individual"],"quota_ip_container","inline",e),setInvisibleIfIdMatches("quota_reset",["hour","day"],"quota_day_container","block",e),setInvisibleIfIdMatches("quota_reset",["hour"],"quota_hour_container","block",e),setInvisibleIfIdMatches("max_up_type",["unlimited"],"max_up_container","inline",e),setInvisibleIfIdMatches("max_down_type",["unlimited"],"max_down_container","inline",e),setInvisibleIfIdMatches("max_combined_type",["unlimited"],"max_combined_container","inline",e),setInvisibleIfIdMatches("quota_active",["always"],"quota_active_type","inline",e),setInvisibleIfIdMatches("quota_active",["always"],"quota_active_controls_container","block",e),getSelectedValue("quota_active",e)!="always"?(setInvisibleIfIdMatches("quota_active_type",["days","weekly_range"],"active_hours_container","block",e),setInvisibleIfIdMatches("quota_active_type",["hours","weekly_range"],"active_days_container","block",e),setInvisibleIfIdMatches("quota_active_type",["hours","days","days_and_hours"],"active_weekly_container","block",e)):(setInvisibleIfIdMatches("quota_active",["always"],"active_hours_container","block",e),setInvisibleIfIdMatches("quota_active",["always"],"active_days_container","block",e),setInvisibleIfIdMatches("quota_active",["always"],"active_weekly_container","block",e)),setInvisibleIfIdMatches("quota_exceeded",["hard_cutoff"],"quota_only_qos_container","block",e),setInvisibleIfIdMatches("quota_exceeded",["hard_cutoff"],"quota_full_qos_container","block",e),fullQosEnabled?e.getElementById("quota_only_qos_container").style.display="none":e.getElementById("quota_full_qos_container").style.display="none";
///////////////////////// Start //////////////////////////////////////////////////////
var t=getSelectedValue("quota_reset",e);
if(t=="none"){var n=[],r=[],i=0}setAllowableSelections("quota_day",n,r,e)
///////////////////////// End ///////////////////////////////////////////////////////
if(t=="month"){var n=[],r=[],i=1;for(i=1;i<=28;i++){var s=""+i,o=s.substr(s.length-1,1),u=quotasStr.Digs;i%100!=11&&o=="1"&&(u=quotasStr.LD1s),i%100!=12&&o=="2"&&(u=quotasStr.LD2s),i%100!=13&&o=="3"&&(u=quotasStr.LD3s),r.push(s+u),n.push((i-1)*60*60*24+"")}setAllowableSelections("quota_day",n,r,e)}
if(t=="week"){var r=[UI.Sunday,UI.Monday,UI.Tuesday,UI.Wednesday,UI.Thursday,UI.Friday,UI.Saturday],n=[],a;for(a=0;a<7;a++)n.push(a*60*60*24+"");setAllowableSelections("quota_day",n,r,e)}}
function getDaySeconds(e){return Math.floor(e/86400)*86400}
function getHourSeconds(e){return Math.floor(e%86400/3600)*3600}
function timeVariablesToWeeklyRanges(e,t,n,r){var e=e==null?"":e,t=t==null?"":t,n=n==null?"":n,i=[];i[UI.Sun.toUpperCase()]=0,i[UI.Mon.toUpperCase()]=1,i[UI.Tue.toUpperCase()]=2,i[UI.Wed.toUpperCase()]=3,i[UI.Thu.toUpperCase()]=4,i[UI.Fri.toUpperCase()]=5,i[UI.Sat.toUpperCase()]=6;var s=function(e,t){var n=[],r;for(r=0;r<e.length;r+=2){if(e[r+1]<e[r]){var i=e[r+1];e[r+1]=t,e.push(0),e.push(i)}var s=e[r],o=e[r+1];n.push([s,o])}var u=function(e,t){return e[0]-t[0]},a=n.sort(u),f=[];for(r=0;r<a.length;r++)f.push(a[r][0]),f.push(a[r][1]);return f},o=[];if(e==""&&t==""&&n=="")o=[0,604800],r=!1;else if(n!=""){var u=function(e){var t=e.split(/[:\t ]+/),n=t[0].substr(0,3).toUpperCase();return t[0]=i[n]!=null?i[n]*24*60*60:0,t[1]=parsePaddedInt(t[1])+""!="NaN"?parsePaddedInt(t[1])*60*60:0,t[2]=parsePaddedInt(t[2])+""!="NaN"?parsePaddedInt(t[2])*60:0,t[3]=t[3]!=null?parsePaddedInt(t[3])+""!="NaN"?parsePaddedInt(t[3]):0:0,t[0]+t[1]+t[2]+t[3]},a=n.split(/[\t ]*,[\t ]*/),f;for(f=0;f<a.length;f++){var l=a[f].split(/[\t ]*\-[\t ]*/);o.push(u(l[0])),o.push(u(l[1]))}o=s(o,604800)}else{var c=[1,1,1,1,1,1,1],h=[];if(t!=""){c=[0,0,0,0,0,0,0];var p=t.split(/[\t ]*,[\t ]*/),d;for(d=0;d<p.length;d++){var v=p[d].substr(0,3).toUpperCase();i[v]!=null&&(c[i[v]]=1)}}if(e!=""){var u=function(e){var t=e.split(/[:\t ]+/);return t[0]=parsePaddedInt(t[0])+""!="NaN"?parsePaddedInt(t[0])*60*60:0,t[1]=parsePaddedInt(t[1])+""!="NaN"?parsePaddedInt(t[1])*60:0,t[2]=t[2]!=null?parsePaddedInt(t[2])+""!="NaN"?parsePaddedInt(t[2]):0:0,t[0]+t[1]+t[2]},a=e.split(/[\t ]*,[\t ]*/),f;for(f=0;f<a.length;f++){var m=a[f].replace(/^[\t ]*/,"").replace(/[\t ]*$/,""),l=m.split(/[\t ]*\-[\t ]*/);h.push(u(l[0])),h.push(u(l[1]))}h=s(h,86400)}h=h.length==0?[0,86400]:h;var d;for(d=0;d<c.length;d++)if(c[d]!=0){var g;for(g=0;g<h.length;g++)o.push(d*24*60*60+h[g])}}return r&&(o[0]==0?o.shift():o.unshift(0),o[o.length-1]==7*24*60*60?o.pop():o.push(604800)),o}
function rangesOverlap(e,t){var n=timeVariablesToWeeklyRanges(e[0],e[1],e[2],e[3]),r=timeVariablesToWeeklyRanges(t[0],t[1],t[2],t[3]),i=0,s=0,o=!1;for(i=0;i<n.length&&!o;i+=2){var u=n[i],a=n[i+1],f=r[s],l=r[s+1];o=o||a>f&&u<l;while(!o&&f<u&&s<r.length){s+=2;if(s<r.length){var f=r[s],l=r[s+1];o=o||a>f&&u<l}}}return o}
function validateQuota(e,t,n){t=t==null?"":t,n=n==null?"none":n,e=e==null?document:e;var r=["max_up","max_down","max_combined","active_hours","active_weekly"],i=["max_up_label","max_down_label","max_combined_label","quota_active_label","quota_active_label"],s=[validateDecimal,validateDecimal,validateDecimal,validateHours,validateWeeklyRange],o=[0,0,0,0,0],u=["max_up_container","max_down_container","max_combined_container","active_hours_container","active_weekly_container"],a=proofreadFields(r,i,s,o,u,e);if(a.length==0&&getSelectedValue("applies_to_type",e)=="only"&&e.getElementById("add_ip").value!=""){var f=addAddressesToTable(e,"add_ip","quota_ip_table_container","quota_ip_table",!1,3,!1,250);f||a.push('"'+e.getElementById("add_ip").value+'" is not a valid IP or IP range')}var l="";a.length==0&&(l=getIpFromDocument(e),l==""&&a.push(quotasStr.IPError)),a.length==0&&getSelectedValue("max_up_type",e)=="unlimited"&&getSelectedValue("max_down_type",e)=="unlimited"&&getSelectedValue("max_combined_type",e)=="unlimited"&&a.push(quotasStr.AllUnlimitedError);if(a.length==0&&l!=n){var c=uci.getAllSectionsOfType(pkg,"quota"),h,p=!1;for(h=0;h<c.length&&!p;h++){var d=uci.get(pkg,c[h],"id");if(d!=t){var v=uci.get(pkg,c[h],"ip"),m=testAddrOverlap(v,l);if(m){var g=getTimeParametersFromDocument(e),y=getTimeParametersFromUci(uci,c[h]);g[3]=g[3]=="except"?!0:!1,y[3]=y[3]=="except"?!0:!1,p=rangesOverlap(g,y)}}}p&&(l.match(/ALL/)?l.match(/OTHER/)?a.push(quotasStr.OneTimeQuotaError):a.push(quotasStr.OneNetworkQuotaError):a.push(quotasStr.DuplicateRange))}return a}
function setDocumentFromUci(e,t,n){e=e==null?document:e;var r="",i=t.getAllSectionsOfType(pkg,"quota");for(sectionIndex=0;sectionIndex<i.length&&r=="";sectionIndex++)t.get(pkg,i[sectionIndex],"id")==n&&(r=i[sectionIndex]);var s=t.get(pkg,r,"ip");s=s==""?"ALL":s;var o=t.get(pkg,r,"reset_interval"),u=t.get(pkg,r,"egress_limit"),a=t.get(pkg,r,"ingress_limit"),f=t.get(pkg,r,"combined_limit");o=o==""||o=="minute"?"day":o;var l=t.get(pkg,r,"reset_time");l=l==""?0:parseInt(l);var c=getDaySeconds(l),h=getHourSeconds(l),p=t.get(pkg,r,"exceeded_up_speed"),d=t.get(pkg,r,"exceeded_down_speed"),v=t.get(pkg,r,"exceeded_up_class_mark"),m=t.get(pkg,r,"exceeded_down_class_mark");setDocumentIp(s,e),setSelectedValue("quota_reset",o,e);var g=getTimeParametersFromUci(t,r),y=g[1],b=["sun","mon","tue","wed","thu","fri","sat"],w=[];y==""?w=b:w=y.split(/,/);var E=0;for(E=0;E<b.length;E++){var S=b[E],x=!1,T=0;for(T=0;T<w.length&&!x;T++)x=w[T]==S;e.getElementById("quota_"+b[E]).checked=x}e.getElementById("active_hours").value=g[0],e.getElementById("active_weekly").value=g[2];var N=g[3];setSelectedValue("quota_active",N,e);if(N!="always"){var C=[];C["000"]="hours",C[100]="hours",C["010"]="days",C[110]="days_and_hours";var k=(g[0]!=""?"1":"0")+(g[1]!=""?"1":"0")+(g[2]==""?"0":"1"),L=C[k]!=null?C[k]:"weekly_range";setSelectedValue("quota_active_type",L,e)}setSelectedValue("max_up_type",u==""?"unlimited":"limited",e),setSelectedValue("max_down_type",a==""?"unlimited":"limited",e),setSelectedValue("max_combined_type",f==""?"unlimited":"limited",e),setDocumentLimit(u,"max_up","max_up_unit",e),setDocumentLimit(a,"max_down","max_down_unit",e),setDocumentLimit(f,"max_combined","max_combined_unit",e);var A=p!=""&&d!=""&&!fullQosEnabled||v!=""&&m!=""&&fullQosEnabled?"throttle":"hard_cutoff";setSelectedValue("quota_exceeded",A,e),setDocumentSpeed(p,"quota_qos_up","quota_qos_up_unit",e),setDocumentSpeed(d,"quota_qos_down","quota_qos_down_unit",e),setVisibility(e),setSelectedValue("quota_day",c+"",e),setSelectedValue("quota_hour",h+"",e),fullQosEnabled&&(setAllowableSelections("quota_full_qos_up_class",upQosMarks,upQosClasses,e),setAllowableSelections("quota_full_qos_down_class",downQosMarks,downQosClasses,e),v!=""&&m!=""&&(setSelectedValue("quota_full_qos_up_class",v,e),setSelectedValue("quota_full_qos_down_class",m,e)))}
function setDocumentLimit(e,t,n,r){e=e==""?0:parseInt(e);var i=r.getElementById(t),s=UI.MB,o=880000;if(e<=0)setSelectedValue(n,s,r),i.value="0";else{var u=parseBytes(e),a=s,f=o;var l=truncateDecimal(e/f);i.value=l}}
function setDocumentSpeed(e,t,n,r){var i=UI.KBs,s=r.getElementById(t);setSelectedValue(n,i,r),e=e==""?0:parseInt(e);if(e<=0)s.value="0";else{var o=parseKbytesPerSecond(e),u=o.split(/[\t ]+/);s.value=u[0];switch(u[1]){case UI.KBs:i="KBytes/s";break;case UI.MBs:i="MBytes/s"}setSelectedValue(n,i,r)}}
function setUciFromDocument(e,t){e=e==null?document:e;var n=getIpFromDocument(e);t=t==null?"":t,t=t==""?getIdFromIp(n):t;var r="",i=uci.getAllSectionsOfType(pkg,"quota");for(sectionIndex=0;sectionIndex<i.length;sectionIndex++)uci.get(pkg,i[sectionIndex],"id")==t&&(r=i[sectionIndex]);if(r==""){var s=1;while(uci.get(pkg,"quota_"+s,"")!="")s++;r="quota_"+s,uci.set(pkg,r,"","quota")}var o=uci.get(pkg,r,"ip");o!=n&&(testAddrOverlap(o,n)||(changedIds[t]=1)),uci.set(pkg,r,"ingress_limit",getDocumentLimit("max_down","max_down_type","max_down_unit",e)),uci.set(pkg,r,"egress_limit",getDocumentLimit("max_up","max_up_type","max_up_unit",e)),uci.set(pkg,r,"combined_limit",getDocumentLimit("max_combined","max_combined_type","max_combined_unit",e)),uci.set(pkg,r,"exceeded_up_speed",getDocumentSpeed("quota_only_qos_container","quota_qos_up","quota_qos_up_unit",e)),uci.set(pkg,r,"exceeded_down_speed",getDocumentSpeed("quota_only_qos_container","quota_qos_down","quota_qos_down_unit",e)),uci.set(pkg,r,"exceeded_up_class_mark",getDocumentMark("quota_full_qos_container","quota_full_qos_up_class",e)),uci.set(pkg,r,"exceeded_down_class_mark",getDocumentMark("quota_full_qos_container","quota_full_qos_down_class",e)),uci.set(pkg,r,"reset_interval",getSelectedValue("quota_reset",e)),uci.set(pkg,r,"ip",n),uci.set(pkg,r,"id",t);var u=getSelectedValue("quota_day",e),a=getSelectedValue("quota_hour",e);u=u==""?"0":u,a=a==""?"0":a;var f=parseInt(u)+parseInt(a);if(f>0){var l=f+"";uci.set(pkg,r,"reset_time",l)}else uci.remove(pkg,r,"reset_time");var c=getTimeParametersFromDocument(e),h=c[3],p=["offpeak","onpeak"],d=0;for(d=0;d<p.length;d++){var v=p[d],m=function(e,t,n){e?uci.set(pkg,r,t,n):uci.remove(pkg,r,t)},g=v=="offpeak"&&h=="except"||v=="onpeak"&&h=="only";m(g,v+"_hours",c[0]),m(g,v+"_weekdays",c[1]),m(g,v+"_weekly_ranges",c[2])}}
function getTimeParametersFromDocument(e){var t=e.getElementById("active_hours_container").style.display!="none"?e.getElementById("active_hours").value:"",n=e.getElementById("active_weekly_container").style.display!="none"?e.getElementById("active_weekly").value:"",r=[];if(e.getElementById("active_days_container").style.display!="none"){var i=["sun","mon","tue","wed","thu","fri","sat"],s;for(s=0;s<i.length;s++)e.getElementById("quota_"+i[s]).checked&&r.push(i[s])}var o=""+r.join(","),u=getSelectedValue("quota_active",e);return[t,o,weekly_i18n(n,"page"),u]}
function getTimeParametersFromUci(e,t,n){var r=e.get(pkg,t,"offpeak_hours"),i=e.get(pkg,t,"offpeak_weekdays"),s=e.get(pkg,t,"offpeak_weekly_ranges"),o=r!=""||i!=""||s!=""?"except":"always";return o=="always"&&(r=e.get(pkg,t,"onpeak_hours"),i=e.get(pkg,t,"onpeak_weekdays"),s=e.get(pkg,t,"onpeak_weekly_ranges"),o=r!=""||i!=""||s!=""?"only":"always"),[r,n==1?dayToi18n(i):i,weekly_i18n(s,"uci"),o]}
function getDocumentLimit(e,t,n,r){var i="";if(getSelectedValue(t,r)!="unlimited"){var s=getSelectedValue(n,r),o=880000;s=="MB"&&(o=880000),s=="GB"&&(o=1073741824),s=="TB"&&(o=1099511627776);var u=Math.round(o*parseFloat(r.getElementById(e).value));i=""+u}return i}
function getDocumentSpeed(e,t,n,r){var i="";if(r.getElementById(e).style.display!="none"){var s=getSelectedValue(n,r);s=="MBytes/s"&&(multiple=1024),s=="KBytes/s"&&(multiple=1);var o=Math.round(multiple*parseFloat(r.getElementById(t).value));i=""+o}return i}
function getDocumentMark(e,t,n){var r="";return n.getElementById(e).style.display!="none"&&(r=getSelectedValue(t,n)),r}
function createEnabledCheckbox(e){return enabledCheckbox=createInput("checkbox"),enabledCheckbox.onclick=setRowEnabled,enabledCheckbox.checked=e,enabledCheckbox}
function createEditButton(e){return editButton=createInput("button"),editButton.value=UI.Edit,editButton.className="default_button",editButton.onclick=editQuota,editButton.className=e?"default_button":"default_button_disabled",editButton.disabled=e?!1:!0,editButton}
function setRowEnabled(){enabled=this.checked?"1":"0",enabledRow=this.parentNode.parentNode,enabledRow.childNodes[rowCheckIndex+1].firstChild.disabled=this.checked?!1:!0,enabledRow.childNodes[rowCheckIndex+1].firstChild.className=this.checked?"default_button":"default_button_disabled";var e=this.id,t=e.split(/\./);uci.get(pkg,t[0])!=""&&uci.set(pkg,t[0],"enabled",enabled),uci.get(pkg,t[1])!=""&&uci.set(pkg,t[1],"enabled",enabled)}
function removeQuotaCallback(e,t){var n=t.childNodes[rowCheckIndex].firstChild.id,r=uci.getAllSectionsOfType(pkg,"quota");for(sectionIndex=0;sectionIndex<r.length;sectionIndex++)uci.get(pkg,r[sectionIndex],"id")==n&&uci.removeSection(pkg,r[sectionIndex]);changedIds[n]=1}
function editQuota(){if(typeof editQuotaWindow!="undefined")try{editQuotaWindow.close()}catch(e){}try{xCoor=window.screenX+225,yCoor=window.screenY+225}catch(e){xCoor=window.left+225,yCoor=window.top+225}editQuotaWindow=window.open("quotas_edit.sh","edit","width=560,height=600,left="+xCoor+",top="+yCoor);var t=createInput("button",editQuotaWindow.document),n=createInput("button",editQuotaWindow.document);t.value=UI.CApplyChanges,t.className="default_button",n.value=UI.CDiscardChanges,n.className="default_button";var r=this.parentNode.parentNode,i=r.childNodes[rowCheckIndex].firstChild.id,s,o="",u=uci.getAllSectionsOfType(pkg,"quota");for(sectionIndex=0;sectionIndex<u.length&&o=="";sectionIndex++)uci.get(pkg,u[sectionIndex],"id")==i&&(o=u[sectionIndex],s=uci.get(pkg,o,"ip"));var a=uci.get(pkg,o,"egress_limit"),f=uci.get(pkg,o,"ingress_limit"),l=uci.get(pkg,o,"combined_limit"),c=function(){var e=!1;editQuotaWindow.document!=null&&editQuotaWindow.document.getElementById("bottom_button_container")!=null&&(editQuotaWindow.document.getElementById("bottom_button_container").appendChild(t),editQuotaWindow.document.getElementById("bottom_button_container").appendChild(n),setDocumentFromUci(editQuotaWindow.document,uci,i),n.onclick=function(){editQuotaWindow.close()},t.onclick=function(){var e=validateQuota(editQuotaWindow.document,i,s);if(e.length>0)alert(e.join("\n")+"\n"+quotasStr.QuotaAddError);else{var t=getIpFromDocument(editQuotaWindow.document);setUciFromDocument(editQuotaWindow.document,i);var n=function(e,t){var n=r.childNodes[t];while(n.firstChild!=null)n.removeChild(n.firstChild);n.appendChild(e)};if(t!=s){var u=getIdFromIp(t);uci.set(pkg,o,"id",u),testAddrOverlap(t,s)||(changedIds[u]=1),n(ipToTableSpan(t),0),r.childNodes[rowCheckIndex].firstChild.id=u}n(timeParamsToTableSpan(getTimeParametersFromUci(uci,o,1)),1),r.childNodes[2].firstChild.data=getLimitStrFromUci(uci,o),editQuotaWindow.close()}},editQuotaWindow.moveTo(xCoor,yCoor),editQuotaWindow.focus(),e=!0),e||setTimeout(c,250)};c()}
function dayToi18n(e){var t=e.split(",");for(var n=0;n<t.length;n++)t[n]=="sun"&&(t[n]=UI.Sun),t[n]=="mon"&&(t[n]=UI.Mon),t[n]=="tue"&&(t[n]=UI.Tue),t[n]=="wed"&&(t[n]=UI.Wed),t[n]=="thu"&&(t[n]=UI.Thu),t[n]=="fri"&&(t[n]=UI.Fri),t[n]=="sat"&&(t[n]=UI.Sat);return t.join()}
function weekly_i18n(e,t){if(e.length<6)return e;var n=[UI.Sun,UI.Mon,UI.Tue,UI.Wed,UI.Thu,UI.Fri,UI.Sat],r=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],i,s,o,u,a=[];t=="uci"?(i=r,s=n):(i=n,s=r),o=e.split(" ");for(u=0;u<o.length;u++){var f=i.indexOf(o[u]);f>=0?a[u]=s[f]:a[u]=o[u]}return a.join(" ")}var quotasStr=new Object,pkg="firewall",changedIds=[],rowCheckIndex=3,downQosClasses=[],downQosMarks=[],upQosClasses=[],upQosMarks=[];