|
|
|
@ -68,8 +68,10 @@ Visualizer.prototype.initRange = function() { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var rangeChange = function(event) { |
|
|
|
|
this.paused = true; |
|
|
|
|
this.actions = this.sorter.generate(event.target.value); |
|
|
|
|
this.actionIndex = 0; |
|
|
|
|
this.updateButtons(); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var container = document.createElement('div'); |
|
|
|
@ -83,7 +85,7 @@ Visualizer.prototype.initRange = function() { |
|
|
|
|
range.setAttribute('type', 'range'); |
|
|
|
|
range.setAttribute('value', 10); |
|
|
|
|
range.setAttribute('min', 10); |
|
|
|
|
range.setAttribute('max', 40); |
|
|
|
|
range.setAttribute('max', 30); |
|
|
|
|
range.addEventListener('change', rangeChange.bind(this)); |
|
|
|
|
range.addEventListener('input', rangeInput.bind(null, msg)); |
|
|
|
|
|
|
|
|
@ -91,7 +93,27 @@ Visualizer.prototype.initRange = function() { |
|
|
|
|
container.appendChild(msg); |
|
|
|
|
|
|
|
|
|
return container; |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
Visualizer.prototype.updateButtons = function() { |
|
|
|
|
if (this.paused === true) { |
|
|
|
|
this.play.className = 'fa fa-play'; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
this.play.className = 'fa fa-pause'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.play.disabled = false; |
|
|
|
|
this.forward.disabled = false; |
|
|
|
|
|
|
|
|
|
if (this.actionIndex >= (this.actions.length - 1)) { |
|
|
|
|
this.play.disabled = true; |
|
|
|
|
this.forward.disabled = true; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
@ -99,21 +121,12 @@ Visualizer.prototype.initRange = function() { |
|
|
|
|
Visualizer.prototype.initControls = function() { |
|
|
|
|
var _this = this; |
|
|
|
|
|
|
|
|
|
var updatePlayPause = function(paused) { |
|
|
|
|
if (paused === true) { |
|
|
|
|
play.className = 'fa fa-play'; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
play.className = 'fa fa-pause'; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var playclick = function() { |
|
|
|
|
this.paused = !this.paused; |
|
|
|
|
updatePlayPause(this.paused); |
|
|
|
|
this.updateButtons(); |
|
|
|
|
|
|
|
|
|
if (this.actionIndex === this.actions.length) { |
|
|
|
|
this.reset(); |
|
|
|
|
this.actionIndex = 0; |
|
|
|
|
this.paused = false; |
|
|
|
|
this.go(); |
|
|
|
|
} |
|
|
|
@ -129,20 +142,21 @@ Visualizer.prototype.initControls = function() { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var restartclick = function() { |
|
|
|
|
this.actionIndex = 0; |
|
|
|
|
this.paused = true; |
|
|
|
|
updatePlayPause(this.paused); |
|
|
|
|
this.reset(); |
|
|
|
|
this.updateButtons(); |
|
|
|
|
this.go(); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var play = document.createElement('button'); |
|
|
|
|
play.className = 'fa fa-play'; |
|
|
|
|
play.title = 'Play' |
|
|
|
|
play.addEventListener('click', playclick.bind(this)); |
|
|
|
|
this.play = document.createElement('button'); |
|
|
|
|
this.play.className = 'fa fa-play'; |
|
|
|
|
this.play.title = 'Play' |
|
|
|
|
this.play.addEventListener('click', playclick.bind(this)); |
|
|
|
|
|
|
|
|
|
var forward = document.createElement('button'); |
|
|
|
|
forward.className = 'fa fa-step-forward' |
|
|
|
|
forward.title = 'Step Forward'; |
|
|
|
|
forward.addEventListener('click', forwardclick.bind(this)); |
|
|
|
|
this.forward = document.createElement('button'); |
|
|
|
|
this.forward.className = 'fa fa-step-forward' |
|
|
|
|
this.forward.title = 'Step Forward'; |
|
|
|
|
this.forward.addEventListener('click', forwardclick.bind(this)); |
|
|
|
|
|
|
|
|
|
var reset = document.createElement('button'); |
|
|
|
|
reset.className = 'fa fa-undo'; |
|
|
|
@ -153,8 +167,8 @@ Visualizer.prototype.initControls = function() { |
|
|
|
|
container.className = 'controls-container'; |
|
|
|
|
|
|
|
|
|
container.appendChild(reset); |
|
|
|
|
container.appendChild(play); |
|
|
|
|
container.appendChild(forward); |
|
|
|
|
container.appendChild(this.play); |
|
|
|
|
container.appendChild(this.forward); |
|
|
|
|
|
|
|
|
|
return container; |
|
|
|
|
}; |
|
|
|
|