Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%#
- Copyright 2014 Aedan Renner <chipdankly@gmail.com>
- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
- Licensed to the public under the GNU General Public License v2.
- -%>
- <script type="text/javascript">//<![CDATA[
- function secondsToString(time) {
- var seconds = parseInt(time, 10);
- var hrs = Math.floor(seconds / 3600);
- seconds -= hrs*3600;
- var mnts = Math.floor(seconds / 60);
- seconds -= mnts*60;
- return String.format("%sh:%sm:%ss", hrs, mnts, seconds);
- }
- XHR.poll(-1, '<%=luci.dispatcher.build_url("admin", "status", "mwan", "interface_status")%>', null,
- function(x, status)
- {
- var statusDiv = document.getElementById('mwan_status_text');
- if (status.interfaces)
- {
- var statusview = '';
- var wan0 = '';
- var wan1 = '';
- var wan2 = '';
- var wan3 = '';
- var wan4 = '';
- var wanX = '';
- function makehtmlstuff() {
- var temphtml = '';
- switch (status.interfaces[iface].status)
- {
- case 'online':
- state = '<%:Online%>';
- time = String.format(
- '<div><strong><%:Uptime%>: </strong>%s</div>',
- secondsToString(status.interfaces[iface].online)
- );
- css = 'success';
- break;
- case 'offline':
- state = '<%:Offline%>';
- time = String.format(
- '<div><strong><%:Downtime%>: </strong>%s</div>',
- secondsToString(status.interfaces[iface].offline)
- );
- css = 'danger';
- break;
- case 'notracking':
- state = '<%:No Tracking%>';
- if ((status.interfaces[iface].uptime) > 0) {
- time = String.format(
- '<div><strong><%:Uptime%>: </strong>%s</div>',
- secondsToString(status.interfaces[iface].uptime)
- );
- css = 'success';
- }
- else {
- time = '<div> </div>'
- css = 'warning';
- }
- break;
- default:
- state = '<%:Disabled%>';
- time = '<div> </div>'
- css = 'warning';
- break;
- }
- temphtml += String.format(
- '<div class="alert-message %s">',
- css
- );
- temphtml += String.format(
- '<div><strong><%:Interface%>: </strong>%s</div>',
- iface
- );
- temphtml += String.format(
- '<div><strong><%:Status%>: </strong>%s</div>',
- state
- );
- if (time)
- {
- temphtml += time;
- }
- temphtml += '</div>'
- return temphtml;
- }
- for ( var iface in status.interfaces)
- {
- var state = '';
- var css = '';
- var time = '';
- if ( iface.includes("0") )
- { wan0 =makehtmlstuff();
- } else if ( iface.includes("1") )
- { wan1 =makehtmlstuff();
- } else if ( iface.includes("2") )
- { wan2 =makehtmlstuff();
- } else if ( iface.includes("3") )
- { wan3 =makehtmlstuff();
- } else if ( iface.includes("4") )
- { wan4 =makehtmlstuff();
- } else { wanX +=makehtmlstuff();
- }
- }
- statusDiv.innerHTML = wan0+wan1+wan2+wan3+wan4+wanX;
- }
- else
- {
- statusDiv.innerHTML = '<strong><%:No MWAN interfaces found%></strong>';
- }
- }
- );
- //]]></script>
- <style type="text/css">
- #mwan_status_text > div {
- display: inline-block;
- margin: 1rem;
- padding: 1rem;
- width: 15rem;
- float: left;
- line-height: 125%;
- }
- </style>
- <fieldset id="interface_field" class="cbi-section">
- <legend><%:MWAN Interfaces%></legend>
- <div id="mwan_status_text">
- <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
- <%:Collecting data...%>
- </div>
- </fieldset>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement