-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathindex.html
More file actions
214 lines (194 loc) · 9.94 KB
/
Copy pathindex.html
File metadata and controls
214 lines (194 loc) · 9.94 KB
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Advanced Template Browser</title>
<style>
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; line-height: 1.6; color: #333; }
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }
h1 { text-align: center; color: #1a1a1a; }
.filters { display: flex; justify-content: space-between; margin-bottom: 20px; background: #f9f9f9; padding: 15px; border-radius: 8px; }
.filters input, .filters select { padding: 10px; font-size: 16px; border: 1px solid #ddd; border-radius: 4px; }
.card-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.card { background: #fff; border: 1px solid #ddd; border-radius: 8px; padding: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); transition: transform 0.2s; }
.card:hover { transform: translateY(-5px); }
.card h2 { font-size: 1.2rem; margin: 0 0 10px; }
.card p { margin: 0 0 15px; color: #666; }
.tags { margin-bottom: 15px; }
.tag { display: inline-block; background: #eee; padding: 5px 10px; border-radius: 12px; font-size: 0.8rem; margin-right: 5px; }
.quality-score { display: inline-block; padding: 5px 10px; border-radius: 12px; font-size: 0.8rem; margin-right: 5px; font-weight: bold; }
.quality-excellent { background: #28a745; color: white; }
.quality-good { background: #ffc107; color: black; }
.quality-fair { background: #fd7e14; color: white; }
.quality-poor { background: #dc3545; color: white; }
.card a { background: #007bff; color: #fff; text-decoration: none; padding: 10px 15px; border-radius: 4px; display: inline-block; }
.related-templates { margin-top: 15px; padding-top: 15px; border-top: 1px solid #eee; }
.related-templates h4 { font-size: 0.9rem; margin: 0 0 8px; color: #666; }
.related-templates ul { list-style: none; padding: 0; margin: 0; }
.related-templates li { margin-bottom: 5px; }
.related-templates a { background: none; color: #007bff; padding: 0; font-size: 0.8rem; text-decoration: underline; }
.feedback-widget { background: #f8f9fa; border: 1px solid #e9ecef; border-radius: 4px; padding: 10px; margin-top: 10px; }
.feedback-widget h5 { margin: 0 0 8px; font-size: 0.9rem; color: #495057; }
.rating-stars { display: flex; gap: 2px; margin-bottom: 8px; }
.star { cursor: pointer; color: #ccc; font-size: 1.2rem; transition: color 0.2s; }
.star:hover, .star.active { color: #ffc107; }
.feedback-form { display: none; margin-top: 10px; }
.feedback-form textarea { width: 100%; height: 60px; padding: 5px; border: 1px solid #ddd; border-radius: 3px; font-size: 0.8rem; }
.feedback-form button { background: #28a745; color: white; border: none; padding: 5px 10px; border-radius: 3px; font-size: 0.8rem; cursor: pointer; margin-top: 5px; }
.feedback-form button:hover { background: #218838; }
</style>
</head>
<body>
<div class="container">
<h1>Advanced Template Browser</h1>
<div class="filters">
<input type="text" id="search-input" placeholder="Search by keyword...">
<select id="methodology-filter">
<option value="all">All Methodologies</option>
</select>
<select id="complexity-filter">
<option value="all">All Complexities</option>
</select>
<select id="sort-by">
<option value="title">Sort by Title</option>
<option value="updated">Sort by Updated</option>
<option value="quality">Sort by Quality Score</option>
</select>
</div>
<div id="card-container"></div>
</div>
<script>
let allTemplates = [];
async function fetchTemplates() {
const response = await fetch('templates.json');
const data = await response.json();
allTemplates = data.templates;
populateFilters(data.statistics);
renderTemplates(allTemplates);
}
function populateFilters(stats) {
const methodologyFilter = document.getElementById('methodology-filter');
for (const methodology in stats.byMethodology) {
const option = document.createElement('option');
option.value = methodology;
option.textContent = `${methodology.charAt(0).toUpperCase() + methodology.slice(1)} (${stats.byMethodology[methodology]})`;
methodologyFilter.appendChild(option);
}
const complexityFilter = document.getElementById('complexity-filter');
for (const complexity in stats.byComplexity) {
const option = document.createElement('option');
option.value = complexity;
option.textContent = `${complexity.charAt(0).toUpperCase() + complexity.slice(1)} (${stats.byComplexity[complexity]})`;
complexityFilter.appendChild(option);
}
}
function getQualityScoreClass(score) {
if (score >= 85) return 'quality-excellent';
if (score >= 70) return 'quality-good';
if (score >= 50) return 'quality-fair';
return 'quality-poor';
}
function renderTemplates(templates) {
const container = document.getElementById('card-container');
container.innerHTML = '';
templates.forEach(template => {
const card = document.createElement('div');
card.className = 'card';
const qualityScore = template.qualityScore || 0;
const qualityClass = getQualityScoreClass(qualityScore);
card.innerHTML = `
<h2>${template.title}</h2>
<p>${template.description}</p>
<div class="tags">
<span class="quality-score ${qualityClass}">Quality: ${qualityScore}/100</span>
<span class="tag">${template.methodology}</span>
<span class="tag">${template.complexity}</span>
${template.tags.map(tag => `<span class="tag">${tag}</span>`).join('')}
</div>
<a href="/${template.path}" target="_blank">View Template</a>
<p style="font-size: 0.8rem; color: #999; margin-top: 10px;">Updated: ${template.updated}</p>
<div class="related-templates">
<h4>Related Templates</h4>
<ul>
${(template.relatedTemplates || []).map(related => `<li><a href="/${related.path}">${related.title}</a> (${related.similarity}%)</li>`).join('')}
</ul>
</div>
<div class="feedback-widget">
<h5>💬 Quick Feedback</h5>
<div class="rating-stars" data-template="${template.title}">
<span class="star" data-rating="1">⭐</span>
<span class="star" data-rating="2">⭐</span>
<span class="star" data-rating="3">⭐</span>
<span class="star" data-rating="4">⭐</span>
<span class="star" data-rating="5">⭐</span>
</div>
<div class="feedback-form">
<textarea placeholder="What did you think of this template? (optional)"></textarea>
<button onclick="submitFeedback(this)">Submit Feedback</button>
</div>
</div>
`;
container.appendChild(card);
});
}
function filterAndSort() {
const searchTerm = document.getElementById('search-input').value.toLowerCase();
const methodology = document.getElementById('methodology-filter').value;
const complexity = document.getElementById('complexity-filter').value;
const sortBy = document.getElementById('sort-by').value;
let filtered = allTemplates.filter(t =>
(t.title.toLowerCase().includes(searchTerm) || t.description.toLowerCase().includes(searchTerm)) &&
(methodology === 'all' || t.methodology === methodology) &&
(complexity === 'all' || t.complexity === complexity)
);
filtered.sort((a, b) => {
if (sortBy === 'updated') {
return new Date(b.updated) - new Date(a.updated);
} else if (sortBy === 'quality') {
return (b.qualityScore || 0) - (a.qualityScore || 0);
}
return a.title.localeCompare(b.title);
});
renderTemplates(filtered);
}
document.addEventListener('DOMContentLoaded', () => {
fetchTemplates();
document.getElementById('search-input').addEventListener('input', filterAndSort);
document.getElementById('methodology-filter').addEventListener('change', filterAndSort);
document.getElementById('complexity-filter').addEventListener('change', filterAndSort);
document.getElementById('sort-by').addEventListener('change', filterAndSort);
// Event delegation for star ratings
document.getElementById('card-container').addEventListener('click', function(e) {
if (e.target && e.target.classList.contains('star')) {
const starsContainer = e.target.parentNode;
const rating = e.target.dataset.rating;
starsContainer.querySelectorAll('.star').forEach(star => {
star.classList.toggle('active', star.dataset.rating <= rating);
});
const feedbackForm = starsContainer.nextElementSibling;
feedbackForm.style.display = 'block';
}
});
});
function submitFeedback(button) {
const feedbackWidget = button.closest('.feedback-widget');
const templateName = feedbackWidget.querySelector('.rating-stars').dataset.template;
const rating = feedbackWidget.querySelectorAll('.star.active').length;
const comment = feedbackWidget.querySelector('textarea').value;
const issueTitle = `[RATING] ${templateName}`;
const issueBody = `
### Template Name
${templateName}
### Overall Rating
${rating} star(s)
### Comments
${comment}
`;
const issueUrl = `https://github.com/mirichard/pm-tools-templates/issues/new?title=${encodeURIComponent(issueTitle)}&body=${encodeURIComponent(issueBody)}&labels=template-rating,community-feedback`;
window.open(issueUrl, '_blank');
feedbackWidget.innerHTML = '<h5>✅ Thank you for your feedback!</h5>';
}
</script>
</body>
</html>