Jorge Bolois Guerrero
9098f42a93
Better configuration menu. Testing retrieving JSON from GitHub (uploading).
23 lines
678 B
JavaScript
23 lines
678 B
JavaScript
import Log from "./Log.js";
|
|
import StringUtil from "./StringUtil.js";
|
|
|
|
export default class Event {
|
|
|
|
static click(selector, callback) {
|
|
this._addEvent('click', selector, callback)
|
|
}
|
|
|
|
static change(selector, callback) {
|
|
this._addEvent('change', selector, callback)
|
|
}
|
|
|
|
static _addEvent(eventName, selector, callback) {
|
|
Log.debug(`Adding event: ${eventName} to: ${selector}`);
|
|
document.addEventListener(eventName, (event) => {
|
|
if (!event.target.matches(selector)) return;
|
|
Log.debug(`${StringUtil.capitalizeFirstLetter(eventName)} on: ${selector}`);
|
|
callback(event.target);
|
|
});
|
|
}
|
|
|
|
} |