-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
109 lines (99 loc) · 2.75 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
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
<!doctype html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="./css/style.css">
<script src="./js/mootools-core-1.4.5-full-nocompat-yc.js" type="text/javascript"></script>
<script src="./js/mootools-more-1.4.0.1.js" type="text/javascript"></script>
<script src="./js/Database.js" type="text/javascript"></script>
<script src="./js/iFixitDevice.js" type="text/javascript"></script>
<script>
var db = new Database();
db.create();
var sortable, gear = [];
var deviceRequest = new Request.JSONP({
url: 'https://www.ifixit.com/api/1.0/topics/all',
callbackKey: 'jsonp',
data: {
limit: 20,
offset: 0
},
onComplete: function(data) {
for( var i = 0; i < data.length; i++ )
{
if( gear.indexOf( data[i].topic ) === -1 )
{
var d = new iFixitDevice( data[i].topic, sortable, null );
d.appendToList( 'device-list' );
}
}
}
});
window.addEvent('domready', function() {
sortable = new Sortables('ul', {
clone: true,
revert: true,
opacity: 0.7,
onStart: function( element, clone ) {
this.parent = element.getParent();
},
onComplete: function( element ) {
var p = element.getParent();
if( p !== this.parent )
{
if( p.get('id') === 'gear-list' )
db.insert( element.get('name'), element.getChildren('img').get('src') );
else if( p.get('id') === 'device-list' )
db.delete( element.get('name') );
}
}
});
db.selectAll( function(length, rows) {
for( i = 0; i < length; i++ )
{
gear.push( rows[i].name );
var d = new iFixitDevice( rows[i].name, sortable, rows[i].thumb );
d.appendToList( 'gear-list' )
}
});
deviceRequest.send();
deviceRequest.options.data.limit = 10;
deviceRequest.options.data.offset += 10;
$('get-more').addEvent( 'click', function() {
deviceRequest.options.data.offset += 10;
deviceRequest.send();
});
$('empty-gear').addEvent( 'click', function() {
db.deleteAll();
$$('#gear-list > li').forEach( function(el, idx, arr) {
$('device-list').adopt(el);
});
});
});
</script>
</head>
<body>
<div id="header">
<h1 id="title">Select Your Gear</h1>
<div class="left-column">
<h3>All Devices</h3>
<p><a id="get-more">- Get More Devices -</a></p>
</div>
<div class="spacer"></div>
<div class="right-column">
<h3>Gear Bag</h3>
<p><a id="empty-gear">- Empty Gearbag -</a></p>
</div>
<div style="clear: both;"></div>
</div>
<div id="content">
<div id="devices" class="left-column bag">
<ul id="device-list"></ul>
</div>
<div class="spacer"></div>
<div id="gearbag" class="right-column bag">
<ul id="gear-list"></ul>
</div>
<div style="clear: both;"></div>
</div>
</body>
</html>