common_js.htm 1.6 KB

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