Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ const csvData = `算法名称,角色,主体名称,应用产品,主要用途,备案编号,批次,备注,场景,输入,输出,用户,其他特色
+ 大麦小蜜智能客服算法,服务提供者,北京大麦文化传媒发展有限公司,大麦(APP),"['应用于在线智能客服场景', '根据用户咨询内容', '生成文本或语音智能回答', '']",网信算备110101128387701230011号,1,,在线智能客服,咨询内容,文本或语音智能回答,,
+ DraftAi绘图生成合成算法-1,服务提供者,图形起源(北京)科技有限公司,Draft(网站),"['应用于图像生成场景', '使用文本条件图像生成模型', '生成与输入文本语义一致的图像', '']",网信算备110108007153201230015号,1,,图像生成,生成与文本语义一致图像,,,`;
+
+ const algorithms = parseCSV(csvData);
+ const grid = document.getElementById('algorithmGrid');
+ const template = document.getElementById('algorithmTemplate');
+ const searchInput = document.getElementById('searchInput');
+ const categoryFilter = document.getElementById('categoryFilter');
+
+ function parseCSV(csv) {
+ const lines = csv.split('\n');
+ const headers = lines[0].split(',');
+ return lines.slice(1).map(line => {
+ const values = line.split(',');
+ return headers.reduce((obj, header, index) => {
+ obj[header] = values[index];
+ return obj;
+ }, {});
+ });
+ }
+
+ function renderAlgorithms(filteredAlgorithms) {
+ grid.innerHTML = '';
+ filteredAlgorithms.forEach(algo => {
+ const card = template.content.cloneNode(true);
+ card.querySelector('.algorithm-name').textContent = algo['算法名称'];
+ card.querySelector('.provider').textContent = `Role: ${algo['角色']}`;
+ card.querySelector('.company').textContent = `Company: ${algo['主体名称']}`;
+ card.querySelector('.product').textContent = `Product: ${algo['应用产品']}`;
+ card.querySelector('.registration').textContent = `Registration: ${algo['备案编号']}`;
+ card.querySelector('.input').textContent = `Input: ${algo['输入']}`;
+ card.querySelector('.output').textContent = `Output: ${algo['输出']}`;
+
+ const uses = JSON.parse(algo['主要用途'].replace(/'/g, '"'));
+ const usesElement = card.querySelector('.uses');
+ uses.forEach(use => {
+ if (use) {
+ const p = document.createElement('p');
+ p.textContent = use;
+ usesElement.appendChild(p);
+ }
+ });
+
+ grid.appendChild(card);
+ });
+ }
+
+ function filterAlgorithms() {
+ const searchTerm = searchInput.value.toLowerCase();
+ const category = categoryFilter.value;
+
+ const filtered = algorithms.filter(algo => {
+ const matchesSearch = Object.values(algo).some(value =>
+ value.toLowerCase().includes(searchTerm)
+ );
+ const matchesCategory = !category || algo['场景'] === category;
+ return matchesSearch && matchesCategory;
+ });
+
+ renderAlgorithms(filtered);
+ }
+
+ searchInput.addEventListener('input', filterAlgorithms);
+ categoryFilter.addEventListener('change', filterAlgorithms);
+
+ renderAlgorithms(algorithms);
+ });