add option to use collabora server

This commit is contained in:
makaveli10
2023-07-13 00:59:48 +05:30
parent 7accea1fdf
commit a634a6d6d3
10 changed files with 109 additions and 13 deletions
+31 -2
View File
@@ -3,6 +3,8 @@ document.addEventListener("DOMContentLoaded", function () {
const startButton = document.getElementById("startCapture");
const stopButton = document.getElementById("stopCapture");
const useServerCheckbox = document.getElementById("useServerCheckbox");
// Add click event listeners to the buttons
startButton.addEventListener("click", startCapture);
stopButton.addEventListener("click", stopCapture);
@@ -16,6 +18,13 @@ document.addEventListener("DOMContentLoaded", function () {
}
});
// Retrieve checkbox state from storage on popup open
chrome.storage.local.get("useServerState", ({ useServerState }) => {
if (useServerState !== undefined) {
useServerCheckbox.checked = useServerState;
}
});
// Function to handle the start capture button click event
async function startCapture() {
// Ignore click if the button is disabled
@@ -27,7 +36,20 @@ document.addEventListener("DOMContentLoaded", function () {
const currentTab = await getCurrentTab();
// Send a message to the background script to start capturing
chrome.runtime.sendMessage({ action: "startCapture", tabId: currentTab.id }, () => {
let host = "localhost";
let port = "9090";
const useCollaboraServer = useServerCheckbox.checked;
if (useCollaboraServer){
host = "transcription.kurg.org"
port = "7090"
}
chrome.runtime.sendMessage(
{
action: "startCapture",
tabId: currentTab.id,
host: host,
port: port }, () => {
// Update capturing state in storage and toggle the buttons
chrome.storage.local.set({ capturingState: { isCapturing: true } }, () => {
toggleCaptureButtons(true);
@@ -64,7 +86,14 @@ document.addEventListener("DOMContentLoaded", function () {
function toggleCaptureButtons(isCapturing) {
startButton.disabled = isCapturing;
stopButton.disabled = !isCapturing;
useServerCheckbox.disabled = isCapturing;
startButton.classList.toggle("disabled", isCapturing);
stopButton.classList.toggle("disabled", !isCapturing);
}
});
// Save the checkbox state when it's toggled
useServerCheckbox.addEventListener("change", () => {
const useServerState = useServerCheckbox.checked;
chrome.storage.local.set({ useServerState });
});
});