diff --git a/app/initialize.coffee b/app/initialize.coffee index 9f0283488..2e76c6de4 100644 --- a/app/initialize.coffee +++ b/app/initialize.coffee @@ -18,11 +18,11 @@ definitionSchemas = 'misc': require './schemas/definitions/misc' init = -> - # Don't initialize all the social scripts when visiting demo pages - if not (/.*\/demo\/.*/).exec window.location.href - initializeSocial() - - initializeVendors() + path = document.location.pathname + testing = path.startsWith '/test' + demoing = path.startsWith '/demo' + initializeServices() unless testing or demoing + # Set up Backbone.Mediator schemas setUpDefinitions() setUpChannels() @@ -33,7 +33,6 @@ init = -> treemaExt = require 'treema-ext' treemaExt.setup() - filepicker.setKey('AvlkNoldcTOU4PvKi2Xm7z') $ -> init() @@ -66,22 +65,17 @@ setUpDefinitions = -> for definition of definitionSchemas Backbone.Mediator.addDefSchemas definitionSchemas[definition] -initializeVendors = -> - initializers = - filepicker: require './lib/filepicker' - segmentio: require './lib/segmentio' +initializeServices = -> + services = [ + './lib/services/filepicker' + './lib/services/segmentio' + './lib/services/olark' + './lib/services/facebook' + './lib/services/google' + './lib/services/twitter' + './lib/services/linkedin' + ] - for name, initializer of initializers - initializer() - -initializeSocial = -> - initializers = - - olark: require './lib/olark' - facebook: require './lib/facebook' - google: require './lib/google' - twitter: require './lib/twitter' - linkedin: require './lib/linkedin' - - for name, initializer of initializers - initializer() + for service in services + service = require service + service() diff --git a/app/lib/facebook.coffee b/app/lib/services/facebook.coffee similarity index 100% rename from app/lib/facebook.coffee rename to app/lib/services/facebook.coffee diff --git a/app/lib/filepicker.coffee b/app/lib/services/filepicker.coffee similarity index 95% rename from app/lib/filepicker.coffee rename to app/lib/services/filepicker.coffee index fde8ccd50..2c16b48bd 100644 --- a/app/lib/filepicker.coffee +++ b/app/lib/services/filepicker.coffee @@ -23,6 +23,7 @@ module.exports = initializeFilepicker = -> while g < e.length d[e[g]] = f(e[g], d._queue) g++ + d.setKey('AvlkNoldcTOU4PvKi2Xm7z') window.filepicker = d return ) document diff --git a/app/lib/google.coffee b/app/lib/services/google.coffee similarity index 100% rename from app/lib/google.coffee rename to app/lib/services/google.coffee diff --git a/app/lib/linkedin.coffee b/app/lib/services/linkedin.coffee similarity index 100% rename from app/lib/linkedin.coffee rename to app/lib/services/linkedin.coffee diff --git a/app/lib/olark.coffee b/app/lib/services/olark.coffee similarity index 100% rename from app/lib/olark.coffee rename to app/lib/services/olark.coffee diff --git a/app/lib/segmentio.coffee b/app/lib/services/segmentio.coffee similarity index 100% rename from app/lib/segmentio.coffee rename to app/lib/services/segmentio.coffee diff --git a/app/lib/twitter.coffee b/app/lib/services/twitter.coffee similarity index 100% rename from app/lib/twitter.coffee rename to app/lib/services/twitter.coffee