Skip to content

Instantly share code, notes, and snippets.

@jtenner
Created October 25, 2013 21:33
Show Gist options
  • Save jtenner/7162176 to your computer and use it in GitHub Desktop.
Save jtenner/7162176 to your computer and use it in GitHub Desktop.
hoodie gist for gr2m
var app = new Hoodie("http://localhost:6001/");
app.account.signIn("admin", "admin").done(function (user) {
app.store.findAll('callback').done(function (callbacks) {
for (var i = 0, _len = callbacks.length; i < _len; i++) {
$(".target").append(JSON.stringify(callbacks[i]) + "<br />")
}
});
console.log(user)
$("#add").click(function () {
app.store.add('callback', {
guid: guid(),
unhandled: true,
created_by: '@Model.User.Display_Name',
user_name: '@Model.User.User_Name',
created_date: new Date(),
date_modified: new Date()
});
});
app.store.on("add:callback", function (obj) {
$(".target").append(JSON.stringify(obj) + "<br />");
});
});
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
};
function guid() {
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment