Commit to not lose files
parent
e63af2581c
commit
9e7d40d707
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"name": "Keyzo",
|
||||||
|
"version": "0.1"
|
||||||
|
}
|
@ -1,20 +1,42 @@
|
|||||||
{
|
[
|
||||||
"Applications": {
|
{
|
||||||
|
"title": "applications",
|
||||||
"description": "Open/Close/Modify your applications",
|
"description": "Open/Close/Modify your applications",
|
||||||
"open app": {
|
"children": [
|
||||||
"description": "Open an application"
|
{
|
||||||
},
|
"title": "open app",
|
||||||
"close app": {
|
"description": "Open an application",
|
||||||
"description": "Close an application"
|
"children": [
|
||||||
}
|
{
|
||||||
|
"title": "test"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "lksfjslkd"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"System": {
|
{
|
||||||
|
"title": "system",
|
||||||
|
"description": "Open/Close/Modify your applications",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"title": "yeetapp",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"title": "lksfjslkd"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "system functions",
|
||||||
"description": "Interact with your system"
|
"description": "Interact with your system"
|
||||||
},
|
},
|
||||||
"Keys": {
|
{
|
||||||
|
"title": "keys",
|
||||||
"description": "Output keyboard inputs"
|
"description": "Output keyboard inputs"
|
||||||
},
|
|
||||||
"System Functions": {
|
|
||||||
"description": "Some predefined functions"
|
|
||||||
}
|
}
|
||||||
}
|
]
|
After Width: | Height: | Size: 13 KiB |
@ -1,159 +0,0 @@
|
|||||||
const app = require("electron").remote.app;
|
|
||||||
const path = app.getAppPath();
|
|
||||||
|
|
||||||
const q = document.querySelector.bind(document);
|
|
||||||
const c = document.createElement.bind(document);
|
|
||||||
|
|
||||||
const $ = require(path + "/src/javascripts/jquery.min.js");
|
|
||||||
const functions = require(path + "/json/functions.json");
|
|
||||||
|
|
||||||
// Predefine some vars
|
|
||||||
var keys = {},
|
|
||||||
showsFunctions = {},
|
|
||||||
keybind;
|
|
||||||
|
|
||||||
// Detect keybinds
|
|
||||||
$(".keybind-input").on("keyup", (e) => {
|
|
||||||
keys[e.key.toUpperCase()] = false;
|
|
||||||
setInput();
|
|
||||||
});
|
|
||||||
|
|
||||||
$(".keybind-input").on("keydown", (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
Object.keys(keys).forEach((g) => {
|
|
||||||
if (!keys[g]) delete keys[g];
|
|
||||||
});
|
|
||||||
|
|
||||||
keys[e.key.toUpperCase()] = true;
|
|
||||||
setInput();
|
|
||||||
});
|
|
||||||
|
|
||||||
function setInput() {
|
|
||||||
keybind = Object.keys(keys).join(" + ");
|
|
||||||
|
|
||||||
if (Object.values(keys).filter((k) => k).length == 0) {
|
|
||||||
$(".keybind-input").hide();
|
|
||||||
$(".customize").show();
|
|
||||||
}
|
|
||||||
|
|
||||||
$(".show-keybind").html(keybind);
|
|
||||||
$(".keybind-input").val(keybind);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure buttons
|
|
||||||
$(".add-keybind").click(() => {
|
|
||||||
$(".dark-overlay").show().addClass("d-flex");
|
|
||||||
$(".keybind-input").show().focus();
|
|
||||||
});
|
|
||||||
|
|
||||||
$(".cancel-btn").click(resetKeyAdder);
|
|
||||||
$(".done-btn").click(resetKeyAdder);
|
|
||||||
|
|
||||||
$(".change-btn").click(() => {
|
|
||||||
$(".keybind-input").show().focus().val("");
|
|
||||||
$(".customize").hide();
|
|
||||||
});
|
|
||||||
|
|
||||||
function resetKeyAdder() {
|
|
||||||
$(".dark-overlay").hide().removeClass("d-flex");
|
|
||||||
|
|
||||||
$(".keybind-input").val("");
|
|
||||||
$(".customize").hide();
|
|
||||||
$(".done-btn").hide();
|
|
||||||
|
|
||||||
keybind = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load functions from json
|
|
||||||
Object.keys(functions).forEach((cat) => {
|
|
||||||
let catNoSpace = cat.replace(/ /g, "");
|
|
||||||
// Select category
|
|
||||||
let catagoryItem = createCatagoryItem(cat, catNoSpace),
|
|
||||||
catagoryFunctions = c("div"),
|
|
||||||
functionItems = createFunctionItem(functions[cat]);
|
|
||||||
|
|
||||||
q(".select-category").appendChild(catagoryItem);
|
|
||||||
|
|
||||||
catagoryFunctions.classList.add(catNoSpace);
|
|
||||||
catagoryFunctions.style.display = "none";
|
|
||||||
|
|
||||||
functionItems.forEach((item) => {
|
|
||||||
catagoryFunctions.appendChild(item);
|
|
||||||
});
|
|
||||||
|
|
||||||
q(".select-function").appendChild(catagoryFunctions);
|
|
||||||
});
|
|
||||||
|
|
||||||
function createCatagoryItem(f, noSpace) {
|
|
||||||
let title = c("div"),
|
|
||||||
trailing = c("i"),
|
|
||||||
subtitle = c("div");
|
|
||||||
|
|
||||||
title.classList.add("category-item");
|
|
||||||
title.classList.add("bold");
|
|
||||||
title.innerHTML = f.toUpperCase();
|
|
||||||
|
|
||||||
title.addEventListener("click", () => {
|
|
||||||
showsFunctions[f] = !showsFunctions[f] ?? true;
|
|
||||||
|
|
||||||
Object.keys(showsFunctions).forEach((i) => {
|
|
||||||
if (f !== i) {
|
|
||||||
showsFunctions[i] = false;
|
|
||||||
$("." + i.replace(/ /g, "")).hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (showsFunctions[f]) {
|
|
||||||
$(".select-function").show();
|
|
||||||
$("." + noSpace).show();
|
|
||||||
} else {
|
|
||||||
$(".select-function").hide();
|
|
||||||
$("." + noSpace).hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
trailing.classList.add("category-arrow");
|
|
||||||
trailing.classList.add("material-icons");
|
|
||||||
trailing.innerHTML = "arrow_forward_ios";
|
|
||||||
|
|
||||||
subtitle.classList.add("text-muted");
|
|
||||||
subtitle.innerHTML = functions[f].description;
|
|
||||||
|
|
||||||
title.appendChild(subtitle);
|
|
||||||
title.appendChild(trailing);
|
|
||||||
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createFunctionItem(f) {
|
|
||||||
delete f.description;
|
|
||||||
var result = [];
|
|
||||||
|
|
||||||
Object.keys(f).forEach((func) => {
|
|
||||||
result.push(createFunctionItem(func, f[func].description));
|
|
||||||
});
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createListItem(title, subtitle) {
|
|
||||||
let titleEl = c("div"),
|
|
||||||
trailing = c("i"),
|
|
||||||
subtitleEl = c("div");
|
|
||||||
|
|
||||||
titleEl.classList.add("category-item");
|
|
||||||
titleEl.classList.add("bold");
|
|
||||||
titleEl.innerHTML = title.toUpperCase();
|
|
||||||
|
|
||||||
trailing.classList.add("category-arrow");
|
|
||||||
trailing.classList.add("material-icons");
|
|
||||||
trailing.innerHTML = "arrow_forward_ios";
|
|
||||||
|
|
||||||
subtitleEl.classList.add("text-muted");
|
|
||||||
subtitleEl.innerHTML = subtitle;
|
|
||||||
|
|
||||||
titleEl.appendChild(trailing);
|
|
||||||
titleEl.appendChild(subtitleEl);
|
|
||||||
return titleEl;
|
|
||||||
}
|
|
@ -0,0 +1,59 @@
|
|||||||
|
const path = require("electron").remote.app.getAppPath();
|
||||||
|
const $ = require(path + "/src/javascripts/jquery.min.js");
|
||||||
|
|
||||||
|
// Predefine some vars
|
||||||
|
var keys = {},
|
||||||
|
keybind;
|
||||||
|
|
||||||
|
// Detect keybinds
|
||||||
|
$(".keybind-input").on("keyup", (e) => {
|
||||||
|
keys[e.key.toUpperCase()] = false;
|
||||||
|
setInput();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".keybind-input").on("keydown", (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
Object.keys(keys).forEach((g) => {
|
||||||
|
if (!keys[g]) delete keys[g];
|
||||||
|
});
|
||||||
|
|
||||||
|
keys[e.key.toUpperCase()] = true;
|
||||||
|
setInput();
|
||||||
|
});
|
||||||
|
|
||||||
|
function setInput() {
|
||||||
|
keybind = Object.keys(keys).join(" + ");
|
||||||
|
|
||||||
|
if (Object.values(keys).filter((k) => k).length == 0) {
|
||||||
|
$(".keybind-input").hide();
|
||||||
|
$(".customize").show();
|
||||||
|
}
|
||||||
|
|
||||||
|
$(".show-keybind").html(keybind);
|
||||||
|
$(".keybind-input").val(keybind);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configure buttons
|
||||||
|
$(".add-keybind").click(() => {
|
||||||
|
$(".dark-overlay").show().addClass("d-flex");
|
||||||
|
$(".keybind-input").show().focus();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".cancel-btn").click(resetKeyAdder);
|
||||||
|
$(".done-btn").click(resetKeyAdder);
|
||||||
|
|
||||||
|
$(".change-btn").click(() => {
|
||||||
|
$(".keybind-input").show().focus().val("");
|
||||||
|
$(".customize").hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
function resetKeyAdder() {
|
||||||
|
$(".dark-overlay").hide().removeClass("d-flex");
|
||||||
|
|
||||||
|
$(".keybind-input").val("");
|
||||||
|
$(".customize").hide();
|
||||||
|
$(".done-btn").hide();
|
||||||
|
|
||||||
|
keybind = null;
|
||||||
|
}
|
@ -0,0 +1,75 @@
|
|||||||
|
const c = document.createElement.bind(document);
|
||||||
|
const q = document.querySelector.bind(document);
|
||||||
|
|
||||||
|
const functions = require(path + "/json/functions.json");
|
||||||
|
var showsFunctions = [];
|
||||||
|
|
||||||
|
// Load functions from json
|
||||||
|
function init() {
|
||||||
|
cycleList(functions, "", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function cycleList(list, title, i) {
|
||||||
|
let div = c("div");
|
||||||
|
|
||||||
|
showsFunctions[i] = {};
|
||||||
|
list.forEach((item) => {
|
||||||
|
showsFunctions[i][item.title] = false;
|
||||||
|
div.appendChild(createListItem(i, item.title, item.description));
|
||||||
|
if (item.children) {
|
||||||
|
cycleList(item.children, item.title.replace(/ /g, ""), i + 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (title) div.classList.add(title);
|
||||||
|
q(".select-function-" + i).appendChild(div);
|
||||||
|
}
|
||||||
|
|
||||||
|
function createListItem(which, t, s) {
|
||||||
|
let showsFunctionsLocal = showsFunctions[which],
|
||||||
|
title = c("div"),
|
||||||
|
trailing = c("i"),
|
||||||
|
subtitle = c("div"),
|
||||||
|
noSpace = t.replace(/ /g, "");
|
||||||
|
|
||||||
|
title.classList.add("category-item");
|
||||||
|
title.classList.add("bold");
|
||||||
|
title.innerHTML = t.toUpperCase();
|
||||||
|
|
||||||
|
trailing.classList.add("category-arrow");
|
||||||
|
trailing.classList.add("material-icons");
|
||||||
|
trailing.innerHTML = "arrow_forward_ios";
|
||||||
|
|
||||||
|
title.addEventListener("click", () => {
|
||||||
|
showsFunctionsLocal[t] = !showsFunctionsLocal[t];
|
||||||
|
|
||||||
|
Object.keys(showsFunctionsLocal).forEach((i) => {
|
||||||
|
if (t !== i) {
|
||||||
|
showsFunctionsLocal[i] = false;
|
||||||
|
// console.log("Clicked: " + t, "Did not click: " + i);
|
||||||
|
$("." + i.replace(/ /g, "")).hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// console.log(showsFunctions, which, t);
|
||||||
|
|
||||||
|
if (showsFunctionsLocal[t]) {
|
||||||
|
$(".select-function-" + (which + 1)).show();
|
||||||
|
$("." + noSpace).show();
|
||||||
|
} else {
|
||||||
|
$(".select-function-" + (which + 1)).hide();
|
||||||
|
$("." + noSpace).hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
subtitle.classList.add("text-muted");
|
||||||
|
subtitle.innerHTML = s;
|
||||||
|
|
||||||
|
title.appendChild(trailing);
|
||||||
|
|
||||||
|
if (s) title.appendChild(subtitle);
|
||||||
|
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
init();
|
Reference in new issue