-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
72 lines (60 loc) · 2.05 KB
/
test.html
File metadata and controls
72 lines (60 loc) · 2.05 KB
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
72
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Test</title>
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="item.classes.js"></script>
</head>
<body>
<script type="text/javascript">
var res = new ResourceItem();
console.log(res instanceof ResourceItem);
console.log(res instanceof Item);
var food = new FoodItem();
console.log(food instanceof FoodItem);
console.log(food instanceof Item);
var obj = new ObjectItem();
console.log(obj instanceof ObjectItem);
console.log(obj instanceof Item);
var con = new ContainerItem();
console.log(con instanceof ContainerItem);
console.log(con instanceof Item);
var itemsJsonData = function () {
var json = null;
$.ajax({
//jsonp: 'jsonp_callback',
async: false,
global: false,
url: "items.json",
dataType: "json",
success: function (data) {
json = data;
},
error: function (data) {
}
});
return json;
};
var itemList = [];
var items = itemsJsonData();
for (var i=0; i<items.length; i++) {
var item = null;
switch (items[i]['type'].toLowerCase()) {
case 'resource': item = new ResourceItem(); break;
case 'food': item = new FoodItem(); break;
case 'drug': item = new DrugItem(); break;
case 'container': item = new ContainerItem(); break;
default: console.log(items[i]['type']);break;
}
for (j in items[i]) {
item[j] = items[i][j];
}
itemList.push( item);
}
console.log(itemList);
</script>
</body>
</html>