Advertisement
xapu

Untitled

Jul 19th, 2017
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. function submit () {
  2. let commandTokens = input.value.split(' ').filter(e => e !== '')
  3. console.log('Submitted: ' + commandTokens)
  4. if (!initialized) {
  5. theArray = commandTokens.slice(0)
  6. input.value = ''
  7. initialized = true
  8. output.value += theArray.join(' ') + '\n'
  9. return
  10. }
  11. try {
  12. commands[commandTokens[0]](commandTokens.slice(1))
  13. } catch (err) {
  14. output.value += 'Error: invalid command' + '\n'
  15. } finally {
  16. input.value = ''
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement