Spaces:
Running
Running
管理方法変更
Browse files- control.js +1 -0
- history.js +54 -4
- index.html +1 -1
- prompt.js +2 -2
- storage.js +0 -4
control.js
CHANGED
@@ -113,4 +113,5 @@ async function updateModelList() {
|
|
113 |
} catch (error) {
|
114 |
console.error('モデルリストの更新中にエラーが発生しました:', error);
|
115 |
}
|
|
|
116 |
}
|
|
|
113 |
} catch (error) {
|
114 |
console.error('モデルリストの更新中にエラーが発生しました:', error);
|
115 |
}
|
116 |
+
loadFromUserStorage();
|
117 |
}
|
history.js
CHANGED
@@ -35,9 +35,38 @@ function updateHistoryList() {
|
|
35 |
noHistoryMessage.classList.add('d-none');
|
36 |
historyList.classList.remove('d-none');
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
history.forEach((item, index) => {
|
39 |
const li = document.createElement('li');
|
40 |
li.className = 'list-group-item list-group-item-action d-flex justify-content-between align-items-start';
|
|
|
41 |
|
42 |
const contentDiv = document.createElement('div');
|
43 |
contentDiv.className = 'ms-2 me-auto';
|
@@ -83,10 +112,14 @@ function updateHistoryList() {
|
|
83 |
|
84 |
contentDiv.style.width = `calc(100% - ${buttonsContainer.offsetWidth}px)`;
|
85 |
});
|
|
|
|
|
|
|
|
|
86 |
}
|
87 |
}
|
88 |
function deleteHistoryItem(index) {
|
89 |
-
if (confirm('
|
90 |
let history = JSON.parse(localStorage.getItem('gemini_prompt_history') || '[]');
|
91 |
history.splice(index, 1);
|
92 |
localStorage.setItem('gemini_prompt_history', JSON.stringify(history));
|
@@ -106,7 +139,7 @@ function loadHistoryItem(index) {
|
|
106 |
}
|
107 |
|
108 |
function clearHistory() {
|
109 |
-
if (confirm('
|
110 |
localStorage.removeItem('gemini_prompt_history');
|
111 |
updateHistoryList();
|
112 |
}
|
@@ -137,7 +170,7 @@ function createHistoryItem(item, index) {
|
|
137 |
deleteButton.className = 'btn btn-sm btn-danger';
|
138 |
deleteButton.innerHTML = '<i class="fas fa-trash"></i>';
|
139 |
deleteButton.onclick = () => {
|
140 |
-
if (confirm('
|
141 |
deleteHistoryItem(index);
|
142 |
}
|
143 |
};
|
@@ -155,7 +188,7 @@ function editHistoryItemTitle(index, titleDiv) {
|
|
155 |
const item = history[index];
|
156 |
const currentTitle = item.title || item.query.slice(0, 10);
|
157 |
|
158 |
-
const newTitle = prompt('
|
159 |
if (newTitle !== null && newTitle.trim() !== '') {
|
160 |
item.title = newTitle.trim();
|
161 |
history[index] = item;
|
@@ -163,3 +196,20 @@ function editHistoryItemTitle(index, titleDiv) {
|
|
163 |
titleDiv.textContent = newTitle.trim();
|
164 |
}
|
165 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
noHistoryMessage.classList.add('d-none');
|
36 |
historyList.classList.remove('d-none');
|
37 |
|
38 |
+
// 容量プログレスバーを追加
|
39 |
+
const storageUsage = JSON.stringify(history).length;
|
40 |
+
const storageLimit = 3 * 1024 * 1024; // 3MB
|
41 |
+
const usagePercentage = (storageUsage / storageLimit) * 100;
|
42 |
+
|
43 |
+
const progressBarContainer = document.createElement('div');
|
44 |
+
progressBarContainer.className = 'mb-3';
|
45 |
+
progressBarContainer.innerHTML = `
|
46 |
+
<div class="progress" style="height: 24px; border: 1px solid #dee2e6; position: relative;">
|
47 |
+
<div class="progress-bar ${usagePercentage > 90 ? 'bg-danger' : 'bg-primary'}" role="progressbar"
|
48 |
+
style="width: ${usagePercentage}%;" aria-valuenow="${usagePercentage}" aria-valuemin="0" aria-valuemax="100"></div>
|
49 |
+
<div class="position-absolute w-100 h-100 d-flex align-items-center justify-content-center" style="top: 0; left: 0;">
|
50 |
+
<span style="color: white; text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;">
|
51 |
+
${(storageUsage / 1024 / 1024).toFixed(2)}MB / ${storageLimit / 1024 / 1024}MB
|
52 |
+
</span>
|
53 |
+
</div>
|
54 |
+
</div>
|
55 |
+
`;
|
56 |
+
historyList.appendChild(progressBarContainer);
|
57 |
+
|
58 |
+
// 検索フォームを追加
|
59 |
+
const searchForm = document.createElement('div');
|
60 |
+
searchForm.className = 'mb-3';
|
61 |
+
searchForm.innerHTML = `
|
62 |
+
<input type="text" class="form-control" id="historySearchInput" placeholder="履歴を検索...">
|
63 |
+
`;
|
64 |
+
historyList.appendChild(searchForm);
|
65 |
+
|
66 |
history.forEach((item, index) => {
|
67 |
const li = document.createElement('li');
|
68 |
li.className = 'list-group-item list-group-item-action d-flex justify-content-between align-items-start';
|
69 |
+
li.dataset.item = JSON.stringify(item);
|
70 |
|
71 |
const contentDiv = document.createElement('div');
|
72 |
contentDiv.className = 'ms-2 me-auto';
|
|
|
112 |
|
113 |
contentDiv.style.width = `calc(100% - ${buttonsContainer.offsetWidth}px)`;
|
114 |
});
|
115 |
+
|
116 |
+
// 検索機能を追加
|
117 |
+
const searchInput = document.getElementById('historySearchInput');
|
118 |
+
searchInput.addEventListener('input', filterHistory);
|
119 |
}
|
120 |
}
|
121 |
function deleteHistoryItem(index) {
|
122 |
+
if (confirm('Are you sure you want to delete this history item?')) {
|
123 |
let history = JSON.parse(localStorage.getItem('gemini_prompt_history') || '[]');
|
124 |
history.splice(index, 1);
|
125 |
localStorage.setItem('gemini_prompt_history', JSON.stringify(history));
|
|
|
139 |
}
|
140 |
|
141 |
function clearHistory() {
|
142 |
+
if (confirm('Are you sure you want to delete all history items?')) {
|
143 |
localStorage.removeItem('gemini_prompt_history');
|
144 |
updateHistoryList();
|
145 |
}
|
|
|
170 |
deleteButton.className = 'btn btn-sm btn-danger';
|
171 |
deleteButton.innerHTML = '<i class="fas fa-trash"></i>';
|
172 |
deleteButton.onclick = () => {
|
173 |
+
if (confirm('Are you sure you want to delete this history item?')) {
|
174 |
deleteHistoryItem(index);
|
175 |
}
|
176 |
};
|
|
|
188 |
const item = history[index];
|
189 |
const currentTitle = item.title || item.query.slice(0, 10);
|
190 |
|
191 |
+
const newTitle = prompt('New title:', currentTitle);
|
192 |
if (newTitle !== null && newTitle.trim() !== '') {
|
193 |
item.title = newTitle.trim();
|
194 |
history[index] = item;
|
|
|
196 |
titleDiv.textContent = newTitle.trim();
|
197 |
}
|
198 |
}
|
199 |
+
|
200 |
+
function filterHistory() {
|
201 |
+
const searchInput = document.getElementById('historySearchInput');
|
202 |
+
const searchTerm = searchInput.value.toLowerCase();
|
203 |
+
const historyItems = document.querySelectorAll('#historyList li[data-item]');
|
204 |
+
|
205 |
+
historyItems.forEach(item => {
|
206 |
+
const itemData = JSON.parse(item.dataset.item);
|
207 |
+
const searchableText = `${itemData.title} ${itemData.query} ${itemData.promptEn} ${itemData.promptMyLanguage} ${itemData.danbooruTags}`.toLowerCase();
|
208 |
+
|
209 |
+
if (searchableText.includes(searchTerm)) {
|
210 |
+
item.classList.remove('d-none');
|
211 |
+
} else {
|
212 |
+
item.classList.add('d-none');
|
213 |
+
}
|
214 |
+
});
|
215 |
+
}
|
index.html
CHANGED
@@ -168,7 +168,7 @@
|
|
168 |
<!-- 新しいボタンを追加 -->
|
169 |
<div class="mt-4">
|
170 |
<button id="clearStorageButton" class="btn btn-danger w-100">
|
171 |
-
|
172 |
</button>
|
173 |
</div>
|
174 |
</div>
|
|
|
168 |
<!-- 新しいボタンを追加 -->
|
169 |
<div class="mt-4">
|
170 |
<button id="clearStorageButton" class="btn btn-danger w-100">
|
171 |
+
Clear All Settings
|
172 |
</button>
|
173 |
</div>
|
174 |
</div>
|
prompt.js
CHANGED
@@ -12,7 +12,7 @@ async function getModelList() {
|
|
12 |
|
13 |
function generatePrompt() {
|
14 |
if (!document.getElementById('apiKey').value) {
|
15 |
-
alert("API
|
16 |
return;
|
17 |
}
|
18 |
let query = document.getElementById('query').value;
|
@@ -79,7 +79,7 @@ function generatePrompt() {
|
|
79 |
safetySettings: [
|
80 |
{
|
81 |
category: "HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
82 |
-
threshold: "
|
83 |
}
|
84 |
]
|
85 |
};
|
|
|
12 |
|
13 |
function generatePrompt() {
|
14 |
if (!document.getElementById('apiKey').value) {
|
15 |
+
alert("Please enter your API key.");
|
16 |
return;
|
17 |
}
|
18 |
let query = document.getElementById('query').value;
|
|
|
79 |
safetySettings: [
|
80 |
{
|
81 |
category: "HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
82 |
+
threshold: "OFF"
|
83 |
}
|
84 |
]
|
85 |
};
|
storage.js
CHANGED
@@ -23,8 +23,4 @@ function loadFromUserStorage() {
|
|
23 |
input.value = v;
|
24 |
}
|
25 |
});
|
26 |
-
// エンドポイントが保存されていない場合、デフォルト値を設定
|
27 |
-
if (!data.endpointSelect) {
|
28 |
-
document.getElementById('endpointSelect').value = "gemini-1.5-pro-exp-0827";
|
29 |
-
}
|
30 |
}
|
|
|
23 |
input.value = v;
|
24 |
}
|
25 |
});
|
|
|
|
|
|
|
|
|
26 |
}
|