Update package.json and assets
This commit is contained in:
42
assets/linker/js/app.coffee
Normal file
42
assets/linker/js/app.coffee
Normal file
@@ -0,0 +1,42 @@
|
||||
window.App = App || {}
|
||||
App.Features = {}
|
||||
App.Routers = {}
|
||||
App.Views = {}
|
||||
App.Collections = {}
|
||||
App.Models = {}
|
||||
App.Data = {}
|
||||
App.Dispatcher = _.clone(Backbone.Events)
|
||||
|
||||
App.initFeatures = ->
|
||||
$('[data-features]').each ->
|
||||
el = `$(this)`
|
||||
features = (el.attr 'data-features').split ' '
|
||||
for key in features
|
||||
if App.Features[key]
|
||||
new App.Features[key](el)
|
||||
|
||||
App.initBackbone = ->
|
||||
App.Data.verses = new App.Collections.Verses()
|
||||
|
||||
mainRouter = new App.Routers.MainRouter()
|
||||
Backbone.history.start()
|
||||
mainRouter.navigate 'read', trigger: true
|
||||
|
||||
App.setupEvents = ->
|
||||
App.Dispatcher.on 'show-loader', () ->
|
||||
$('#loader').show()
|
||||
App.Dispatcher.on 'hide-loader', () ->
|
||||
$('#loader').hide()
|
||||
|
||||
$(window).on 'keydown', (e) ->
|
||||
App.Dispatcher.trigger 'keydown', e
|
||||
|
||||
App.init = ->
|
||||
@initFeatures()
|
||||
@initBackbone()
|
||||
@setupEvents()
|
||||
|
||||
|
||||
$(->
|
||||
App.init()
|
||||
)
|
||||
71
assets/linker/js/features/socket.js
Normal file
71
assets/linker/js/features/socket.js
Normal file
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* app.js
|
||||
*
|
||||
* This file contains some conventional defaults for working with Socket.io + Sails.
|
||||
* It is designed to get you up and running fast, but is by no means anything special.
|
||||
*
|
||||
* Feel free to change none, some, or ALL of this file to fit your needs!
|
||||
*/
|
||||
|
||||
|
||||
(function (io) {
|
||||
|
||||
// as soon as this file is loaded, connect automatically,
|
||||
var socket = io.connect();
|
||||
if (typeof console !== 'undefined') {
|
||||
log('Connecting to Sails.js...');
|
||||
}
|
||||
|
||||
socket.on('connect', function socketConnected() {
|
||||
|
||||
// Listen for Comet messages from Sails
|
||||
socket.on('message', function messageReceived(message) {
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Replace the following with your own custom logic
|
||||
// to run when a new message arrives from the Sails.js
|
||||
// server.
|
||||
///////////////////////////////////////////////////////////
|
||||
log('New comet message received :: ', message);
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
});
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Here's where you'll want to add any custom logic for
|
||||
// when the browser establishes its socket connection to
|
||||
// the Sails.js server.
|
||||
///////////////////////////////////////////////////////////
|
||||
log(
|
||||
'Socket is now connected and globally accessible as `socket`.\n' +
|
||||
'e.g. to send a GET request to Sails, try \n' +
|
||||
'`socket.get("/", function (response) ' +
|
||||
'{ console.log(response); })`'
|
||||
);
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
// Expose connected `socket` instance globally so that it's easy
|
||||
// to experiment with from the browser console while prototyping.
|
||||
window.socket = socket;
|
||||
|
||||
|
||||
// Simple log function to keep the example simple
|
||||
function log () {
|
||||
if (typeof console !== 'undefined') {
|
||||
console.log.apply(console, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
})(
|
||||
|
||||
// In case you're wrapping socket.io to prevent pollution of the global namespace,
|
||||
// you can replace `window.io` with your own `io` here:
|
||||
window.io
|
||||
|
||||
);
|
||||
1951
assets/linker/js/vendor/bootstrap.js
vendored
Normal file
1951
assets/linker/js/vendor/bootstrap.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
9111
assets/linker/js/vendor/jquery-2.1.0.js
vendored
Normal file
9111
assets/linker/js/vendor/jquery-2.1.0.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
167
assets/linker/js/vendor/sails.io.js
generated
vendored
Normal file
167
assets/linker/js/vendor/sails.io.js
generated
vendored
Normal file
@@ -0,0 +1,167 @@
|
||||
/**
|
||||
* sails.io.js
|
||||
*
|
||||
* This file is completely optional, and merely here for your convenience.
|
||||
*
|
||||
* It reduces the amount of browser code necessary to send and receive messages
|
||||
* to & from Sails by simulating a REST client interface on top of socket.io.
|
||||
* It models its API after the pattern in jQuery you might be familiar with.
|
||||
*
|
||||
* So to switch from using AJAX to Socket.io, instead of:
|
||||
* `$.post( url, [data], [cb] )`
|
||||
*
|
||||
* You would use:
|
||||
* `socket.post( url, [data], [cb] )`
|
||||
*
|
||||
* For more information, visit:
|
||||
* http://sailsjs.org/#documentation
|
||||
*/
|
||||
|
||||
(function (io) {
|
||||
|
||||
|
||||
// We'll be adding methods to `io.SocketNamespace.prototype`, the prototype for the
|
||||
// Socket instance returned when the browser connects with `io.connect()`
|
||||
var Socket = io.SocketNamespace;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Simulate a GET request to sails
|
||||
* e.g.
|
||||
* `socket.get('/user/3', Stats.populate)`
|
||||
*
|
||||
* @param {String} url :: destination URL
|
||||
* @param {Object} params :: parameters to send with the request [optional]
|
||||
* @param {Function} cb :: callback function to call when finished [optional]
|
||||
*/
|
||||
|
||||
Socket.prototype.get = function (url, data, cb) {
|
||||
return this.request(url, data, cb, 'get');
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Simulate a POST request to sails
|
||||
* e.g.
|
||||
* `socket.post('/event', newMeeting, $spinner.hide)`
|
||||
*
|
||||
* @param {String} url :: destination URL
|
||||
* @param {Object} params :: parameters to send with the request [optional]
|
||||
* @param {Function} cb :: callback function to call when finished [optional]
|
||||
*/
|
||||
|
||||
Socket.prototype.post = function (url, data, cb) {
|
||||
return this.request(url, data, cb, 'post');
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Simulate a PUT request to sails
|
||||
* e.g.
|
||||
* `socket.post('/event/3', changedFields, $spinner.hide)`
|
||||
*
|
||||
* @param {String} url :: destination URL
|
||||
* @param {Object} params :: parameters to send with the request [optional]
|
||||
* @param {Function} cb :: callback function to call when finished [optional]
|
||||
*/
|
||||
|
||||
Socket.prototype.put = function (url, data, cb) {
|
||||
return this.request(url, data, cb, 'put');
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Simulate a DELETE request to sails
|
||||
* e.g.
|
||||
* `socket.delete('/event', $spinner.hide)`
|
||||
*
|
||||
* @param {String} url :: destination URL
|
||||
* @param {Object} params :: parameters to send with the request [optional]
|
||||
* @param {Function} cb :: callback function to call when finished [optional]
|
||||
*/
|
||||
|
||||
Socket.prototype['delete'] = function (url, data, cb) {
|
||||
return this.request(url, data, cb, 'delete');
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Simulate HTTP over Socket.io
|
||||
* @api private :: but exposed for backwards compatibility w/ <= sails@~0.8
|
||||
*/
|
||||
|
||||
Socket.prototype.request = request;
|
||||
function request (url, data, cb, method) {
|
||||
|
||||
var socket = this;
|
||||
|
||||
var usage = 'Usage:\n socket.' +
|
||||
(method || 'request') +
|
||||
'( destinationURL, dataToSend, fnToCallWhenComplete )';
|
||||
|
||||
// Remove trailing slashes and spaces
|
||||
url = url.replace(/^(.+)\/*\s*$/, '$1');
|
||||
|
||||
// If method is undefined, use 'get'
|
||||
method = method || 'get';
|
||||
|
||||
|
||||
if ( typeof url !== 'string' ) {
|
||||
throw new Error('Invalid or missing URL!\n' + usage);
|
||||
}
|
||||
|
||||
// Allow data arg to be optional
|
||||
if ( typeof data === 'function' ) {
|
||||
cb = data;
|
||||
data = {};
|
||||
}
|
||||
|
||||
// Build to request
|
||||
var json = window.io.JSON.stringify({
|
||||
url: url,
|
||||
data: data
|
||||
});
|
||||
|
||||
|
||||
// Send the message over the socket
|
||||
socket.emit(method, json, function afterEmitted (result) {
|
||||
|
||||
var parsedResult = result;
|
||||
|
||||
if (result && typeof result === 'string') {
|
||||
try {
|
||||
parsedResult = window.io.JSON.parse(result);
|
||||
} catch (e) {
|
||||
if (typeof console !== 'undefined') {
|
||||
console.warn("Could not parse:", result, e);
|
||||
}
|
||||
throw new Error("Server response could not be parsed!\n" + result);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Handle errors more effectively
|
||||
if (parsedResult === 404) throw new Error("404: Not found");
|
||||
if (parsedResult === 403) throw new Error("403: Forbidden");
|
||||
if (parsedResult === 500) throw new Error("500: Server error");
|
||||
|
||||
cb && cb(parsedResult);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}) (
|
||||
|
||||
// In case you're wrapping socket.io to prevent pollution of the global namespace,
|
||||
// you can replace `window.io` with your own `io` here:
|
||||
window.io
|
||||
|
||||
);
|
||||
3328
assets/linker/js/vendor/socket.io.js
generated
vendored
Normal file
3328
assets/linker/js/vendor/socket.io.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user