Skip to content

Instantly share code, notes, and snippets.

@andrewwakeling
Created May 26, 2014 05:32
Show Gist options
  • Save andrewwakeling/c73dcce384028c07ee70 to your computer and use it in GitHub Desktop.
Save andrewwakeling/c73dcce384028c07ee70 to your computer and use it in GitHub Desktop.
GDB example
<!doctype html>
<html>
<head>
<script src="jquery-1.11.1.min.js"></script>
<script src="jquery.gdb.js"></script>
<script src="main.js"></script>
</head>
<body>
<div data-bindto="data.lastUpdated"></div>
</body>
</html>
(function ($, window) {
models = {data: {
lastUpdated: '1234'
}};
function getResult(callback) {
var BASE_RESULT =
{
"resource": "current",
"results": [
{
"PERIOD": "Lunch 2",
"SHORT_NAME": "L2",
"PERIOD_TYPE": "Break",
"START_TIME": "13:01:00",
"END_TIME": "13:20:00",
"AM_PM": "Afternoon"
}
],
"lastUpdated": "2014-05-26T03:13:27.546Z"
};
BASE_RESULT.lastUpdated = (new Date()).toISOString();
callback(BASE_RESULT);
}
function pollIt() {
getResult(function (data) {
models.data.lastUpdated = data.lastUpdated;
console.log(data.lastUpdated);
setTimeout(pollIt, 1000);
});
}
$(function () {
window.GDB(models, {debugLogging: true});
pollIt();
});
}($, this));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment