Anton Shestakov <av6@dwimlabs.net>, Wed, 01 Nov 2017 00:50:57 +0800
Makefile: use file targets more, results in incremental building
Less work to do when only some files get changed, but more work when building
from scratch. But, multiple compilers can run in parallel.
coffee/messages.coffee
Permissions: -rw-r--r--
class Tram.Message extends Backbone.Model @on 'add change:stamp', -> @set('d/mstamp', moment(@get('stamp'))) class Tram.Messages extends Backbone.Collection splitThreshold: 30 * 60 * 1000 model.get('stamp').valueOf() @_splitOrFold(prev, model) @_splitOrFold(model, next) _splitOrFold: (m1, m2) -> Math.abs(m1.get('stamp').valueOf() - m2.get('stamp').valueOf()) > @splitThreshold m1.get('from') is m2.get('from') and Math.abs(m1.get('stamp').valueOf() - m2.get('stamp').valueOf()) < @foldThreshold class Tram.MessageView extends Backbone.View templateEl: $($('#message-template').html()) @setElement(@templateEl.clone()) @$avatarColumn = @$('.avatar-column') @listenTo(@model, 'change:contact', @updateContact) if not @model.previous('contact')? and @model.get('contact')? @av = new Tram.AvatarView(model: contact) @$avatarColumn.prepend(@av.render().el) @rivet = rivets.bind(@el, message: @model, view: @) contact = @model.get('contact') @av = new Tram.AvatarView(model: contact) @$avatarColumn.prepend(@av.render().el) class Tram.LogApp extends Backbone.View templateEl: $($('#chat-template').html()) @setElement(@templateEl.clone()) @rivet = rivets.bind(@el, model: @model, view: @) @listenTo(@collection, 'add', @onAdd) onAdd: (model, collection) -> mi = collection.indexOf(model) view = new Tram.MessageView(model: model) @$log.children().eq(mi - 1).after(el) @$el.scrollTop() + @$el.innerHeight() == @el.scrollHeight @$el.scrollTop(@el.scrollHeight)