Created
May 26, 2014 05:32
-
-
Save andrewwakeling/c73dcce384028c07ee70 to your computer and use it in GitHub Desktop.
GDB example
This file contains hidden or 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> | |
<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> |
This file contains hidden or 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
(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