common_js.js 1.5 KB

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