-
Notifications
You must be signed in to change notification settings - Fork 0
/
DayMenuView.qml
71 lines (52 loc) · 2.52 KB
/
DayMenuView.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import "js/constants.js" as constants;
import "MenuDelegate.qml";
GridView {
id: itemsMenuView;
delegate: MenuDelegate {}
model: ListModel { id: itemsModelMenu; }
function loadData(url) {
itemsMenuView.loading = true;
var request = new XMLHttpRequest();
emptyMenu.visible = false;
request.onreadystatechange = function() {
if (request.readyState !== XMLHttpRequest.DONE)
return;
if (request.status && request.status === 200) {
log("response was received");
itemsModelMenu.reset();
//log(request.responseText);
if(request.responseText != "0 results[]"){
var catalog = JSON.parse(request.responseText);
catalog["data"].forEach(function (catalogItem) {
itemsModelMenu.append( { id: catalogItem["item_id"],
title: catalogItem["title"],
date: catalogItem["date"],
kkal: catalogItem["kkal"] + "к.",
porsiya: catalogItem["porsiya"],
time: catalogItem["time"]+"м.",
type: catalogItem["type"] } );
});
weekMenu.exist = true;
itemsMenuView.loading = false;
itemsMenuView.setFocus();
}else{
weekMenu.exist = false;
emptyMenu.visible = true;
itemsMenuView.loading = false;
reloadMenu.setFocus();
}
log("catalog was updated");
} else
log("unhandled status", request.status);
}
request.open("GET", url, true);
request.send();
log("request was sended:"+url);
}
property bool loading: false;
cellWidth: 220;
cellHeight: 120;
visible: !loading;
focus: true;
clip: true;
}