mirror of
https://github.com/MrUnknownDE/utools.git
synced 2026-04-17 13:23:45 +02:00
try again mac-lookup
This commit is contained in:
@@ -88,11 +88,11 @@
|
||||
<h1>uTools Network Suite</h1> <!-- Name angepasst -->
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="index.html">IP Info & Tools</a></li> <!-- Angepasst -->
|
||||
<li><a href="index.html">IP Info & Tools</a></li>
|
||||
<li><a href="subnet-calculator.html">Subnetz Rechner</a></li>
|
||||
<li><a href="dns-lookup.html">DNS Lookup</a></li>
|
||||
<li><a href="whois-lookup.html">WHOIS Lookup</a></li>
|
||||
<!-- REMOVED: MAC Lookup Link -->
|
||||
<li><a href="mac-lookup.html">MAC Lookup</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
90
frontend/app/mac-lookup.html
Normal file
90
frontend/app/mac-lookup.html
Normal file
@@ -0,0 +1,90 @@
|
||||
// frontend/app/mac-lookup.html
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>MAC Vendor Lookup - uTools</title>
|
||||
<!-- Tailwind CSS Play CDN -->
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<!-- Eigene Styles -->
|
||||
<style>
|
||||
.loader {
|
||||
border: 4px solid rgba(168, 85, 247, 0.3);
|
||||
border-left-color: #a855f7;
|
||||
border-radius: 50%;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
@keyframes spin { to { transform: rotate(360deg); } }
|
||||
.result-pre {
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
font-family: monospace;
|
||||
background-color: #1f2937;
|
||||
color: #d1d5db;
|
||||
padding: 1rem;
|
||||
border-radius: 0.375rem;
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
font-size: 1.25rem; /* Larger font for the result */
|
||||
text-align: center;
|
||||
}
|
||||
nav ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 1rem; }
|
||||
nav a { color: #c4b5fd; text-decoration: none; white-space: nowrap; }
|
||||
nav a:hover { color: #a78bfa; text-decoration: underline; }
|
||||
header { background-color: #374151; padding: 1rem; margin-bottom: 1.5rem; border-radius: 0.5rem; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
|
||||
@media (min-width: 768px) { header { flex-direction: row; justify-content: space-between; } }
|
||||
header h1 { font-size: 1.5rem; font-weight: bold; color: #e5e7eb; }
|
||||
.hidden { display: none; }
|
||||
</style>
|
||||
</head>
|
||||
<body class="bg-gray-900 text-gray-200 font-sans p-4 md:p-8">
|
||||
|
||||
<header>
|
||||
<h1>uTools Network Suite</h1>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="index.html">IP Info & Tools</a></li>
|
||||
<li><a href="subnet-calculator.html">Subnetz Rechner</a></li>
|
||||
<li><a href="dns-lookup.html">DNS Lookup</a></li>
|
||||
<li><a href="whois-lookup.html">WHOIS Lookup</a></li>
|
||||
<li><a href="mac-lookup.html">MAC Lookup</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<div class="container mx-auto max-w-4xl bg-gray-800 rounded-lg shadow-xl p-6">
|
||||
|
||||
<h1 class="text-3xl font-bold mb-6 text-purple-400 text-center">MAC Address Vendor Lookup</h1>
|
||||
|
||||
<div class="mt-8 p-4 bg-gray-700 rounded">
|
||||
<div class="flex flex-col sm:flex-row gap-2 mb-4">
|
||||
<input type="text" id="mac-input" placeholder="Enter MAC address (e.g., 00:1A:2B:3C:4D:5E)"
|
||||
class="flex-grow px-3 py-2 bg-gray-800 border border-gray-600 rounded text-gray-200 focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent font-mono">
|
||||
<button id="mac-lookup-button"
|
||||
class="bg-purple-600 hover:bg-purple-700 text-white font-bold py-2 px-4 rounded transition duration-150 ease-in-out">
|
||||
Find Vendor
|
||||
</button>
|
||||
</div>
|
||||
<div id="mac-lookup-error" class="text-red-400 mb-4 hidden"></div>
|
||||
<div id="mac-lookup-results-section" class="hidden mt-4 border-t border-gray-600 pt-4">
|
||||
<h3 class="text-lg font-semibold text-purple-300 mb-2">Vendor for: <span id="mac-lookup-query" class="font-mono text-purple-400"></span></h3>
|
||||
<div id="mac-lookup-loader" class="loader hidden mb-2 mx-auto"></div>
|
||||
<pre id="mac-lookup-output" class="result-pre"></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="global-error" class="mt-6 p-4 bg-red-800 text-red-100 rounded hidden"></div>
|
||||
|
||||
<footer class="mt-8 pt-4 border-t border-gray-600 text-center text-xs text-gray-500">
|
||||
<p>© 2025 <a href="https://johanneskr.de" class="text-purple-400 hover:underline">Johannes Krüger</a></p>
|
||||
<p>Version: <span id="commit-sha" class="font-mono">loading...</span></p>
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="mac-lookup.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
77
frontend/app/mac-lookup.js
Normal file
77
frontend/app/mac-lookup.js
Normal file
@@ -0,0 +1,77 @@
|
||||
// frontend/app/mac-lookup.js
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const macInput = document.getElementById('mac-input');
|
||||
const macLookupButton = document.getElementById('mac-lookup-button');
|
||||
const macLookupErrorEl = document.getElementById('mac-lookup-error');
|
||||
const macLookupResultsSection = document.getElementById('mac-lookup-results-section');
|
||||
const macLookupQueryEl = document.getElementById('mac-lookup-query');
|
||||
const macLookupLoader = document.getElementById('mac-lookup-loader');
|
||||
const macLookupOutputEl = document.getElementById('mac-lookup-output');
|
||||
const commitShaEl = document.getElementById('commit-sha');
|
||||
const globalErrorEl = document.getElementById('global-error');
|
||||
|
||||
const API_BASE_URL = '/api';
|
||||
|
||||
function showGlobalError(message) {
|
||||
if (!globalErrorEl) return;
|
||||
globalErrorEl.textContent = `Error: ${message}`;
|
||||
globalErrorEl.classList.remove('hidden');
|
||||
}
|
||||
|
||||
async function fetchVersionInfo() {
|
||||
if (!commitShaEl) return;
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/version`);
|
||||
if (!response.ok) throw new Error(`Network response: ${response.statusText}`);
|
||||
const data = await response.json();
|
||||
commitShaEl.textContent = data.commitSha || 'unknown';
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch version info:', error);
|
||||
commitShaEl.textContent = 'error';
|
||||
}
|
||||
}
|
||||
|
||||
function displayMacResult(data, outputEl) {
|
||||
outputEl.textContent = data.vendor || 'No vendor found.';
|
||||
}
|
||||
|
||||
async function handleMacLookup() {
|
||||
const mac = macInput.value.trim();
|
||||
if (!mac) {
|
||||
macLookupErrorEl.textContent = 'Please enter a MAC address.';
|
||||
macLookupErrorEl.classList.remove('hidden');
|
||||
return;
|
||||
}
|
||||
|
||||
macLookupResultsSection.classList.remove('hidden');
|
||||
macLookupLoader.classList.remove('hidden');
|
||||
macLookupErrorEl.classList.add('hidden');
|
||||
macLookupOutputEl.textContent = '';
|
||||
macLookupQueryEl.textContent = mac;
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/mac-lookup?mac=${encodeURIComponent(mac)}`);
|
||||
const data = await response.json();
|
||||
|
||||
if (!response.ok || !data.success) {
|
||||
throw new Error(data.error || `Request failed with status ${response.status}`);
|
||||
}
|
||||
|
||||
displayMacResult(data, macLookupOutputEl);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch MAC vendor:', error);
|
||||
macLookupErrorEl.textContent = `Error: ${error.message}`;
|
||||
macLookupErrorEl.classList.remove('hidden');
|
||||
macLookupOutputEl.textContent = '';
|
||||
} finally {
|
||||
macLookupLoader.classList.add('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
fetchVersionInfo();
|
||||
macLookupButton.addEventListener('click', handleMacLookup);
|
||||
macInput.addEventListener('keypress', (event) => {
|
||||
if (event.key === 'Enter') handleMacLookup();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user