aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--webclient/alias/alias.html20
-rw-r--r--webclient/alias/alias.js36
-rw-r--r--webclient/alias/fixtures/fixtures.js2
-rw-r--r--webclient/alias/models/contact.js40
-rw-r--r--webclient/alias/models/models.js2
-rw-r--r--webclient/alias/test/qunit/contact_test.js51
-rw-r--r--webclient/alias/test/qunit/qunit.js2
-rw-r--r--webclient/config.js.sample4
-rw-r--r--webclient/index.html91
9 files changed, 132 insertions, 116 deletions
diff --git a/webclient/alias/alias.html b/webclient/alias/alias.html
index 7d8da8d..01cae99 100644
--- a/webclient/alias/alias.html
+++ b/webclient/alias/alias.html
@@ -9,20 +9,10 @@
<li>Steal plugins and files in <i>alias/alias.js</i>.</li>
<li>Change to production mode by changing <i>steal.js</i> to <i>steal.production.js</i> in this file.</li>
</ul>
- <hr>
- <b>Here are some links to get you started:</b>
- <ul>
- <li><a href="http://javascriptmvc.com/docs.html#!getstarted">Getting Started Guide</a></li>
- <li><a href="http://javascriptmvc.com/docs.html#!organizing">Organizing Your App</a></li>
- <li><a href="http://javascriptmvc.com/docs.html#!services">Ajax Service Guidelines</a></li>
- <li><a href="http://javascriptmvc.com/docs.html#!examples">Example Apps</a></li>
- </ul>
- <hr>
- <b>Join the community:</b>
- <ul>
- <li>Follow <a href="http://twitter.com/javascriptmvc">@javascriptmvc</a> on Twitter</li>
- <li>Join <a href="http://forum.javascriptmvc.com/">the forums</a></li>
- </ul>
+
+ <div id="roster">
+
+ </div>
<script type='text/javascript' src='../steal/steal.js?alias'></script>
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/webclient/alias/alias.js b/webclient/alias/alias.js
index 77c001e..d07ece5 100644
--- a/webclient/alias/alias.js
+++ b/webclient/alias/alias.js
@@ -1,7 +1,29 @@
-steal(
- './alias.css', // application CSS file
- './models/models.js', // steals all your models
- './fixtures/fixtures.js', // sets up fixtures for your models
- function(){ // configure your application
-
- }) \ No newline at end of file
+steal('./alias.css',
+ './models/models.js',
+ './fixtures/fixtures.js',
+ 'lib/strophe/src/md5.js',
+ 'lib/strophe/src/sha1.js',
+ 'lib/strophe/src/base64.js',
+ 'lib/strophe/src/core.js',
+ 'config.js',
+ function(){
+ function connect_callback(status){
+ if ( status == Strophe.Status.CONNECTING ) {
+ steal.dev.log('Strophe is connecting.');
+ } else if ( status == Strophe.Status.CONNFAIL ) {
+ steal.dev.log('Strophe failed to connect.');
+ } else if ( status == Strophe.Status.DISCONNECTING ) {
+ steal.dev.log('Strophe is disconnecting.');
+ } else if ( status == Strophe.Status.DISCONNECTED ) {
+ steal.dev.log('Strophe is disconnected.');
+ } else if ( status == Strophe.Status.CONNECTED ) {
+ steal.dev.log('Strophe is connected.');
+ $("#roster").roster({connection: connection});
+ }
+ };
+ // configure your application
+ var connection = new Strophe.Connection(BOSH_SERVICE);
+ connection.connect(NAME, PASSWORD, connect_callback);
+
+
+ }) \ No newline at end of file
diff --git a/webclient/alias/fixtures/fixtures.js b/webclient/alias/fixtures/fixtures.js
index 1e662ac..636837a 100644
--- a/webclient/alias/fixtures/fixtures.js
+++ b/webclient/alias/fixtures/fixtures.js
@@ -2,4 +2,4 @@
steal("jquery/dom/fixture", function(){
-}) \ No newline at end of file
+})
diff --git a/webclient/alias/models/contact.js b/webclient/alias/models/contact.js
new file mode 100644
index 0000000..53c11ed
--- /dev/null
+++ b/webclient/alias/models/contact.js
@@ -0,0 +1,40 @@
+steal('jquery/model/list',
+ 'jquery/controller',
+
+function(){
+
+ $.Model('Contact', {
+
+ }, {});
+
+ $.Model.List('Contact.List', {
+
+ }, {});
+
+ $.Controller('Roster', {
+ onRoster: function(iq) {
+ var elems = iq.getElementsByTagName('query');
+ var query = elems[0];
+ Strophe.forEachChild(query, 'item', function(item){
+ var jid = item.getAttribute('jid');
+ var name = item.getAttribute('name') || jid;
+ var id = jid;
+ steal.dev.log("<li id='" + id + "' class='roster-contact offline'>"
+ + "<div class='roster-name'>" + name + "</div>"
+ + "<div class='roster-jid'>" + jid + "</div></li>");
+ });
+ return true;
+ },
+
+ }, {
+
+ init: function() {
+ var roster = $iq({type : 'get'}).c('query', {xmlns : Strophe.NS.ROSTER});
+ this.options.connection.sendIQ(roster, Roster.onRoster);
+ },
+
+ });
+
+
+
+}) \ No newline at end of file
diff --git a/webclient/alias/models/models.js b/webclient/alias/models/models.js
index 9224b68..e0f0ec7 100644
--- a/webclient/alias/models/models.js
+++ b/webclient/alias/models/models.js
@@ -1,2 +1,2 @@
// steal model files
-steal("jquery/model") \ No newline at end of file
+steal("jquery/model", './contact.js') \ No newline at end of file
diff --git a/webclient/alias/test/qunit/contact_test.js b/webclient/alias/test/qunit/contact_test.js
new file mode 100644
index 0000000..e4c8b23
--- /dev/null
+++ b/webclient/alias/test/qunit/contact_test.js
@@ -0,0 +1,51 @@
+steal("funcunit/qunit", "alias/fixtures", "alias/models/contact.js", function(){
+ module("Model: Alias.Models.Contact")
+
+ test("findAll", function(){
+ expect(4);
+ stop();
+ Alias.Models.Contact.findAll({}, function(contacts){
+ ok(contacts)
+ ok(contacts.length)
+ ok(contacts[0].name)
+ ok(contacts[0].description)
+ start();
+ });
+
+ })
+
+ test("create", function(){
+ expect(3)
+ stop();
+ new Alias.Models.Contact({name: "dry cleaning", description: "take to street corner"}).save(function(contact){
+ ok(contact);
+ ok(contact.id);
+ equals(contact.name,"dry cleaning")
+ contact.destroy()
+ start();
+ })
+ })
+ test("update" , function(){
+ expect(2);
+ stop();
+ new Alias.Models.Contact({name: "cook dinner", description: "chicken"}).
+ save(function(contact){
+ equals(contact.description,"chicken");
+ contact.update({description: "steak"},function(contact){
+ equals(contact.description,"steak");
+ contact.destroy();
+ start();
+ })
+ })
+
+ });
+ test("destroy", function(){
+ expect(1);
+ stop();
+ new Alias.Models.Contact({name: "mow grass", description: "use riding mower"}).
+ destroy(function(contact){
+ ok( true ,"Destroy called" )
+ start();
+ })
+ })
+}) \ No newline at end of file
diff --git a/webclient/alias/test/qunit/qunit.js b/webclient/alias/test/qunit/qunit.js
index 91674b7..f025b68 100644
--- a/webclient/alias/test/qunit/qunit.js
+++ b/webclient/alias/test/qunit/qunit.js
@@ -1 +1 @@
-steal("funcunit/qunit", "./alias_test.js"); \ No newline at end of file
+steal("funcunit/qunit", "./alias_test.js", './contact_test.js'); \ No newline at end of file
diff --git a/webclient/config.js.sample b/webclient/config.js.sample
new file mode 100644
index 0000000..3a0aae6
--- /dev/null
+++ b/webclient/config.js.sample
@@ -0,0 +1,4 @@
+var BOSH_SERVICE = 'http://alias.im/http-bind';
+var server_component = 'social.alias.im';
+var NAME = "zaran@alias.im";
+var PASSWORD = "xxxx"; \ No newline at end of file
diff --git a/webclient/index.html b/webclient/index.html
deleted file mode 100644
index 85ff64e..0000000
--- a/webclient/index.html
+++ /dev/null
@@ -1,91 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC
- "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <title>Alias</title>
- <script type="text/javascript" src="lib/jquery-1.4.4.js"></script>
- <script type="text/javascript" src="lib/jquery.tipTip.js"></script>
- <script type="text/javascript" src="lib/jquery.tabs.js"></script>
- <script type="text/javascript" src="lib/jquery.dialog.js"></script>
- <script type="text/javascript" src="lib/jquery.forms.js"></script>
- <script type="text/javascript" src="lib/strophe.js"></script>
- <script type="text/javascript" src="lib/jsbn.js"></script>
- <script type="text/javascript" src="lib/jsbn2.js"></script>
- <script type="text/javascript" src="lib/rsa.js"></script>
- <script type="text/javascript" src="lib/rsa2.js"></script>
- <script type="text/javascript" src="lib/prng4.js"></script>
- <script type="text/javascript" src="lib/rng.js"></script>
- <script type="text/javascript" src="lib/sjcl.js"></script>
- <script type="text/javascript" src="lib/config.js"></script>
- <script type="text/javascript" src="lib/alias.js"></script>
- <link rel="stylesheet" type="text/css" href="style/alias.css" />
- <link rel="stylesheet" type="text/css" href="style/tabs.css" />
- <link rel="stylesheet" type="text/css" href="style/tipTip.css" />
- <link rel="stylesheet" type="text/css" href="style/dialog.css" />
- <link rel="shortcut icon" href="favicon.ico" />
- </head>
- <body>
-
- <div id="dialogs">
- <div id="dialog-overlay"></div>
- <div class="dialog" id="register">test</div>
- </div>
-
- <div id="header">
- <img src="style/images/logo.png" height=60 style="padding-left:20px"/>
- <span id="logo">Alias</span>
- <span id="status"></span>
- </div>
-
- <div id='login'>
- <h2>Connection</h2>
- <div class="content">
- <p class="info">
- You can register with any Jabber account.
- <br/> No account? Then you can
- <a href="test">register</a> on this server.
- </p>
- <hr/>
- <p>
- <label for='jid'>Address:</label>
- <input type='text' id='jid'/>
- </p>
- <p>
- <label for='pass'>Password:</label>
- <input type='password' id='pass'/>
- </p>
- <p class="connect">
- <button id="connect" type="button">Connect</button>
- </p>
- </div>
- </div>
-
- <div id='left'>
- <h2>Contacts</h2>
- <div id='roster'>
- <input type="text" id="rosterfilter" name="test"/>
- <ul>
- </ul>
- </div>
- </div>
-
- <div id='right'>
- <div id='tabs'>
- <ul class="tabbar">
- <li><a href="#profile">Profile</a></li>
- </ul>
- <div style="clear:both"/>
- <div id='profile' class="tab">
- </div>
- </div>
- </div>
-
- <div id='bottom'>
- <div id='bottomup'><a href="#" id='consolea'>Console</a></div>
- <div id='log'></div>
- </div>
- </body>
-</html>