video-list.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. $(document).ready(function () {
  2. initList(".");
  3. });
  4. function initList(dir) {
  5. $.ajax({
  6. url: "./script/php/video/getDir.php",
  7. type: "POST",
  8. data: {
  9. dir: dir,
  10. },
  11. dataType: "json"
  12. }).done(function (result) {
  13. $("#video-list").empty();
  14. dir_names = result["dir_names"];
  15. file_tables = result["file_tables"];
  16. if (result["parent"] != undefined)
  17. parent = result["parent"];
  18. //directory
  19. for (i = 0; i < dir_names.length; i++) {
  20. $("#video-list").append('<div class="col-md-3">' +
  21. '<section class="panel">' +
  22. "<a href='#' onclick='initList(\"" + dir_names[i]["dir_name"] + "\")'>" +
  23. '<img class="active" src="./assets/images/folder-icon.png">' +
  24. '</a>' +
  25. '<div class="panel-body" id="">' +
  26. "<p><i class='fa fa-folder'></i><a href='#' onclick='initList(\"" + dir_names[i]["dir_name"] + "\")'>" + dir_names[i]["dir_name"] + "</a></p>" +
  27. '</div>' +
  28. '</section>' +
  29. '</div>');
  30. }
  31. //video
  32. for (j = 0; j < file_tables.length; j++) {
  33. if (file_tables[j]["file_path"].includes(".m3u8")) {
  34. $("#video-list").append('<div class="col-md-3">' +
  35. '<section class="panel">' +
  36. "<a href='#' onclick='getVideo(" + file_tables[j]["id"] + ")'>" +
  37. '<img class="static" src="' + file_tables[j]["file_path"].replace("m3u8", "jpg") + '">' +
  38. '<img class="active" src="' + file_tables[j]["file_path"].replace("m3u8", "gif") +
  39. '">' +
  40. '</a>' +
  41. '<div class="panel-body" id="">' +
  42. "<p><i class='fa fa-video-camera'></i><a href='#' onclick='getVideo(" + file_tables[j]["title"].split("-")[0] + ")'>" + file_tables[j]["title"] + "</a></p>" +
  43. '</div>' +
  44. '</section>' +
  45. '</div>');
  46. }
  47. }
  48. }).error(function (error) {
  49. console.log(error);
  50. });
  51. }
  52. function getVideo(id) {
  53. $.redirect('./video-play.php', {
  54. 'id': id
  55. });
  56. }