Wikipedia para siempre
ShareCode
Permalink: http://www.treeweb.es/u/974/ 01/02/2011

ShareCode

1 document.addEventListener('DOMContentLoaded', function() {2  // Mostrar el modal de bienvenida al cargar la página3  document.getElementById('welcome-modal').classList.remove('hidden');4 });5 6 function closeWelcomeModal() {7  document.getElementById('welcome-modal').classList.add('hidden');8 }9 10 function addVariable() {11  const list = document.getElementById('variables-list');12  const li = document.createElement('li');13  li.classList.add('flex', 'space-x-4', 'items-center');14  li.innerHTML = `15  <input type="text" placeholder="Variable Name" class="flex-1 p-2 border border-gray-300 rounded" title="Ingrese el nombre de la variable" />16  <input type="text" placeholder="Variable Value" class="flex-1 p-2 border border-gray-300 rounded" title="Ingrese el valor de la variable" />17  <button type="button" onclick="removeVariable(this)" class="text-red-500">x</button>18  `;19  list.appendChild(li);20 }21 22 function removeVariable(element) {23  element.parentElement.remove();24 }25 26 function saveTest() {27  const variables = [];28  const listItems = document.getElementById('variables-list').children;29  for (let i = 0; i < listItems.length; i++) {30  const name = listItems[i].children[0].value;31  const value = listItems[i].children[1].value;32  if (name && value) {33  variables.push({ name, value });34  } else {35  alert('Please fill out both name and value for all variables.');36  return;37  }38  }39  console.log('Variables:', variables);40  alert('Test saved!');41 }42 
Enlace
El enlace para compartir es: