2022-03-04 17:53:18 +00:00
|
|
|
import {ipcRenderer} from "electron";
|
|
|
|
import {addStyle} from "../utils";
|
2021-12-26 18:58:05 +00:00
|
|
|
import * as fs from "fs";
|
|
|
|
import * as path from "path";
|
2022-07-04 14:39:22 +00:00
|
|
|
import os from "os";
|
2021-12-24 21:56:49 +00:00
|
|
|
export function injectTitlebar() {
|
2022-03-04 17:53:18 +00:00
|
|
|
document.addEventListener("DOMContentLoaded", function (event) {
|
|
|
|
var elem = document.createElement("div");
|
|
|
|
elem.innerHTML = `<nav class="titlebar">
|
2021-12-24 21:56:49 +00:00
|
|
|
<div class="window-title" id="window-title"></div>
|
|
|
|
<div id="window-controls-container">
|
2022-05-22 11:52:26 +00:00
|
|
|
<div id="spacer"></div>
|
|
|
|
<div id="minimize"><div id="minimize-icon"></div></div>
|
|
|
|
<div id="maximize"><div id="maximize-icon"></div></div>
|
|
|
|
<div id="quit"><div id="quit-icon"></div></div>
|
2021-12-24 21:56:49 +00:00
|
|
|
</div>
|
|
|
|
</nav>`;
|
2022-03-04 17:53:18 +00:00
|
|
|
elem.classList.add("withFrame-haYltI");
|
|
|
|
if (document.getElementById("app-mount") == null) {
|
|
|
|
document.body.appendChild(elem);
|
|
|
|
} else {
|
|
|
|
document.getElementById("app-mount")!.prepend(elem);
|
|
|
|
}
|
2022-05-22 11:52:26 +00:00
|
|
|
const titlebarcssPath = path.join(__dirname, "../", "/content/css/titlebar.css");
|
|
|
|
const wordmarkcssPath = path.join(__dirname, "../", "/content/css/logos.css");
|
|
|
|
addStyle(fs.readFileSync(titlebarcssPath, "utf8"));
|
|
|
|
addStyle(fs.readFileSync(wordmarkcssPath, "utf8"));
|
2022-07-04 14:39:22 +00:00
|
|
|
document.body.setAttribute("customTitlebar", "");
|
2022-07-05 17:02:49 +00:00
|
|
|
document.body.setAttribute("armcord-platform", os.platform());
|
2021-12-26 18:58:05 +00:00
|
|
|
|
2022-03-04 17:53:18 +00:00
|
|
|
var minimize = document.getElementById("minimize");
|
|
|
|
var maximize = document.getElementById("maximize");
|
|
|
|
var quit = document.getElementById("quit");
|
2021-12-26 18:58:05 +00:00
|
|
|
|
2022-03-04 17:53:18 +00:00
|
|
|
minimize!.addEventListener("click", () => {
|
|
|
|
ipcRenderer.send("win-minimize");
|
|
|
|
});
|
2021-12-26 18:58:05 +00:00
|
|
|
|
2022-03-04 17:53:18 +00:00
|
|
|
maximize!.addEventListener("click", () => {
|
|
|
|
if (ipcRenderer.sendSync("win-isMaximized") == true) {
|
|
|
|
ipcRenderer.send("win-unmaximize");
|
2022-07-04 14:39:22 +00:00
|
|
|
document.body.removeAttribute("isMaximized");
|
|
|
|
} else if (ipcRenderer.sendSync("win-isNormal") == true) {
|
2022-03-04 17:53:18 +00:00
|
|
|
ipcRenderer.send("win-maximize");
|
|
|
|
}
|
|
|
|
});
|
2021-12-26 18:58:05 +00:00
|
|
|
|
2022-03-04 17:53:18 +00:00
|
|
|
quit!.addEventListener("click", () => {
|
|
|
|
if (ipcRenderer.sendSync("minimizeToTray") === true) {
|
|
|
|
ipcRenderer.send("win-hide");
|
|
|
|
} else if (ipcRenderer.sendSync("minimizeToTray") === false) {
|
|
|
|
ipcRenderer.send("win-quit");
|
|
|
|
}
|
|
|
|
});
|
2021-12-26 18:58:05 +00:00
|
|
|
});
|
2021-12-24 21:56:49 +00:00
|
|
|
}
|
2022-07-18 15:13:52 +00:00
|
|
|
export function injectHummusTitlebar() {
|
|
|
|
document.addEventListener("DOMContentLoaded", function (event) {
|
|
|
|
var elem = document.createElement("div");
|
|
|
|
elem.innerHTML = `
|
|
|
|
<button class="win-minimize" id="minimize"></button><button class="win-maximize" id="maximize"></button><button class="win-close" id="quit"></button>
|
|
|
|
`;
|
|
|
|
elem.classList.add("win-buttons");
|
|
|
|
elem.classList.add("win-buttons-light");
|
|
|
|
document.getElementsByClassName("titlebar")[0].appendChild(elem);
|
|
|
|
document.body.setAttribute("customTitlebar", "");
|
2022-08-22 09:24:55 +00:00
|
|
|
document.body.setAttribute("hummus", "");
|
2022-07-18 15:13:52 +00:00
|
|
|
document.body.setAttribute("armcord-platform", os.platform());
|
2022-08-22 09:24:55 +00:00
|
|
|
addStyle(`
|
|
|
|
html, body {
|
|
|
|
background-color: #1e2124;
|
|
|
|
}
|
|
|
|
|
|
|
|
.friends-header,
|
|
|
|
.chat > .title-wrap {
|
|
|
|
float: right !important;
|
|
|
|
padding-right: 140px !important;
|
|
|
|
}`);
|
2022-07-18 15:13:52 +00:00
|
|
|
var minimize = document.getElementById("minimize");
|
|
|
|
var maximize = document.getElementById("maximize");
|
|
|
|
var quit = document.getElementById("quit");
|
|
|
|
|
|
|
|
minimize!.addEventListener("click", () => {
|
|
|
|
ipcRenderer.send("win-minimize");
|
|
|
|
});
|
|
|
|
|
|
|
|
maximize!.addEventListener("click", () => {
|
|
|
|
if (ipcRenderer.sendSync("win-isMaximized") == true) {
|
|
|
|
ipcRenderer.send("win-unmaximize");
|
|
|
|
document.body.removeAttribute("isMaximized");
|
|
|
|
} else if (ipcRenderer.sendSync("win-isNormal") == true) {
|
|
|
|
ipcRenderer.send("win-maximize");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
quit!.addEventListener("click", () => {
|
|
|
|
if (ipcRenderer.sendSync("minimizeToTray") === true) {
|
|
|
|
ipcRenderer.send("win-hide");
|
|
|
|
} else if (ipcRenderer.sendSync("minimizeToTray") === false) {
|
|
|
|
ipcRenderer.send("win-quit");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|