Movie search #OMDB
via omdb api
HTML
<!-- Voir the movie database https://www.themoviedb.org/documentation/api?language=fr -->
<!-- Bootstrap -->
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet">
<!-- Recherche de film -->
<form class="form-inline">
<input type="text" name="moviesearch" class="movie-search" placeholder="Rechercher un film" /><span class="help-inline">
</span>
</form>
<div id="searchresults"></div>
CSS
/* Voir the movie database https://www.themoviedb.org/documentation/api?language=fr */
/*
API OMDB http://www.omdbapi.com/
JSON Formater http://jsonformatter.curiousconcept.com/
JQUERY http://api.jquery.com/jQuery.getJSON/
MySQL PHP Code Generator : http://www.turningturnip.co.uk/free-mysql-php-generator/
*/
body {
margin-top: 20px !important;
}
.small-prints {
font-size: 12px;
line-height: 14px;
}
.progress {
width: 70px;
margin-bottom: 0px !important;
}
.label {
font-size: 10px !important;
line-height:12px !important;
padding: 2px 4px !important;
margin-top: 2px;
}
JavaScript
// Voir the movie database https://www.themoviedb.org/documentation/api?language=fr
// Champ de Recherche
$(".movie-search").keyup(function () {
var searchvalue = $(".movie-search").val();
$('#searchresults').empty();
SearchMovie(searchvalue);
});
// résultats de recherche JSON
// http://www.omdbapi.com/?s=hobbit
function SearchMovie(themovie) {
$.ajax({
type: 'POST',
url: 'http://www.omdbapi.com/?s=' + themovie,
dataType: 'jsonp',
success: function (data) {
$.each(data.Search, function (i, search) {
var content = '<p><a href="http://www.imdb.com/title/' + search.imdbID + '" target="_blank">' + search.Title + ' - ' + search.Year + ' - ' + search.imdbID + ' - ' + search.Type + '</a></p>';
$(content).appendTo("#searchresults");
});
}
});
}
/*
$.ajax({
type: 'POST',
url: 'http://www.omdbapi.com/?s=' + 'down',
dataType: 'jsonp',
success: function (data) {
console.log(data.Search);
var result = '<p>' + data.1.Title + '</p>';
$('#searchresults').append(result);
$.each(data.Search, function(i,search){
content = '<p>' + search.Title + '</p>';
content += '<p>' + search.Year + '</p>';
content += '<br/>';
$(content).appendTo("#searchresults");
});
}
});
*/