Spaces:
Sleeping
Sleeping
File size: 5,045 Bytes
d97b8f9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
#mobile-console {
display: none;
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 200px;
background-color: #000;
color: #fff;
font-family: monospace;
overflow-y: auto;
z-index: 9999;
border-top: 2px solid #444;
padding: 10px;
box-sizing: border-box;
}
#console-toggle {
position: fixed;
bottom: 10px;
right: 10px;
width: 60px;
height: 60px;
background-color: red;
color: white;
border-radius: 50%;
text-align: center;
line-height: 60px;
font-weight: bold;
z-index: 10000;
cursor: pointer;
box-shadow: 0 0 10px rgba(0,0,0,0.5);
user-select: none;
}
.log-entry {
margin: 5px 0;
border-bottom: 1px solid #333;
padding-bottom: 5px;
word-wrap: break-word;
}
.log-entry.error { color: #ff5252; }
.log-entry.warn { color: #ffab40; }
.log-entry.info { color: #2196f3; }
.log-entry.log { color: #ffffff; }
</style>
</head>
<body>
<div id="root"></div>
<!-- Mobile Console Elements -->
<div id="mobile-console"></div>
<div id="console-toggle">LOGS</div>
<script>
// Make sure the script runs even if DOMContentLoaded already fired
function initMobileConsole() {
var consoleEl = document.getElementById('mobile-console');
var toggleEl = document.getElementById('console-toggle');
var isVisible = false;
// Create toggle functionality
toggleEl.addEventListener('click', function() {
isVisible = !isVisible;
consoleEl.style.display = isVisible ? 'block' : 'none';
toggleEl.textContent = isVisible ? 'HIDE' : 'LOGS';
});
// Force a few test logs
setTimeout(function() {
console.log('Mobile console is ready!');
console.info('This is an info message');
console.warn('This is a warning message');
console.error('This is an error message');
}, 1000);
// Store original console methods
var originalConsole = {
log: console.log,
info: console.info,
warn: console.warn,
error: console.error
};
// Override console methods
console.log = function() {
originalConsole.log.apply(console, arguments);
addLogEntry('log', arguments);
};
console.info = function() {
originalConsole.info.apply(console, arguments);
addLogEntry('info', arguments);
};
console.warn = function() {
originalConsole.warn.apply(console, arguments);
addLogEntry('warn', arguments);
};
console.error = function() {
originalConsole.error.apply(console, arguments);
addLogEntry('error', arguments);
};
// Handle window errors
window.onerror = function(message, source, lineno, colno, error) {
console.error('ERROR:', message, 'at', source, lineno + ':' + colno);
};
// Add log entry to console
function addLogEntry(type, args) {
var entry = document.createElement('div');
entry.className = 'log-entry ' + type;
var timestamp = new Date().toLocaleTimeString();
var prefix = '[' + timestamp + '] ' + type.toUpperCase() + ': ';
var text = prefix;
for (var i = 0; i < args.length; i++) {
if (typeof args[i] === 'object') {
try {
text += JSON.stringify(args[i]) + ' ';
} catch (e) {
text += "[Object] ";
}
} else {
text += args[i] + ' ';
}
}
entry.textContent = text;
consoleEl.appendChild(entry);
consoleEl.scrollTop = consoleEl.scrollHeight;
// Flash the toggle button to indicate new log
if (!isVisible) {
toggleEl.style.backgroundColor = 'green';
setTimeout(function() {
toggleEl.style.backgroundColor = 'red';
}, 300);
}
}
console.log('Mobile console initialized');
}
// Run the initialization
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initMobileConsole);
} else {
initMobileConsole();
}
</script>
</body>
</html> |