diff --git a/Message/Notification/App/AppNotification.js b/Message/Notification/App/AppNotification.js index e69de29..d520214 100644 --- a/Message/Notification/App/AppNotification.js +++ b/Message/Notification/App/AppNotification.js @@ -0,0 +1,34 @@ +/** + * App notification. + * + * @copyright Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @since 1.0.0 + */ +(function (jsOMS) +{ + "use strict"; + + /** @namespace jsOMS.Message.Notification.App */ + jsOMS.Autoloader.defineNamespace('jsOMS.Message.Notification.App'); + + jsOMS.Message.Notification.App.AppNotification = function() + { + this.status = 0; + }; + + jsOMS.Message.Notification.App.AppNotification.prototype.setStatus = function(status) + { + this.status = status; + } + + jsOMS.Message.Notification.App.AppNotification.prototype.requestPermission = function() + { + const self = this; + }; + + jsOMS.Message.Notification.App.AppNotification.prototype.send = function(msg) + { + }; +}(window.jsOMS = window.jsOMS || {})); \ No newline at end of file diff --git a/UI/Input/Voice/ReadManager.js b/UI/Input/Voice/ReadManager.js index 7d844fb..74de2c7 100644 --- a/UI/Input/Voice/ReadManager.js +++ b/UI/Input/Voice/ReadManager.js @@ -14,9 +14,9 @@ jsOMS.Autoloader.defineNamespace('jsOMS.UI.Input.Voice'); // todo: remove once obsolete - var SpeechRecognition = SpeechRecognition || webkitSpeechRecognition - var SpeechGrammarList = SpeechGrammarList || webkitSpeechGrammarList - var SpeechRecognitionEvent = SpeechRecognitionEvent || webkitSpeechRecognitionEvent + var SpeechRecognition = typeof SpeechRecognition !== 'undefined' ? SpeechRecognition : typeof webkitSpeechRecognition !== 'undefined' ? webkitSpeechRecognition : null; + var SpeechGrammarList = typeof SpeechGrammarList !== 'undefined' ? SpeechGrammarList : typeof webkitSpeechGrammarList !== 'undefined' ? webkitSpeechGrammarList : null; + var SpeechRecognitionEvent = typeof SpeechRecognitionEvent !== 'undefined' ? SpeechRecognitionEvent : typeof webkitSpeechRecognitionEvent !== 'undefined' ? webkitSpeechRecognitionEvent : null; /** * @constructor @@ -28,9 +28,13 @@ this.pitch = 1; this.rate = 1; this.lang = typeof lang === 'undefined' ? 'en-US' : lang; - - this.voices = window.speechSynthesis.getVoices(); - this.voice = this.voices[0]; + this.voices = []; + this.voice = null; + + if(SpeechRecognition !== null) { + this.voices = window.speechSynthesis.getVoices(); + this.voice = this.voices[0]; + } }; /** diff --git a/UI/Input/Voice/VoiceManager.js b/UI/Input/Voice/VoiceManager.js index 851ce5b..2799dce 100644 --- a/UI/Input/Voice/VoiceManager.js +++ b/UI/Input/Voice/VoiceManager.js @@ -14,9 +14,9 @@ jsOMS.Autoloader.defineNamespace('jsOMS.UI.Input.Voice'); // todo: remove once obsolete - var SpeechRecognition = SpeechRecognition || webkitSpeechRecognition - var SpeechGrammarList = SpeechGrammarList || webkitSpeechGrammarList - var SpeechRecognitionEvent = SpeechRecognitionEvent || webkitSpeechRecognitionEvent + var SpeechRecognition = typeof SpeechRecognition !== 'undefined' ? SpeechRecognition : typeof webkitSpeechRecognition !== 'undefined' ? webkitSpeechRecognition : null; + var SpeechGrammarList = typeof SpeechGrammarList !== 'undefined' ? SpeechGrammarList : typeof webkitSpeechGrammarList !== 'undefined' ? webkitSpeechGrammarList : null; + var SpeechRecognitionEvent = typeof SpeechRecognitionEvent !== 'undefined' ? SpeechRecognitionEvent : typeof webkitSpeechRecognitionEvent !== 'undefined' ? webkitSpeechRecognitionEvent : null; /** * @constructor @@ -26,10 +26,15 @@ jsOMS.UI.Input.Voice.VoiceManager = function (app, commands, lang) { this.app = app; - this.recognition = new SpeechRecognition(); - this.speechRecognitionList = new SpeechGrammarList(); this.commands = typeof commands === 'undefined' ? {} : commands; - this.lang = typeof lang === 'undefined' ? 'en-US' : lang; + this.lang = typeof lang === 'undefined' ? 'en-US' : lang; + this.recognition = null; + this.speechRecognitionList = null; + + if(SpeechRecognition !== null) { + this.recognition = new SpeechRecognition(); + this.speechRecognitionList = new SpeechGrammarList(); + } }; /** @@ -41,6 +46,10 @@ */ jsOMS.UI.Input.Voice.VoiceManager.prototype.setup = function() { + if(SpeechRecognition === null) { + return; + } + const self = this; this.recognition.lang = this.lang; @@ -127,6 +136,10 @@ */ jsOMS.UI.Input.Voice.VoiceManager.prototype.start = function() { + if(SpeechRecognition === null) { + return; + } + this.recognition.start(); }; @@ -139,6 +152,10 @@ */ jsOMS.UI.Input.Voice.VoiceManager.prototype.stop = function() { + if(SpeechRecognition === null) { + return; + } + this.recognition.stop(); }; }(window.jsOMS = window.jsOMS || {})); \ No newline at end of file