This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async = require 'async' | |
| # The `parallel` middleware allows to run several middlewares in parallel. | |
| # It does this by simply using AsyncJS' `applyEach` on the middlewares. | |
| # | |
| # The middlewares will receive 3 parameters: `request`, `response` and | |
| # `next`, in the same way and order they usually get them. As the | |
| # execution is in parallel, if one of the middlewares will have an error | |
| # the second one will continue to execute. If an error is passed to the | |
| # `next` callback it will be passed correctly forward. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Load the environment configuration options | |
| config = require '../../config/environments' | |
| # Require Redis | |
| redis = require 'redis' | |
| # Create a Redis client | |
| client = redis.createClient() | |
| # `queue` handles queueing a background job to Resque. We directly use |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| captain.up(function() { | |
| captain.hud.minimize() | |
| }); | |
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Used as a wrapper to make sure Captain Up has loaded on the page | |
| captain.up(function() { | |
| // `captain.player` holds all the information about the users, including anonymous users information | |
| user_details = captain.player | |
| // Do whatever you want with the data, maybe send it to your server side? | |
| $.ajax({type: 'POST', url: 'http://mysite.com/users/', data: captain.player}) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Asynchronous wrapper around the function, to make sure Captain | |
| // Up has loaded completely. | |
| captain.up(function() { | |
| // Set the points string | |
| captain.l.points = "XP"; | |
| // Set the shorthand name | |
| captain.l.shorthand_points = "XP"; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Asynchronous wrapper around the function, to make sure Captain | |
| // Up has loaded completely. | |
| captain.up(function() { | |
| // Minimize the HUD | |
| captain.hud.minimize(); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Asynchronous wrapper, the code will only run after Captain Up has loaded | |
| captain.up(function() { | |
| // Maximize the HUD | |
| captain.hud.maximize(); | |
| // Minimize the HUD | |
| captain.hud.minimize(); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Asynchronous wrapper to ensure Captain Up has loaded | |
| captain.up(function() { | |
| //open the sign up modal | |
| captain.open_sign_up_modal(); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # The CoffeeScriptJSON module is a Sprockets engine that can be used to write | |
| # JSON files in CoffeeScript. | |
| # | |
| # This CoffeeScript: | |
| # | |
| # # whatever.json.coffee_json | |
| # hello: 'world!' | |
| # | |
| # Will be compiled down to: | |
| # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Asynchronous wrapper around Captain Up, code will run once Captain Up has loaded. | |
| captain.up(function() { | |
| // Periodically test if the user has read the page | |
| setInterval(function(){ | |
| // You need to implement `user_read_the_page` by yourself, maybe as a check | |
| // that the user scrolled to the bottom? Or spent at least a minute on the page? | |
| if (user_read_the_page()) { | |
| // Track the action with Captain Up, remember to configure the action settings for it | |
| // by creating a new 'read' action in your admin panel. | |
| captain.action('read', { |