Add support to remember Window

pull/127/head
Andrew 3 years ago
parent 8250949c17
commit 7262af3cbd

@ -32,7 +32,7 @@
"description": "Download videos and audios from YouTube and many other sites",
"devDependencies": {
"electron": "^22.0.3",
"electron-builder": "^23.6.0"
"electron-builder": "^24.0.0-alpha.13"
},
"build": {
"productName": "YTDownloader",
@ -85,6 +85,11 @@
],
"category": "Utility"
},
"snap": {
"grade": "stable",
"base": "core22"
},
"win": {
"target": "nsis",
"artifactName": "${productName}_Win.${ext}"

@ -10,17 +10,26 @@ function getId(id) {
// Video and audio toggle
videoToggle.addEventListener("click", (event) => {
selectVideo()
});
audioToggle.addEventListener("click", (event) => {
selectAudio()
});
/////////////
function selectVideo(){
localStorage.setItem("defaultWindow", "video")
videoToggle.style.backgroundColor = "var(--box-toggleOn)";
audioToggle.style.backgroundColor = "var(--box-toggle)";
getId("audioList").style.display = "none";
getId("videoList").style.display = "block";
});
}
audioToggle.addEventListener("click", (event) => {
function selectAudio(){
localStorage.setItem("defaultWindow", "audio")
audioToggle.style.backgroundColor = "var(--box-toggleOn)";
videoToggle.style.backgroundColor = "var(--box-toggle)";
getId("videoList").style.display = "none";
getId("audioList").style.display = "block";
});
/////////////
}

@ -61,10 +61,10 @@ checkMaxDownloads();
// Check for auto updates
let autoUpdate = true;
const autoUpdateStatus = localStorage.getItem("autoUpdate")
if (autoUpdateStatus){
if (autoUpdateStatus == "false"){
autoUpdate = false
const autoUpdateStatus = localStorage.getItem("autoUpdate");
if (autoUpdateStatus) {
if (autoUpdateStatus == "false") {
autoUpdate = false;
}
}
ipcRenderer.send("autoUpdate", autoUpdate);
@ -204,10 +204,15 @@ cp.exec("yt-dlp --version", (error, stdout, stderr) => {
});
function defaultVideoToggle() {
videoToggle.style.backgroundColor = "var(--box-toggleOn)";
audioToggle.style.backgroundColor = "var(--box-toggle)";
getId("audioList").style.display = "none";
getId("videoList").style.display = "block";
let defaultWindow = "video";
if (localStorage.getItem("defaultWindow")) {
defaultWindow = localStorage.getItem("defaultWindow");
}
if (defaultWindow == "video") {
selectVideo()
} else {
selectAudio()
}
}
// Pasting url from clipboard
@ -338,7 +343,6 @@ async function getInfo(url) {
getId("loadingWrapper").style.display = "none";
getId("hidden").style.display = "inline-block";
getId("title").innerHTML = `<b>${i18n.__("Title ")}</b>: ` + title;
getId("videoList").style.display = "block";
let audioSize = 0;
let defaultVideoFormat = 0;
@ -526,7 +530,9 @@ getId("videoDownload").addEventListener("click", (event) => {
const randId = Math.random().toFixed(10).toString().slice(2);
const item = `
<div class="item" id="${randId}">
<img src="${thumbnail || "../assets/images/thumb.png"}" alt="No thumbnail" class="itemIcon" crossorigin="anonymous">
<img src="${
thumbnail || "../assets/images/thumb.png"
}" alt="No thumbnail" class="itemIcon" crossorigin="anonymous">
<div class="itemBody">
<div class="itemTitle">${title}</div>

Loading…
Cancel
Save