Simon Legner 1 year ago
parent 416363a551
commit ff7a10c003

@ -87,7 +87,8 @@ class App extends Events {
}, },
dataCallback(data) { dataCallback(data) {
try { try {
$.extend(data.user || (data.user = {}), app.settings.dump()); data.user ||= {};
Object.assign(data.user, app.settings.dump());
if (data.user.docs) { if (data.user.docs) {
data.user.docs = data.user.docs.split("/"); data.user.docs = data.user.docs.split("/");
} }

@ -185,7 +185,7 @@ app.Searcher = class Searcher extends Events {
constructor(options) { constructor(options) {
super(); super();
this.options = $.extend({}, Searcher.DEFAULTS, options || {}); this.options = { ...Searcher.DEFAULTS, ...(options || {}) };
} }
find(data, attr, q) { find(data, attr, q) {
@ -332,7 +332,7 @@ app.Searcher = class Searcher extends Events {
for (let j = this.scoreMap.length - 1; j >= 0; j--) { for (let j = this.scoreMap.length - 1; j >= 0; j--) {
var objects = this.scoreMap[j]; var objects = this.scoreMap[j];
if (objects) { if (objects) {
results.push.apply(results, objects); results.push(...objects);
} }
} }
return results.slice(0, this.options.max_results); return results.slice(0, this.options.max_results);
@ -369,7 +369,7 @@ app.SynchronousSearcher = class SynchronousSearcher extends app.Searcher {
if (!this.allResults) { if (!this.allResults) {
this.allResults = []; this.allResults = [];
} }
this.allResults.push.apply(this.allResults, this.getResults()); this.allResults.push(...this.getResults());
} }
return super.match(...arguments); return super.match(...arguments);
} }

@ -421,18 +421,6 @@ $.smoothScroll = function (el, end) {
// Utilities // Utilities
// //
$.extend = function (target, ...objects) {
for (var object of objects) {
if (object) {
for (var key in object) {
var value = object[key];
target[key] = value;
}
}
}
return target;
};
$.makeArray = function (object) { $.makeArray = function (object) {
if (Array.isArray(object)) { if (Array.isArray(object)) {
return object; return object;
@ -573,10 +561,7 @@ const HIGHLIGHT_DEFAULTS = {
}; };
$.highlight = function (el, options) { $.highlight = function (el, options) {
if (options == null) { options = { ...HIGHLIGHT_DEFAULTS, ...(options || {}) };
options = {};
}
options = $.extend({}, HIGHLIGHT_DEFAULTS, options);
el.classList.add(options.className); el.classList.add(options.className);
setTimeout(() => el.classList.remove(options.className), options.delay); setTimeout(() => el.classList.remove(options.className), options.delay);
}; };

@ -10,7 +10,7 @@ app.views.Notif = class Notif extends app.View {
constructor(type, options) { constructor(type, options) {
super(); super();
this.type = type; this.type = type;
this.options = $.extend({}, this.constructor.defaultOptions, options || {}); this.options = { ...this.constructor.defaultOptions, ...(options || {}) };
this.init0(); // needs this.options this.init0(); // needs this.options
this.refreshElements(); this.refreshElements();
} }

Loading…
Cancel
Save