View snippet.js
(function(w,d,s,a){
var t,f;w['NextTripBookingRef']=a;w[a]=w[a]||function(){(w[a].q=w[a].q||[]).push(arguments)};
w[a].s=w.location.origin;t=d.createElement('script');f=d.getElementsByTagName('script')[0];
t.async=1;t.src=s;f.parentNode.insertBefore(t,f);d.querySelectorAll('[data-nexttrip]').forEach(
function(b){b.addEventListener('click', function(e){w[a]('dataset', e.target.dataset);
e.preventDefault()})})
})(window, document,'http://localhost:3000/booking.js','nextTrip');
nextTrip.customerId = 'ALLUSA'
nextTrip.dealId = 'SHUTTLES'
View uniqueReq.js
const merge = require('ramda/src/merge')
const m = require('mithril')
/*
@param {string} key - The unique key of the request
@param {Object} params - The same params used in m.request of mithril
@returns Promise
@link https://mithril.js.org/request.html
View prop.js
const m = require('mithril')
function emitChangeToSubscribers(subscribers, newState, oldState){
subscribers.forEach(function(subscriber){
subscriber.call(null, newState, oldState)
})
}
module.exports = function(initState){
const store = m.prop(initState)
View component.js
void function(m) {
function closure(fn) {
var component = {
controller : function(options) {
component.view = fn(options);
}
};
return component;
View routes.js
// The limited unauthenticated routemap
var authRoutes = {
'/signup' : modules.signup,
'/login' : modules.login
};
// The whole shebang
var appRoutes = Object.assign( {
'/:semantic/:app/:routes' : various.modules
}, authRoutes );
View randomHash.js
var crypto = require('crypto');
crypto.randomBytes(16).toString('hex');
// 'e834ba2133229fb78a693f5ca3ae05de'
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View example.js
// Example take from the book Java Application Design (http://www.bevacqua.io/buildfirst)
// https://github.com/buildfirst/buildfirst/blob/master/ch05/06_prototypal-modularity/protolib.js
// Still using an IIFE to expose the library!
(function(window){
// use these to sign each instance and access its private scope
var lastId = 0;
var data = {};
function Lib () {
View loadScript.js
// Inspired (stolen?) from JQuery (https://github.com/jquery/jquery/blob/1.3.2/src/ajax.js#L264)
// and http://www.nczonline.net/blog/2009/07/28/the-best-way-to-load-external-javascript/
function loadJS(url, callback){
var head = document.getElementsByTagName("head")[0];
var script = document.createElement("script");
script.src = url;
script.async = true;
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function(){