source/lib/VBListPanel.js
// Create the list panel UI components and initiate device discovery

Create the list panel UI components and initiate device discovery
Create the list panel UI components and initiate device discovery
init() {
    this.config = this.vbConfig.init()
    if (!this.config) {
      ipcRenderer.send('fatal-error-dialog', 'Unable to read config file')
      return
    }
    this.portList = this.restorePortList()
    this.snTable = this.restoreDeviceList()
    this.connectToIp.value = this.config.lastConnectedIp
    this.connectToPort.value = this.config.lastConnectedPort
    this.updateUIDevices()
    ipcRenderer.on('portListChanged',
      (e, portListJson) => this.onPortListChanged(e, portListJson)
    )
    this.connectButton.addEventListener('click',
      e => this.onConnectClick(e)
    )
    this.discoveredDevices.addEventListener('click',
      e => this.onDeviceListClick(e)
    )
    this.discoveredDevices.addEventListener('dblclick',
      e => this.onDeviceListDblClick(e)
    )
    this.friendlyName.addEventListener('input',
      e => this.onFriendlyNameChanged(e)
    )
    this.discoveredDevices.addEventListener('mousedown', e => {
      e.preventDefault()
      return false
    })
    this.connectButton.focus()
    this.deviceListPage.addEventListener('keydown', e => {
      if (VBKeys.keyVal(e) === VBKeys.ENTER) {
        const elem = document.activeElement
        if (elem.tagName === 'TR' && elem.id.startsWith('sn-')) {
          elem.click()
        }
        this.connectButton.click()
      }
    })
    VBDiscover.discover(this.onDiscoveredDevice.bind(this),
                        this.config.maxHostsToScan)
  }
init ( ) { this . config = this . vbConfig . init ( ) if ( ! this . config ) { ipcRenderer . send ( 'fatal-error-dialog' , 'Unable to read config file' ) return } this . portList = this . restorePortList ( ) this . snTable = this . restoreDeviceList ( ) this . connectToIp . value = this . config . lastConnectedIp this . connectToPort . value = this . config . lastConnectedPort this . updateUIDevices ( ) ipcRenderer . on ( 'portListChanged' , ( e , portListJson ) => this . onPortListChanged ( e , portListJson ) ) this . connectButton . addEventListener ( 'click' , e => this . onConnectClick ( e ) ) this . discoveredDevices . addEventListener ( 'click' , e => this . onDeviceListClick ( e ) ) this . discoveredDevices . addEventListener ( 'dblclick' , e => this . onDeviceListDblClick ( e ) ) this . friendlyName . addEventListener ( 'input' , e => this . onFriendlyNameChanged ( e ) ) this . discoveredDevices . addEventListener ( 'mousedown' , e => { e . preventDefault ( ) return false } ) this . connectButton . focus ( ) this . deviceListPage . addEventListener ( 'keydown' , e => { if ( VBKeys . keyVal ( e ) === VBKeys . ENTER ) { const elem = document . activeElement if ( elem . tagName === 'TR' && elem . id . startsWith ( 'sn-' ) ) { elem . click ( ) } this . connectButton . click ( ) } } ) VBDiscover . discover ( this . onDiscoveredDevice . bind ( this ) , this . config . maxHostsToScan ) }
Create the list panel UI components and initiate device discovery
Create the list panel UI components and initiate device discovery
// Read the config data, getting a reference to the JSON config info
 // Restore the port list (from the config object)
 // Restore the saved list of devices (from the config object)
 // Fill in the last connected device and port
 // Update the UI based on the restored device list
 // Listen for updates from the Main Process when port list changes
 // Add Connect button event listener
 // Clicking a device list entry will select it and display its details
 // Double-clicking a device list entry will connect to it
 // The friendly name field for a device entry can be changed by the user
 // Prevent text selection on double-clicking a device list entry
 // Set the initial keyboard focus to the Connect button
 // Add an event handler to the device list page to generate a click event
 // on the Connect button whenever the Enter key is pressed
 // Check whether a device list row is focused; if so, select that item
 // Initiate SSDP discovery
 // Make sure not to start discovery until List panel set up
