mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-14 07:00:01 -04:00
Refactored vendor loading
This commit is contained in:
parent
2e40a53674
commit
1c671a3c25
7 changed files with 31 additions and 38 deletions
|
@ -43,19 +43,6 @@
|
|||
|
||||
<script>require('initialize');</script>
|
||||
|
||||
<!-- begin LinkedIn code -->
|
||||
<script>
|
||||
window.linkedInAsyncInit = function() {
|
||||
Backbone.Mediator.publish('linkedin-loaded');
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
|
||||
api_key: 75v8mv4ictvmx6
|
||||
onLoad: linkedInAsyncInit
|
||||
authorize: true
|
||||
</script>
|
||||
<!-- end LinkedIn code -->
|
||||
|
||||
</head>
|
||||
<body class="nano clearfix">
|
||||
<div id="fb-root"></div>
|
||||
|
|
|
@ -18,8 +18,12 @@ definitionSchemas =
|
|||
'misc': require './schemas/definitions/misc'
|
||||
|
||||
init = ->
|
||||
# Set up Backbone.Mediator schemas
|
||||
# Don't initialize all the social scripts when visiting demo pages
|
||||
if not (/.*\/demo\/.*/).exec window.location.href
|
||||
initializeSocial()
|
||||
|
||||
initializeVendors()
|
||||
# Set up Backbone.Mediator schemas
|
||||
setUpDefinitions()
|
||||
setUpChannels()
|
||||
Backbone.Mediator.setValidationEnabled document.location.href.search(/codecombat.com/) is -1
|
||||
|
@ -65,11 +69,19 @@ setUpDefinitions = ->
|
|||
initializeVendors = ->
|
||||
initializers =
|
||||
filepicker: require './lib/filepicker'
|
||||
#olark: require './lib/olark'
|
||||
segmentio: require './lib/segmentio'
|
||||
|
||||
for name, initializer of initializers
|
||||
initializer()
|
||||
|
||||
initializeSocial = ->
|
||||
initializers =
|
||||
|
||||
olark: require './lib/olark'
|
||||
facebook: require './lib/facebook'
|
||||
google: require './lib/google'
|
||||
twitter: require './lib/twitter'
|
||||
#segmentio: require './lib/segmentio'
|
||||
linkedin: require './lib/linkedin'
|
||||
|
||||
for name, initializer of initializers
|
||||
initializer()
|
||||
|
|
|
@ -14,7 +14,7 @@ module.exports = initializeFilepicker = ->
|
|||
->
|
||||
b.push [
|
||||
a
|
||||
arguments_
|
||||
arguments
|
||||
]
|
||||
return
|
||||
|
||||
|
|
12
app/lib/linkedin.coffee
Normal file
12
app/lib/linkedin.coffee
Normal file
|
@ -0,0 +1,12 @@
|
|||
module.exports = initializeLinkedIn = ->
|
||||
window.linkedInAsyncInit = ->
|
||||
Backbone.Mediator.publish 'linkedin-loaded'
|
||||
|
||||
linkedInSnippet =
|
||||
'<script type="text/javascript" async src="http://platform.linkedin.com/in.js">
|
||||
api_key: 75v8mv4ictvmx6
|
||||
onLoad: linkedInAsyncInit
|
||||
authorize: true
|
||||
</script>'
|
||||
|
||||
$('head').append(linkedInSnippet)
|
|
@ -11,7 +11,7 @@ module.exports = initializeOlark = ->
|
|||
f[z] r
|
||||
return
|
||||
f[z] = ->
|
||||
(a.s = a.s or []).push arguments_
|
||||
(a.s = a.s or []).push arguments
|
||||
return
|
||||
|
||||
a = f[z]._ = {}
|
||||
|
@ -19,7 +19,7 @@ module.exports = initializeOlark = ->
|
|||
while q--
|
||||
((n) ->
|
||||
f[z][n] = ->
|
||||
f[z] "call", n, arguments_
|
||||
f[z] "call", n, arguments
|
||||
return
|
||||
|
||||
return
|
||||
|
|
|
@ -17,7 +17,7 @@ module.exports = initializeSegmentio = ->
|
|||
]
|
||||
t = (e) ->
|
||||
->
|
||||
analytics.push [e].concat(Array::slice.call(arguments_, 0))
|
||||
analytics.push [e].concat(Array::slice.call(arguments, 0))
|
||||
return
|
||||
|
||||
n = 0
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
/*<![CDATA[*/window.olark||(function(c){var f=window,d=document,l=f.location.protocol=="https:"?"https:":"http:",z=c.name,r="load";var nt=function(){
|
||||
f[z]=function(){
|
||||
(a.s=a.s||[]).push(arguments)};var a=f[z]._={
|
||||
},q=c.methods.length;while(q--){(function(n){f[z][n]=function(){
|
||||
f[z]("call",n,arguments)}})(c.methods[q])}a.l=c.loader;a.i=nt;a.p={
|
||||
0:+new Date};a.P=function(u){
|
||||
a.p[u]=new Date-a.p[0]};function s(){
|
||||
a.P(r);f[z](r)}f.addEventListener?f.addEventListener(r,s,false):f.attachEvent("on"+r,s);var ld=function(){function p(hd){
|
||||
hd="head";return["<",hd,"></",hd,"><",i,' onl' + 'oad="var d=',g,";d.getElementsByTagName('head')[0].",j,"(d.",h,"('script')).",k,"='",l,"//",a.l,"'",'"',"></",i,">"].join("")}var i="body",m=d[i];if(!m){
|
||||
return setTimeout(ld,100)}a.P(1);var j="appendChild",h="createElement",k="src",n=d[h]("div"),v=n[j](d[h](z)),b=d[h]("iframe"),g="document",e="domain",o;n.style.display="none";m.insertBefore(n,m.firstChild).id=z;b.frameBorder="0";b.id=z+"-loader";if(/MSIE[ ]+6/.test(navigator.userAgent)){
|
||||
b.src="javascript:false"}b.allowTransparency="true";v[j](b);try{
|
||||
b.contentWindow[g].open()}catch(w){
|
||||
c[e]=d[e];o="javascript:var d="+g+".open();d.domain='"+d.domain+"';";b[k]=o+"void(0);"}try{
|
||||
var t=b.contentWindow[g];t.write(p());t.close()}catch(x){
|
||||
b[k]=o+'d.write("'+p().replace(/"/g,String.fromCharCode(92)+'"')+'");d.close();'}a.P(2)};ld()};nt()})({
|
||||
loader: "static.olark.com/jsclient/loader0.js",name:"olark",methods:["configure","extend","declare","identify"]});
|
||||
/* custom configuration goes here (www.olark.com/documentation) */
|
||||
olark.identify('1451-787-10-5544');/*]]>*/
|
Loading…
Reference in a new issue