An electron-based WIP aesthetic file explorer ^^
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
FileKade/scripts/startup/preload.js

75 lines
2.6 KiB

3 years ago
const os = require('os');
const moment = require('../dep/moment');
const {ipcRenderer} = require('electron');
3 years ago
const setButtons = require('./setbuttons');
const hideContext = require('../contextmenu/hidecontext');
const lightRefresh = require('../fileview/lightrefresh');
const checkDir = require('../fileview/checkdir');
const createToast = require('../toast/createtoast');
3 years ago
window.addEventListener('DOMContentLoaded', () => {
window.kade = {
elc: false,
cpath: '',
sort: 'Name',
ascend: true,
context: false,
chdir: [],
3 years ago
ctxFunc: {},
modals: [],
modal: false,
version: {
name: "Alpha",
semver: require('../../package.json').version
},
platform: undefined
};
3 years ago
const platform = ipcRenderer.sendSync('preload', 'request-platform');
window.kade.platform = platform;
let startDir
switch (platform) {
case 'win32':
startDir = `${os.homedir}\\Desktop`;
break;
case 'linux':
startDir = `/home`;
break;
}
3 years ago
require('./initcontext')();
3 years ago
require('../fileview/refresh')(startDir);
setButtons();
document.onclick = () => {
setTimeout(function () {
if (window.kade.elc) {window.kade.elc = false; return;}
if (window.kade.cl) {window.kade.cl.classList.remove('file-active');}
window.kade.ctxel = null;
3 years ago
}, 100);
if (window.kade.context) {hideContext(window);}
3 years ago
}
window.kade.refreshInterval = setInterval(() => {if (!window.kade.modal) {lightRefresh();}}, 60000);
window.kade.checkDirInterval = setInterval(checkDir, 5000);
require('../keybinds/handleKey')();
setTimeout(() => {createToast("Welcome", ["Welcome to FileKade!", "App by WubzyGD", "Alpha/Pre-release Build"], '#5d60ca', false, 20);}, 1600);
setTimeout(() => {createToast("Welcome", [`Today is ${moment().format('MMMM Do, YYYY')}`, `The time is ${moment().format('h:mma')}`], '#5d60ca', false, 20);}, 1300);
setTimeout(() => {createToast("Recent Changes", "Click to view changelog", '#5d60ca', false, 10, () => {require('./changelog')();});}, 1000);
document.getElementById('title').innerHTML = `FileKade - ${window.kade.version.name} ${window.kade.version.semver}`;
3 years ago
});
window.addEventListener('contextmenu', e => {
e.preventDefault();
require('../contextmenu/createcontext')(e, e.target, window);
setTimeout(function () {
if (window.kade.elc) {window.kade.elc = false; return;}
if (window.kade.cl) {window.kade.cl.classList.remove('file-active');}
}, 100);
});