video-list.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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]["title"].split("-")[0] + ")'>" +
  37. '<img class="static" src="./assets/videos/教育訓練/108年Revit上課影音檔/' + file_tables[j]["title"] + '.jpg">' +
  38. '<img class="active" src="./assets/videos/教育訓練/108年Revit上課影音檔/' + file_tables[j]["title"] + '.gif">' +
  39. '</a>' +
  40. '<div class="panel-body" id="">' +
  41. "<p><i class='fa fa-video-camera'></i><a href='#' onclick='getVideo(" + file_tables[j]["title"].split("-")[0] + ")'>" + file_tables[j]["title"] + "</a></p>" +
  42. '</div>' +
  43. '</section>' +
  44. '</div>');
  45. }
  46. }
  47. }).error(function(error) {
  48. console.log(error);
  49. });
  50. }
  51. function getVideo(id) {
  52. $.redirect('./video-play.php', {
  53. 'id': id
  54. });
  55. }