Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Movies</title>
- <style type="text/css">
- label{
- display: inline-block;
- width: 100px;
- margin: 5px;
- }
- input{
- width: 90px;
- margin: 5px;
- }
- .container{
- float:left;
- margin:20px;
- padding: 5px;
- }
- li:hover{
- cursor: pointer;
- }
- .content{
- width:300px;
- background:#eef;
- padding: 5px;
- border:1px gray dotted;
- font-size: 1.4em;
- }
- #list1, #list2, #fav { list-style-type: none;
- margin: 0;
- padding: 0;
- float: left;
- margin-right: 10px;
- background: #eee;
- padding: 5px; width: 143px;
- }
- #list1 li, #list2 li, #fav li {
- margin: 5px;
- padding: 5px;
- font-size: 1.2em;
- width: 120px;
- }
- .ui-widget-content {
- border: 2px solid #333333;
- background: #eeeeee !important;
- font-size: 14px !important;
- width: 300px;
- }
- #low-level #left, #low-level #right{
- float: left;
- }
- #low-level #right{
- margin-left: 20px;
- }
- </style>
- <link rel="stylesheet" href="jquery/jquery-ui.css">
- <script type="text/javascript" src="jquery/jquery.js"></script>
- <script type="text/javascript" src="jquery/jquery-ui.js"></script>
- <script type="text/javascript">
- var autoComplete = [ "The Hobbit: The Battle of the Five Armies",
- "Guardians of the Galaxy" ,
- "Interstellar" ,
- "The Hunger Games: Mockingjay - Part 1" ,
- "Birdman" ,
- "Exodus: Gods and Kings",
- "Gone Girl" ,
- "The Equalizer" ,
- "The Wolf of Wall Street" ,
- "The Hobbit: The Desolation of Smaug" ,
- "Frozen" ,
- "The Hunger Games: Catching Fire" ,
- "Snowpiercer" ,
- "American Hustle",
- "Lone Survivor",
- "Anchorman 2: The Legend Continues",
- "Begin Again",
- "Prisoners",
- "Now You See Me"
- ];
- var currentItem = null;
- function getData(title){
- $.ajax({
- url: "http://omdbapi.com/?t=" + title,
- dataType: "json",
- success: function(data){
- var title = data.Title;
- var year = data.Year;
- var rating = data.imdbRating;
- var actors = data.Actors;
- var img = data.Poster;
- var released = data.Released;
- var genre = data.Genre;
- var director = data.Director;
- if(year == 2014)
- $("#list1").append("<li class='ui-widget-content' title1='"+title+"' year='"+year+"' rating='"+rating+"' actors='"+actors+"' im='"+img+"' released='"+released+"' genre='"+genre+"' director='"+director+"'>"+title+"</li>");
- if(year == 2013)
- $("#list2").append("<li class='ui-widget-content' title1='"+title+"' year='"+year+"' rating='"+rating+"' actors='"+actors+"' im='"+img+"' released='"+released+"' genre='"+genre+"' director='"+director+"'>"+title+"</li>");
- }
- });
- }
- $(document).ready(function(){
- $("#searchTerm").autocomplete({
- source: autoComplete
- });
- $("#search").click(function(){
- var title = $("#searchTerm").val();
- getData(title);
- $("#searchTerm").val("");
- });
- $("#det").hide();
- $(document).tooltip({
- items: "#list1 li, #list2 li, #fav li",
- content: function(){
- rounded = parseInt($(this).attr("rating"));
- content = "<div class='tooltip'>";
- for(i=0;i<rounded;i++)
- content += "<img src='star1.png'>";
- for(i=rounded;i<10;i++)
- content += "<img src='star0.png'>";
- content += "</div>";
- return content;
- }
- });
- $("#fav").sortable();
- $("#list1, #list2").sortable({
- connectWith: "#fav"
- });
- $("#list1, #list2, #fav").disableSelection();
- function addAttr(){
- $("#tit").html(currentItem.attr("title1"));
- $("#im").attr("src",currentItem.attr("im"));
- $("#rel").html(currentItem.attr("released"));
- $("#gen").html(currentItem.attr("genre"));
- $("#act").html(currentItem.attr("actors"));
- $("#dir").html(currentItem.attr("director"));
- $("#rat").html(currentItem.attr("rating"));
- }
- $("#list1, #list2, #fav").on("click", "li", function(){
- currentItem = $(this);
- addAttr();
- $("#movies").hide();
- $("#det").show();
- });
- $("#next").click(function(){
- t = currentItem.next();
- if(t.length==0)
- t = currentItem.parent().find("li:first-child");
- currentItem = t;
- addAttr();
- });
- $("#prev").click(function(){
- t = currentItem.prev();
- if(t.length==0)
- t = currentItem.parent().find("li:last-child");
- currentItem=t;
- addAttr();
- });
- $("#top").click(function(){
- $("#det").hide();
- $("#movies").show();
- });
- });
- </script>
- </head>
- <body>
- <div id="movies">
- <div >
- <span id="search_interface">
- <h1> Movies </h1>
- <input type="text" id="searchTerm" />
- <button id="search">Search</button>
- </span>
- </div>
- <div class="container" id="high-level1">
- <strong>2014</strong>
- <br>
- <ul id="list1" class='droptrue'>
- </ul>
- </div>
- <div class="container" id="high-level2">
- <strong>2013</strong>
- <br>
- <ul id="list2" class='dropfalse'>
- </ul>
- </div>
- <div class="container" id="high-level3">
- <strong>Favourites</strong>
- <br>
- <ul id="fav" class="droptrue">
- </ul>
- </div>
- </div>
- <div id="det">
- <div>
- <input id="prev" value="prev" type="button"/>
- <input id="top" value="top" type="button"/>
- <input id="next" value="next" type="button"/>
- </div>
- <div id="left">
- <label>Title:</label>
- <div id="tit" class="content"></div>
- <label>Rating:</label>
- <div id="rat" class="content"></div>
- <label>Director:</label>
- <div id="dir" class="content"></div>
- <label>Actors:</label>
- <div id="act" class="content"></div>
- <label>Genre:</label>
- <div id="gen" class="content"></div>
- <label>Released:</label>
- <div id="rel" class="content"></div>
- </div>
- <div id="right">
- <img id="im">
- </div>
- </div>
- </body>
- </html>
Add Comment
Please, Sign In to add comment