Created
December 21, 2010 16:30
-
-
Save framallo/750159 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<link rel="stylesheet" type="text/css" media="all" | |
href="css/docs.css" /> | |
<title>me</title> | |
<script src="js/ext/jquery.js"></script> | |
<script src="../browser-couch.js"></script> | |
<script type='text/javascript'> | |
var repaint = function(db){ | |
console.log('repaint') | |
db.onload(function(x){ | |
x.view({ | |
finished: function(x){ | |
$("#bookmarks").html("<ul />"); | |
var rows = x.rows; | |
for (var y in rows){ | |
console.log(rows[y]); | |
$("#bookmarks").append($("<li>" + rows[y].value + "</li>")); | |
} | |
}, | |
map : function(doc, emit){ | |
if(doc){ | |
emit(doc.id, doc.url); | |
} | |
} | |
}); | |
}); | |
} | |
$(function(){ | |
console.log("Document Loaded"); | |
console.log("Adding test data"); | |
var test_data = [ | |
{_id : "0", hello : 'world'}, {_id : "1", chunky : 'monkey'}, {_id : "2", foo : 'bar'}, {_id : "3", black : 'hat'}, | |
{_id : "4", black : 'tea'}, {_id : "5", words : 'two foo three'}, {_id : "6", words: 'two'} | |
]; | |
db = BrowserCouch('bar'); | |
db.onload(function(){ | |
db.put(test_data, function(){}); | |
}); | |
allDocuments = function(db) { | |
console.log("Show All Docs"+ db.getLength()); | |
db.view({ | |
map : function(doc, emit){ console.log(doc) }, | |
finished : function(view){ } | |
}); | |
} | |
allDocuments2 = function(db) { | |
var results = db.allDocs(); | |
var rows = results.rows; | |
return rows | |
} | |
allDocuments(db); | |
db2 = BrowserCouch('pages'); | |
db2.sync('http://admin:admin@localhost:5984/pages', | |
{'continuous' :true, | |
'interval' :500, | |
'update' : function(){ | |
console.log('update'); | |
console.log(db2.getLength()); | |
} | |
}); | |
allDocuments(db2); | |
}); | |
</script> | |
</head> | |
<body> | |
<h1>Me</h1> | |
<p>This is an application to demonstrate/experiment with | |
uses of browsercouch. Explore the code | |
<a href="index.html#bookmarks.js">here</a>. | |
</p> | |
<div id = "bookmarks"> | |
<p>Loading... | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment