Last active
February 16, 2019 19:49
-
-
Save bostrot/948a5f861887d657446ff8dc2f755718 to your computer and use it in GitHub Desktop.
HTML file for TVMaze API Quick Search GUI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>TV Series Search</title> | |
<link href="https://fonts.googleapis.com/css?family=VT323" rel="stylesheet"> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"> | |
<div class="box"> | |
<div class="box-icon"> | |
<span class="fa fa-4x fa-tv"></span> | |
</div> | |
<div class="info"> | |
<p class="text-center">TV Show Search</p> | |
<div class="row"> | |
<div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12"> | |
<input type="text" class="form-control" id="name" placeholder="Search for tv show"> | |
</div> | |
</div> | |
<div class="row" style="align-content: center; align-items: center;"> | |
<div class="col-xs-12 col-sm-4 col-md-4 col-lg-4 info"> | |
<a id="search" class="btn">Search</a> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div id="resultsContainer"> | |
<div class="box"> | |
<div class="info" id="results"> | |
</div> | |
</div> | |
</div> | |
</div> | |
</body> | |
<footer> | |
<script> | |
var searchBTN = document.getElementById('search'); | |
searchBTN.addEventListener('click', function () { | |
window.location.href = "?show=" + document.getElementById("name").value; | |
}, false); | |
var urlParam = window.location.href.split("?show=")[1]; | |
if (urlParam !== undefined) { | |
search(urlParam); | |
} else { | |
search("stargate"); | |
} | |
function search(query) { | |
$("#results").html(""); | |
document.getElementById('results').style.height = '100%'; | |
fetch("https://api.tvmaze.com/search/shows?q=" + query) | |
.then(function (response) { | |
return response.json(); | |
}) | |
.then(function (myJson) { | |
console.log(myJson); | |
for (var i in myJson) { | |
if (i != "result" && name != "name") { | |
var status = | |
'<br />Status: ' + myJson[i].show.status; | |
if (myJson[i].show.status === "Running") { | |
var dat = (new Date(myJson[i].show.schedule.days[0] + ", 2019, " + myJson[i].show.schedule.time + " UTC+7")).toLocaleString() | |
.split(", ")[1].substr(0,5); | |
status += "<br /> Next episode on " + myJson[i].show.schedule.days[0] + " at " + dat; | |
} | |
var html = '<div class="row"><div class="col-4"><img src="' + | |
myJson[i].show.image.medium.replace("http", "https") + | |
'"></img></div><div class="col-6"><a href="' + | |
myJson[i].show.url + | |
'" target="_blank">' + | |
myJson[i].show.name + | |
' [' + | |
myJson[i].show.rating.average + | |
'/10]</a><br />Premiered: ' + | |
myJson[i].show.premiered + | |
status + '<br />Summary: ' + | |
myJson[i].show.summary.substr(0, 250) + | |
'<a href="' + | |
myJson[i].show.url + | |
'" target="_blank">... more</a>' + | |
'</div></div>'; | |
$("#results").append(html); | |
} | |
} | |
}); | |
} | |
</script> | |
</footer> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body {padding-top:50px;} | |
td { | |
border-top: none !important; | |
} | |
.row { | |
padding-bottom: 10px; | |
} | |
.box { | |
border-radius: 3px; | |
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12); | |
padding: 10px 15px; | |
text-align: left; | |
display: block; | |
margin-top: 60px; | |
} | |
.box-icon { | |
background-color: #57a544; | |
border-radius: 50%; | |
display: table; | |
height: 100px; | |
margin: 0 auto; | |
width: 100px; | |
margin-top: -61px; | |
} | |
.box-icon span { | |
color: #fff; | |
display: table-cell; | |
text-align: center; | |
vertical-align: middle; | |
} | |
.info { | |
} | |
.info h4 { | |
font-size: 26px; | |
letter-spacing: 2px; | |
text-transform: uppercase; | |
} | |
.info > p { | |
color: #717171; | |
font-size: 16px; | |
padding-top: 10px; | |
} | |
#search { | |
background-color: #03a9f4; | |
border-radius: 2px; | |
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12); | |
color: #fff; | |
transition: all 0.5s ease 0s; | |
margin-top: 1em; | |
} | |
#search a:hover { | |
background-color: #0288d1; | |
box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.16), 0 2px 5px 0 rgba(0, 0, 0, 0.12); | |
color: #fff; | |
transition: all 0.5s ease 0s; | |
} | |
input { | |
width: 100%; | |
} | |
html { | |
width: 100%; | |
height: 100%; | |
} | |
.content { | |
font-family: 'VT323', monospace; | |
font-size: 30px; | |
} | |
#search { | |
color: #fff !important; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment