Skip to content

Instantly share code, notes, and snippets.

@MariuszWisniewski
Last active August 29, 2015 14:11
Show Gist options
  • Save MariuszWisniewski/a03368e22289441af000 to your computer and use it in GitHub Desktop.
Save MariuszWisniewski/a03368e22289441af000 to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<script src="http://cdn.jsdelivr.net/sockjs/0.3.4/sockjs.min.js"></script>
<script src="http://cdn.jsdelivr.net/syncanojs/3.1.3beta/syncano.min.js"></script>
<script src="http://cdn.jsdelivr.net/jquery/2.1.1/jquery.min.js"></script>
<head></head>
<body>
<div id="wrapper">
<div id="notification-body" style="font-size: 150px; font-weight:bold;">
</div>
</div>
<script>
var syncano = SyncanoConnector.getInstance();
var authData = {
api_key: 'API_KEY',
instance: 'INSTANCE_NAME'
};
var PROJECT_ID = 4187;
var COLLECTION_ID = 15191;
syncano.connect(authData, function (auth) {
console.log("Connected");
});
syncano.on('syncano:authorized', function (uuid) {
syncano.Subscription.subscribeProject(PROJECT_ID, function (result) {
console.log("Subscribed!");
})
});
syncano.Data.get(PROJECT_ID, COLLECTION_ID, {
include_children: false,
folders: 'Default'
}, function (data) {
console.log('Received', data.length, 'objects');
data.forEach(function (d) {
console.log(d);
});
});
syncano.on('syncano:newdata:project-4187', function (data) {
if (data) {
console.log("Received Data:");
console.log(data[0]);
$("#notification-body").html(data[0].title);
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment