Sandbox: Difference between revisions

From Hidden Mickey Wiki

No edit summary
No edit summary
Line 1: Line 1:
<htmltag tagname="script" type="text/javascript">
<htmltag tagname="script" type="text/javascript">
mw.hook('wikipage.content').add(function ($content) {
(function() {
   var logDiv = document.getElementById('debug-log');
  // IDs to check
   if (!logDiv) {
  var ids = ['Sandbox1','Sandbox2','Sandbox3'];
      logDiv = document.createElement('pre');
 
      logDiv.id = 'debug-log';
  // Create a table
      document.body.appendChild(logDiv);
  var table = document.createElement('table');
  table.style.borderCollapse = 'collapse';
  table.style.margin = '10px 0';
  table.style.width = '300px';
 
  // Table header
  var header = table.insertRow();
  header.insertCell().innerText = 'ID';
  header.insertCell().innerText = 'Checkbox State';
   header.insertCell().innerText = 'Timestamp';
    
  // Style header
  for (var i=0;i<header.cells.length;i++) {
    header.cells[i].style.border = '1px solid black';
    header.cells[i].style.padding = '4px';
    header.cells[i].style.fontWeight = 'bold';
    header.cells[i].style.textAlign = 'center';
   }
   }
   logDiv.innerText = '';
 
  for (var i = 0; i < localStorage.length; i++) {
  // Fill rows
      var key = localStorage.key(i);
   ids.forEach(function(id) {
      var value = localStorage.getItem(key);
    var row = table.insertRow();
      logDiv.innerText += key + ' ' + value + '\n';
   
   }
    // ID column
});
    var cellId = row.insertCell();
    cellId.innerText = id;
    cellId.style.border = '1px solid black';
    cellId.style.padding = '4px';
   
    // Checkbox column
    var cellCheckbox = row.insertCell();
    cellCheckbox.innerText = localStorage.getItem(id) || '(none)';
    cellCheckbox.style.border = '1px solid black';
    cellCheckbox.style.padding = '4px';
    cellCheckbox.style.textAlign = 'center';
   
    // Timestamp column
    var cellTs = row.insertCell();
    cellTs.innerText = localStorage.getItem(id + '-ts') || '(none)';
    cellTs.style.border = '1px solid black';
    cellTs.style.padding = '4px';
    cellTs.style.textAlign = 'center';
   });
 
  // Append table to body
  document.body.appendChild(table);
})();
</htmltag>
</htmltag>

Revision as of 10:17, 1 October 2025