codecombat/app/lib/services/olark.coffee

116 lines
2.6 KiB
CoffeeScript
Raw Normal View History

module.exports = initializeOlark = ->
window.olark or ((c) -> #<![CDATA[
f = window
d = document
2014-06-30 22:16:26 -04:00
l = (if f.location.protocol is 'https:' then 'https:' else 'http:')
z = c.name
2014-06-30 22:16:26 -04:00
r = 'load'
nt = ->
s = ->
a.P r
f[z] r
return
f[z] = ->
2014-06-16 06:55:58 -04:00
(a.s = a.s or []).push arguments
return
a = f[z]._ = {}
q = c.methods.length
while q--
((n) ->
f[z][n] = ->
2014-06-30 22:16:26 -04:00
f[z] 'call', n, arguments
return
return
) c.methods[q]
a.l = c.loader
a.i = nt
a.p = 0: +new Date
a.P = (u) ->
a.p[u] = new Date - a.p[0]
return
2014-06-30 22:16:26 -04:00
(if f.addEventListener then f.addEventListener(r, s, false) else f.attachEvent('on' + r, s))
ld = ->
p = (hd) ->
2014-06-30 22:16:26 -04:00
hd = 'head'
[
2014-06-30 22:16:26 -04:00
'<'
hd
2014-06-30 22:16:26 -04:00
'></'
hd
2014-06-30 22:16:26 -04:00
'><'
i
2014-06-30 22:16:26 -04:00
' onl' + 'oad=\"var d='
g
";d.getElementsByTagName('head')[0]."
j
2014-06-30 22:16:26 -04:00
'(d.'
h
"('script'))."
k
"='"
l
2014-06-30 22:16:26 -04:00
'//'
a.l
"'"
2014-06-30 22:16:26 -04:00
'\"'
'></'
i
2014-06-30 22:16:26 -04:00
'>'
].join ''
i = 'body'
m = d[i]
return setTimeout(ld, 100) unless m
a.P 1
2014-06-30 22:16:26 -04:00
j = 'appendChild'
h = 'createElement'
k = 'src'
n = d[h]('div')
v = n[j](d[h](z))
2014-06-30 22:16:26 -04:00
b = d[h]('iframe')
g = 'document'
e = 'domain'
o = undefined
2014-06-30 22:16:26 -04:00
n.style.display = 'none'
m.insertBefore(n, m.firstChild).id = z
2014-06-30 22:16:26 -04:00
b.frameBorder = '0'
b.id = z + '-loader'
b.src = 'javascript:false' if /MSIE[ ]+6/.test(navigator.userAgent)
b.allowTransparency = 'true'
v[j] b
try
b.contentWindow[g].open()
catch w
c[e] = d[e]
2014-06-30 22:16:26 -04:00
o = 'javascript:var d=' + g + ".open();d.domain='" + d.domain + "';"
b[k] = o + 'void(0);'
try
t = b.contentWindow[g]
t.write p()
t.close()
catch x
2014-06-30 22:16:26 -04:00
b[k] = o + 'd.write(\"' + p().replace(/"/g, String.fromCharCode(92) + '\"') + '\");d.close();'
a.P 2
return
ld()
return
nt()
return
)(
2014-06-30 22:16:26 -04:00
loader: 'static.olark.com/jsclient/loader0.js'
name: 'olark'
methods: [
2014-06-30 22:16:26 -04:00
'configure'
'extend'
'declare'
'identify'
]
)
2014-06-30 22:16:26 -04:00
# custom configuration goes here (www.olark.com/documentation)
olark.identify '1451-787-10-5544' #]]>