Skip to content

Commit ace23f8

Browse files
authored
Update index.html
1 parent 2d5c482 commit ace23f8

1 file changed

Lines changed: 12 additions & 18 deletions

File tree

index.html

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,10 @@ <h1 class="text-2xl sm:text-3xl font-bold text-gray-800" data-translate-key="tit
211211
<div class="mt-4 text-center border-t pt-4 flex justify-center items-center gap-4">
212212
<button id="open-theme-modal-btn" class="text-xs text-gray-500 hover:underline">テーマ設定</button>
213213
<button id="open-quality-modal-btn" class="text-xs text-gray-500 hover:underline" data-translate-key="qualitySettingsBtn">画質設定</button>
214-
<!-- APIキー設定ボタン削除済み -->
215214
</div>
216215
</div>
217216

218217
<!-- Modals -->
219-
<!-- APIキー設定モーダル削除済み -->
220-
221218
<div id="barcode-modal" class="modal-overlay hidden" role="dialog" aria-modal="true" aria-labelledby="barcode-modal-title">
222219
<div class="bg-white rounded-lg shadow-xl w-11/12 max-w-lg p-6 relative modal-content">
223220
<h2 id="barcode-modal-title" class="text-2xl font-bold text-center mb-4">バーコードで分別</h2>
@@ -387,7 +384,6 @@ <h2 id="theme-modal-title" class="text-2xl font-bold text-center mb-4">テーマ
387384
const languageDropdown = document.getElementById('language-dropdown');
388385
const currentLangSpan = document.getElementById('current-lang');
389386
const langChevron = document.getElementById('lang-chevron');
390-
// APIキー関連の要素は削除
391387
const openQualityModalBtn = document.getElementById('open-quality-modal-btn');
392388

393389
// --- State Variables (index.html specific) ---
@@ -525,12 +521,7 @@ <h2 id="theme-modal-title" class="text-2xl font-bold text-center mb-4">テーマ
525521
toast.classList.add('show');
526522
setTimeout(() => { toast.classList.remove('show'); }, duration);
527523
}
528-
function updateApiKeyModalStatus() {
529-
// 削除済み
530-
}
531-
function openApiKeyModal() {
532-
// 削除済み
533-
}
524+
534525
async function compressImage(file) {
535526
const qualitySetting = localStorage.getItem('imageQuality') || 'high';
536527
const settings = {
@@ -571,9 +562,13 @@ <h2 id="theme-modal-title" class="text-2xl font-bold text-center mb-4">テーマ
571562
reader.onerror = reject;
572563
});
573564
}
565+
566+
// --- API & Analysis Functions (Updated) ---
574567
async function analyzeImageWithRetry(base64ImageData) {
575-
// 固定のAPIキーと安定版モデルを使用
576-
const apiKey = 'AIzaSyCTdOKx1eZ_BjXxi1q1SwVKnIaZW_dXJSs';
568+
// APIキーをハードコードに変更
569+
const apiKey = 'AIzaSyCTdOKx1eZ_BjXxi1q1SwVKnIaZW_dXJSs';
570+
571+
// モデルを安定版の gemini-1.5-flash に変更
577572
const apiUrl = `https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=${apiKey}`;
578573

579574
const prompt = `この画像に写っている主要な物体を1つ特定し、それが日本の一般的なゴミ分別においてどのカテゴリに分類されるか判断してください。カテゴリは必ず以下のリストから選択してください: 「燃えるゴミ」「燃えないゴミ」「びん」「かん」「ペットボトル」「プラスチック」「紙類」「有害ごみ」「粗大ごみ」。以下のJSON形式で、キーは英語、値は日本語で厳密に回答してください。JSON以外のテキストは含めないでください。 { "itemName": "物体の名前", "category": "カテゴリ名", "note": "分別する際の一般的な注意点" }`;
@@ -613,11 +608,11 @@ <h2 id="theme-modal-title" class="text-2xl font-bold text-center mb-4">テーマ
613608
switch (aiResult.status) {
614609
case 400:
615610
errorTitle = '不正なリクエスト';
616-
troubleshootingSteps = `<p class="font-bold text-sm mt-4 mb-2">考えられる原因 (エラーコード 400):</p><ul class="list-disc list-inside text-sm space-y-1"><li>APIキーの文字列が正しくない可能性があります。</li></ul>`;
611+
troubleshootingSteps = `<p class="font-bold text-sm mt-4 mb-2">考えられる原因 (エラーコード 400):</p><ul class="list-disc list-inside text-sm space-y-1"><li>APIキーが無効である可能性があります。</li><li>Google Cloudプロジェクトで<strong>請求が有効になっていない</strong>可能性があります。</li></ul>`;
617612
break;
618613
case 403:
619614
errorTitle = '権限がありません';
620-
troubleshootingSteps = `<p class="font-bold text-sm mt-4 mb-2">考えられる原因 (エラーコード 403):</p><ul class="list-disc list-inside text-sm space-y-1"><li>Google Cloudプロジェクトで <strong>Generative Language API</strong> が有効になっていない可能性があります。</li></ul>`;
615+
troubleshootingSteps = `<p class="font-bold text-sm mt-4 mb-2">考えられる原因 (エラーコード 403):</p><ul class="list-disc list-inside text-sm space-y-1"><li>APIキーの制限設定が厳しすぎる可能性があります。</li></ul>`;
621616
break;
622617
case 429:
623618
errorTitle = '利用上限のエラー';
@@ -647,8 +642,9 @@ <h2 id="theme-modal-title" class="text-2xl font-bold text-center mb-4">テーマ
647642
async function handleFile(file) {
648643
if (isAnalyzing) return;
649644
isAnalyzing = true;
650-
// APIキーチェック処理を削除(固定キーを使用するため)
651645

646+
// APIキーチェック処理を削除(ハードコード済みのため)
647+
652648
resultArea.classList.remove('hidden');
653649
resultArea.innerHTML = `<div class="bg-gray-50 rounded-lg p-4"><h2 class="text-lg font-bold text-gray-800 mb-4 text-center">AI判定結果</h2><div class="flex justify-center items-center h-48"><div class="flex flex-col items-center gap-4"><div class="spinner"></div><p class="text-gray-600">画像を圧縮し、AIが解析中です...</p></div></div></div>`;
654650
try {
@@ -782,7 +778,7 @@ <h2 id="theme-modal-title" class="text-2xl font-bold text-center mb-4">テーマ
782778
suggestionsContainer.classList.add('hidden');
783779
return;
784780
}
785-
const filteredCities = ALL_JAPAN_CITIES.filter(city => city.toLowerCase().includes(query)).slice(100);
781+
const filteredCities = ALL_JAPAN_CITIES.filter(city => city.toLowerCase().includes(query)).slice(0, 100);
786782
showSuggestions(filteredCities);
787783
});
788784
getLocationBtn.addEventListener('click', () => {
@@ -869,7 +865,6 @@ <h2 id="theme-modal-title" class="text-2xl font-bold text-center mb-4">テーマ
869865
openDisasterBtn.addEventListener('click', () => { openModal('disaster-modal'); });
870866
notificationBtn.addEventListener('click', handleNotificationRequest);
871867
openQualityModalBtn.addEventListener('click', () => { openModal('quality-modal'); });
872-
// APIキーボタンのリスナー削除
873868

874869
// --- Settings Event Listeners ---
875870
document.querySelectorAll('input[name="quality-setting"]').forEach(radio => {
@@ -880,7 +875,6 @@ <h2 id="theme-modal-title" class="text-2xl font-bold text-center mb-4">テーマ
880875
closeModal('quality-modal');
881876
});
882877
});
883-
// APIキー保存・削除ボタンのリスナー削除
884878

885879
</script>
886880
</body>

0 commit comments

Comments
 (0)