Spaces:
Running
Running
初回訪問時にAPIキーの入力を促す
Browse files- control.js +38 -2
- index.html +1 -1
control.js
CHANGED
@@ -21,7 +21,12 @@ setInterval(() => {
|
|
21 |
}, 60000);
|
22 |
// 入力フォームの内容を保存する
|
23 |
document.querySelectorAll('input, textarea').forEach(input => {
|
24 |
-
input.addEventListener('input',
|
|
|
|
|
|
|
|
|
|
|
25 |
});
|
26 |
// Ctrl+Enterでプロンプト生成を実行する
|
27 |
document.addEventListener('keydown', function (event) {
|
@@ -106,7 +111,10 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
106 |
resizeMain();
|
107 |
initSidebarResize();
|
108 |
initClearStorageButton();
|
109 |
-
updateModelList();
|
|
|
|
|
|
|
110 |
});
|
111 |
|
112 |
window.addEventListener("resize", resizeMain);
|
@@ -131,3 +139,31 @@ async function updateModelList() {
|
|
131 |
}
|
132 |
loadFromUserStorage();
|
133 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
}, 60000);
|
22 |
// 入力フォームの内容を保存する
|
23 |
document.querySelectorAll('input, textarea').forEach(input => {
|
24 |
+
input.addEventListener('input', () => {
|
25 |
+
saveToUserStorage();
|
26 |
+
if (input.id === "apiKey") {
|
27 |
+
updateModelList();
|
28 |
+
}
|
29 |
+
});
|
30 |
});
|
31 |
// Ctrl+Enterでプロンプト生成を実行する
|
32 |
document.addEventListener('keydown', function (event) {
|
|
|
111 |
resizeMain();
|
112 |
initSidebarResize();
|
113 |
initClearStorageButton();
|
114 |
+
updateModelList();
|
115 |
+
|
116 |
+
// APIキーの設定状態をチェック
|
117 |
+
checkApiKeySettings();
|
118 |
});
|
119 |
|
120 |
window.addEventListener("resize", resizeMain);
|
|
|
139 |
}
|
140 |
loadFromUserStorage();
|
141 |
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* APIキーの設定状態をチェックし、未設定の場合はユーザーに入力を促す
|
145 |
+
*/
|
146 |
+
function checkApiKeySettings() {
|
147 |
+
const apiKeyInput = document.getElementById('apiKey');
|
148 |
+
const sidebarContainer = document.getElementById('sidebar-container');
|
149 |
+
const content = document.getElementById('content');
|
150 |
+
|
151 |
+
if (!apiKeyInput.value) {
|
152 |
+
// サイドバーを開く
|
153 |
+
sidebarContainer.style.width = '250px';
|
154 |
+
content.style.marginLeft = '250px';
|
155 |
+
sidebarContainer.classList.add('active');
|
156 |
+
|
157 |
+
// APIキー入力欄を強調表示
|
158 |
+
apiKeyInput.classList.add('border', 'border-danger', 'border-3');
|
159 |
+
apiKeyInput.focus();
|
160 |
+
|
161 |
+
// APIキーが入力されたら強調表示を解除
|
162 |
+
apiKeyInput.addEventListener('input', function removeHighlight() {
|
163 |
+
if (apiKeyInput.value) {
|
164 |
+
apiKeyInput.classList.remove('border', 'border-danger', 'border-3');
|
165 |
+
apiKeyInput.removeEventListener('input', removeHighlight);
|
166 |
+
}
|
167 |
+
});
|
168 |
+
}
|
169 |
+
}
|
index.html
CHANGED
@@ -159,7 +159,7 @@
|
|
159 |
</div>
|
160 |
<div class="form-group">
|
161 |
<label for="characterCount" class="form-label" id="characterCountLabel">文字数</label>
|
162 |
-
<input type="number" value="
|
163 |
placeholder="生成するプロンプトの文字数を入力してください">
|
164 |
</div>
|
165 |
<div class="form-group">
|
|
|
159 |
</div>
|
160 |
<div class="form-group">
|
161 |
<label for="characterCount" class="form-label" id="characterCountLabel">文字数</label>
|
162 |
+
<input type="number" value="576" class="form-control" id="characterCount"
|
163 |
placeholder="生成するプロンプトの文字数を入力してください">
|
164 |
</div>
|
165 |
<div class="form-group">
|