Skip to content

Commit

Permalink
Add reload option
Browse files Browse the repository at this point in the history
  • Loading branch information
aandrew-me committed Nov 20, 2022
1 parent bfa04fe commit 1668cbb
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 25 deletions.
3 changes: 2 additions & 1 deletion html/preferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

<body>
<div id="top">
<a id="restart">Restart app</a>
<a id="back">Homepage</a>
<!-- <a id="restart" onclick="restartApp()">Restart app</a> -->
</div>
Expand Down Expand Up @@ -119,7 +120,7 @@ <h1 id="preferences">Preferences</h1>


<script>

</script>
</body>

Expand Down
11 changes: 7 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ function createWindow() {
contextIsolation: false,
},
});

win.loadFile("html/index.html");
win.maximize();
// win.setMenu(null)
Expand Down Expand Up @@ -67,9 +66,13 @@ app.whenReady().then(() => {
}
});

ipcMain.on("restart", () => {
app.relaunch();
app.exit();
ipcMain.on("reload", () => {
if (win) {
win.reload();
}
if (secondaryWindow) {
secondaryWindow.reload();
}
});

ipcMain.on("get-version", () => {
Expand Down
7 changes: 7 additions & 0 deletions src/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,12 @@ getId("preferredAudioQuality").addEventListener("change", ()=>{
localStorage.setItem("preferredAudioQuality", preferredAudioQuality) = preferredAudioQuality
})

// Reload
function reload(){
ipcRenderer.send("reload")
}
getId("restart").addEventListener("click", () =>{
reload()
})

require("../src/translate_preferences")
45 changes: 25 additions & 20 deletions src/translate_preferences.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
function getId(id){
return document.getElementById(id)
function getId(id) {
return document.getElementById(id);
}
function querySelectorAll(element){
return document.querySelectorAll(element)
function querySelectorAll(element) {
return document.querySelectorAll(element);
}
var i18n = new(require('../translations/i18n'))
var i18n = new (require("../translations/i18n"))();

// Translating texts
getId("title").textContent = i18n.__("Preferences")
getId("back").textContent = i18n.__("Homepage")
getId("dlText").textContent = i18n.__("Download location")
getId("clText").innerHTML = i18n.__("Current download location - ")
getId("selectLocation").textContent = i18n.__("Select Download Location")
getId("transparentText").textContent = i18n.__("Enable transparent dark mode(only Linux, needs relaunch)")
getId("preferences").textContent = i18n.__("Preferences")
getId("selectLn").textContent = i18n.__("Select Language (Requires relaunch)")
getId("browserInfo").title = i18n.__("This option lets you download restricted content. You will get errors if cookies are not there")
getId("browserTxt").textContent = i18n.__("Select browser to use cookies from")
getId("none").textContent = i18n.__("None")
querySelectorAll(".autoTxt").forEach(item => {
item.textContent = i18n.__("Automatic")
getId("title").textContent = i18n.__("Preferences");
getId("back").textContent = i18n.__("Homepage");
getId("dlText").textContent = i18n.__("Download location");
getId("clText").innerHTML = i18n.__("Current download location - ");
getId("selectLocation").textContent = i18n.__("Select Download Location");
getId("transparentText").textContent = i18n.__(
"Enable transparent dark mode(only Linux, needs relaunch)"
);
getId("preferences").textContent = i18n.__("Preferences");
getId("selectLn").textContent = i18n.__("Select Language (Requires relaunch)");
getId("browserInfo").title = i18n.__(
"This option lets you download restricted content. You will get errors if cookies are not there"
);
getId("browserTxt").textContent = i18n.__("Select browser to use cookies from");
getId("none").textContent = i18n.__("None");
querySelectorAll(".autoTxt").forEach((item) => {
item.textContent = i18n.__("Automatic");
});
getId("preferredAudioTxt").textContent = i18n.__("Preferred audio format")
getId("preferredVideoTxt").textContent = i18n.__("Preferred video quality")
getId("preferredAudioTxt").textContent = i18n.__("Preferred audio format");
getId("preferredVideoTxt").textContent = i18n.__("Preferred video quality");
getId("restart").textContent = i18n.__("Restart app");

0 comments on commit 1668cbb

Please sign in to comment.