code cleanup part 2

This commit is contained in:
smartfridge 2022-07-11 21:42:35 +02:00
parent d8fe49df3f
commit 5b509d948f
6 changed files with 100 additions and 82 deletions

View File

@ -0,0 +1,21 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="HtmlUnknownTag" enabled="true" level="WARNING" enabled_by_default="true">
<option name="myValues">
<value>
<list size="7">
<item index="0" class="java.lang.String" itemvalue="nobr" />
<item index="1" class="java.lang.String" itemvalue="noembed" />
<item index="2" class="java.lang.String" itemvalue="comment" />
<item index="3" class="java.lang.String" itemvalue="noscript" />
<item index="4" class="java.lang.String" itemvalue="embed" />
<item index="5" class="java.lang.String" itemvalue="script" />
<item index="6" class="java.lang.String" itemvalue="color" />
</list>
</value>
</option>
<option name="myCustomValuesEnabled" value="true" />
</inspection_tool>
</profile>
</component>

View File

@ -0,0 +1,68 @@
.desktop-capturer-selection {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100vh;
background: rgba(30, 30, 30, 0.75);
color: #ffffff;
z-index: 10000000;
display: flex;
align-items: center;
justify-content: center;
}
.desktop-capturer-selection__scroller {
width: 100%;
max-height: 100vh;
overflow-y: auto;
}
.desktop-capturer-selection__list {
max-width: calc(100% - 100px);
margin: 50px;
padding: 0;
display: flex;
flex-wrap: wrap;
list-style: none;
overflow: hidden;
justify-content: center;
}
.desktop-capturer-selection__item {
display: flex;
margin: 4px;
}
.desktop-capturer-selection__btn {
display: flex;
flex-direction: column;
align-items: stretch;
width: 145px;
margin: 0;
border: 0;
border-radius: 3px;
padding: 4px;
background: #2c2f33;
text-align: left;
}
@media (prefers-reduced-motion: no-preference) {
}
.desktop-capturer-selection__btn:hover,
.desktop-capturer-selection__btn:focus {
background: #7289da;
box-shadow: 0 0 4px rgba(0, 0, 0, 0.45), 0 0 2px rgba(0, 0, 0, 0.25);
color: #fff;
}
.desktop-capturer-selection__thumbnail {
width: 100%;
height: 81px;
object-fit: cover;
}
.desktop-capturer-selection__name {
margin: 6px 0;
white-space: nowrap;
color: white;
text-overflow: ellipsis;
text-align: center;
overflow: hidden;
}
.desktop-capturer-selection__name--cancel {
margin: auto 0;
}

View File

@ -2,6 +2,8 @@
//original https://github.com/electron/electron/issues/16513#issuecomment-602070250
import {ipcRenderer} from "electron";
import {addStyle, addScript} from "../utils";
import fs from "fs";
import path from "path";
const desktopCapturer = {
getSources: (opts: any) => ipcRenderer.invoke("DESKTOP_CAPTURER_GET_SOURCES", opts)
};
@ -41,76 +43,7 @@ export async function getDisplayMediaSelector() {
}
const screenShareCSS = `
.desktop-capturer-selection {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100vh;
background: rgba(30,30,30,.75);
color: #FFFFFF;
z-index: 10000000;
display: flex;
align-items: center;
justify-content: center;
}
.desktop-capturer-selection__scroller {
width: 100%;
max-height: 100vh;
overflow-y: auto;
}
.desktop-capturer-selection__list {
max-width: calc(100% - 100px);
margin: 50px;
padding: 0;
display: flex;
flex-wrap: wrap;
list-style: none;
overflow: hidden;
justify-content: center;
}
.desktop-capturer-selection__item {
display: flex;
margin: 4px;
}
.desktop-capturer-selection__btn {
display: flex;
flex-direction: column;
align-items: stretch;
width: 145px;
margin: 0;
border: 0;
border-radius: 3px;
padding: 4px;
background: #2C2F33;
text-align: left;
@media (prefers-reduced-motion: no-preference) {
transition: background-color .15s, box-shadow .15s, color .15s;
}
color: #dedede;
}
.desktop-capturer-selection__btn:hover,
.desktop-capturer-selection__btn:focus {
background: #7289DA;
box-shadow: 0 0 4px rgba(0,0,0,0.45), 0 0 2px rgba(0,0,0,0.25);
color: #fff;
}
.desktop-capturer-selection__thumbnail {
width: 100%;
height: 81px;
object-fit: cover;
}
.desktop-capturer-selection__name {
margin: 6px 0;
white-space: nowrap;
color: white;
text-overflow: ellipsis;
text-align: center;
overflow: hidden;
}
.desktop-capturer-selection__name--cancel {
margin: auto 0;
}
`;
const screenShareJS = `
@ -155,6 +88,7 @@ window.navigator.mediaDevices.getDisplayMedia = () => new Promise(async (resolve
document.addEventListener("DOMContentLoaded", function () {
addScript(screenShareJS);
addStyle(screenShareCSS);
const screenshareCss = path.join(__dirname, "../", "/content/css/screenshare.css");
addStyle(fs.readFileSync(screenshareCss, "utf8"));
console.log("Capturer injected.");
});

View File

@ -6,14 +6,10 @@ export function injectMobileStuff() {
document.addEventListener("DOMContentLoaded", function (event) {
const mobileCSS = path.join(__dirname, "../", "/content/css/mobile.css");
addStyle(fs.readFileSync(mobileCSS, "utf8"));
var logo = document.getElementById("window-title");
logo!.addEventListener("click", () => {
if (ipcRenderer.sendSync("minimizeToTray") === true) {
ipcRenderer.send("win-hide");
} else if (ipcRenderer.sendSync("minimizeToTray") === false) {
ipcRenderer.send("win-quit");
}
});
// TO-DO: clicking on the logo, or additional button triggers ESC button to move around the UI quicker
// var logo = document.getElementById("window-title");
// logo!.addEventListener("click", () => {
//
// });
});
}

View File

@ -2,7 +2,6 @@ import * as fs from "fs";
import { app, dialog } from "electron";
import path from "path";
export var firstRun: boolean;
export var isSetup: boolean;
export var contentPath: string;
//utility functions that are used all over the codebase or just too obscure to be put in the file used in
export function addStyle(styleString: string) {

View File

@ -4,7 +4,7 @@
// I'm sorry for this mess but I'm not sure how to fix it.
import { BrowserWindow, shell, app, dialog } from "electron";
import path from "path";
import { checkIfConfigIsBroken, firstRun, getConfig, contentPath, isSetup, setConfig, setLang, setWindowState } from "./utils";
import { checkIfConfigIsBroken, firstRun, getConfig, contentPath, setConfig, setLang, setWindowState } from "./utils";
import { registerIpc } from "./ipc";
import * as fs from "fs";
import startServer from "./socket";