Skip to content

Commit 342586f

Browse files
author
Michelle Tilley
committed
Trim commands
Fixes #73
1 parent 941d1d7 commit 342586f

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

js/controlbox.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,24 +220,25 @@ function(_yargs, d3, demos) {
220220
},
221221

222222
command: function(entry) {
223-
if (entry.trim() === '') {
223+
entry = entry.trim()
224+
if (entry === '') {
224225
return;
225226
}
226227

227228
document.getElementById('last-command').textContent = entry
228229

229-
if (entry.trim() === 'pres()') {
230+
if (entry === 'pres()') {
230231
window.pres()
231232
return
232233
}
233234

234-
if (entry.trim().toLowerCase().indexOf('mode ') === 0) {
235-
var mode = entry.trim().split(' ').pop().trim()
235+
if (entry.toLowerCase().indexOf('mode ') === 0) {
236+
var mode = entry.split(' ').pop()
236237
this.changeMode(mode)
237238
return
238239
}
239240

240-
if (entry.trim().toLowerCase() === 'undo') {
241+
if (entry.toLowerCase() === 'undo') {
241242
var lastId = this.undoHistory.pointer - 1
242243
var lastState = this.undoHistory.stack[lastId]
243244
if (lastState) {
@@ -255,7 +256,7 @@ function(_yargs, d3, demos) {
255256
return
256257
}
257258

258-
if (entry.trim().toLowerCase() === 'redo') {
259+
if (entry.toLowerCase() === 'redo') {
259260
var lastId = this.undoHistory.pointer + 1
260261
var lastState = this.undoHistory.stack[lastId]
261262
if (lastState) {
@@ -273,7 +274,7 @@ function(_yargs, d3, demos) {
273274
return
274275
}
275276

276-
if (entry.trim().toLowerCase() === 'clear') {
277+
if (entry.toLowerCase() === 'clear') {
277278
window.resetVis()
278279
return
279280
}

0 commit comments

Comments
 (0)