Class: AjaxChatPluginVoiceRecognition

Inherits:
AjaxChatPlugin
  • Object
show all
Defined in:
lib/h2g_ajaxchat-plugin-voicerecognition.rb

Instance Method Summary collapse

Constructor Details

#initialize(ac, settings, debug: false) ⇒ AjaxChatPluginVoiceRecognition

Returns a new instance of AjaxChatPluginVoiceRecognition.



12
13
14
15
# File 'lib/h2g_ajaxchat-plugin-voicerecognition.rb', line 12

def initialize(ac, settings, debug: false)
  super(ac, settings, debug: debug)
  @lang = settings[:lang] || 'en-GB'
end

Instance Method Details

#applyObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/h2g_ajaxchat-plugin-voicerecognition.rb', line 17

def apply()

  html = @ac.views[:index].html

  a = html.lines
  r = a.grep /<input name="usermsg"/
  i = a.index(r.first)
  a2 = a.insert i+1, "<button id='start-button'>Start Listening</button>\n"
  @ac.views[:index].html = a2.join

  @ac.views[:index].js = @ac.views[:index].js + js()

end