Skip to content

Commit

Permalink
added customisation to skipDuration
Browse files Browse the repository at this point in the history
  • Loading branch information
frostnova721 committed Dec 18, 2023
1 parent f63867f commit f230f9f
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 1 deletion.
26 changes: 26 additions & 0 deletions Public/css/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,32 @@ button.item {
display: flex;
}

.skipDurationDiv {
display: flex;
font-size: 1.2rem;
}

.skipInput {
margin-left: 20px;
border: none;
border-bottom: 2px solid grey;
background-color: transparent;
color: white;
font-family: Poppins-Bold;
font-size: 1.2rem;
width: 40px;
}

.skipInput:focus {
outline: none;
border-bottom: 2px solid #caf979;
}

.skipInput:hover {
border-bottom: 2px solid #caf979;
}


/* .dropdown.drop {
opacity: 1;
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion Public/css/watch.css
Original file line number Diff line number Diff line change
Expand Up @@ -425,4 +425,4 @@ button:focus {
100% {
box-shadow: 19px 0 0 0, 38px 0 0 3px, 57px 0 0 7px;
}
}
}
3 changes: 3 additions & 0 deletions Public/html/Settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<div class="options" id="options" data-value="cache">
<p>Cache</p>
</div>
<div class="options" id="options" data-value="player">
<p>Player</p>
</div>
<div class="options" id="options" data-value="info">
<p>Info</p>
</div>
Expand Down
6 changes: 6 additions & 0 deletions src/Core/Subrender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,9 @@ export async function getAppDetails(): Promise<{ version: string; name: string }
export async function reload() {
await ipcRenderer.invoke('reloadMain');
}

export async function setDefaultSkipTime(duration: number) {
const settings = await readSettings()
settings.skipDuration = duration < 60 ? duration : 60
await writeSettings(settings)
}
45 changes: 45 additions & 0 deletions src/Render/renderSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ import {
getDataBase,
getDefaultStream,
readSettings,
setDefaultSkipTime,
} from '../Core';
import { Settings } from '../Types';

const defaultSettings: Settings = {
database: 'anilist',
defaultStream: 'gogoanime',
skipDuration: 5
}

//just tried making the html in js(bad idea)

const options = document.getElementById('left');

Expand All @@ -30,11 +40,14 @@ document.addEventListener('DOMContentLoaded', async () => {
await appendGeneral();
} else if (selectedElement.getAttribute('data-value') === 'info') {
await appendInfo();
} else if (selectedElement.getAttribute('data-value') === 'player') {
await appendPlayer()
}
}
});
});

//CACHE
function appendCache() {
clearPage();
const right = document.getElementById('insidediv');
Expand All @@ -61,6 +74,7 @@ function appendCache() {
right.appendChild(element);
}

//GENERAL
async function appendGeneral() {
clearPage();
const insidediv = document.getElementById('insidediv');
Expand All @@ -82,6 +96,7 @@ function clearPage() {
inside.innerHTML = '';
}

//streams
async function loadStreamOptions() {
const imgPath = '../../Public/Assets/Icons/down-arrow.png';

Expand Down Expand Up @@ -128,6 +143,7 @@ async function loadStreamOptions() {
return element;
}

//dbs
async function loadDbOptions() {
const element = document.createElement('div');
element.className = 'db'; //unused
Expand Down Expand Up @@ -174,6 +190,7 @@ async function loadDbOptions() {
return element;
}

//INFO
async function appendInfo() {
clearPage();
const html = `<h2>INFO</h2>
Expand All @@ -200,3 +217,31 @@ async function appendInfo() {
shell.openExternal((e.target as HTMLAnchorElement).href);
};
}

//PLAYER
async function appendPlayer() {
clearPage()

const insidediv = document.getElementById('insidediv');
if(!insidediv) return

const settings = await readSettings()

const html = `<div class="skipDurationDiv">
<div class="skipTitle">skip duration</div>
<input type="number" max="60" min="0" class="skipInput" id="skipInput" value="${settings.skipDuration}">s
</div>`

insidediv.innerHTML = html

const skipInput = document.getElementById('skipInput') as HTMLInputElement
skipInput?.addEventListener('input', async() => {
const enteredVal = parseInt(skipInput.value, 10);
console.log('inp')
if(enteredVal > 60) {
skipInput.value = '60'
}
await setDefaultSkipTime(enteredVal)
})

}

0 comments on commit f230f9f

Please sign in to comment.