|
|
|
|
|
|
|
|
| document.addEventListener('DOMContentLoaded', function () {
|
| var modelInput = document.querySelector('input[name="model_id"]');
|
| if (modelInput) {
|
| modelInput.addEventListener('keypress', function (e) {
|
| if (e.key === 'Enter') {
|
| e.preventDefault();
|
| var btn = document.getElementById('generate-button');
|
| if (btn) btn.click();
|
| }
|
| });
|
| }
|
| });
|
|
|
|
|
|
|
|
|
| function switchTab(tabId) {
|
|
|
| var tabContents = document.getElementsByClassName('tab-content');
|
| for (var i = 0; i < tabContents.length; i++) {
|
| tabContents[i].classList.remove('active');
|
| }
|
|
|
|
|
| var tabs = document.getElementsByClassName('aibom-tab');
|
| for (var i = 0; i < tabs.length; i++) {
|
| tabs[i].classList.remove('active');
|
| }
|
|
|
|
|
| var content = document.getElementById(tabId);
|
| if (content) content.classList.add('active');
|
|
|
| var selectedTab = document.querySelector('.aibom-tab[onclick="switchTab(\'' + tabId + '\')"]');
|
| if (selectedTab) selectedTab.classList.add('active');
|
| }
|
|
|
| function toggleCollapsible(element) {
|
| element.classList.toggle('active');
|
| var content = element.nextElementSibling;
|
| if (content) {
|
| content.classList.toggle('active');
|
|
|
| if (content.classList.contains('active')) {
|
| content.style.maxHeight = content.scrollHeight + 'px';
|
| } else {
|
| content.style.maxHeight = '0';
|
| }
|
| }
|
| }
|
|
|
| |
| |
| |
| |
|
|
| function downloadJSON(content, filename) {
|
| var jsonString = (typeof content === 'string') ? content : JSON.stringify(content, null, 2);
|
| var dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(jsonString);
|
|
|
| var downloadAnchorNode = document.createElement('a');
|
| downloadAnchorNode.setAttribute("href", dataStr);
|
| downloadAnchorNode.setAttribute("download", filename || "aibom.json");
|
| document.body.appendChild(downloadAnchorNode);
|
| downloadAnchorNode.click();
|
| downloadAnchorNode.remove();
|
| }
|
|
|
|
|
| document.addEventListener('DOMContentLoaded', function () {
|
| var collapsibles = document.getElementsByClassName('collapsible');
|
| for (var i = 0; i < collapsibles.length; i++) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| }
|
|
|
| });
|
|
|
|
|
| document.addEventListener('DOMContentLoaded', function () {
|
| var modelInput = document.getElementById('model-input');
|
| var generateButton = document.getElementById('generate-button');
|
|
|
| if (modelInput && generateButton) {
|
| function validateInput() {
|
| var value = modelInput.value.trim();
|
|
|
|
|
| var isUrl = value.startsWith('https://huggingface.co/');
|
|
|
| var isModelId = /^[a-zA-Z0-9_\-\.]+\/[a-zA-Z0-9_\-\.]+$/.test(value);
|
|
|
| if (isUrl || isModelId) {
|
| generateButton.disabled = false;
|
| generateButton.style.cursor = 'pointer';
|
| generateButton.style.opacity = '1';
|
| } else {
|
| generateButton.disabled = true;
|
| generateButton.style.cursor = 'not-allowed';
|
| generateButton.style.opacity = '0.6';
|
| }
|
| }
|
|
|
| modelInput.addEventListener('input', validateInput);
|
|
|
| validateInput();
|
| }
|
| });
|
|
|