mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-02 00:18:17 +00:00
basic dropdown support (still wip w/ URL, style)
This commit is contained in:
1 parent
717b5a3758
commit
e24c87c76f
4 files changed
+27
-1
No files matched your search
@@ -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();
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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 = [];
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user