Skip to content

Commit

Permalink
Refactoriser la configuration des comptes uniques et l'ordre des débr…
Browse files Browse the repository at this point in the history
…ideurs
  • Loading branch information
LimeDrive committed Sep 30, 2024
1 parent b93c803 commit 5dd37a0
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions stream_fusion/static/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,15 +246,15 @@ function updateDebridOrderList() {
debridOrderList.innerHTML = '';

let debridOrder = [];
try {
const currentUrl = window.location.href;
let data = currentUrl.match(/\/([^\/]+)\/configure$/);
if (data && data[1]) {
const currentUrl = window.location.href;
let data = currentUrl.match(/\/([^\/]+)\/configure$/);
if (data && data[1]) {
try {
const decodedData = JSON.parse(atob(data[1]));
debridOrder = decodedData.service || [];
} catch (error) {
console.warn("No valid debrid order data in URL, using default order.");
}
} catch (error) {
console.error("Error getting debrid order:", error);
}

const rdEnabled = document.getElementById('debrid_rd').checked || document.getElementById('debrid_rd').disabled;
Expand Down Expand Up @@ -431,22 +431,21 @@ function loadData() {
try {
decodedData = JSON.parse(atob(data[1]));
} catch (error) {
console.error("Error decoding data:", error);
console.warn("No valid data to decode in URL, using default values.");
}
}

function setElementValue(id, value, defaultValue) {
const element = document.getElementById(id);
if (element) {
if (typeof value === 'boolean') {
if (typeof defaultValue === 'boolean') {
element.checked = value ?? defaultValue;
} else {
element.value = value || defaultValue || '';
}
}
}

// Configuration des éléments avec des valeurs par défaut
setElementValue('jackett', decodedData.jackett, false);
setElementValue('cache', decodedData.cache, false);
setElementValue('cacheUrl', decodedData.cacheUrl, '');
Expand Down Expand Up @@ -499,7 +498,6 @@ function loadData() {
updateDebridOrderList();
}


function getLink(method) {
const data = {
addonHost: new URL(window.location.href).origin,
Expand Down

0 comments on commit 5dd37a0

Please sign in to comment.