vikktree44 commited on
Commit
5655f17
·
verified ·
1 Parent(s): dd41c7a

Button calculte IPs is not working and the button Copy to clipboard either

Browse files
Files changed (1) hide show
  1. script.js +10 -13
script.js CHANGED
@@ -11,7 +11,6 @@ document.addEventListener('DOMContentLoaded', function() {
11
  const outputContainer = document.getElementById('outputContainer');
12
  const emailOutput = document.getElementById('emailOutput');
13
  const copyBtn = document.getElementById('copyBtn');
14
-
15
  // Toggle between service types
16
  internetBtn.addEventListener('click', function() {
17
  internetBtn.classList.add('bg-blue-600', 'text-white');
@@ -21,8 +20,10 @@ document.addEventListener('DOMContentLoaded', function() {
21
  internetForm.classList.remove('hidden');
22
  l2lForm.classList.add('hidden');
23
  outputContainer.classList.add('hidden');
24
- });
25
- }
 
 
26
  l2lBtn.addEventListener('click', function() {
27
  l2lBtn.classList.add('bg-blue-600', 'text-white');
28
  l2lBtn.classList.remove('bg-gray-200', 'text-gray-800');
@@ -99,10 +100,9 @@ l2lBtn.addEventListener('click', function() {
99
  }
100
  outputContainer.classList.remove('hidden');
101
  });
102
- // Copy table to clipboard - ensure button is properly initialized
103
  const copyTableBtn = document.getElementById('copyTableBtn');
104
- if (copyTableBtn) {
105
- copyTableBtn.addEventListener('click', function() {
106
  let tableText = 'Type\tIP Address\tSubnet Mask\n';
107
  const rows = ipTableBody.querySelectorAll('tr');
108
 
@@ -120,9 +120,8 @@ let tableText = 'Type\tIP Address\tSubnet Mask\n';
120
  }, 2000);
121
  });
122
  }
123
- // Copy email to clipboard - ensure button is properly initialized
124
- if (copyBtn) {
125
- copyBtn.addEventListener('click', function() {
126
  const textToCopy = emailOutput.textContent;
127
  navigator.clipboard.writeText(textToCopy).then(() => {
128
  const originalText = copyBtn.innerHTML;
@@ -133,8 +132,8 @@ navigator.clipboard.writeText(textToCopy).then(() => {
133
  }, 2000);
134
  });
135
  });
136
- // Helper functions - add null checks for DOM elements
137
- function addTableRow(type, ip, mask) {
138
  if (!ipTableBody) return;
139
  const row = document.createElement('tr');
140
  row.innerHTML = `
@@ -193,7 +192,6 @@ ipTableBody.appendChild(row);
193
  return ipArray.join('.');
194
  }
195
  function generateInternetEmail() {
196
- if (!emailOutput) return;
197
  const client = document.getElementById('client').value;
198
  const serviceNumber = document.getElementById('serviceNumber').value;
199
  const address = document.getElementById('address').value;
@@ -255,7 +253,6 @@ emailOutput.textContent = emailText;
255
  feather.replace();
256
  }
257
  function generateL2LEmail() {
258
- if (!emailOutput) return;
259
  const client = document.getElementById('l2lClient').value;
260
  const serviceNumber = document.getElementById('l2lServiceNumber').value;
261
  const bandwidth = document.getElementById('l2lBandwidth').value;
 
11
  const outputContainer = document.getElementById('outputContainer');
12
  const emailOutput = document.getElementById('emailOutput');
13
  const copyBtn = document.getElementById('copyBtn');
 
14
  // Toggle between service types
15
  internetBtn.addEventListener('click', function() {
16
  internetBtn.classList.add('bg-blue-600', 'text-white');
 
20
  internetForm.classList.remove('hidden');
21
  l2lForm.classList.add('hidden');
22
  outputContainer.classList.add('hidden');
23
+ });
24
+
25
+ // Initialize Feather Icons
26
+ feather.replace();
27
  l2lBtn.addEventListener('click', function() {
28
  l2lBtn.classList.add('bg-blue-600', 'text-white');
29
  l2lBtn.classList.remove('bg-gray-200', 'text-gray-800');
 
100
  }
101
  outputContainer.classList.remove('hidden');
102
  });
103
+ // Copy table to clipboard
104
  const copyTableBtn = document.getElementById('copyTableBtn');
105
+ copyTableBtn.addEventListener('click', function() {
 
106
  let tableText = 'Type\tIP Address\tSubnet Mask\n';
107
  const rows = ipTableBody.querySelectorAll('tr');
108
 
 
120
  }, 2000);
121
  });
122
  }
123
+ // Copy email to clipboard
124
+ copyBtn.addEventListener('click', function() {
 
125
  const textToCopy = emailOutput.textContent;
126
  navigator.clipboard.writeText(textToCopy).then(() => {
127
  const originalText = copyBtn.innerHTML;
 
132
  }, 2000);
133
  });
134
  });
135
+ // Helper functions
136
+ function addTableRow(type, ip, mask) {
137
  if (!ipTableBody) return;
138
  const row = document.createElement('tr');
139
  row.innerHTML = `
 
192
  return ipArray.join('.');
193
  }
194
  function generateInternetEmail() {
 
195
  const client = document.getElementById('client').value;
196
  const serviceNumber = document.getElementById('serviceNumber').value;
197
  const address = document.getElementById('address').value;
 
253
  feather.replace();
254
  }
255
  function generateL2LEmail() {
 
256
  const client = document.getElementById('l2lClient').value;
257
  const serviceNumber = document.getElementById('l2lServiceNumber').value;
258
  const bandwidth = document.getElementById('l2lBandwidth').value;