--- a/coffee/index.coffee Mon Mar 21 19:57:24 2016 +0800
+++ b/coffee/index.coffee Mon Mar 21 20:10:19 2016 +0800
+window.messages ?= new Tram.Messages()
+window.logApp ?= new Tram.LogApp(el: $('[data-app="log"]'), collection: messages)
+ if el.childNodes.length is 0 and el.nodeType is Strophe.ElementType.TEXT
+ for node in el.childNodes
+ if node.nodeType is Strophe.ElementType.TEXT
+ iq = $iq(type: 'get', id: X.conn.getUniqueId('version'), to: Tram.config.domain).c('query', xmlns: Strophe.NS.VERSION)
+ name = getText stanza.getElementsByTagName('name')[0]
+ version = getText stanza.getElementsByTagName('version')[0]
+ os = getText stanza.getElementsByTagName('os')[0]
+ delay = stanza.getElementsByTagName('delay')[0]
+ stamp = if delay then new Date(delay.getAttribute('stamp')) else new Date()
+ id: stanza.getAttribute('id')
+ type: stanza.getAttribute('type')
+ from: stanza.getAttribute('from')
+ text: "connected to #{ name } #{ version } on #{ os }"
+ console.error("couldn't get version", stanza?.innerHTML)
+ X.conn.sendIQ(iq.tree(), okcb, failcb, 5000)
window.X = new Tram.XMPPInterface()
X.on 'connected attached', ->
$('[data-step="login"]').addClass('uk-hidden')
$('[data-step="main"]').removeClass('uk-hidden')
$('button[data-disconnect]').on 'click', ->
--- a/css/tram-im.css Mon Mar 21 19:57:24 2016 +0800
+++ b/css/tram-im.css Mon Mar 21 20:10:19 2016 +0800
border-top: 1px solid lightgray;
--- a/index.html Mon Mar 21 19:57:24 2016 +0800
+++ b/index.html Mon Mar 21 20:10:19 2016 +0800
<button type="button" class="uk-button" data-disconnect>
<i class="uk-icon-sign-out"></i> Log out
+ <div class="log" data-app="log"></div>
<script type="text/template" id="message-template">
--- a/js/index.js Mon Mar 21 19:57:24 2016 +0800
+++ b/js/index.js Mon Mar 21 20:10:19 2016 +0800
// Generated by CoffeeScript 1.10.0
+ var $form, getText, getVersion, onConnected;
+ if (window.messages == null) {
+ window.messages = new Tram.Messages();
+ if (window.logApp == null) {
+ window.logApp = new Tram.LogApp({
+ el: $('[data-app="log"]'),
+ onConnected = function() {
+ getText = function(el) {
+ var i, len, node, ref, str;
+ if (el.childNodes.length === 0 && el.nodeType === Strophe.ElementType.TEXT) {
+ for (i = 0, len = ref.length; i < len; i++) {
+ if (node.nodeType === Strophe.ElementType.TEXT) {
+ getVersion = function() {
+ id: X.conn.getUniqueId('version'),
+ xmlns: Strophe.NS.VERSION
+ okcb = function(stanza) {
+ var delay, name, os, stamp, version;
+ name = getText(stanza.getElementsByTagName('name')[0]);
+ version = getText(stanza.getElementsByTagName('version')[0]);
+ os = getText(stanza.getElementsByTagName('os')[0]);
+ delay = stanza.getElementsByTagName('delay')[0];
+ stamp = delay ? new Date(delay.getAttribute('stamp')) : new Date();
+ id: stanza.getAttribute('id'),
+ type: stanza.getAttribute('type'),
+ from: stanza.getAttribute('from'),
+ text: "connected to " + name + " " + version + " on " + os
+ failcb = function(stanza) {
+ return console.error("couldn't get version", stanza != null ? stanza.innerHTML : void 0);
+ return X.conn.sendIQ(iq.tree(), okcb, failcb, 5000);
window.X = new Tram.XMPPInterface();
X.on('connected attached', function() {
$('[data-step="login"]').addClass('uk-hidden');
- return $('[data-step="main"]').removeClass('uk-hidden');
+ $('[data-step="main"]').removeClass('uk-hidden');
$('button[data-disconnect]').on('click', function() {
--- a/js/index.js.map Mon Mar 21 19:57:24 2016 +0800
+++ b/js/index.js.map Mon Mar 21 20:10:19 2016 +0800
- "mappings": ";AAAA;AAAA,MAAA;;EAAA,MAAM,CAAC,CAAP,GAAe,IAAA,IAAI,CAAC,aAAL,CAAA;;EAGf,CAAC,CAAC,EAAF,CAAK,YAAL,EAAmB,SAAA;WACjB,CAAA,CAAE,kBAAF,CAAqB,CAAC,QAAtB,CAA+B,WAA/B;EADiB,CAAnB;;EAIA,CAAC,CAAC,EAAF,CAAK,UAAL,EAAiB,SAAA;WACf,CAAA,CAAE,qBAAF,CAAwB,CAAC,WAAzB,CAAqC,WAArC;EADe,CAAjB;;EAIA,CAAC,CAAC,EAAF,CAAK,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