Anton Shestakov <av6@dwimlabs.net>, Wed, 23 Mar 2016 16:55:52 +0800
index: maintain only one contact with type 'self'
This isn't done in an event handler of contacts collection because doing it in
'add' handler would trigger 'sort' event after the model has been added, but
before its 'add' event has propagated, and that's dumb.
index.html
Permissions: -rw-r--r--
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/uikit/2.25.0/css/uikit.min.css"> <link rel="stylesheet" href="/css/tram-im.css"> <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.2.3/backbone-min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/rivets/0.8.1/rivets.bundled.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/2.25.0/js/uikit.min.js"></script> <script src="/vendor/strophejs/strophe.min.js"></script> <script src="/vendor/strophejs-plugins/vcard/strophe.vcard.js"></script> <div class="smart-container" data-step="noscript"> <p class="uk-text-center">This page needs JavaScript to work.
</p> <small>It uses resources from code.jquery.com and cdnjs.cloudflare.com.
</small> <div class="smart-container uk-hidden" data-step="login"> <div class="uk-form uk-form-horizontal" data-form="connect"> <div class="uk-form-row"> <label for="username" class="uk-form-label">Username
</label> <div class="uk-form-controls"> <input id="username" type="text" class="uk-width-1-1" required autofocus> <div class="uk-form-row"> <label for="password" class="uk-form-label">Password
</label> <div class="uk-form-controls"> <input id="password" type="password" class="uk-width-1-1" value="" required> <div class="uk-form-row"> <div class="uk-form-controls"> <div class="uk-alert uk-alert-danger uk-hidden" data-msg="a/fail">Invalid username or password.
</div> <button type="button" class="uk-button uk-button-primary"><i class="uk-icon-sign-out"></i> Log in
</button> <a class="uk-float-right uk-button uk-button-link" href="/register.html">Register
</a> $('[data-step="noscript"]').addClass('uk-hidden'); $('[data-step="login"]').removeClass('uk-hidden'); <div class="uk-hidden" data-step="main"> <button type="button" class="uk-button" data-disconnect> <i class="uk-icon-sign-out"></i> Log out
<div data-app="calls"></div> <div class="uk-width-large-1-4 uk-width-medium-1-3 uk-width-small-1-2"> <ul class="uk-list uk-list-line contact-list" data-app="contacts"></ul> <div class="uk-width-large-3-4 uk-width-medium-2-3 uk-width-small-1-2"> <div class="log" data-app="log"></div> <script type="text/template" id="avatar-template"> <img class="avatar" rv-if="model:d/avatar" rv-src="model:d/avatar"> <div class="avatar" rv-unless="model:d/avatar" rv-text="model:d/handle | first-letter" rv-style="view.getHashedColors < model:jid"></div> <script type="text/template" id="message-template"> <div class="splitter" rv-if="model:d/split"></div> <div class="column avatar-column" rv-class-uk-invisible="model:d/fold"></div> <div class="column uk-width-1-1"> <div style="padding-top: 4px;" rv-hide="model:d/fold"> <strong rv-text="view.getHandle < model:contact:d/handle model:from"></strong> <time class="stamp uk-text-muted" rv-datetime="model:d/mstamp | iso-date" rv-title="model:d/mstamp | format-date 'HH:mm:ss'" rv-text="model:d/mstamp | from-now"></time> <div rv-data-id="model:id" rv-class="model:cls" rv-text="model:text"></div> <script type="text/template" id="contact-template"> <div class="column avatar-column"> <div class="status-pip" rv-title="model:d/pip" rv-style="view.getPipStyle < model:d/pip"></div> <div class="column uk-width-1-1"> <div class="uk-text-bold" rv-text="model:d/handle"></div> <div class="uk-text-nowrap"> <span rv-text="model:status"></span> <span rv-hide="model:type | eq 'self'" rv-text="model:chatstate | only 'composing'"></span> <script src='/js/tram.js'></script> <script src='/js/rivets.js'></script> <script src='/js/validation.js'></script> <script src='/js/xmpp.js'></script> <script src='/js/contacts.js'></script> <script src='/js/messages.js'></script> <script src='/config.js'></script> <script src='/js/index.js'></script>