2023-10-19 20:54:43 +08:00
|
|
|
|
|
|
|
document.getElementById('save-button').addEventListener('click', function (e) {
|
|
|
|
e.preventDefault();
|
2023-11-08 17:59:53 +08:00
|
|
|
const chatbotUrl = document.getElementById('chatbot-url').value;
|
|
|
|
const errorTip = document.getElementById('error-tip');
|
2023-10-19 20:54:43 +08:00
|
|
|
|
2023-11-08 17:59:53 +08:00
|
|
|
if (chatbotUrl.trim() === "") {
|
|
|
|
errorTip.textContent = "Dify ChatBot URL cannot be empty.";
|
2023-10-19 20:54:43 +08:00
|
|
|
} else {
|
|
|
|
errorTip.textContent = "";
|
|
|
|
|
|
|
|
chrome.storage.sync.set({
|
2023-11-08 17:59:53 +08:00
|
|
|
'chatbotUrl': chatbotUrl,
|
2023-10-19 20:54:43 +08:00
|
|
|
}, function () {
|
|
|
|
alert('Save Success!');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Load parameters from chrome.storage when the page loads
|
2023-11-08 17:59:53 +08:00
|
|
|
chrome.storage.sync.get(['chatbotUrl'], function (result) {
|
|
|
|
const chatbotUrlInput = document.getElementById('chatbot-url');
|
2023-10-19 20:54:43 +08:00
|
|
|
|
2023-11-08 17:59:53 +08:00
|
|
|
if (result.chatbotUrl) {
|
|
|
|
chatbotUrlInput.value = result.chatbotUrl;
|
2023-10-19 20:54:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|