]>
Commit | Line | Data |
---|---|---|
2d183941 JR |
1 | // Mustis WebOS |
2 | ||
3 | state = {} | |
4 | ||
5 | function poster(addr, data, cb) { | |
6 | if (!cb) cb = processResponse; | |
7 | ||
8 | if (state.uid) data.uid = state.uid; | |
9 | if (state.sid) data.sid = state.sid; | |
10 | $.post('backend/'+addr, data, cb, 'json'); | |
11 | } | |
12 | ||
13 | function processResponse(resp) { | |
14 | loc = "div#body"; | |
15 | if (resp.success) { | |
16 | if (resp.contents) { | |
17 | $(loc).html(resp.contents); | |
18 | } | |
19 | if (resp.data) { | |
20 | for (key in resp.data) { | |
21 | state[key] = resp.data[key]; | |
22 | } | |
23 | } | |
24 | } else { | |
8e9adb3f JR |
25 | $("div#error").append('<p>'+resp.error.reason+'</p>'); |
26 | $("div#error").slideDown(400); | |
27 | $("div#error").click(function () { | |
28 | $("div#error").slideUp(400); | |
29 | $("div#error").html('<p><small>click to close</small></p>'); | |
30 | }); | |
2d183941 JR |
31 | } |
32 | } |