basic dropdown support (still wip w/ URL, style)

This commit is contained in:
Brandon Thomas committed 2016-02-11 05:25:56 -05:00
1 parent 717b5a3758
commit e24c87c76f
4 files changed
+27 -1

No files matched your search

+9 -1
View File
@@ -24,12 +24,20 @@
}
},
/** Handle changing voices. */
handleVoiceSelect: function(ev) {
var selectedVoice = $('select').val();
Ui.clearInput();
Ui.setVoice(selectedVoice);
Ui.setStateFromInput();
},
/** Handle form submission. */
handleFormSubmit: function(ev) {
var $audio = $('#sound'),
sentence = $('#text').val(),
speaker = $('select').val(),
query = encodeURIComponent(sentence),
speaker = 'trump', // TODO: Don't hardcode
url = '/speak?v=' + speaker + '&s=' + query;
ev.preventDefault();
+1
View File
@@ -8,6 +8,7 @@
$('form').submit(function(ev) { return Events.handleFormSubmit(ev); });
$('input').on('keyup', function(ev) { return Events.handleTyping(ev); });
$('body').on('keyup', function(ev) { return Events.handleBodyTyping(ev); });
$('select').on('change', function(ev) { return Events.handleVoiceSelect(ev); });
}
/** Init the UI, possibly from a state passed in from the URL. */
+13
View File
@@ -16,6 +16,19 @@
this.setStateFromInput();
},
/** Set the voice. */
setVoice: function(voice) {
var vocabulary = Library.getSpeakerVocabulary(voice);
if (vocabulary) {
this.currentVocabulary = vocabulary;
}
},
/** Clear the input box. */
clearInput: function() {
$('input').val('');
},
// TODO: Rename, redesign.
setFromInput: function(sentence) {
var suggestedWords = [];
+4
View File
@@ -14,6 +14,10 @@
<div id="controls">
<form id="form" action="#">
<input id="text">
<select name="voice">
<option value="trump">trump</option>
<option value="hillary">hillary</option>
</select>
<button id="submit">Submit</button>
</form>
</div>