class Help { constructor(options) { this._el = $.el('#help'); this._commands = options.commands; this._newTab = options.newTab; this._toggled = false; this._handleKeydown = this._handleKeydown.bind(this); this.toggle = this.toggle.bind(this); this.launch = this.launch.bind(this); this.launchCategory = this.launchCategory.bind(this); this._inputEl = $.el('#search-input'); this._inputElVal = ''; this._suggester = options.suggester; this._invertColors = options.invertedColors; this._buildAndAppendLists(); this._registerEvents(); this._invertValue; } toggle(show) { this._toggled = typeof show !== 'undefined' ? show : !this._toggled; this._toggled ? $.bodyClassAdd('help') : $.bodyClassRemove('help'); } hide() { $.bodyClassRemove('form'); this._inputEl.value = ''; this._inputElVal = ''; this._suggester.suggest(''); } launch() { this.hide(); this.toggle(true); $.bodyClassAdd('help'); CONFIG.commands.forEach(command => { if(command.quickLaunch) window.open(command.url); }); } launchCategory(){ const categorySet = new Set(); CONFIG.commands.forEach(command => { if(command.category) categorySet.add(command.category); }); const targetCategoryIndex = $.el('#search-input').value.replace('!', ''); const targetCategory = Array.from(categorySet)[targetCategoryIndex - 1]; CONFIG.commands.forEach(command => { if(targetCategory && command.category === targetCategory) window.open(command.url); }); } _buildAndAppendLists() { const lists = document.createElement('ul'); lists.classList.add('categories'); this._getCategories().forEach(category => { lists.insertAdjacentHTML( 'beforeend', `