-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
156 lines (141 loc) · 8.37 KB
/
index.html
File metadata and controls
156 lines (141 loc) · 8.37 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!DOCTYPE html>
<html class="no-js" lang="en" >
<head>
<title>Plex Requests!</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="bootstrap.min.css">
<style>
@media (min-width: 768px) {
body {
padding-top: 60px;
}
}
h1 {
font-size: 3.5em;
}
p {
font-size: 1.2em;
}
#results {
padding-left: 15px;
}
</style>
</head>
<body>
<div class="container">
<div class="row col-md-offset-3 col-md-7">
<a href="javascript:window.location.reload();"><h1>Plex Requests!</h1></a>
<p class="lead">Want to watch a movie but it's not currently on Plex?<br>
Use the search box below to do a quick <a href="http://www.omdbapi.com/">OMDB</a> search for a movie!</p>
<br>
<form name="myform" id="myform" action="" method="get" class="form-inline">
<div class="form-group">
<input type="search" id="search" class="form-control" placeholder="Movie title" required>
</div>
<div class="form-group">
<input type="submit" value="Search!" class="btn btn-primary">
</div>
</form>
<div class="overview" id="overview"></div>
<form name="result" id="results" action="" method="get" class="form-group">
</form>
</div>
<div class="row col-md-offset-3 col-sm-6">
<div class="alert" role="alert" id="info"></div>
</div>
<script type="text/javascript">
document.getElementById("myform").onsubmit = function() {
var o = "http://www.omdbapi.com/?s=";
var s = document.getElementById("search").value;
var u = o + s;
(function() {
$.getJSON(u)
.done(function(data) {
document.getElementById("search").blur();
try {
var len = data['Search'].length;
}
catch(err) {
var info = '<p>Hmm we got no results...<a href="javascript:document.getElementById(\'search\').focus()" class="alert-link">try again!</a><p>';
document.getElementById("info").setAttribute("class", "alert alert-warning");
document.getElementById("info").innerHTML = info;
var list = document.getElementById("results");
while (list.firstChild) {
list.removeChild(list.firstChild);
}
var mg = ""
document.getElementById("overview").innerHTML = mg
return;
}
var mg = "<br><h3>Results from the OMDB:</h3>"
document.getElementById("overview").innerHTML = mg;
var list = document.getElementById("results");
while (list.firstChild) {
list.removeChild(list.firstChild);
}
for (i = 0; i < data['Search'].length; i++) {
var t = data['Search'][i]['Title'];
var y = data['Search'][i]['Year'];
var ty = t + " (" + y + ")";
ty = "<p>" + ty + "</p>"
var d = document.createElement("div");
d.setAttribute("class", "radio")
d.setAttribute("id", "for" + i);
document.getElementById("results").appendChild(d);
var l = document.createElement("label");
l.setAttribute("for", "option" + i);
l.setAttribute("id", "foroption" + i);
document.getElementById("for" + i).appendChild(l);
var n = document.createElement("input");
n.setAttribute("type", "radio");
n.setAttribute("value", ty);
n.setAttribute("id", "option" + i);
n.setAttribute("name", "movie");
n.setAttribute("class", "movie");
n.required = true;
document.getElementById("foroption" + i).appendChild(n);
old_html = document.getElementById("foroption" + i).innerHTML;
document.getElementById("foroption" + i).innerHTML = old_html + ty;
var info = '<p>Not find what you were looking for? <a href="javascript:document.getElementById(\'search\').focus()" >Click here to search again!</a></p>';
document.getElementById("info").setAttribute("class", "info");
document.getElementById("info").innerHTML = info;
}
var s = document.createElement("input");
s.setAttribute("type", "submit")
s.setAttribute("value", "Request Movie!")
s.setAttribute("class", "btn btn-primary");
document.getElementById("results").appendChild(s);
document.getElementById('overview').scrollIntoView({block: "end", behavior: "smooth"});
})
.fail(function() {
var mg = '<p>Hmmm something went wrong with your search...<a href="javascript:document.getElementById(\'search\').focus()" class="alert-link">try again in a few moments!</a></p>';
document.getElementById("info").setAttribute("class", "alert alert-danger");
document.getElementById("info").innerHTML = mg;
});
})();
return false;
}
document.getElementById("results").onsubmit = function() {
var movie = document.querySelector('input[name="movie"]:checked').value;
PushBullet.APIKey = "abcdef12345";
PushBullet.push("note", null, null, {title: "Movie Requested", body: movie});
var mg = '<p>Movie was successfully requested! Want to <a href="javascript:document.getElementById(\'search\').focus()" class="alert-link">search again?</a></p>'
document.getElementById("info").setAttribute("class", "alert alert-success");
document.getElementById("info").innerHTML = mg;
var mg = ""
document.getElementById("overview").innerHTML = mg;
var list = document.getElementById("results");
while (list.firstChild) {
list.removeChild(list.firstChild);
}
return false;
}
</script>
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="https://alexschneider.github.io/pushbullet-js/pushbullet.min.js" type="text/javascript"></script>
<noscript><div class="row col-md-offset-3 col-md-7"><h3>No JavaScript Enabled?</h3><p>This web app is entirely dependent on JavaScript, please enable it! Instructions can be found <a href="http://www.activatejavascript.org/" target="_blank">here.</a></p></div>
</div>
</body>
</html>