/* Copyright (c) 2020, 2023, The Unified Company. This code is part of Unify. This program is free software; you can redistribute it and/or modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE, as published by the Free Software Foundation. See the GNU AFFERO GENERAL PUBLIC LICENSE, for more details. https://unifyjs.org */ import vector2 from '../unify/math/vector2.js'; import event from './event.js'; import tools from '../unify/tools.js'; export default class eventManager{ events = new Array(); eventTerms = new Array(); constructor() { var prototype = Object.getPrototypeOf( document.body ); var innerPrototype = Object.getPrototypeOf( prototype ); var objectProperties = Object.getOwnPropertyNames( innerPrototype ); var eventProperties = objectProperties.filter( this.filterEvent ); var properEventTerms = eventProperties.map( this.removeOn ); // console.log( "properEventTerms", JSON.stringify( properEventTerms ) ); this.eventTerms = properEventTerms; } filterEvent( name ) { if( name[0] == "o" && name[1] == "n" ){ return true; } else { return false; } } removeOn( name ) { return name.substr( 2, name.length ); } addClientEvent( className, eventName, callback ) { var newEvent = new event(); newEvent.className = className; newEvent.name = eventName; newEvent.callback = callback; this.events.push(newEvent); } getClientEvents( classname, eventName ){ var events = []; for(var c = 0; c