Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function submit () {
- let commandTokens = input.value.split(' ').filter(e => e !== '')
- console.log('Submitted: ' + commandTokens)
- if (!initialized) {
- theArray = commandTokens.slice(0)
- input.value = ''
- initialized = true
- output.value += theArray.join(' ') + '\n'
- return
- }
- try {
- commands[commandTokens[0]](commandTokens.slice(1))
- } catch (err) {
- output.value += 'Error: invalid command' + '\n'
- } finally {
- input.value = ''
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement