Skip to content

Commit

Permalink
added channel handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Anderson committed May 23, 2009
1 parent c1477c2 commit 8a249dd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
18 changes: 16 additions & 2 deletions _attachments/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -14,11 +21,18 @@ <h1>Toast - Join a Channel:</h1>
<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>
1 change: 0 additions & 1 deletion options.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"include_design": true,
"local_seq": true
}

0 comments on commit 8a249dd

Please sign in to comment.