Files
robot-plugins/index.html

230 lines
9.7 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HRIStudio Robot Plugins</title>
<link rel="stylesheet" href="assets/style.css">
</head>
<body>
<button id="themeToggle" class="theme-toggle" aria-label="Toggle theme">
<svg id="themeIcon" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="5"/>
<line x1="12" y1="1" x2="12" y2="3"/>
<line x1="12" y1="21" x2="12" y2="23"/>
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/>
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/>
<line x1="1" y1="12" x2="3" y2="12"/>
<line x1="21" y1="12" x2="23" y2="12"/>
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/>
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/>
</svg>
</button>
<div class="container">
<div id="loading">Loading repository data...</div>
<div id="content" class="hidden">
<!-- Header -->
<div class="header">
<img id="repoIcon" alt="Repository Icon" class="hidden">
<div>
<h1 id="repoName" class="title"></h1>
<p id="repoDescription" class="description"></p>
</div>
</div>
<img id="repoBanner" class="banner hidden">
<!-- Stats -->
<div class="card">
<div class="stat">
<span>Plugins:</span>
<span id="pluginCount"></span>
</div>
</div>
<!-- Details -->
<div class="grid grid-cols-2">
<!-- Author Info -->
<div class="card">
<h2>Author</h2>
<div class="content">
<div>
<span>Name:</span>
<span id="authorName"></span>
</div>
<div id="authorOrgContainer" class="hidden">
<span>Organization:</span>
<span id="authorOrg"></span>
</div>
<div id="authorUrlContainer" class="hidden">
<a id="authorUrl" target="_blank">View Profile</a>
</div>
</div>
</div>
<!-- Compatibility -->
<div class="card">
<h2>Compatibility</h2>
<div>
<h3>HRIStudio</h3>
<div>
<span>Min Version:</span>
<code id="hriMin"></code>
</div>
<div id="hriRecommendedContainer" class="hidden">
<span>Recommended:</span>
<code id="hriRecommended"></code>
</div>
</div>
<div id="ros2Container" class="hidden">
<h3>ROS 2</h3>
<div id="ros2Distributions"></div>
<div id="ros2RecommendedContainer" class="hidden">
<span>Recommended:</span>
<code id="ros2Recommended"></code>
</div>
</div>
</div>
</div>
<!-- Tags -->
<div class="card">
<h2>Tags</h2>
<div id="tags"></div>
</div>
</div>
</div>
<script>
// Theme management
const themeToggle = document.getElementById('themeToggle');
const themeIcon = document.getElementById('themeIcon');
// Check for saved theme preference or system preference
const savedTheme = localStorage.getItem('theme');
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const defaultTheme = savedTheme || (prefersDark ? 'dark' : 'light');
// Apply theme
function setTheme(theme) {
document.documentElement.setAttribute('data-theme', theme);
localStorage.setItem('theme', theme);
// Update icon
if (theme === 'dark') {
themeIcon.innerHTML = `
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z" />
`;
} else {
themeIcon.innerHTML = `
<circle cx="12" cy="12" r="5"/>
<line x1="12" y1="1" x2="12" y2="3"/>
<line x1="12" y1="21" x2="12" y2="23"/>
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/>
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/>
<line x1="1" y1="12" x2="3" y2="12"/>
<line x1="21" y1="12" x2="23" y2="12"/>
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/>
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/>
`;
}
}
// Set initial theme
setTheme(defaultTheme);
// Theme toggle handler
themeToggle.addEventListener('click', () => {
const currentTheme = document.documentElement.getAttribute('data-theme');
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
setTheme(newTheme);
});
// Repository data loading
async function loadRepositoryData() {
try {
const response = await fetch('repository.json');
const data = await response.json();
// Update page title
document.title = data.name;
// Update header
document.getElementById('repoName').textContent = data.name;
document.getElementById('repoDescription').textContent = data.description || '';
// Update stats
document.getElementById('pluginCount').textContent = data.stats?.plugins || 0;
// Update author info
document.getElementById('authorName').textContent = data.author.name;
if (data.author.organization) {
document.getElementById('authorOrgContainer').classList.remove('hidden');
document.getElementById('authorOrg').textContent = data.author.organization;
}
if (data.author.url) {
document.getElementById('authorUrlContainer').classList.remove('hidden');
document.getElementById('authorUrl').href = data.author.url;
}
// Update compatibility
document.getElementById('hriMin').textContent = data.compatibility.hristudio.min;
if (data.compatibility.hristudio.recommended) {
document.getElementById('hriRecommendedContainer').classList.remove('hidden');
document.getElementById('hriRecommended').textContent = data.compatibility.hristudio.recommended;
}
if (data.compatibility.ros2) {
document.getElementById('ros2Container').classList.remove('hidden');
const distributionsDiv = document.getElementById('ros2Distributions');
data.compatibility.ros2.distributions.forEach(dist => {
const badge = document.createElement('span');
badge.className = 'badge';
badge.textContent = dist;
distributionsDiv.appendChild(badge);
});
if (data.compatibility.ros2.recommended) {
document.getElementById('ros2RecommendedContainer').classList.remove('hidden');
document.getElementById('ros2Recommended').textContent = data.compatibility.ros2.recommended;
}
}
// Update tags
const tagsContainer = document.getElementById('tags');
data.tags.forEach(tag => {
const badge = document.createElement('span');
badge.className = 'tag';
badge.textContent = tag;
tagsContainer.appendChild(badge);
});
// Handle assets
if (data.assets?.icon) {
const iconImg = document.getElementById('repoIcon');
iconImg.src = data.assets.icon;
iconImg.classList.remove('hidden');
}
if (data.assets?.banner) {
const banner = document.getElementById('repoBanner');
banner.src = data.assets.banner;
banner.classList.remove('hidden');
}
// Show content
document.getElementById('loading').classList.add('hidden');
document.getElementById('content').classList.remove('hidden');
} catch (error) {
console.error('Error loading repository data:', error);
document.getElementById('loading').textContent = 'Error loading repository data';
}
}
// Load data when page loads
loadRepositoryData();
</script>
</body>
</html>