| 709 | }, |
| 710 | |
| 711 | importFromCivitai() { |
| 712 | document.body.style["cursor"] = "progress" |
| 713 | fetch("/sha256/lora/" + LoraUI.modelField.value) |
| 714 | .then((result) => result.json()) |
| 715 | .then((json) => fetch("https://civitai.com/api/v1/model-versions/by-hash/" + json.digest)) |
| 716 | .then((result) => result.json()) |
| 717 | .then((json) => { |
| 718 | document.body.style["cursor"] = "default" |
| 719 | if (json == null) { |
| 720 | return |
| 721 | } |
| 722 | if ("trainedWords" in json) { |
| 723 | LoraUI.keywordsField.value = json["trainedWords"].join("\n") |
| 724 | } else { |
| 725 | showToast("No keyword info found.") |
| 726 | } |
| 727 | if ("modelId" in json) { |
| 728 | LoraUI.showCivitaiLink("https://civitai.com/models/" + json.modelId) |
| 729 | } else { |
| 730 | LoraUI.hideCivitaiLink() |
| 731 | } |
| 732 | |
| 733 | LoraUI.saveInfos() |
| 734 | }) |
| 735 | }, |
| 736 | |
| 737 | showCivitaiLink(href) { |
| 738 | LoraUI.civitaiSection.classList.remove("displayNone") |