-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.html
132 lines (113 loc) · 4.35 KB
/
models.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE html>
<meta charset="utf-8">
<head>
<!--<link href="http://cdn.sencha.io/ext-4.1.1-gpl/resources/css/ext-all.css" rel="stylesheet" />
<script src="http://cdn.sencha.io/ext-4.1.1-gpl/ext-all.js"></script>-->
<link href="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.2.0/classic/theme-crisp/resources/theme-crisp-all.css" rel="stylesheet" />
<!--<link href="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.2.0/packages/font-ext/resources/font-ext-all.css" rel="stylesheet" />-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.2.0/ext-all.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.2.0/classic/theme-crisp/theme-crisp.js"></script>
<!--<link href="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.2.0/modern/theme-triton/resources/theme-triton-all.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.2.0/ext-modern-all.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.2.0/modern/theme-triton/theme-triton.js"></script>-->
<link rel="stylesheet" type="text/css" href="style/main.css">
</head>
<style>
.largeThumbNail {
width: 200px;
height: 200px;
}
</style>
<script>
// Set up a model to use in our Store
Ext.define('Kitty', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'int'},
{name: 'name', type: 'string'},
{name: 'image_url', type: 'string'},
{name: 'image_url_cdn', type: 'string'},
{name: 'generation', type: 'int'},
{name: 'image_url', type: 'string'},
{name: 'created_at', type: 'string'},
{name: 'color', type: 'string'},
{name: 'is_fancy', type: 'bool'},
{name: 'is_exclusive', type: 'bool'},
{name: 'fancy_type', type: 'string'},
//{name: 'status', type: 'string'}, // object
//{name: 'purrs', type: 'string'},
//{name: 'watchlist', type: 'string'},
{name: 'hatched', type: 'bool'},
//{name: 'auction', type: 'string'}, // object
//{name: 'owner', type: 'string'}, // object
//{name: 'sire', type: 'string'}, // object
//{name: 'matron', type: 'string'}, // object
]
});
//var playerUrl = "https://api.cryptokitties.co/kitties?offset=0&limit=20&owner_wallet_address=0xcb187babff22a47f59cfad0439b9d655fc9070dd&parents=false";
var playerKitties = Ext.create('Ext.data.Store', {
model: 'Kitty',
autoLoad: false,
proxy: {
type: 'ajax',
reader: {
type: 'json',
root: 'kitties'
}
},
sorters: [{
property: 'generation',
direction: 'ASC'
}]
});
function createView() {
var kittyTpl = new Ext.XTemplate(
'<tpl for=".">',
'<div style="margin-bottom: 10px;" class="thumb-wrap">',
'{id} - {name}',
'<img class="largeThumbNail" src="{image_url}">',
'</div>',
'</tpl>'
);
Ext.create('Ext.view.View', {
store: playerKitties,
tpl: kittyTpl,
itemSelector: 'div.thumb-wrap',
emptyText: 'No images available',
renderTo: Ext.getBody()
});
}
var CK_API = "https://api.cryptokitties.co"
function requestPlayerKitties(addr, offset, limit=20, parents=false) {
console.log(offset);
Ext.Ajax.request({
url: `${CK_API}/kitties?offset=${offset}&limit=${limit}&owner_wallet_address=${addr}&parents=${parents}`,
success: function(response, opts) {
var obj = Ext.decode(response.responseText);
console.dir(obj);
playerKitties.loadRawData(obj, true);
if (offset + limit < obj.total)
requestPlayerKitties(addr, offset+limit, limit, parents);
},
failure: function(response, opts) {
console.log('server-side failure with status code ' + response.status);
}
});
}
function populationPlayerKitties(addr) {
//playerKitties.clear();
requestPlayerKitties(addr, 0);
}
populationPlayerKitties("0xcb187babff22a47f59cfad0439b9d655fc9070dd");
/*playerKitties.load( () => {
playerKitties.sort('generation', 'ASC');
playerKitties.each(function(record,id){
console.info(record);
});
});*/
Ext.onReady(createView);
</script>
<body>
<div class="thumb-wrap"></div>
</body>
</html>