-
Notifications
You must be signed in to change notification settings - Fork 0
/
insta-dev.php
221 lines (203 loc) · 6.39 KB
/
insta-dev.php
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<!DOCTYPE HTML>
<html>
<head>
<title>#RFmakerspace</title>
<style>
body {
margin: 0px;
}
#pictureframe {
padding: 0px;
margin: 0px auto;
border: none;
width: 1224px;
height: 612px;
}
#instabox {
margin: 0 auto;
display: table;
border: none;
margin-top: 0px;
text-align: left;
float:left;
}
#box {
margin: 0 auto;
margin-top: 60px;
display: table;
border: none;
}
#headline {
font-weight: bold;
}
.super {
float: left;
margin: 0px;
width: 306px;
height: 306px;
}
.container {
width: 306px;
height: 306px;
margin: 0px auto;
display: table-cell;
vertical-align: middle;
text-align: center;
}
#statuscolor2 {
text-align: left;
background-color: white;
height: 20px;
width: 20px;
}
</style>
<script type="text/javascript" src="instafeed.min.js"></script>
<script>
var consdebug = false;
var url,id;
var numPics = 0;
var id;
var maxImages = 8;
var currentIndex = 0; // which picture are we updating next?
inStore = new Array();
var iterations = 0;
// make maxImages img-nodes
function mkImages(maxImages) {
for (numPics=0; numPics < maxImages;numPics++) {
var parent = document.getElementById('showcase');
var superdiv = document.createElement('div');
superdiv.setAttribute('class','super');
var newdiv = document.createElement('div');
newdiv.setAttribute('class','container');
newdiv.setAttribute('style','vertical-align: middle;');
var newimg = document.createElement('img');
var imgIdName = 'img'+numPics;
newimg.setAttribute('id',imgIdName);
newimg.setAttribute('src','keepcalm' + ("00" + numPics).slice(-2) + '.jpg');
newimg.setAttribute('width',306);
newimg.setAttribute('height',306);
newimg.setAttribute('style','opacity: 1');
newdiv.appendChild(newimg);
superdiv.appendChild(newdiv);
parent.appendChild(superdiv);
}
var newdiv = document.createElement('div');
newdiv.setAttribute('style','clear:both;');
parent.appendChild(newdiv);
}
// flips images out and back in
// sluggish on slow machines.. the RPI will suffer
function animateOut(t,n) {
// in case of high load of images, just set t.src = n and return true
var target = t;
maxh = 306;
maxw = 306;
minh = 0;
var b = t;
var h = t.style.height;
h = h.replace('px','');
if (!h) { h = 1; }
var direction = 0;
var timer = setInterval(
function() {
if (h > minh && !direction) {
h = parseInt(h * 0.8);
b.style.height = h+'px';
b.style.width = h+'px';
} else if (h == 0) {
b.src=n; direction == 1;
clearInterval(timer);
h = 1; if (consdebug) { console.log('og så blæser vi op igen..' + h); }
var t2 = setTimeout(
function() {
var timer2 = setInterval(
function() {
if (h < maxh) {
h = h*1.1;
if (h > maxh) { h = maxh; }
b.style.height = parseInt(h)+'px';
b.style.width = parseInt(h)+'px';
} else if (h == maxh) {
clearInterval(timer2);
}
}, 1
);
},1000
);
}
}, 30
);
}
</script>
</head>
<body onLoad="javascript:mkImages(maxImages);">
<div style="width:95%;margin: 0 auto; border: none; padding: 0px; text-align: center;">
<div id="box">
<div id="instafeed" style="display:true"></div><!-- hidden div for instafeed to output to -->
<div id="debug" style="display:true"></div> <!-- debug - hidden. duh -->
<div id="pictureframe">
<div id="showcase" style="margin: 0px auto; border: none;"></div> <!-- contains the actual pictures -->
</div>
<div id="statuscolor2"> </div>
</div><!-- eo box -->
</div>
<script type="text/javascript">
function setMotion(s) {
var parent = document.getElementById('showcase');
var n = s.split("|");
n.pop(); // the last item is always trash (|)
var debug = '';
var newImages = 0;
debug = debug + 'images fetched: ' + n.length + '<br>';
debug = debug + 'iterations: ' + iterations + '<br>';
if (consdebug) { console.log(n.length-1 + ' items fetched'); }
for (i=n.length-1;i>=0;i--) { // sort with oldest first
debug = debug + '<br>' + n[i];
if (inStore.indexOf(n[i]) == -1) {
// add image to showcase on currentIndex
// make some fancy in/out-animation when replacing image
// add a setTimeout so multiple pictures cascade in
animateOut(parent.childNodes[currentIndex].childNodes[0].childNodes[0],n[i]);
currentIndex++;
if (currentIndex > maxImages-1) { currentIndex = 0; }
inStore.unshift(n[i]); // add the url at the beginning of inStore
if (inStore.length > maxImages) { inStore.pop(); }
newImages++;
}
//else { console.log('not new');}
}
if (consdebug ) { console.log(newImages + ' images added'); }
document.getElementById('debug').innerHTML = debug + 'inStore: ' + inStore.length;
document.getElementById('instafeed').innerHTML = '';
iterations++;
}
var options = {
get: 'tagged',
tagName: 'diy',
sortBy: 'most-recent',
links: 'false',
limit: '8',
resolution: 'low_resolution',
clientId: '48e3a611d4484383bb87ca5c528c7cef',
template: '{{image}}|',
target: 'instafeed',
before: function() { document.getElementById('statuscolor2').style.backgroundColor = 'orange'; },
after: function() { document.getElementById('statuscolor2').style.backgroundColor = 'white'; setMotion(document.getElementById('instafeed').innerHTML); },
}
var feed = new Instafeed(options);
/*
setTimeout(function() {
feed.run();
var interval = setInterval(function() {
feed.run();
}, 4000);
},5000);
*/
feed.run();
setTimeout( function() { feed.run(); },5000);
setTimeout( function() { feed.run(); },10000);
setTimeout( function() { feed.run(); },15000);
setTimeout( function() { feed.run(); },20000);
</script>
</body>
</html>