Permalink
Browse files

added channel handler

  • Loading branch information...
1 parent c1477c2 commit 8a249dd3643fb928ed917b193f1bd2a41b1a95a6 Chris Anderson committed May 23, 2009
Showing with 16 additions and 3 deletions.
  1. +16 −2 _attachments/index.html
  2. +0 −1 options.json
@@ -5,7 +5,14 @@
<link rel="stylesheet" href="style/main.css" type="text/css">
</head>
<body>
- <h1>Toast - Join a Channel:</h1>
+ <h1>Toast - Join a Channel (or Create one):</h1>
+ <form id="new_channel" action="#">
+
+ <p><label for="name">Channel Name</label> <input type="text" name="name" value="" id="name"></p>
+ <p><label for="message">Initial Message</label> <input type="text" name="message" value="" id="message">
+ </p>
+ <p><input type="submit" value="Go &rarr;"></p>
+ </form>
<ul id="channels"></ul>
</body>
<script src="/_utils/script/json2.js"></script>
@@ -14,11 +21,18 @@
<script src="vendor/couchapp/jquery.couchapp.js"></script>
<script type="text/javascript" charset="utf-8">
$.CouchApp(function(app) {
- app.view("channels",{success: function(json) {
+ app.view("channels",{group_level: 1, success: function(json) {
$("#channels").html(json.rows.map(function(row) {
return '<li>'+JSON.stringify(row)+'</li>';
}).join(''));
}});
+
+ $("#new_channel").submit(function() {
+ var name = $('#name').val();
+ var message = $('#message').val();
+ app.db.saveDoc({channel:name,message:message});
+ return false;
+ });
});
</script>
</html>
View
@@ -1,4 +1,3 @@
{
- "include_design": true,
"local_seq": true
}

0 comments on commit 8a249dd

Please sign in to comment.