diff --git a/platypush/backend/http/static/css/tts.css b/platypush/backend/http/static/css/tts.css new file mode 100644 index 0000000000..2714662ea8 --- /dev/null +++ b/platypush/backend/http/static/css/tts.css @@ -0,0 +1,9 @@ +#tts-container { + max-width: 60em; + margin: 3em auto; +} + + #tts-form input[type=text] { + width: 100%; + } + diff --git a/platypush/backend/http/static/js/tts.js b/platypush/backend/http/static/js/tts.js new file mode 100644 index 0000000000..2b46af89c2 --- /dev/null +++ b/platypush/backend/http/static/js/tts.js @@ -0,0 +1,65 @@ +$(document).ready(function() { + var $container = $('#tts-container'), + $ttsForm = $('#tts-form'); + + var execute = function(request, onSuccess, onError, onComplete) { + request['target'] = 'localhost'; + return $.ajax({ + type: 'POST', + url: '/execute', + contentType: 'application/json', + dataType: 'json', + data: JSON.stringify(request), + complete: function() { + if (onComplete) { + onComplete(); + } + }, + error: function(xhr, status, error) { + if (onError) { + onError(xhr, status, error); + } + }, + success: function(response, status, xhr) { + if (onSuccess) { + onSuccess(response, status, xhr); + } + }, + beforeSend: function(xhr) { + if (window.token) { + xhr.setRequestHeader('X-Token', window.token); + } + }, + }); + }; + + var initBindings = function() { + $ttsForm.on('submit', function(event) { + var formData = $(this).serializeArray().reduce(function(obj, item) { + var value = item.value.trim(); + if (value.length > 0) { + obj[item.name] = item.value; + } + + return obj; + }, {}); + + execute( + { + type: 'request', + action: 'tts.say', + args: formData, + } + ); + + return false; + }); + }; + + var init = function() { + initBindings(); + }; + + init(); +}); + diff --git a/platypush/backend/http/templates/plugins/tts.html b/platypush/backend/http/templates/plugins/tts.html new file mode 100644 index 0000000000..e33391fbd5 --- /dev/null +++ b/platypush/backend/http/templates/plugins/tts.html @@ -0,0 +1,19 @@ + + + +