279 lines
No EOL
13 KiB
HTML
279 lines
No EOL
13 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>MIME Type Reference</title>
|
|
<style>
|
|
body, html {
|
|
margin: 0; padding: 0; font-family: "Helvetica Neue", Arial, sans-serif;
|
|
background-color: #f4f7f6; color: #333; font-size: 16px;
|
|
}
|
|
.page-header {
|
|
background-color: #2a3f54; color: #e1e1e1; padding: 20px 30px;
|
|
text-align: center; border-bottom: 3px solid #1a2c3a;
|
|
}
|
|
.page-header h1 { margin: 0; font-size: 2em; font-weight: 300; letter-spacing: 1px; }
|
|
.content-wrapper { max-width: 900px; margin: 30px auto; padding: 0 20px; }
|
|
.search-container {
|
|
margin-bottom: 30px; padding: 15px; background-color: #fff;
|
|
border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.08);
|
|
}
|
|
.search-input {
|
|
width: 100%; padding: 12px 15px; font-size: 1.1em;
|
|
border: 1px solid #dce4ec; border-radius: 4px; box-sizing: border-box;
|
|
transition: border-color 0.3s, box-shadow 0.3s;
|
|
}
|
|
.search-input:focus {
|
|
outline: none; border-color: #5c97bf;
|
|
box-shadow: 0 0 0 3px rgba(92,151,191,0.2);
|
|
}
|
|
.status-text {
|
|
text-align: center; font-size: 1.2em; color: #777; padding: 40px 20px;
|
|
background-color: #fff; border-radius: 6px; margin-top: 20px;
|
|
}
|
|
.status-text.error {
|
|
color: #c0392b; background-color: #fdecea; border: 1px solid #f5c6cb;
|
|
}
|
|
.mime-category, .obsolete-main-section { /* Shared styling for main blocks */
|
|
margin-bottom: 35px; background-color: #fff; border-radius: 6px;
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.08); overflow: hidden;
|
|
}
|
|
.category-title-bar, .obsolete-main-title-bar { /* Shared for main titles */
|
|
background-color: #e8eff5; color: #3a506b; padding: 12px 20px;
|
|
border-bottom: 1px solid #dce4ec;
|
|
}
|
|
.obsolete-main-section .obsolete-main-title-bar { /* Specific for main obsolete title */
|
|
background-color: #fadbd8; color: #78281f; border-bottom-color: #f1c1bc;
|
|
}
|
|
.category-title-bar h2, .obsolete-main-title-bar h2 { margin: 0; font-size: 1.5em; font-weight: 400; }
|
|
|
|
/* Styling for sub-categories within Obsolete section */
|
|
.obsolete-subcategory {
|
|
margin: 10px 20px; /* Indent subcategories */
|
|
border: 1px solid #eef2f7; /* Lighter border for sub-items */
|
|
border-radius: 4px;
|
|
}
|
|
.obsolete-subcategory-header {
|
|
background-color: #f8f9fa; /* Very light grey for sub-headers */
|
|
color: #495057;
|
|
padding: 8px 15px;
|
|
border-bottom: 1px solid #eef2f7;
|
|
cursor: pointer;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
.obsolete-subcategory-header:hover { background-color: #f1f3f5; }
|
|
.obsolete-subcategory-header h3 { font-size: 1.1em; font-weight: 500; margin:0; }
|
|
.toggle-arrow { font-size: 0.9em; transition: transform 0.2s; }
|
|
.obsolete-subcategory.open .toggle-arrow { transform: rotate(90deg); }
|
|
|
|
.mime-item-list, .obsolete-subcategory-list { padding: 10px 20px 20px 20px; }
|
|
.obsolete-subcategory-list { display: none; padding: 10px 15px; } /* Collapsed by default */
|
|
.obsolete-subcategory.open .obsolete-subcategory-list { display: block; }
|
|
|
|
|
|
.mime-entry { padding: 12px 0; border-bottom: 1px solid #f0f3f5; }
|
|
.mime-entry:last-child { border-bottom: none; }
|
|
.mime-name {
|
|
font-size: 1.1em; font-weight: 500; color: #2c3e50; margin-bottom: 4px;
|
|
}
|
|
.mime-template {
|
|
font-family: "SFMono-Regular", Consolas, Menlo, Courier, monospace;
|
|
font-size: 0.95em; color: #555; background-color: #f8f9fa;
|
|
padding: 3px 6px; border-radius: 3px; display: inline-block;
|
|
word-break: break-all;
|
|
}
|
|
.hidden { display: none !important; }
|
|
@media (max-width: 768px) {
|
|
.page-header h1 { font-size: 1.6em; }
|
|
.content-wrapper { margin-top: 20px; padding: 0 15px; }
|
|
.category-title-bar h2, .obsolete-main-title-bar h2 { font-size: 1.3em; }
|
|
.obsolete-subcategory-header h3 { font-size: 1em; }
|
|
.mime-name { font-size: 1em; }
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<header class="page-header"><h1>MIME Type Reference</h1></header>
|
|
<div class="content-wrapper">
|
|
<div class="search-container">
|
|
<input type="text" id="searchInput" class="search-input" placeholder="Search types (e.g., json, text/plain)...">
|
|
</div>
|
|
<div id="mimeDisplayArea">
|
|
<p id="loadingIndicator" class="status-text">Loading MIME types...</p>
|
|
<p id="noResultsIndicator" class="status-text hidden">No matching MIME types found.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<script async>
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
const displayArea = document.getElementById('mimeDisplayArea');
|
|
const searchInput = document.getElementById('searchInput');
|
|
const loadingIndicator = document.getElementById('loadingIndicator');
|
|
const noResultsIndicator = document.getElementById('noResultsIndicator');
|
|
let searchTimeout;
|
|
|
|
let allMimeData = {};
|
|
const MAIN_CATEGORY_ORDER = [
|
|
"text", "image", "audio", "video", "application",
|
|
"font", "model", "multipart", "message", "haptics"
|
|
];
|
|
const OBSOLETE_DATA_KEY = "obsolete_deprecated";
|
|
|
|
function createMimeEntryHTML(type) {
|
|
return `
|
|
<div class="mime-entry">
|
|
<div class="mime-name">${type.name}</div>
|
|
<div class="mime-template">${type.template}</div>
|
|
</div>`;
|
|
}
|
|
|
|
function createCategorySectionDOM(categoryKey, categoryTitle, typesToDisplay) {
|
|
const sectionDiv = document.createElement('div');
|
|
sectionDiv.className = 'mime-category';
|
|
sectionDiv.innerHTML = `
|
|
<div class="category-title-bar">
|
|
<h2>${categoryTitle} (${typesToDisplay.length})</h2>
|
|
</div>
|
|
<div class="mime-item-list">
|
|
${typesToDisplay.map(createMimeEntryHTML).join('')}
|
|
</div>`;
|
|
return sectionDiv;
|
|
}
|
|
|
|
function createObsoleteSectionDOM(obsoleteData, searchTerm) {
|
|
const mainObsoleteSection = document.createElement('div');
|
|
mainObsoleteSection.className = 'obsolete-main-section';
|
|
|
|
let totalObsoleteCount = 0;
|
|
let subCategoryHTML = '';
|
|
|
|
// Iterate through original categories within obsolete_deprecated data
|
|
// The keys in obsoleteData are the original category names (e.g., "text")
|
|
for (const originalCatKey in obsoleteData) {
|
|
if (obsoleteData.hasOwnProperty(originalCatKey)) {
|
|
let typesForSubCat = obsoleteData[originalCatKey];
|
|
let filteredSubCatTypes = typesForSubCat;
|
|
|
|
if (searchTerm) {
|
|
filteredSubCatTypes = typesForSubCat.filter(type =>
|
|
type.name.toLowerCase().includes(searchTerm) ||
|
|
type.template.toLowerCase().includes(searchTerm)
|
|
);
|
|
}
|
|
|
|
if (filteredSubCatTypes.length > 0) {
|
|
totalObsoleteCount += filteredSubCatTypes.length;
|
|
const originalCatTitle = originalCatKey.charAt(0).toUpperCase() + originalCatKey.slice(1);
|
|
|
|
subCategoryHTML += `
|
|
<div class="obsolete-subcategory">
|
|
<div class="obsolete-subcategory-header">
|
|
<h3>From: ${originalCatTitle} (${filteredSubCatTypes.length})</h3>
|
|
<span class="toggle-arrow">▶</span>
|
|
</div>
|
|
<div class="obsolete-subcategory-list">
|
|
${filteredSubCatTypes.map(createMimeEntryHTML).join('')}
|
|
</div>
|
|
</div>`;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (totalObsoleteCount === 0 && searchTerm) return null; // No matching obsolete items for search
|
|
if (totalObsoleteCount === 0 && !searchTerm) return null; // No obsolete items at all
|
|
|
|
|
|
mainObsoleteSection.innerHTML = `
|
|
<div class="obsolete-main-title-bar">
|
|
<h2>Obsolete / Deprecated (${totalObsoleteCount})</h2>
|
|
</div>
|
|
<div class="obsolete-subcategories-container">
|
|
${subCategoryHTML}
|
|
</div>`;
|
|
|
|
// Add event listeners for collapsible subcategories
|
|
mainObsoleteSection.querySelectorAll('.obsolete-subcategory-header').forEach(header => {
|
|
header.addEventListener('click', () => {
|
|
header.parentElement.classList.toggle('open');
|
|
});
|
|
});
|
|
return mainObsoleteSection;
|
|
}
|
|
|
|
|
|
function renderMimeData(data, searchTerm = "") {
|
|
displayArea.innerHTML = '';
|
|
let foundAnyContent = false;
|
|
const lowerSearchTerm = searchTerm.toLowerCase().trim();
|
|
|
|
// Render main categories
|
|
MAIN_CATEGORY_ORDER.forEach(categoryKey => {
|
|
if (data[categoryKey]) {
|
|
let typesToDisplay = data[categoryKey];
|
|
if (lowerSearchTerm) {
|
|
typesToDisplay = typesToDisplay.filter(type =>
|
|
type.name.toLowerCase().includes(lowerSearchTerm) ||
|
|
type.template.toLowerCase().includes(lowerSearchTerm)
|
|
);
|
|
}
|
|
if (typesToDisplay.length > 0) {
|
|
foundAnyContent = true;
|
|
const categoryTitle = categoryKey.charAt(0).toUpperCase() + categoryKey.slice(1);
|
|
displayArea.appendChild(
|
|
createCategorySectionDOM(categoryKey, categoryTitle, typesToDisplay)
|
|
);
|
|
}
|
|
}
|
|
});
|
|
|
|
// Render obsolete/deprecated section
|
|
if (data[OBSOLETE_DATA_KEY]) {
|
|
const obsoleteSectionElement = createObsoleteSectionDOM(data[OBSOLETE_DATA_KEY], lowerSearchTerm);
|
|
if (obsoleteSectionElement) {
|
|
displayArea.appendChild(obsoleteSectionElement);
|
|
foundAnyContent = true; // Count if obsolete section has content
|
|
}
|
|
}
|
|
|
|
loadingIndicator.classList.add('hidden');
|
|
noResultsIndicator.classList.toggle('hidden', foundAnyContent || !lowerSearchTerm);
|
|
|
|
if (!foundAnyContent && !lowerSearchTerm && Object.keys(data).length === 0) {
|
|
displayArea.innerHTML = '<p class="status-text error">MIME type data is empty or not loaded.</p>';
|
|
} else if (!foundAnyContent && !lowerSearchTerm && Object.keys(data).length > 0 && !data[OBSOLETE_DATA_KEY] && MAIN_CATEGORY_ORDER.every(k => !data[k] || data[k].length === 0)) {
|
|
displayArea.innerHTML = '<p class="status-text">No MIME type data available in active categories.</p>';
|
|
}
|
|
}
|
|
|
|
fetch('mime_types.json')
|
|
.then(response => {
|
|
if (!response.ok) throw new Error(`Failed to load mime_types.json: ${response.status} ${response.statusText}`);
|
|
return response.json();
|
|
})
|
|
.then(data => {
|
|
allMimeData = data;
|
|
renderMimeData(allMimeData);
|
|
})
|
|
.catch(error => {
|
|
console.error('Error fetching/processing MIME data:', error);
|
|
loadingIndicator.classList.add('hidden');
|
|
displayArea.innerHTML = `<p class="status-text error">Error: ${error.message}</p>`;
|
|
});
|
|
|
|
function debounce(func, delay) {
|
|
return function(...args) {
|
|
clearTimeout(searchTimeout);
|
|
searchTimeout = setTimeout(() => func.apply(this, args), delay);
|
|
};
|
|
}
|
|
|
|
searchInput.addEventListener('input', debounce((e) => {
|
|
renderMimeData(allMimeData, e.target.value)
|
|
}, 250));
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |