-
Notifications
You must be signed in to change notification settings - Fork 3
/
unityComm.html
434 lines (371 loc) · 18.7 KB
/
unityComm.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
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Unity Web Player | Unity_Html</title>
<script type='text/javascript' src='https://ssl-webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/jquery.min.js'></script>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript" src="http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject.js"></script>
<script type="text/javascript" src="http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject2.js"></script>
<script type="text/javascript">
<!--
var unityObjectUrl = "http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject2.js";
if (document.location.protocol == 'https:')
unityObjectUrl = unityObjectUrl.replace("http://", "https://ssl-");
document.write('<script type="text\/javascript" src="' + unityObjectUrl + '"><\/script>');
-->
</script>
<script type="text/javascript">
<!--
var loggedIn = false;
var friendsImages = [];
var myImages = [];
var fImagesCount = 0,
myImagesCount = 0;
var friendsImagesUrl = [];
var myImagesUrl =[];
var popularUrl=[];
var recentUrl=[];
var count = 0;
var limitPics = 100;
var config = {
width: 960,
height: 600,
params: { enableDebugging:"0" }
};
var u = new UnityObject2(config);
jQuery(function() {
var $missingScreen = jQuery("#unityPlayer").find(".missing");
var $brokenScreen = jQuery("#unityPlayer").find(".broken");
$missingScreen.hide();
$brokenScreen.hide();
u.observeProgress(function (progress) {
switch(progress.pluginStatus) {
case "broken":
$brokenScreen.find("a").click(function (e) {
e.stopPropagation();
e.preventDefault();
u.installPlugin();
return false;
});
$brokenScreen.show();
break;
case "missing":
$missingScreen.find("a").click(function (e) {
e.stopPropagation();
e.preventDefault();
u.installPlugin();
return false;
});
$missingScreen.show();
break;
case "installed":
$missingScreen.remove();
break;
case "first":
break;
}
});
u.initPlugin(jQuery("#unityPlayer")[0], "unityComm.unity3d");
});
//facebook Integration
function loadAlbums()
{
FB.init({
appId : '189710761220128',
status : true,
cookie : true,
xfbml : true
});
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
FB.login(function(response)
{
if (response.authResponse)
{
document.getElementById("status").innerHTML = "Getting album information from your Facebook profile";
// Most recently 30 created photos from friends
FB.api(
{
method:'fql.query',
query:'SELECT pid, src_big \
FROM photo \
WHERE aid IN (SELECT aid \
FROM album WHERE owner IN \
(SELECT uid2 \
FROM friend \
WHERE uid1=me() ORDER BY rand() LIMIT 10) ORDER BY rand() LIMIT 20) \
ORDER BY created DESC LIMIT 30'
},
function(response){
for(var i=0;i<response.length;i++){
//alert("FRIENDS url"+response[i].src_big);
recentUrl[i]=response[i].src_big;
//var oImg = document.createElement("img");
//oImg.setAttribute('src',response[i].src_big);
//oImg.setAttribute('alt', 'friend image');
//oImg.setAttribute('height', '200px');
//oImg.setAttribute('width', '200px');
//document.getElementById("recent").appendChild(oImg);
}
},{scope:'public_profile, basic_info, user_photos, user_friends, friends_photos' }
);
// Most popular number of photos from friends
FB.api(
{
method:'fql.query',
query:'SELECT like_info,src_big FROM photo WHERE aid IN (SELECT aid FROM album WHERE owner IN (SELECT uid2 from friend WHERE uid1=me())) ORDER BY like_info.like_count DESC LIMIT 20'
},
function(response){
for (var i=0;i<response.length;i++){
//alert("popular"+response[i].src_big);
//alert("like: "+response[i].like_info.like_count);
popularUrl[i]=response[i].src_big;
//var oImg = document.createElement("img");
//oImg.setAttribute('src',response[i].src_big);
//oImg.setAttribute('alt', 'popular photos');
//oImg.setAttribute('height', '200px');
//oImg.setAttribute('width', '200px');
//document.getElementById("popular").appendChild(oImg);
}
},{scope:'public_profile, basic_info, user_photos, user_friends, user_status, friends_likes, friends_photos'}
);
//randomly get photos from your ablums
FB.api(
{
method:'fql.query',
query:'SELECT src_big,aid FROM photo WHERE aid IN (SELECT aid FROM album WHERE owner=me() ORDER BY rand() LIMIT 10 ) ORDER BY rand() LIMIT 50'
},
function(response){
for (var i=0;i<response.length;i++){
myImagesUrl[i]=response[i].src_big;
//var oImg = document.createElement("img");
//oImg.setAttribute('src',response[i].src_big);
//oImg.setAttribute('alt', 'popular photos');
//oImg.setAttribute('height', '200px');
//oImg.setAttribute('width', '200px');
//document.getElementById("me").appendChild(oImg);
}
},{scope:'public_profile, basic_info, user_photos, user_friends, user_status,friends_photos'}
);
/*
var counter = 0;
FB.api('/me/albums', function(response)
{
var albumid;
var d = response.data;
for (var i=0; i<Math.min(d.length,3); i++)
{
albumid = d[i].id;
FB.api("/"+albumid+"/photos", function(response){
var d_pics = response.data;
var pElement = document.createElement('p');
for(var j = 0; j< Math.min(d_pics.length,20);j++ ){
myImages[myImagesCount] = new Image();
myImages[myImagesCount].src = d_pics[j].source;
myImagesUrl[myImagesCount]= myImages[myImagesCount].src;
myImagesCount += 1;
var oImg = document.createElement("img");
oImg.setAttribute('src', d_pics[j].source);
oImg.setAttribute('alt', d_pics[j].name);
oImg.setAttribute('height', '200px');
oImg.setAttribute('width', '200px');
pElement.appendChild(oImg);
divElement.appendChild(pElement);
}
});
counter++;
}
document.getElementById("status").innerHTML = "There are "+ counter +" albums in your Facebook profile";
});*/
//randonly get photos from your friends
FB.api(
{
method:'fql.query',
query:'SELECT src_big,aid FROM photo WHERE aid IN (SELECT aid FROM album WHERE owner IN (SELECT uid FROM user where uid IN (select uid2 from friend where uid1 = me() ORDER BY rand() LIMIT 50)) ORDER BY rand() LIMIT 10) ORDER BY rand() LIMIT 50'
},
function(response){
for (var i=0;i<response.length;i++){
friendsImagesUrl[i]=response[i].src_big;
//var oImg = document.createElement("img");
//oImg.setAttribute('src',response[i].src_big);
//oImg.setAttribute('alt', 'popular photos');
//oImg.setAttribute('height', '200px');
//oImg.setAttribute('width', '200px');
//document.getElementById("friends").appendChild(oImg);
}
},{scope:'public_profile, basic_info, user_photos, user_friends, user_status,friends_photos'}
);
/*
FB.api('/me/friends/', function(response) {
for(var i = 0; i < Math.min(response.data.length, 20); i++) {
FB.api('/'+response.data[i].id+'/albums' , function(friendsAlbums) {
for(var k = 0; k < Math.min(friendsAlbums.data.length, 2); k++) {
FB.api('/'+friendsAlbums.data[k].id + '?fields=photos' , function(friendsPhotos) {
for(var z = 0; z < Math.min(friendsPhotos.photos.data.length, 2); z++) {
for(var zD = 0; zD < Math.min(friendsPhotos.photos.data[z].images.length, 1); zD++) {
friendsImages[fImagesCount] = new Image();
friendsImages[fImagesCount].src = friendsPhotos.photos.data[z].images[zD].source;
//alert("friendsurl:"+friendsImages[fImagesCount].src);
//document.getElementById("status").innerHTML = "friendsImages "+url;
friendsImagesUrl[fImagesCount]= friendsImages[fImagesCount].src;
//alert(friendsImagesUrl[fImagesCount]);
fImagesCount += 1;
var oImg = document.createElement("img");
oImg.setAttribute('src', friendsPhotos.photos.data[z].images[zD].source);
oImg.setAttribute('alt', 'wer');
oImg.setAttribute('height', '200px');
oImg.setAttribute('width', '200px');
document.body.appendChild(oImg);
//alert(friendsPhotos.photos.data[z].images[zD].source);
//alert("haha");
}
}
});
}
});
}
});*/
}
},{scope:'read_stream,publish_stream,offline_access,user_photos,friends_photos,user_photo_video_tags,friends_photo_video_tags'});
}
/*
function shufflePics(){
if(count == 0){
for(var i = 0; i < 10; i++){
var oImg = document.createElement("img");
count += 1;
//alert(i);
//if(i%2 == 0)
oImg.setAttribute('src', friendsImages[i].src);
//else oImg.setAttribute('src', myImages[i].src);
oImg.setAttribute('alt', 'wer');
oImg.setAttribute('height', '200px');
oImg.setAttribute('width', '200px');
document.body.appendChild(oImg);
}
}
}*/
//send imagesURL to unity
function myAlbums(){
for (var i = 0; i< Math.min(myImagesUrl.length,50);i++){
u.getUnity().SendMessage("Game","myPicture",myImagesUrl[i]);
}
}
function myfAlbums(){
for(var i=0; i<Math.min(friendsImagesUrl.length,50);i++){
u.getUnity().SendMessage("Game","myfPicture",friendsImagesUrl[i]);
}
}
function popularPhotos(){
//alert("popularUrl"+popularUrl.length);
for (var i = 0; i< Math.min(popularUrl.length,50);i++){
u.getUnity().SendMessage("Game","popularPicture",popularUrl[i]);
}
}
function recentPhotos(){
for (var i = 0; i< Math.min(recentUrl.length,50);i++){
u.getUnity().SendMessage("Game","recentPicture",recentUrl[i]);
}
}
//
//function Check(s){
// alert(s);
//}
function init()
{
loadAlbums();
}
//calls init function once all the resources are loaded
window.addEventListener("load",init,true);
-->
</script>
<style type="text/css">
<!--
body {
font-family: Helvetica, Verdana, Arial, sans-serif;
background-color: white;
color: black;
text-align: center;
}
a:link, a:visited {
color: #000;
}
a:active, a:hover {
color: #666;
}
p.header {
font-size: small;
}
p.header span {
font-weight: bold;
}
p.footer {
font-size: x-small;
}
div.content {
margin: auto;
width: 960px;
}
div.broken,
div.missing {
margin: auto;
position: relative;
top: 50%;
width: 193px;
}
div.broken a,
div.missing a {
height: 63px;
position: relative;
top: -31px;
}
div.broken img,
div.missing img {
border-width: 0px;
}
div.broken {
display: none;
}
div#unityPlayer {
cursor: default;
height: 600px;
width: 960px;
}
-->
</style>
</head>
<body>
<p class="header"><span>Unity Web Player | </span>Unity_Html</p>
<h1>Just Remember </h1>
<p id="status"> ... </p>
<div class="content">
<div id="unityPlayer">
<div class="missing">
<a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now!">
<img alt="Unity Web Player. Install now!" src="http://webplayer.unity3d.com/installation/getunity.png" width="193" height="63" />
</a>
</div>
<div class="broken">
<a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now! Restart your browser after install.">
<img alt="Unity Web Player. Install now! Restart your browser after install." src="http://webplayer.unity3d.com/installation/getunityrestart.png" width="193" height="63" />
</a>
</div>
</div>
</div>
<p>Most recent photos</p>
<div id = "recent"></div>
<p>Most popular photos</p>
<div id="popular"></div>
<p> randomly photos from friends</p>
<div id="friends"></div>
<p>randomly photos from your own albums</p>
<div id="me"></div>
<p class="footer">« created with <a href="http://unity3d.com/unity/" title="Go to unity3d.com">Unity</a> »</p>
</body>
</html>