GPTfree api commited on
Commit
4fbb53d
·
verified ·
1 Parent(s): 9d4076c

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +112 -1
index.html CHANGED
@@ -1 +1,112 @@
1
- <!DOCTYPE html><html lang=ja><head><meta charset=UTF-8><title>モデル一覧</title><style>.tile-container{display:flex;flex-wrap:wrap;gap:10px}.tile{cursor:pointer;border:1px solid #ccc;border-radius:8px;overflow:hidden;width:200px;text-align:center;box-shadow:0 2px 5px rgba(0,0,0,.1)}.tile img{width:100%;height:auto}.tile .info{padding:10px}.tile .info .version{font-weight:700}</style></head><body><h1>モデル一覧</h1><div class=tile-container></div><script>const jsonUrl="https://huggingface.co/spaces/GPT-free-api/genshin-models/raw/main/model.json";async function fetchAndDisplayModels(){try{const e=await fetch(jsonUrl),t=await e.json(),n=document.querySelector(".tile-container");t.model_data.forEach((e=>{const[t,a,c,o]=e,d=document.createElement("div");d.className="tile",d.addEventListener("click",(e=>{navigator.clipboard.writeText(c).then((()=>{alert(URLがクリップボードにコピーされました: ${c})})).catch((e=>{console.error("URLのコピーに失敗しました:",e)}))}));const s=document.createElement("img");s.src=o,s.alt=a;const l=document.createElement("div");l.className="info";const r=document.createElement("div");r.className="version",r.textContent=バージョン: ${t};const i=document.createElement("div");i.className="name",i.textContent=名前: ${a},l.appendChild(r),l.appendChild(i),d.appendChild(s),d.appendChild(l),n.appendChild(d)}))}catch(e){console.error("JSONデータの取得または処理中にエラーが発生しました:",e)}}document.addEventListener("DOMContentLoaded",fetchAndDisplayModels)</script></body></html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="ja">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>モデル一覧</title>
6
+ <style>
7
+ .tile-container {
8
+ display: flex;
9
+ flex-wrap: wrap;
10
+ gap: 10px;
11
+ justify-content: center;
12
+ }
13
+ .tile {
14
+ cursor: pointer;
15
+ border: 1px solid #ccc;
16
+ border-radius: 8px;
17
+ overflow: hidden;
18
+ width: 200px;
19
+ text-align: center;
20
+ box-shadow: 0 2px 5px rgba(0, 0, 0, .1);
21
+ transition: transform 0.2s;
22
+ }
23
+ .tile:hover {
24
+ transform: scale(1.05);
25
+ }
26
+ .tile img {
27
+ width: 100%;
28
+ height: auto;
29
+ }
30
+ .tile .info {
31
+ padding: 10px;
32
+ }
33
+ .tile .info .version {
34
+ font-weight: 700;
35
+ }
36
+ </style>
37
+ </head>
38
+ <body>
39
+ <h1>モデル一覧</h1>
40
+ <div class="tile-container"></div>
41
+ <script>
42
+ const jsonUrl = "/model.json";
43
+
44
+ async function fetchAndDisplayModels() {
45
+ try {
46
+ // JSONデータの取得
47
+ const response = await fetch(jsonUrl);
48
+
49
+ if (!response.ok) {
50
+ throw new Error(`HTTPエラー: ${response.status}`);
51
+ }
52
+
53
+ const data = await response.json();
54
+ const container = document.querySelector(".tile-container");
55
+
56
+ // モデルデータの描画
57
+ data.model_data.forEach((model) => {
58
+ const version = model[0]; // インデックス0: バージョン
59
+ const name = model[1]; // インデックス1: 名前
60
+ const url = model[2]; // インデックス2: URL
61
+ const image = model[3]; // インデックス3: 画像URL
62
+
63
+ const tile = document.createElement("div");
64
+ tile.className = "tile";
65
+
66
+ // タイルクリック時のURLコピー機能
67
+ tile.addEventListener("click", () => {
68
+ navigator.clipboard.writeText(url)
69
+ .then(() => {
70
+ alert(`URLがクリップボードにコピーされました: ${url}`);
71
+ })
72
+ .catch((error) => {
73
+ console.error("URLのコピーに失敗しました:", error);
74
+ });
75
+ });
76
+
77
+ // 画像要素
78
+ const img = document.createElement("img");
79
+ img.src = image;
80
+ img.alt = name;
81
+
82
+ // 情報セクション
83
+ const info = document.createElement("div");
84
+ info.className = "info";
85
+
86
+ const versionDiv = document.createElement("div");
87
+ versionDiv.className = "version";
88
+ versionDiv.textContent = `バージョン: ${version}`;
89
+
90
+ const nameDiv = document.createElement("div");
91
+ nameDiv.className = "name";
92
+ nameDiv.textContent = `名前: ${name}`;
93
+
94
+ info.appendChild(versionDiv);
95
+ info.appendChild(nameDiv);
96
+ tile.appendChild(img);
97
+ tile.appendChild(info);
98
+ container.appendChild(tile);
99
+ });
100
+ } catch (error) {
101
+ console.error("JSONデータの取得または処理中にエラーが発生しました:");
102
+ console.error(`エラーメッセージ: ${error.message}`);
103
+ console.error(`エラー名: ${error.name}`);
104
+ console.error(`スタックトレース: ${error.stack}`);
105
+ alert("データの取得中に問題が発生しました。詳細はコンソールをご確認ください。");
106
+ }
107
+ }
108
+
109
+ document.addEventListener("DOMContentLoaded", fetchAndDisplayModels);
110
+ </script>
111
+ </body>
112
+ </html>