-
Notifications
You must be signed in to change notification settings - Fork 0
/
insta.php
201 lines (184 loc) · 5.7 KB
/
insta.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
<!DOCTYPE HTML>
<html>
<head>
<style>
body {
margin: 0px;
}
#pictureframe {
padding: 0px;
margin: 0px auto;
border: none;
width: 640px;
height: 1280px;
}
#instabox {
margin: 0 auto;
display: table;
border: none;
margin-top: 0px;
text-align: left;
float:left;
}
#box {
margin: 0 auto;
margin-top: 40px;
display: table;
/* border: black solid 1px;*/
border: none;
}
#headline {
font-weight: bold;
}
.super {
float: left;
margin: 0px;
width: 320px;
height: 320px;
}
.container {
width: 320px;
height: 320px;
margin: 0px auto;
display: table-cell;
vertical-align: middle;
text-align: center;
}
</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();
// 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','keepcalm2' + ("00" + numPics).slice(-2) + '.jpg');
newimg.setAttribute('width',320);
newimg.setAttribute('height',320);
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) {
//t.src=n; return true; // uncomment this line if the there are _lots_ of pictures coming in
var target = t;
maxh = 320;
maxw = 320;
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.2;
if (h > maxh) { h = maxh; }
b.style.height = parseInt(h)+'px';
b.style.width = parseInt(h)+'px';
} else if (h == maxh) {
clearInterval(timer2);
}
}, 1
);
},800
);
}
}, 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:none"></div><!-- hidden div for instafeed to output to -->
<div id="debug" style="display:none"></div> <!-- debug - hidden. duh -->
<div id="pictureframe">
<div id="showcase" style="margin: 0px auto; border: none;"></div> <!-- contains the actual pictures -->
<div style="clear:both"></div>
</div>
</div>
</div>
<script type="text/javascript">
function setMotion(s) {
var parent = document.getElementById('showcase');
var n = s.split("|");
n.pop();
var debug = '';
var newImages = 0;
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
animateOut(parent.childNodes[currentIndex].childNodes[0].childNodes[0],n[i]);
// parent.childNodes[currentIndex].src=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;
}
var options = {
get: 'tagged',
tagName: 'rfchange',
sortBy: 'most-recent',
links: 'false',
limit: '8',
resolution: 'low_resolution',
clientId: '48e3a611d4484383bb87ca5c528c7cef',
template: '{{image}}|',
target: 'instafeed',
after: function() { setMotion(document.getElementById('instafeed').innerHTML); },
}
var feed = new Instafeed(options);
setTimeout(function() {
feed.run();
var interval = setInterval(function() {
feed.run();
}, 4000);
},5000);
</script>
</body>
</html>