Skip to content

Instantly share code, notes, and snippets.

@latentflip
latentflip / index.js
Last active August 29, 2015 14:06
Rendering a tree with ampersand
var AmpersandState = require('ampersand-state');
var AmpersandCollection = require('ampersand-collection');
var View = require('ampersand-view');
var NodeList = AmpersandCollection.extend({
});
var Node = AmpersandState.extend({
props: {
id: 'string',
@latentflip
latentflip / index.js
Last active August 29, 2015 14:06
requirebin sketch
var AmpersandState = require('ampersand-state');
var AmpersandCollection = require('ampersand-collection');
var View = require('ampersand-view');
var NodeList = AmpersandCollection.extend({
});
var Node = AmpersandState.extend({
props: {
id: 'string',
@latentflip
latentflip / index.js
Created September 8, 2014 17:37
requirebin sketch
var AmpersandView = require('ampersand-view');
module.exports = AmpersandView.extend({
initialize: function () {
var self = this;
app.people.getOrFetch(options.personId, function (err, person) {
if (err) { throw err; }
self.model = person;
});
//
// Lame implementation of a channel
function channel() {
return new Channel();
}
var id = 0;
function Channel(opts) {
this._queue = [];
@latentflip
latentflip / index.js
Created September 26, 2014 08:43
requirebin sketch
var View = require('ampersand-view');
var MyView = View.extend({
template: '<h1>Hello</h1>'
});
var view = new MyView();
view.render();
document.body.appendChild(view.el);
@latentflip
latentflip / index.js
Created October 30, 2014 09:54
requirebin sketch
var State = require('ampersand-state').extend({
props: {
id: 'number',
age: 'number'
}
});
var s = new State({ id: 1, age: 10 })
@latentflip
latentflip / index.js
Created December 1, 2014 16:34
requirebin sketch
var View = require('ampersand-view').extend({
template: '<div><input type="checkbox" ><a>click me</a></div>',
props: {
theState: 'boolean'
},
events: {
'click [type=checkbox]': 'toggleState',
'click a': 'toggleState'
},
bindings: {
@latentflip
latentflip / index.js
Created December 9, 2014 20:06
requirebin sketch
var src = "<div class=\"landing\"><div class=\"container\"><section id=\"pages\"><section role=\"main\" class=\"page create\"><div class=\"room cf\"><a href=\"/\" title=\"Welcome to Talky!\" class=\"talky-logo\"></a><form id=\"createRoom\" class=\"cf\"><p>Truly simple video chat and screen sharing for small groups.</p><input id=\"sessionInput\" placeholder=\"Name the conversation\" autofocus=\"autofocus\" type=\"text\"><button type=\"submit\" class=\"primary large\">Let’s go!</button></form></div><div class=\"features cf\"><h2>Anonymous. Peer‑to‑peer. No plugins, signup, or payment required.</h2><div class=\"feature\"><h3>Group video chat</h3><p>Add up to 5 people to the conversation </p></div><div class=\"feature\"><h3>Screen sharing</h3><p>Easily add anyone's screen to the conversation</p></div><div class=\"feature\"><h3>Locked rooms</h3><p>Add a shared key to a room for added privacy</p></div><div class=\"feature\"><h3>Mobile, too!</h3><p> \nTalky iOS is available</p><a href=\"https://itunes.apple.com/app/
@latentflip
latentflip / index.js
Created December 18, 2014 09:24
requirebin sketch
var AmpersandModel = require('ampersand-model');
var AmpersandCollection = require('ampersand-rest-collection');
var Model = AmpersandModel.extend({
props: {
title: 'string'
}
});
var MyCollection = AmpersandCollection.extend({
@latentflip
latentflip / index.js
Last active August 29, 2015 14:13
requirebin sketch
var Collection = require('ampersand-collection');
var SubCollection = require('ampersand-subcollection');
var Model = require('ampersand-model');
var MyModel = Model.extend({
props: {
name: 'string',
selected: 'boolean'
}
});