This repository has been archived by the owner on Oct 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmember-index.php
3492 lines (2936 loc) · 122 KB
/
member-index.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
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
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
require_once('auth.php');
?>
<!DOCTYPE html>
<!--
--------------------------------------------------------------------------
Copyright 2012 British Broadcasting Corporation and Vrije Universiteit
Amsterdam
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--------------------------------------------------------------------------
-->
<html>
<head>
<title>N-Screen</title>
<script type="text/javascript" src="lib/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="lib/jquery-ui-1.8.10.custom.min.js"></script>
<script type="text/javascript" src="lib/jquery.ui.touch-punch.min.js"></script>
<script type="text/javascript" src="lib/strophe.js"></script>
<script type="text/javascript" src="lib/buttons.js"></script>
<script type="text/javascript" src="lib/spin.min.js"></script>
<script type="text/javascript" src="lib/play_video.js"></script>
<link type="text/css" rel="stylesheet" href="css/new.css" />
</head>
<body onload="javascript:init()">
<!-- workaround for audio problems on ipad - http://stackoverflow.com/questions/2894230/fake-user-initiated-audio-tag-on-ipad -->
<div id="junk" style="display:none">
<audio src="sounds/x4.wav" id="a1" preload="auto" autobuffer="autobuffer" controls="" ></audio>
<audio src="sounds/x1.wav" id="a2" preload="auto" autobuffer="autobuffer" controls="" ></audio>
</div>
<script type="text/javascript">
//the main buttons object
var buttons = null;
//if there's more than one TV you'll get more than one message so this is to limit the duplication
var lastmsg="";
//this is so we can link to the TV and perhaps the api easily
var clean_loc = String(window.location).replace(/\#.*/,"");
//group name is based on the part after # in the url, handled in init()
var my_group=null;
//for api calls
//could be a web service
var api_root = "data/";
var recommendations_url=api_root+"recommendations.js"
var channels_url=api_root+"channels.js";
var search_url = api_root+"search.js";
var start_url = "get_channel.php";
var random_url = "get_random.php"
//jabber server
var server = "localhost";
//var server = "jabber.notu.be";
//polling interval (for changes to channels)
var interval = null;
//handle back and forward navigating
var overlay_navigation = [];
var overlaycounter = null;
//var list = new Array(); //initialazing array
// Set of local variables that help us to store later (if so)
var list_watch_later = [];
var watch_later_json = {};
var list_recently_viewed = [];
var recently_viewed_json = {};
var list_shared_by_friends = [];
var shared_by_friends_json = {};
var list_likes = [];
var list_dislikes = [];
var likes_json = {};
var real_likesdislikes_json = {}; //to update later
var dislikes_json = {};
var random_json = {};
var recommendations_json = {};
var related_json = {};
var ted_key = "xbsdfg4uhxf6prsp8c7adrty";
var ted_api_request = "https://api.ted.com/v1/talks.json?api-key=xbsdfg4uhxf6prsp8c7adrty"
var ted_api_filter_id= "filter=id:>"; //Remember to make "&" between them and provide int!!
var ted_api_filter_limit = "limit=";
var ted_api_filter_offset = "offset=";
var local_search = false;
var suggestions = null;
$.fn.hasOverflow = function() {
var $this = $(this);
var $children = $this.find('*');
var len = $children.length;
if (len) {
var maxWidth = 0;
var maxHeight = 0
$children.map(function(){
maxWidth = Math.max(maxWidth, $(this).outerWidth(true));
maxHeight = Math.max(maxHeight, $(this).outerHeight(true));
});
return maxWidth > $this.width() || maxHeight > $this.height();
}
return false;
};
window.onresize = function(event) {
if ($("#side-b")[0].scrollHeight > $("#side-b").innerHeight()) {
$('#moreblue1').show();
}
else{
$('#moreblue1').hide();
}
if ($("#content")[0].scrollHeight > $("#content").innerHeight()) {
$('#moreblue2').show();
}
else{
$('#moreblue2').hide();
}
if ($("#content2")[0].scrollHeight > $("#content2").innerHeight()) {
$('#moreblue3').show();
}
else{
$('#moreblue3').hide();
}
if ($("#content3")[0].scrollHeight > $("#content").innerHeight()) {
$('#moreblue4').show();
}
else{
$('#moreblue4').hide();
}
if ($("#content4")[0].scrollHeight > $("#content2").innerHeight()) {
$('#moreblue5').show();
}
else{
$('#moreblue5').hide();
}
if ($("#content5")[0].scrollHeight > $("#content2").innerHeight()) {
$('#moreblue6').show();
}
else{
$('#moreblue6').hide();
}
};
function check_overflow(){
if ($("#side-b")[0].scrollHeight > $("#side-b").innerHeight()) {
$('#moreblue1').show();
}
else{
$('#moreblue1').hide();
}
if ($("#content")[0].scrollHeight > $("#content").innerHeight()) {
$('#moreblue2').show();
}
else{
$('#moreblue2').hide();
}
if ($("#content2")[0].scrollHeight > $("#content2").innerHeight()) {
$('#moreblue3').show();
}
else{
$('#moreblue3').hide();
}
if ($("#content3")[0].scrollHeight > $("#content").innerHeight()) {
$('#moreblue4').show();
}
else{
$('#moreblue4').hide();
}
if ($("#content4")[0].scrollHeight > $("#content2").innerHeight()) {
$('#moreblue5').show();
}
else{
$('#moreblue5').hide();
}
if ($("#content5")[0].scrollHeight > $("#content2").innerHeight()) {
$('#moreblue6').show();
}
else{
$('#moreblue6').hide();
}
}
function init(){
//detect ipads etc
//console.log("platform "+navigator.platform);
if(navigator.platform.indexOf("iPad") != -1 || navigator.platform.indexOf("Linux armv7l") != -1){
$("#inner").addClass("inner_noscroll");
$(".slidey").addClass("slidey_noscroll");
$("#search_results").css("width","80%");
}else{
$("#inner").addClass("inner_scroll");
}
create_buttons();
// $("#main_title").html("N-SCREEN");
$sr=$("#search_results");
$sr.css("display","none");
// $container=$("#browser");
// $container.css("display","block");
// $browse=$("#browse");
// $browse.addClass("blue").removeClass("grey");
// $random=$("#random");
// $random.addClass("grey").removeClass("blue");
var grp = window.location.hash;
if(grp){
my_group = grp.substring(1);
//$("#header").show();
// $("#roster_wrapper").show();
//$(".about").hide();
//create_buttons();
}else{
$.ajax({
url: "get_group.php",
async: false,
success: function (response) {
console.log("Th group is = " + response);
if(response == null || response == ""){my_group = Math.floor(Math.random()*9999)} //prevent cookie problems
else{my_group = response;}
//$("#header").show();
//$("#roster_wrapper").show();
}
});
}
history.pushState(state, "N-Screen", "http://localhost/N-Screen/");
clean_loc = String(window.location);
window.location.hash=my_group;
//$("#group_name").html(my_group);
// $("#grp_link").html(clean_loc+"#"+my_group);
// $("#grp_link").attr("href",clean_loc+"#"+my_group);
var state = {"canBeAnything": true};
$(".more_blue").hide();
add_name();
//load the start url or random if no start_url (see conf.js)
//get a random set of starting points
// ??????????????????????????????????????????????????
//do_start("progs","get_suggestions.php");
}
function add_name(){
var name = get_name();
if(name){
var me = new Person(name,name);
buttons.me = me;
$(document).trigger('send_name');
//get some 'recommendations' --> this should be rendered by a recommendation algorithm
$.ajax({
type: "POST",
url: "get_channel.php",
async: false,
data: {channel: "recommendations"},
dataType: "json",
success: function(data){
//console.log(data);
//var whatever = changeData(data);
recommendations_json = data; //set global variable to use later if so
console.log("THIS IS RECOMM")
console.log(recommendations_json);
recommendations(data,"progs");
// check_overflow();
},
error: function(jqXHR, textStatus, errorThrown){
console.log("!!nokkkk "+textStatus);
}
});
//Get WATCH LATER
$.ajax({
type: "POST",
url: "get_channel.php",
async: false,
data: {channel: "watch_later"},
dataType: "json",
success: function(data){
if(data!= null){
watch_later_json = data;
// console.log(watch_later_json);
var watch_later_items = watch_later_json.suggestions;
for(var i in watch_later_items){
var pid = watch_later_items[i].pid;
list_watch_later.push(pid);
}
recommendations(data,"list_later");
check_overflow();
}
else{
watch_later_json = {
suggestions: []
};
list_watch_later = [];
}
},
error: function(jqXHR, textStatus, errorThrown){
console.log("!!nok "+textStatus);
}
});
//GET RECENTLY VIEWED
$.ajax({
type: "POST",
url: "get_channel.php",
async: false,
data: {channel: "recently_viewed"},
dataType: "json",
success: function(data){
if(data!= null){
//console.log(data);
recently_viewed_json = data;
var recently_viewed_items = recently_viewed_json.suggestions;
//console.log(recently_viewed_items);
if(recently_viewed_items.length != 0){
for(var i in recently_viewed_items){
var pid = recently_viewed_items[i].pid;
list_recently_viewed.push(pid);
}
}
recommendations(data,"history");
check_overflow();
}
else{
recently_viewed_json = {
suggestions: []
};
list_recently_viewed = [];
}
},
error: function(jqXHR, textStatus, errorThrown){
console.log("!!nok "+textStatus);
}
});
$.ajax({
type: "POST",
url: "get_channel.php",
async: false,
data: {channel: "shared_by_friends"},
dataType: "json",
success: function(data){
if(data!= null){
//console.log(data);
//var whatever = changeData(data);
shared_by_friends_json = data; //set global variable to use later if so
var shared_by_friends_items = shared_by_friends_json.suggestions;
if(shared_by_friends_items.length != 0){
for(var i in shared_by_friends_items){
var pid = shared_by_friends_items[i].pid;
list_shared_by_friends.push(pid);
}
}
//console.log(recommendations_json);
recommendations(data,"results");
check_overflow();
}
else{
shared_by_friends_json = {
suggestions: []
};
list_shared_by_friends = [];
}
},
error: function(jqXHR, textStatus, errorThrown){
console.log("!!nokkkk "+textStatus);
}
});
$.ajax({
type: "POST",
url: "get_channel.php",
async: false,
data: {channel: "like_dislike"},
dataType: "json",
success: function(data){
real_likesdislikes_json = data;
// console.log(JSON.stringify(data));
//console.log(data);
likes_json = {
suggestions: []
};
dislikes_json = {
suggestions: []
};
if(data.likes.length >0){
// ---- LIKES ----
// likes_json = data.likes;
likes_json.suggestions = JSON.parse(JSON.stringify(data.likes));//set global variable to use later if so
var likes_items = likes_json.suggestions;
if(likes_items.length != 0){
for(var i in likes_items){
var pid = likes_items[i].pid;
list_likes.push(pid);
}
}
console.log(likes_json);
recommendations(likes_json,"list_likes");
check_overflow();
}
if(data.dislikes.length >0){
// ---- DISLIKES ----
dislikes_json = {
suggestions: []
};
dislikes_json.suggestions = JSON.parse(JSON.stringify(data.dislikes));//set global variable to use later if so
var dislikes_items = dislikes_json.suggestions;
if(dislikes_items.length != 0){
for(var i in dislikes_items){
var pid = dislikes_items[i].pid;
list_dislikes.push(pid);
}
}
//console.log(recommendations_json);
console.log(likes_json);
console.log(dislikes_json);
recommendations(dislikes_json,"list_dislikes");
check_overflow();
}
},
error: function(jqXHR, textStatus, errorThrown){
console.log("!!nokkkk "+textStatus);
}
});
recommendations(recommendations_json,"progs");
recommendations(watch_later_json,"list_later");
recommendations(recently_viewed_json,"history");
recommendations(shared_by_friends_json,"results");
recommendations(likes_json,"list_likes");
recommendations(dislikes_json,"list_dislikes");
}
var state = {"canBeAnything": true};
//history.pushState(state, "N-Screen", "/N-Screen/");
window.location.hash=my_group;
$("#logoutspan").show();
}
//creates and initialises the buttons object
function create_buttons(){
//$("#inner").addClass("inner_noscroll");
// $(".slidey").addClass("slidey_noscroll");
//$(".about").hide();
// $("#header").show();
$("#roster_wrapper").show();
//set up notifications area
$("#notify").toggle(
function (){
//console.log("SHOW");
$("#notify_large").show();
},
function (){
//console.log("HIDE");
$("#notify_large").hide();
$("#notify").html("");
$("#notify_large").html("");
$("#notify").hide();
}
);
//initialise buttons object and start the link
buttons = new ButtonsLink({"server":server});
}
// called when buttons link is created
function blink_callback(blink){
// console.log("INSIDE BLINK CALLBACK --> GOING TO CALL GET CHANNEL")
//var delay = 60000;
//interval = setInterval(get_channels, delay);
get_roster(blink);
// ???????????????????????????????????????????
// $(document).trigger('refresh');
// $(document).trigger('refresh_buttons');
// $(document).trigger('refresh_group');
// $(document).trigger('refresh_history');
// $(document).trigger('refresh_recs');
// $(document).trigger('refresh_search');
// //my new channels
// $(document).trigger('refresh_later');
// $(document).trigger('refresh_ld');
}
//http://fgnass.github.com/spin.js/
var opts = {
lines: 12, // The number of lines to draw
length: 5, // The length of each line
width: 3, // The line thickness
radius: 5, // The radius of the inner circle
color: '#fff', // #rbg or #rrggbb
speed: 1, // Rounds per second
trail: 100, // Afterglow percentage
shadow: true // Whether to render a shadow
};
//UPDATE REGARDING COLUMN IN CONTENT DATABASE
// watch_later, recently_viewed, shared_by_friends....
function update_channel(channel, data){
if(channel == "like_dislike"){
console.log(JSON.stringify(real_likesdislikes_json));
real_likesdislikes_json.likes = likes_json.suggestions;
real_likesdislikes_json.dislikes = dislikes_json.suggestions;
console.log(JSON.stringify(real_likesdislikes_json));
$.ajax({
url: "set_channel.php",
type: "POST",
data: {data : JSON.stringify(real_likesdislikes_json), channel : channel},
dataType: "json",
success: function (response) {
console.log("Correct " + channel + " updated");
}
});
}
else{
$.ajax({
url: "set_channel.php",
type: "POST",
data: {data : JSON.stringify(data), channel : channel},
dataType: "json",
success: function (response) {
console.log("Correct " + channel + " updated");
}
});
}
}
//display suggestions based on id
// RECENTLY VIEWED !!
function insert_suggest2(id) {
// console.log("list shared by friends");
// console.log(list_shared_by_friends);
if (overlaycounter == null){
overlaycounter = 0;
}
else{
overlaycounter ++;
}
overlay_navigation.splice(overlaycounter, 0, id);
for (var i= overlay_navigation.length - 1; i > overlaycounter ; i--){
overlay_navigation.splice(i, 1);
}
var item = {};
var flag = false //to set recently viewed icon or not
//code to check how to place the element in recently viewed
if(update_list(id,list_recently_viewed) == false){ //this means that the element IS already in the list
flag = true;
$('#history').find("#"+id).remove();
for(var i in recently_viewed_json.suggestions){
if(recently_viewed_json.suggestions[i].pid == ('' + id)){
// console.log("inside if");
item = recently_viewed_json.suggestions[i];
recently_viewed_json.suggestions.splice(i,1); //we remove the item from the local json
}
}recently_viewed_json.suggestions.splice(0,0,item);
}
else{
$.ajax({
url: "get_tedtalks_by_id.php",
type: "POST",
async: false,
data: {id: id},
dataType: "json",
success: function (data) {
item = changeData(data); //JSON with suggestions format
recently_viewed_json.suggestions.splice(0,0,item.suggestions[0]);
}
});
}//recently_viewed_json.suggestions[0] is the current video now displayed
update_channel("recently_viewed", recently_viewed_json);
var div = $("#"+id);
var speaker = (/(.*):.*?/.exec(recently_viewed_json.suggestions[0].title))[1];
var title = (/.*?:(.*)/.exec(recently_viewed_json.suggestions[0].title))[1];
var description = recently_viewed_json.suggestions[0].description;
// var tags = lalala **********************TO DO*********************
var video = recently_viewed_json.suggestions[0].video;
var pid = recently_viewed_json.suggestions[0].pid;
var img = recently_viewed_json.suggestions[0].image;
var speaker_id = recently_viewed_json.suggestions[0].speaker[0].speaker.id;
console.log("THIS IS SPEKAER ID");
console.log(speaker_id);
var tags = Object.keys(recently_viewed_json.suggestions[0]["tags"]);
// var tags = (/[^,]*/.exec(tags));
// tags = (/[^, ]*/.exec(tags)); //array of tags
html = [];
html.push("<div id=\""+id+"\" pid=\""+pid+"\" href=\""+video+"\" class=\"ui-widget-content button programme ui-draggable\"" + "onclick=\"javascript:insert_suggest2("+pid+");return true\">");
html.push("<img class=\"img img_small\" src=\""+img+"\" />");
html.push("<div style='margin-top:-54px;'>");
if(not_in_list(id,list_watch_later)){
html.push("<img class=\"overlapicon\" src=\"images/icons/watch_later.png\"/>");
}
else{
html.push("<img class=\"overlapicon\" src=\"images/icons/on_watch_later.png\"/>");
}
if(not_in_list(id,list_likes)){
html.push("<img class=\"overlapicon\" src=\"images/icons/like.png\" />");
}
else{
html.push("<img class=\"overlapicon\" src=\"images/icons/on_like.png\" />");
}
if(not_in_list(id,list_dislikes)){
html.push("<img class=\"overlapicon\" src=\"images/icons/dislike.png\" />");
}
else{
html.push("<img class=\"overlapicon\" src=\"images/icons/on_dislike.png\" />");
}
if(not_in_list(id,list_recently_viewed)){
html.push("<img class=\"overlapicon\" src=\"images/icons/recently_viewed.png\" />");
}
else{
html.push("<img class=\"overlapicon\" src=\"images/icons/on_recently_viewed.png\" />");
}
if(not_in_list(id,list_shared_by_friends)){
html.push("<img class=\"overlapicon\" src=\"images/icons/shared.png\" />");
}
else{
html.push("<img class=\"overlapicon\" src=\"images/icons/on_shared.png\" />");
}
html.push("</div>");
html.push("<span class=\"p_title p_title_small\"><a>"+title+"</a></span>");
html.push("<p class=\"description large\">"+description+"</p>");
html.push("</div>");
$('#history').prepend(html.join(''));
html2 = [];
html2.push("<div class='close_button'><img src='images/icons/exit.png' width='12px' onclick='javascript:hide_overlay();'/></div>");
html2.push("<div class='navigation_buttons'><img onclick='javascript:navigation(-1);' style='display: inline; margin: 0 5px; cursor:pointer;' title='back' src='images/icons/backward.png' width='30'/><img onclick='javascript:navigation(+1);' style='display: inline; margin: 0 5px; cursor:pointer;' title='forward' src='images/icons/forward.png' width='30'/></div>");
html2.push("<div id=\""+id+"\" pid=\""+pid+"\" href=\""+video+"\" class=\"large_prog\" style=\"position: relative;\">");
html2.push("<div class=\"gradient_div\" style=\"text-align: center; margin-left: 45%; position: absolute; \"> <img class=\"img\" src=\""+img+"\" />");
html2.push("<div class=\"play_button\"><img style='width: 120px;' src=\"images/icons/play.png\" /></a></div></div>");
html2.push("<div style='padding-left: 20px; padding-right: 20px; width: 50%; left: 0px; position: absolute;'>");
html2.push("<div style ='cursor: pointer;'class=\"p_title_large_speaker\" onclick=\"javascript:insert_speaker("+speaker_id+");return true\">"+speaker+':'+"</div>");
html2.push("<div class=\"p_title_large\">"+title+"</div>");
html2.push("<p class=\"description\">"+description+"</p>");
html2.push("<div class=\"list_tags\" style='display:inline;'>");
for(var i=0; i<tags.length; i++){
if(tags[i].indexOf(' ') >= 0 || /^[A-Z]/.test(tags[i])){ }
else{
html2.push("<span class=\"item_tag\" onclick=\"javascript:insert_suggest_by_tag('"+tags[i]+"');return true\">#"+tags[i]+"</span>");
}
}
html2.push("</div>");
// html2.push("<p class=\"explain\">"+explanation+"</p>");
// html2.push("<p class=\"keywords\">"+keywords+"</p>");
html2.push("<p class=\"link\"><a href=\"http://www.ted.com/talks/view/id/"+pid+"\" target=\"_blank\">Sharable Link</a></p></div>");
html2.push("<div class='vertical_buttons' style='display:table-cell; vertical-align: middle; margin-right: 7%; position: absolute; text-align: center; right:0; top: 10px'>");
if(not_in_list(id,list_watch_later)){
html2.push("<div id='watchlater'class=\"interactive_icon\"><img id='addtowatchlater' style='width: 40px;' src=\"images/icons/watch_later.png\" /><span style='display: block'; class ='inter_span'>Watch Later</span></div>");
}
else{
html2.push("<div id='watchlater'class=\"interactive_icon\"><img id='deletewatchlater' style='width: 40px;' src=\"images/icons/on_watch_later.png\" /><span style='display: block'; class ='on_inter_span'>Watch Later</span></div>");
}
if(not_in_list(id,list_likes)){
html2.push("<div id='like' class=\"interactive_icon\"><img id='addtolike' style='width: 40px;' src=\"images/icons/like.png\" /><span style='display: block'; class ='inter_span'>Like</span></div>");
}
else{
html2.push("<div id='like' class=\"interactive_icon\"><img id='deletelike' style='width: 40px;' src=\"images/icons/on_like.png\" /><span style='display: block'; class ='on_inter_span'>Like</span></div>");
}
if(not_in_list(id,list_dislikes)){
html2.push("<div id='dislike' class=\"interactive_icon\"><img id = 'addtodislike' style='width: 40px;' src=\"images/icons/dislike.png\" /><span style='display: block'; class ='inter_span'>Dislike</span></div>");
}
else{
html2.push("<div id='dislike' class=\"interactive_icon\"><img id = 'deletedislike' style='width: 40px;' src=\"images/icons/on_dislike.png\" /><span style='display: block'; class ='on_inter_span'>Dislike</span></div>");
}
if(not_in_list(id,list_shared_by_friends)){
html2.push("<div class=\"interactive_icon\"><img style='width: 40px;' src=\"images/icons/shared.png\" /><span style='display: block'; class ='inter_span'>Shared by friends</span></div>");
}
else{
html2.push("<div class=\"interactive_icon\"><img style='width: 40px;' src=\"images/icons/on_shared.png\" /><span style='display: block'; class ='on_inter_span'>Shared by friends</span></div>");
}
if(flag == false){
html2.push("<div class=\"interactive_icon\"><img style='width: 40px;' src=\"images/icons/recently_viewed.png\" /><span style='display: block'; class ='inter_span'>Recenlty Viewed</span></div></div>");
}
else{
html2.push("<div class=\"interactive_icon\"><img style='width: 40px;' src=\"images/icons/on_recently_viewed.png\" /><span style='display: block'; class ='on_inter_span'>Recenlty Viewed</span></div></div>");
}
html2.push("</div>");
html2.push("</div>");
if(recently_viewed_json.suggestions[0].manifest){
var manifest = recently_viewed_json.suggestions[0].manifest;
var data = recently_viewed_json.suggestions[0].manifest;
set_playable(data);
// $.ajax({
// url: recently_viewed_json.suggestions[0].manifest,
// dataType: "json",
// success: function(data){
// set_playable(data);
// },
// error: function(jqXHR, textStatus, errorThrown){
// alert("oh dear "+textStatus);
// }
// });
}
$('#new_overlay').html(html2.join(''));
$('#new_overlay').show();
show_grey_bg();
// $(".play_button").live( "click", function() {
// console.log("PLAY PRESSED!!!");
// var res = {};
// // res["id"]=id;
// res["pid"]=pid;
// res["title"]=title;
// res["video"]=video;
// res["description"]=description;
// // res["explanation"]=explanation;
// res["img"]=id;
// sendProgrammeTVs(res,my_tv);
// return false;
// });
$('#new_overlay').append("<div id=\"more_like_this\" class=\"more_like_this\" style=\"margin-top: 400px;\"><span class=\"sub_title\">MORE LIKE THIS</span><span class=\"more_blue\"><a id ='more_related' onclick='show_related();''>View All ▿</a></span></div>");
// $('#new_overlay').append("<br clear=\"both\"/>");
$('#new_overlay').append("<div id='spinner' style=\"float: left;\"></div>");
$('#new_overlay').append("<div class='clear'></div>");
check_overflow();
// var target = document.getElementById('spinner');//??
// var spinner = new Spinner(opts).spin(target);
for(var i=0; i<tags.length; i++){
//console.log("THIS IS TAG " + tags[i]);
if(tags[i].indexOf(' ') >= 0 || /^[A-Z]/.test(tags[i])){}
else {
tag = tags[i];
break;
}
}
$.ajax({
url: "get_tedtalks_related.php",
data: {tag : tag},
type: 'POST',
dataType: "json",
success: function(data){
var related = changeData(data);
related_json = related;
recommendations(related,"spinner",false,title);
// recommendations(data,"new_overlay",false,title);
},
error: function(jqXHR, textStatus, errorThrown){
//alert("oh dear "+textStatus);
}
});
}
function insert_speaker(id) {
// console.log("list shared by friends");
// console.log(list_shared_by_friends);
// var item;
// if (overlaycounter == null){
// overlaycounter = 0;
// }
// else{
// overlaycounter ++;
// }
// overlay_navigation.splice(overlaycounter, 0, id);
// for (var i= overlay_navigation.length - 1; i > overlaycounter ; i--){
// overlay_navigation.splice(i, 1);
// }
var item = {};
var flag = false //to set recently viewed icon or not
$.ajax({
url: "get_speaker.php",
type: "POST",
async: false,
data: {id: id},
dataType: "json",
success: function (data) {
item = data; //JSON with suggestions format
}
});
var div = $("#"+id);
var speaker = item["speakers"][0].speaker.firstname + " " + item.speakers[0].speaker.lastname;
var title = item.speakers[0].speaker.description;
var description = item.speakers[0].speaker.whylisten;
// var tags = lalala **********************TO DO*********************
var video = item.speakers[0].speaker.photo_url;
var pid = item.speakers[0].speaker.id;
var img = item.speakers[0].speaker.photo_url;
html = [];
html.push("<div id=\""+id+"\" pid=\""+pid+"\" href=\""+video+"\" class=\"ui-widget-content button programme ui-draggable\"" + "onclick=\"javascript:insert_speaker("+id+");return true\">");
html.push("<img class=\"img img_small\" src=\""+img+"\" />");
html.push("<div style='margin-top:-54px;'>");
if(not_in_list(id,list_watch_later)){
html.push("<img class=\"overlapicon\" src=\"images/icons/watch_later.png\"/>");
}
else{
html.push("<img class=\"overlapicon\" src=\"images/icons/on_watch_later.png\"/>");
}
if(not_in_list(id,list_likes)){
html.push("<img class=\"overlapicon\" src=\"images/icons/like.png\" />");
}
else{
html.push("<img class=\"overlapicon\" src=\"images/icons/on_like.png\" />");
}
if(not_in_list(id,list_dislikes)){
html.push("<img class=\"overlapicon\" src=\"images/icons/dislike.png\" />");
}
else{
html.push("<img class=\"overlapicon\" src=\"images/icons/on_dislike.png\" />");
}
if(not_in_list(id,list_recently_viewed)){
html.push("<img class=\"overlapicon\" src=\"images/icons/recently_viewed.png\" />");
}
else{
html.push("<img class=\"overlapicon\" src=\"images/icons/on_recently_viewed.png\" />");
}
if(not_in_list(id,list_shared_by_friends)){
html.push("<img class=\"overlapicon\" src=\"images/icons/shared.png\" />");
}
else{
html.push("<img class=\"overlapicon\" src=\"images/icons/on_shared.png\" />");
}
html.push("</div>");
html.push("<span class=\"p_title p_title_small\"><a>"+speaker+"</a></span>");
html.push("<p class=\"description large\">"+title+"</p>");
html.push("</div>");
$('#history').prepend(html.join(''));
html2 = [];
html2.push("<div class='close_button'><img src='images/icons/exit.png' width='12px' onclick='javascript:hide_overlay();'/></div>");
html2.push("<div class='navigation_buttons'><img onclick='javascript:navigation(-1);' style='display: inline; margin: 0 5px; cursor:pointer;' title='back' src='images/icons/backward.png' width='30'/><img onclick='javascript:navigation(+1);' style='display: inline; margin: 0 5px; cursor:pointer;' title='forward' src='images/icons/forward.png' width='30'/></div>");
html2.push("<div id=\""+id+"\" pid=\""+pid+"\" href=\""+video+"\" class=\"large_prog\" style=\"position: relative;\">");
html2.push("<div class=\"gradient_div\" style=\"text-align: center; margin-left: 59%; position: absolute; \"> <img class=\"img\" src=\""+img+"\" />");
html2.push("</div>");
html2.push("<div style='font-size: 0.9em; left: 0; padding-left: 19px; padding-right: 20px; position: absolute; width: 71%;'>");
html2.push("<div class=\"p_title_large_speaker\">"+speaker+':'+"</div>");
html2.push("<div>"+title+"</div>");
html2.push("<p >"+description+"</p>");
html2.push("<div class=\"list_tags\" style='display:inline;'>");
html2.push("</div>");
// html2.push("<p class=\"explain\">"+explanation+"</p>");
// html2.push("<p class=\"keywords\">"+keywords+"</p>");
html2.push("<p class=\"link\"><a href=\"http://www.ted.com/talks/view/id/"+pid+"\" target=\"_blank\">Sharable Link</a></p></div>");
html2.push("<div class='vertical_buttons' style='display:table-cell; vertical-align: middle; margin-right: 7%; position: absolute; text-align: center; right:0; top: 10px'>");
if(not_in_list(id,list_watch_later)){
html2.push("<div id='watchlater'class=\"interactive_icon\"><img style='width: 40px;' src=\"images/icons/watch_later.png\" /><span style='display: block'; class ='inter_span'>Watch Later</span></div>");
}
else{
html2.push("<div id='watchlater'class=\"interactive_icon\"><img style='width: 40px;' src=\"images/icons/on_watch_later.png\" /><span style='display: block'; class ='on_inter_span'>Watch Later</span></div>");
}
if(not_in_list(id,list_likes)){
html2.push("<div id='like' class=\"interactive_icon\"><img style='width: 40px;' src=\"images/icons/like.png\" /><span style='display: block'; class ='inter_span'>Like</span></div>");
}
else{
html2.push("<div id='like' class=\"interactive_icon\"><img style='width: 40px;' src=\"images/icons/on_like.png\" /><span style='display: block'; class ='on_inter_span'>Like</span></div>");
}
if(not_in_list(id,list_dislikes)){
html2.push("<div id='dislike' class=\"interactive_icon\"><img style='width: 40px;' src=\"images/icons/dislike.png\" /><span style='display: block'; class ='inter_span'>Dislike</span></div>");
}
else{
html2.push("<div id='dislike' class=\"interactive_icon\"><img style='width: 40px;' src=\"images/icons/on_dislike.png\" /><span style='display: block'; class ='on_inter_span'>Dislike</span></div>");
}
if(not_in_list(id,list_shared_by_friends)){
html2.push("<div class=\"interactive_icon\"><img style='width: 40px;' src=\"images/icons/shared.png\" /><span style='display: block'; class ='inter_span'>Shared by friends</span></div>");
}
else{
html2.push("<div class=\"interactive_icon\"><img style='width: 40px;' src=\"images/icons/on_shared.png\" /><span style='display: block'; class ='on_inter_span'>Shared by friends</span></div>");
}
if(flag == false){
html2.push("<div class=\"interactive_icon\"><img style='width: 40px;' src=\"images/icons/recently_viewed.png\" /><span style='display: block'; class ='inter_span'>Recenlty Viewed</span></div></div>");
}
else{
html2.push("<div class=\"interactive_icon\"><img style='width: 40px;' src=\"images/icons/on_recently_viewed.png\" /><span style='display: block'; class ='on_inter_span'>Recenlty Viewed</span></div></div>");
}
html2.push("</div>");
html2.push("</div>");
$('#new_overlay').html(html2.join(''));
$('#new_overlay').show();
show_grey_bg();
// $(".play_button").live( "click", function() {
// console.log("PLAY PRESSED!!!");
// var res = {};
// // res["id"]=id;
// res["pid"]=pid;
// res["title"]=title;
// res["video"]=video;
// res["description"]=description;
// // res["explanation"]=explanation;
// res["img"]=id;
// sendProgrammeTVs(res,my_tv);
// return false;
// });
$('#new_overlay').append("<div id=\"more_like_this\" class=\"more_like_this\" style=\"margin-top: 400px;\"><span class=\"sub_title\">" + speaker + " talks: </span><span class=\"more_blue\"><a id ='more_related' onclick='show_related();''>View All ▿</a></span></div>");
// $('#new_overlay').append("<br clear=\"both\"/>");
$('#new_overlay').append("<div id='spinner' style=\"float: left;\"></div>");
$('#new_overlay').append("<div class='clear'></div>");
check_overflow();
var speaker_talks = {
suggestions: []
};