-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
139 lines (125 loc) · 5 KB
/
script.js
File metadata and controls
139 lines (125 loc) · 5 KB
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
$(document).ready(function() {
google.charts.load('current', {'packages':['corechart']});
$(".btn-pref .btn").click(function () {
$(".btn-pref .btn").removeClass("btn-primary").addClass("btn-default");
// $(".tab").addClass("active"); // instead of this do the below
$(this).removeClass("btn-default").addClass("btn-primary");
});
$( "#directors" ).click(function() {
if (document.getElementById('minMoviesD') != null) {
var qMin = document.getElementById("minMoviesD").value;
} else{
var qMin = 10;
}
document.getElementById("limitNumber").innerHTML = "Directors";
$.ajax({
url: "http://localhost:8888/dbFinal/results.php?var=directors&count="+document.getElementById("itemsDisplayed").value+"&qmin="+qMin
}).done(function(data) { // data what is sent back by the php page
$('#tab2').html(data); // display data
});
});
$( "#actors" ).click(function() {
if (document.getElementById('minMoviesA') != null) {
var qMin = document.getElementById("minMoviesA").value;
} else{
var qMin = 10;
}
document.getElementById("limitNumber").innerHTML = "Actors";
$.ajax({
url: "http://localhost:8888/dbFinal/results.php?var=actors&count="+document.getElementById("itemsDisplayed").value+"&qmin="+qMin
}).done(function(data) { // data what is sent back by the php page
$('#tab3').html(data); // display data
});
});
$( "#popular" ).click(function() {
document.getElementById("limitNumber").innerHTML = "Popular";
$.ajax({
url: "http://localhost:8888/dbFinal/results.php?var=popular&count="+document.getElementById("itemsDisplayed").value
}).done(function(data) { // data what is sent back by the php page
$('#tab1').html(data); // display data
});
});
$( "#timeline" ).click(function() {
if (document.getElementById("userID").innerHTML != null) {
var userID = document.getElementById("userID").value;
$.ajax({
url: "http://localhost:8888/dbFinal/results.php?var=timeline&count="+document.getElementById("itemsDisplayed").value+"&term="+userID
}).done(function(data) { // data what is sent back by the php page
$('#userData').html(data); // display data
});
} else{
var qMin = 10;
}
document.getElementById("limitNumber").innerHTML = "Timeline";
});
$( "#search" ).click(function() {
document.getElementById("limitNumber").innerHTML = "Search";
$( "#searchBtn" ).trigger( "click" );
});
$( "#genres" ).click(function() {
document.getElementById("limitNumber").innerHTML = "Genres";
$( "#genres" ).trigger( "click" );
});
$( "#userIDBtn" ).click(function() {
$type = "#"+($('#limitNumber')[0].innerHTML);
$type=$type.toLowerCase();
$($type).trigger( "click" );
});
$( "#searchBtn" ).click(function() {
if(document.getElementById("searchTerm").value != ""){
$.ajax({
url: "http://localhost:8888/dbFinal/results.php?var="+document.getElementById("filterText").innerHTML+"&count="+document.getElementById("itemsDisplayed").value+"&term="+document.getElementById("searchTerm").value
}).done(function(data) { // data what is sent back by the php page
$('#searchResults').html(data); // display data
});
}
});
$( "#popular" ).trigger( "click" );
$( "#limitBtn" ).click(function() {
$type = "#"+($('#limitNumber')[0].innerHTML);
$type=$type.toLowerCase();
$($type).trigger( "click" );
});
});
function searchGenre(genre){
$.ajax({
url: "http://localhost:8888/dbFinal/results.php?var=genre&count="+document.getElementById("itemsDisplayed").value+"&term="+genre
}).done(function(data) { // data what is sent back by the php page
$('#genreResults').html(data); // display data
var divLoc = $('#resultText').offset();
$('html, body').animate({scrollTop: divLoc.top}, "slow");
});
};
function searchTerm(term){
document.getElementById("searchTerm").value = term;
$("#search").trigger( "click" );
};
function setSearch(tag){
document.getElementById("filterText").innerHTML=tag;
document.getElementById("filterBtn").innerHTML=tag.toUpperCase();;
console.log(tag);
};
function init() {
gapi.client.setApiKey("AIzaSyBUZLs6B8PtskGwpp-YnVbTaQEHQoi_HPE");
gapi.client.load("youtube", "v3", function() {
// yt api is ready
});
};
function search(term,id){
// prepare the request
var request = gapi.client.youtube.search.list({
part: "snippet",
type: "video",
q: term,
maxResults: 1
});
// execute the request
request.execute(function(response) {
var results = response.result;
$("#"+id).attr('src', "https://www.youtube.com/embed/"+results.items[0].id.videoId)
resetVideoHeight();
});
};
function resetVideoHeight() {
$(".video").css("height", $("#results").width() * 9/16);
}