Module: ZopimRails

Defined in:
lib/zopim_rails.rb,
lib/zopim_rails/chatbox.rb,
lib/zopim_rails/version.rb

Defined Under Namespace

Modules: Rails Classes: Chatbox

Constant Summary collapse

PLACEHOLDER_KEY =
"xxxxxxxxx"
VERSION =
"0.0.4"

Class Method Summary collapse

Class Method Details

.api_keyString

Get the current api key.

Returns:

  • (String)


11
12
13
# File 'lib/zopim_rails.rb', line 11

def self.api_key
  @@api_key ||= PLACEHOLDER_KEY
end

.api_key=(api_key) ⇒ Object

Set the current api key.

Parameters:

  • tracker (String)

    The api key.



17
18
19
# File 'lib/zopim_rails.rb', line 17

def self.api_key=(api_key)
  @@api_key = api_key
end

.initObject



32
33
34
# File 'lib/zopim_rails.rb', line 32

def self.init
  self.render.html_safe
end

.renderObject

To be removed



27
28
29
30
31
# File 'lib/zopim_rails.rb', line 27

def self.render
  "  <script type=\"text/javascript\">function zopim_chat(){$('[__jx__id]').remove();window.$zopim = null;(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s=d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set._.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute('charset','utf-8');$.src='//v2.zopim.com/?2ykAW7vz8GhsKrykTWPE7a6SNXEaYNcJ';z.t=+new Date;$.type='text/javascript';e.parentNode.insertBefore($,e)})(document,'script')};$(window).off('page:change.zopim').on('page:change.zopim', zopim_chat);</script>\n  JAVASCRIPT\nend\n"

.valid_api_key?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/zopim_rails.rb', line 22

def self.valid_api_key?
  api_key.nil? || api_key == "" || api_key == PLACEHOLDER_KEY ? false : true
end