Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SEI24 Ray #175

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div class="browse">
<div id="search-form">
<input type="search" placeholder="Search for a title..." id="show-search">
<button>submit</button>
<button id="submit">submit</button>
</div>

<select id="show-select">
Expand Down
60 changes: 60 additions & 0 deletions js/tv_browser.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,62 @@
// API Docs at:
// http://www.tvmaze.com/api

document.querySelector('button').addEventListener('click', search)



function search() {
let input = document.getElementById('show-search');
var url = input.value;

function getData() {
return get("http://api.tvmaze.com/search/shows?q=" + url)
.then(response => {
console.log(response)


output = JSON.parse(response);
output.forEach(progData => {
option = document.createElement('option');
option.innerHTML = progData.show.name;
document.getElementById('show-select').appendChild(option);
})




})
.catch(response => {
alert("wake up your idea")
})
}

getData();

}

function get(url) {
return new Promise((resolve, reject) => {
var request = new XMLHttpRequest()

request.addEventListener("load", function () {
resolve(this.response)
});

request.addEventListener("error", function () {
reject(this.error);
})

request.open("GET", url);

request.send();

})
}