dynamic ctx rendering

toast
Kit Kasune 3 years ago
parent 6064f44a62
commit cff99732b1
  1. 29
      index.html
  2. 14
      json/ctx.json
  3. 4
      main.js
  4. 1
      scripts/fileview/load/render.js
  5. 28
      scripts/startup/initcontext.js
  6. 7
      scripts/startup/preload.js

@ -34,34 +34,7 @@
</div> </div>
</div> </div>
<div id="ctx"> <div id="ctx"></div>
<div class="ctx-group">
<div class="ctx-item">
<p class="ctx-name nosel">New Folder</p>
</div>
</div>
<hr>
<div class="ctx-group">
<div class="ctx-item">
<p class="ctx-name nosel">Sort by: Name</p>
</div>
<div class="ctx-item">
<p class="ctx-name nosel">Order: Ascending</p>
</div>
</div>
<hr>
<div class="ctx-group">
<div class="ctx-item">
<p class="ctx-name nosel">Reload</p>
</div>
<div class="ctx-item">
<p class="ctx-name nosel">Refresh</p>
</div>
<div class="ctx-item">
<p class="ctx-name nosel">Options</p>
</div>
</div>
</div>
<script src="./scripts/renderer.js"></script> <script src="./scripts/renderer.js"></script>

@ -0,0 +1,14 @@
[
[
{"name": "New Folder", "id": "ctx-new-folder", "onclick": "newfolder"}
],
[
{"name": "Sort by: Name", "id": "ctx-sort-by", "onclick": "changesort"},
{"name": "Order: Ascending", "id": "ctx-ascension", "onclick": "changeascend"}
],
[
{"name": "Reload", "id": "ctx-reload", "onclick": "reload"},
{"name": "Refresh", "id": "ctx-refresh", "onclick": "refresh"},
{"name": "Options", "id": "ctx-options", "onclick": "options"}
]
]

@ -22,10 +22,10 @@ async function createWindow () {
// and load the index.html of the app. // and load the index.html of the app.
mainWindow.maximize(); mainWindow.maximize();
await mainWindow.loadFile('index.html'); await mainWindow.loadFile('index.html');
//mainWindow.removeMenu(); mainWindow.removeMenu();
// Open the DevTools. // Open the DevTools.
// mainWindow.webContents.openDevTools() // mainWindow.webContents.openDevTools();
} }
// This method will be called when Electron has finished // This method will be called when Electron has finished

@ -25,6 +25,7 @@ module.exports = (dir, options) => {
if (!cfc.classList.contains('file-active')) {cfc.classList.add('file-active');} if (!cfc.classList.contains('file-active')) {cfc.classList.add('file-active');}
if (window.kade.cl) {window.kade.cl.classList.remove('file-active');} if (window.kade.cl) {window.kade.cl.classList.remove('file-active');}
window.kade.cl = cfc; window.kade.cl = cfc;
window.kade.ctxel = cfc;
}; };
if (options.animate) { if (options.animate) {
cfc.style = `animation-delay: ${num * .03}s`; cfc.style = `animation-delay: ${num * .03}s`;

@ -0,0 +1,28 @@
const ctxl = require('../../json/ctx.json');
module.exports = () => {
document.getElementById('ctx').style.display = 'none';
const ctx = document.getElementById('ctx');
console.log(ctxl);
try {
for (let i = 0; i < ctxl.length; i++) {
let k = ctxl[i];
let ctxg = document.createElement('div');
ctxg.className = 'ctx-group';
ctx.appendChild(ctxg);
for (let x = 0; x < k.length; x++) {
let item = k[x];
let ctxi = document.createElement('div');
ctxi.className = 'ctx-item';
ctxi.id = item.id;
try {ctxi.onclick = require(`../contextmenu/${item.onclick}`);} catch {}
ctxg.appendChild(ctxi);
let name = document.createElement('p');
name.classList.add('ctx-name', 'nosel');
name.innerHTML = item.name;
ctxi.appendChild(name);
}
if (i + 1 < ctxl.length) {ctx.appendChild(document.createElement('hr'));}
}
} catch (e) {console.error(e);}
};

@ -17,6 +17,8 @@ window.addEventListener('DOMContentLoaded', () => {
const startDir = `${os.homedir}\\Desktop`; const startDir = `${os.homedir}\\Desktop`;
require('./initcontext')();
require('../fileview/refresh')(startDir); require('../fileview/refresh')(startDir);
setButtons(); setButtons();
@ -24,13 +26,12 @@ window.addEventListener('DOMContentLoaded', () => {
setTimeout(function () { setTimeout(function () {
if (window.kade.elc) {window.kade.elc = false; return;} if (window.kade.elc) {window.kade.elc = false; return;}
if (window.kade.cl) {window.kade.cl.classList.remove('file-active');} if (window.kade.cl) {window.kade.cl.classList.remove('file-active');}
window.kade.ctxel = null;
}, 100); }, 100);
if (window.kade.context) {hideContext(window);} if (window.kade.context) {hideContext(window);}
} }
document.getElementById('ctx').style.display = 'none'; window.kade.refreshInterval = setInterval(lightRefresh, 60000);
window.kade.refreshInterval = setInterval(lightRefresh, 180000);
window.kade.checkDirInterval = setInterval(checkDir, 5000); window.kade.checkDirInterval = setInterval(checkDir, 5000);
require('../keybinds/handleKey')(); require('../keybinds/handleKey')();

Loading…
Cancel
Save