Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

unmangle/cleanup/simplifying. Ready. #2256

Merged
merged 7 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 31 additions & 41 deletions menu/satus.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,13 @@ satus.isset = function(target, is_object) {
--------------------------------------------------------------*/
satus.isFunction =function(target){return typeof target ==='function';};

satus.isArray =function(t){if(Array.isArray(t)) {return true;}else{return false;}};
satus.isString =function(t){if(typeof t ==='string') {return true;}else{return false;}};
satus.isNumber =function(t){if(typeof t ==='number'&&isNaN(t)===false){return true;}else{return false;}};
satus.isObject =function(t){return t instanceof Object && t !==null;};
satus.isElement =function(t){return t instanceof Element || t instanceof HTMLDocument;};
satus.isNodeList =function(t){return t instanceof NodeList;};
satus.isBoolean =function(t){return t ===false || t ===true;};
satus.isArray = Array.isArray;
satus.isString = function(t) { return typeof t ==='string'; };
satus.isNumber = function(t) { return (typeof t ==='number' && !isNaN(t)); };
satus.isObject = function(t) { return (t instanceof Object && t !== null); };
satus.isElement = function(t) { return (t instanceof Element || t instanceof HTMLDocument); };
satus.isNodeList = function(t) { return t instanceof NodeList; };
satus.isBoolean = function(t) { return (t === false || t === true); };
/*---LOG------------------------------------------------------*/
satus.log =function(){console.log.apply(null, arguments);};

Expand Down Expand Up @@ -1388,9 +1388,7 @@ satus.components.textField = function(component, skeleton) {
handler = component.syntax.handlers[component.syntax.current],
value = component.value || '';

for (var i = this.childNodes.length - 1; i > -1; i--) {
this.childNodes[i].remove();
}
satus.empty(this);

if (handler) {
handler(value, this);
Expand All @@ -1399,10 +1397,10 @@ satus.components.textField = function(component, skeleton) {
}

if (value.length === 0) {
var placeholder = component.placeholder;
let placeholder = component.placeholder;

if (typeof placeholder === 'function') {
placeholder = component.placeholder();
placeholder = placeholder();
} else {
placeholder = satus.locale.get(placeholder);
}
Expand Down Expand Up @@ -1504,9 +1502,9 @@ satus.components.textField = function(component, skeleton) {
});

component.addEventListener('render', function() {
component.lineNumbers.update();
component.pre.update();
component.cursor.update();
this.lineNumbers.update();
this.pre.update();
this.cursor.update();
});

if (skeleton.on?.blur) {
Expand Down Expand Up @@ -1788,17 +1786,14 @@ satus.components.layers = function(component, skeleton) {
--------------------------------------------------------------*/

satus.components.list = function(component, skeleton) {
for (var i = 0, l = skeleton.items.length; i < l; i++) {
var li = component.createChildElement('div', 'item'),
item = skeleton.items[i];

for (var j = 0, k = item.length; j < k; j++) {
var child = item[j];
for (const item of skeleton.items) {
const li = component.createChildElement('div', 'item');

for (const child of item) {
if (satus.isObject(child)) {
satus.render(child, li);
} else {
var span = li.createChildElement('span');
const span = li.createChildElement('span');

span.textContent = satus.locale.get(child);
}
Expand Down Expand Up @@ -2125,7 +2120,7 @@ satus.components.slider = function(component, skeleton) {
--------------------------------------------------------------*/

satus.components.tabs = function(component, skeleton) {
var tabs = skeleton.items,
let tabs = skeleton.items,
value = skeleton.value;

if (satus.isFunction(tabs)) {
Expand All @@ -2136,12 +2131,11 @@ satus.components.tabs = function(component, skeleton) {
value = value();
}

for (var i = 0, l = tabs.length; i < l; i++) {
var tab = tabs[i],
button = component.createChildElement('button');
for (const tab of tabs) {
const button = component.createChildElement('button');

button.addEventListener('click', function() {
var component = this.parentNode,
const component = this.parentNode,
index = satus.elementIndex(this);

component.value = index;
Expand Down Expand Up @@ -2420,7 +2414,7 @@ satus.components.shortcut = function(component, skeleton) {

component.render(component.valueElement);

satus.storage.remove(component.storage.key);
satus.storage.remove();

this.parentNode.parentNode.parentNode.close();

Expand Down Expand Up @@ -3218,9 +3212,7 @@ satus.user.device.connection = function() {
--------------------------------------------------------------*/

satus.search = function(query, object, callback) {
var elements = ['switch', 'select', 'slider', 'shortcut', 'radio', 'color-picker', 'label', 'button'],
threads = 0,
results = {},
const included = ['switch', 'select', 'slider', 'shortcut', 'radio', 'color-picker', 'label', 'button'],
excluded = [
'baseProvider',
'layersProvider',
Expand All @@ -3231,19 +3223,19 @@ satus.search = function(query, object, callback) {
'parentElement',
'rendered'
];
let threads = 0,
results = {};

query = query.toLowerCase();

function parse(items, parent) {
threads++;

for (const key in items) {
for (const [key, item] of Object.entries(items)) {
if (!excluded.includes(key)) {
var item = items[key];

if (item.component && item.text
// list of elements we allow search on
&& elements.includes(item.component)
&& included.includes(item.component)
// only pass buttons whose parents are variant: 'card' or special case 'appearance' (this one abuses variant tag for CSS)
&& (item.component != 'button' || item.parentObject?.variant == "card" || item.parentObject?.variant == "appearance")
// try to match query against localized description, fallback on component name
Expand All @@ -3252,12 +3244,10 @@ satus.search = function(query, object, callback) {
results[key] = Object.assign({}, item);
}

if (
satus.isObject(item) &&
!satus.isArray(item) &&
!satus.isElement(item) &&
!satus.isFunction(item)
) {
if (satus.isObject(item)
&& !satus.isArray(item)
&& !satus.isElement(item)
&& !satus.isFunction(item)) {
parse(item, items);
}
}
Expand Down
4 changes: 2 additions & 2 deletions menu/skeleton-parts/appearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -800,8 +800,8 @@ extension.skeleton.main.layers.section.appearance.on.click.sidebar = {
text: "collapsed",
value: "collapsed"
}, {
text: 'Hide_the_tabs_only',
value: "hidetabs"
text: 'Hide_the_tabs_only',
value: "hidetabs"
}],
tags: "right",
on: {
Expand Down
76 changes: 27 additions & 49 deletions menu/skeleton-parts/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -619,31 +619,9 @@ extension.skeleton.main.layers.section.player.on.click = {
subtitles_window_color: {
component: 'select',
text: 'windowColor',
options: [{
text: 'white',
value: '#fff'
}, {
text: 'yellow',
value: '#ff0'
}, {
text: 'green',
value: '#0f0'
}, {
text: 'cyan',
value: '#0ff'
}, {
text: 'blue',
value: '#00f'
}, {
text: 'magenta',
value: '#f0f'
}, {
text: 'red',
value: '#f00'
}, {
text: 'black',
value: '#000'
}]
options: function () {
return extension.skeleton.main.layers.section.player.on.click.section_1.subtitles.on.click.subtitles_background_color.options;
}
},
subtitles_window_opacity: {
component: 'slider',
Expand Down Expand Up @@ -1063,28 +1041,28 @@ extension.skeleton.main.layers.section.player.on.click = {
component: 'section',
variant: 'card',
title: 'extraButtonsBelowThePlayer',
below_player_screenshot: {
component: 'switch',
text: 'screenshot',
value: true
},
below_player_pip: {
component: 'switch',
text: 'pictureInPicture',
value: true
},
below_player_loop: {
component: 'switch',
text: 'loop',
value: true
}
},
player_hide_controls_options: {
component: "button",
text: "hidePlayerControlsBarButtons",
on: {
click: 'main.layers.section.appearance.on.click.player.on.click.player_hide_controls_options.on.click'
}
},
}
below_player_screenshot: {
component: 'switch',
text: 'screenshot',
value: true
},
below_player_pip: {
component: 'switch',
text: 'pictureInPicture',
value: true
},
below_player_loop: {
component: 'switch',
text: 'loop',
value: true
}
},
player_hide_controls_options: {
component: "button",
text: "hidePlayerControlsBarButtons",
on: {
click: 'main.layers.section.appearance.on.click.player.on.click.player_hide_controls_options.on.click'
}
},
}
};
Loading