1ee763e119578a232f293a55cc622a25a69b94c7
[project/luci.git] / applications / luci-app-olsr / luasrc / view / status-olsr / common_js.htm
1 <% if has_v4 and has_v6 then %>
2 <script type="text/javascript">//<![CDATA[
3
4 function css(selector, property, value) {
5 for (var i=0; i<document.styleSheets.length;i++) {
6 try { document.styleSheets[i].insertRule(selector+ ' {'+property+':'+value+'}', document.styleSheets[i].cssRules.length);
7 } catch(err) {try { document.styleSheets[i].addRule(selector, property+':'+value);} catch(err) {}}//IE
8 }
9 }
10
11 window.onload = function() {
12 buttons = '<input type="button" name="show-proto-4" id="show-proto-4" class="cbi-button cbi-button-apply" style="margin-right: 5px" value="<%:Hide IPv4%>">'
13 buttons += '<input type="button" name="show-proto-6" id="show-proto-6" class="cbi-button cbi-button-apply" value="<%:Hide IPv6%>">'
14
15 document.getElementById('togglebuttons').innerHTML = buttons;
16
17 var visible = true;
18 document.getElementById('show-proto-4').onclick = function() {
19 visible = !visible;
20 document.getElementById('show-proto-4').value = visible ? '<%:Hide IPv4%>' : '<%:Show IPv4%>';
21 document.getElementById('show-proto-4').className = visible ? 'cbi-button cbi-button-apply' : 'cbi-button cbi-button-reset';
22 css('.proto-4', 'display', visible ? 'table-row' : 'none')
23 };
24
25 var visible6 = true;
26 document.getElementById('show-proto-6').onclick = function() {
27 visible6 = !visible6;
28 document.getElementById('show-proto-6').value = visible6 ? '<%:Hide IPv6%>' : '<%:Show IPv6%>';
29 document.getElementById('show-proto-6').className = visible6 ? 'cbi-button cbi-button-apply' : 'cbi-button cbi-button-reset';
30 css('.proto-6', 'display', visible6 ? 'table-row' : 'none')
31 };
32
33 }
34 //]]></script>
35 <%end %>