diff --git a/api.php b/api.php index a542715b11bee0cb58e3cce7ad05067de2cd9818..7963532771815275620c097973e1e3d71c3aa37a 100644 --- a/api.php +++ b/api.php @@ -196,6 +196,23 @@ if ($_GET['get'] == 'latest' && $_GET['type'] == 'shows') { die; } +if ($_GET['get'] == 'latest' && $_GET['type'] == 'movies') { + $cpdb = new PDO('sqlite:'.$cpPath.'/couchpotato.db'); + $cpdb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $movies = $cpdb->query("SELECT lt.title, l.year FROM library AS l + JOIN librarytitle AS lt ON l.id=lt.libraries_id + JOIN movie AS m on l.id=m.library_id + JOIN status AS s ON m.status_id=s.id + WHERE m.status_id = 3 AND `default` = 1 + ORDER BY m.last_edit DESC LIMIT 10;"); + $output = array(); + foreach ($movies as $movie) { + array_push($output, array("movie" => $movie['title'].' ('.$movie['year'].')')); + } + echo json_encode($output); + die; +} + function cleanName($name, $strict = true) { if($strict == true) diff --git a/css/mediarack.css b/css/mediarack.css index 76de92738d0e6ef4a3719defbb3a55de57586fdc..b32c49007359d2ab752074e24462fc41d09cfd2a 100644 --- a/css/mediarack.css +++ b/css/mediarack.css @@ -73,15 +73,19 @@ div#shows, div#movies { display: none; } -ul#latestShows li { +ul#latestShows li, +ul#latestMovies li { text-align: center; } div.epLabel { + max-width: 200px; margin-top: 5px; font-size: 8pt; font-weight: bold; line-height: 15px; + text-align: center; + } .jcarousel-wrapper { diff --git a/index.php b/index.php index 733facc424ccc39dd2228a881bbcf333c5f1f5bd..62214551391b2605df7f2d92091d1b682c49a055 100644 --- a/index.php +++ b/index.php @@ -56,13 +56,34 @@ <div class="container"> - <div class="content jumbotron" id="home"> - <div class="jcarousel-wrapper"> - <div class="jcarousel"> - <ul id="latestShows"></ul> + <div class="content" id="home"> + <div class="panel panel-default"> + <div class="panel-heading"> + <h3 class="panel-title">Newest TV Show Episodes</h3> + </div> + <div class="panel-body"> + <div class="jcarousel-wrapper"> + <div class="jcarousel jcShows"> + <ul id="latestShows"></ul> + </div> + <a href="#" class="jcarousel-control-prev jcShows">‹</a> + <a href="#" class="jcarousel-control-next jcShows">›</a> + </div> + </div> + </div> + <div class="panel panel-default"> + <div class="panel-heading"> + <h3 class="panel-title">Newest Movies</h3> + </div> + <div class="panel-body"> + <div class="jcarousel-wrapper"> + <div class="jcarousel jcMovies"> + <ul id="latestMovies"></ul> + </div> + <a href="#" class="jcarousel-control-prev jcMovies">‹</a> + <a href="#" class="jcarousel-control-next jcMovies">›</a> + </div> </div> - <a href="#" class="jcarousel-control-prev">‹</a> - <a href="#" class="jcarousel-control-next">›</a> </div> </div> diff --git a/js/mediarack.js b/js/mediarack.js index 58cd0ac45e35f16b758513c0657dd8f28e7fc9fc..4c4e9928f2826e4c484a32449abff02abbe49ce1 100644 --- a/js/mediarack.js +++ b/js/mediarack.js @@ -8,7 +8,8 @@ var loadMovies = true; $(document).ready(function() { - getLatest(); + getLatest('Shows'); + getLatest('Movies'); getShows(); getMovies(); @@ -36,17 +37,21 @@ $(document).ready(function() { }); -function getLatest() { +function getLatest(type) { $.getJSON('api.php', { - 'type': 'shows', + 'type': type.toLowerCase(), 'get': 'latest' }, function(data) { $.each(data, function (key, ep) { - var ulLatestContainer = $("#latestShows"); - var liLatestItem = $('<li><img src="api.php?get=poster&show='+escape(ep.show)+'" /><div class="epLabel">'+ep.show+'<br />'+ep.episode+'<br />'+ep.name+'<br />'+ep.airdate+'</div></li>'); + var ulLatestContainer = $("#latest"+type); + if(type == 'Shows') { + var liLatestItem = $('<li><img src="api.php?get=poster&show='+escape(ep.show)+'" /><div class="epLabel">'+ep.show+'<br />'+ep.episode+'<br />'+ep.name+'<br />'+ep.airdate+'</div></li>'); + }else{ + var liLatestItem = $('<li><img src="api.php?get=poster&movie='+escape(ep.movie)+'" /><div class="epLabel">'+ep.movie+'</div></li>'); + } ulLatestContainer.append(liLatestItem); }); - $('.jcarousel') + $('.jcarousel.jc'+type) .on('jcarousel:create jcarousel:reload', function() { var element = $(this), width = element.innerWidth(); @@ -65,7 +70,7 @@ function getLatest() { .jcarousel({ wrap: 'both' }); - $('.jcarousel-control-prev') + $('.jcarousel-control-prev.jc'+type) .on('jcarouselcontrol:active', function() { $(this).removeClass('inactive'); }) @@ -76,7 +81,7 @@ function getLatest() { target: '-=1' }); - $('.jcarousel-control-next') + $('.jcarousel-control-next.jc'+type) .on('jcarouselcontrol:active', function() { $(this).removeClass('inactive'); })