Advertisement
LegoDrifter

Shabloni Movies

Dec 23rd, 2020
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. $(document).ready(function () {
  2. $("#new_movie").dialog({
  3. autoOpen: false,
  4. modal: true,
  5. buttons: {
  6. Add: function () {
  7. var movie_name = $("#movie_name").val()
  8. $("#movies").append("<li>"+movie_name+"</li>")
  9. $("#new_movie").dialog("close")
  10. }
  11. }
  12. })
  13.  
  14. $("#add").click(function () {
  15. $("#new_movie").dialog("open")
  16. })
  17.  
  18. $(document).on("click","#movies li",function () {
  19. console.log("List item clicked")
  20. var movie_name = $(this).html()
  21. console.log(movie_name)
  22. processData(movie_name)
  23. })
  24.  
  25. function processData(movie_name) {
  26. $.ajax({
  27. url: "http://omdbapi.com/?t="+movie_name+"&apikey=a6592a8d",
  28. dataType: "json",
  29. success: function (data) {
  30. console.log(data.Title)
  31. $("#title").html(data.Title)
  32. $("#rating").html(data.imdbRating)
  33. $("#director").html(data.Director)
  34. $("#actors").html(data.Actors)
  35. $("#image").attr("src", data.Poster)
  36. }
  37. })
  38. }
  39. })
  40.  
  41.  
  42.  
  43. <!DOCTYPE html>
  44. <html>
  45. <head>
  46. <meta charset="UTF-8">
  47. <title>Title</title>
  48. <link rel="stylesheet" href="jquery/jquery-ui.css">
  49. <script src="jquery/jquery.js"></script>
  50. <script src="jquery/jquery-ui.js"></script>
  51. <script src="script.js"></script>
  52. <style>
  53. </style>
  54. </head>
  55. <body>
  56. <button id="add">Додај нов филм</button>
  57.  
  58. <div id="new_movie">
  59. <h3>Внеси име на филм</h3>
  60. <input type="text" id="movie_name">
  61. </div>
  62.  
  63. <ul id="movies">
  64.  
  65. </ul>
  66. <p>Title: <span id="title"></span></p>
  67. <p>Rating: <span id="rating"></span></p>
  68. <p>Director: <span id="director"></span></p>
  69. <p>Actors: <span id="actors"></span></p>
  70. <img id="image">
  71. </body>
  72. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement