-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
59 lines (51 loc) · 1.84 KB
/
index.html
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
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://www.celljs.org/cell.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css" rel="stylesheet">
<script src="./bundle.js"></script>
</head>
<script>
var App = {
$cell: true,
_items: [],
$init: function() {
this._query();
}, // use _ to define data and ()'s on elements
_query: function() {
_getItems()
.then(function(res) {
// transform array to clean up
const results = res.map(function(item) {
// console.log(item.node.name, item.node.review_count)
return ({
name: item.node.name,
review_count: item.node.review_count
})
})
// console.log(results)
// console.log(results[0])
this._refresh(results);
}.bind(this));
},
_refresh: function(results) {
this._items = results;
},
_template: function(item) {
return {
$components: [{
$text: item.name
}, {
content: item.review_count ? item.review_count : ""
}]
};
},
$update: function() {
this.$components = this._items.map(this._template)
}
}
</script>
<script src="./bundle.js"></script>
</html>