diff options
Diffstat (limited to 'bin/data/updater.js')
-rw-r--r-- | bin/data/updater.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/bin/data/updater.js b/bin/data/updater.js new file mode 100644 index 0000000..20201f8 --- /dev/null +++ b/bin/data/updater.js | |||
@@ -0,0 +1,20 @@ | |||
1 | var updater = Class.create({ | ||
2 | initialize: function(divToUpdate, interval, file) { | ||
3 | this.divToUpdate = divToUpdate; | ||
4 | this.interval = interval; | ||
5 | this.file = file; | ||
6 | new PeriodicalExecuter(this.getUpdate.bind(this), this.interval); | ||
7 | }, | ||
8 | |||
9 | getUpdate: function() { | ||
10 | var oOptions = { | ||
11 | method: "POST", | ||
12 | parameters: "intervalPeriod="+this.interval, | ||
13 | asynchronous: true, | ||
14 | onComplete: function (oXHR, Json) { | ||
15 | $(this.divToUpdate).innerHTML = oXHR.responseText; | ||
16 | } | ||
17 | }; | ||
18 | var oRequest = new Ajax.Updater(this.divToUpdate, this.file, oOptions); | ||
19 | } | ||
20 | }); \ No newline at end of file | ||