فهرست منبع

change vid from DOM to jQuery

nate 3 سال پیش
والد
کامیت
6b715a47e2
1فایلهای تغییر یافته به همراه13 افزوده شده و 47 حذف شده
  1. 13 47
      video-list.php

+ 13 - 47
video-list.php

@@ -232,14 +232,10 @@ if (!isset($_SESSION['loggedin'])) {
 
 		});
 
-		var dirList = [];
-		var count = 0;
 		var parent = ".";
 
 		function initList(dir) {
 
-			removeChild();
-
 			$.ajax({
 				url: "./script/php/video/getDir.php",
 				type: "POST",
@@ -248,47 +244,26 @@ if (!isset($_SESSION['loggedin'])) {
 				},
 				dataType: "json"
 			}).done(function(result) {
-				console.log(result);
+				
+				$("#video-list").empty();
+
 				data = result["dir_names"];
 				data2 = result["file_tables"];
 				if (result["parent"] != undefined)
 					parent = result["parent"];
 
-				for (j = 0; j < data.length; j++) {
-
-					var p = document.createElement("p");
-					document.getElementById("video-list").appendChild(p);
-
-					var a = document.createElement("a");
-					a.setAttribute("href", "#");
-					a.setAttribute("onclick", "initList('" + data[j]["dir_name"] + "');");
-					a.innerText = data[j]["dir_name"];
-
-					var i = document.createElement("i");
-					i.setAttribute("class", "fa fa-folder");
-
-					p.appendChild(i);
-
-					p.appendChild(a);
-
+				//directory
+				for (i = 0; i < data.length; i++) {
+					$("#video-list").append("<p id='p_dir" + i + "'></p>");
+					$("#p_dir" + i).append("<i class='fa fa-folder'></i><a href='#' onclick='initList(\"" + data[i]["dir_name"] + "\")'>" + data[i]["dir_name"] + "</a>");
 				}
-				for (j = 0; j < data2.length; j++) {
-
-					var p = document.createElement("p");
-					document.getElementById("video-list").appendChild(p);
-
-					var a = document.createElement("a");
-					a.setAttribute("href", "#");
-					//a.setAttribute("onclick", "initList('" + data2[j]["dir_name"] + "');");
-					a.innerText = data2[j]["title"];
-
-					var i = document.createElement("i");
-					i.setAttribute("class", "fa fa-video-camera");
-
-					p.appendChild(i);
-
-					p.appendChild(a);
 
+				//video
+				for (j = 0; j < data2.length; j++) {
+					if (data2[j]["file_path"].includes(".mp4")) {
+						$("#video-list").append("<p id='p_vid" + j + "'></p>");
+						$("#p_vid" + j).append("<i class='fa fa-video-camera'></i><a href='#' onclick='getVideo(" + data2[j]["title"].split("-")[0] + ",\"" + data2[j]["title"] + "\")'>" + data2[j]["title"] + "</a>");
+					}
 				}
 
 			}).error(function(error) {
@@ -300,20 +275,11 @@ if (!isset($_SESSION['loggedin'])) {
 			$.redirect('./video-play.php', {
 				'id': id,
 				'name': name,
-
 			});
 		}
 
-		function removeChild() {
-			var parent = document.getElementById("video-list");
-			while (parent.firstChild) {
-				parent.removeChild(parent.firstChild);
-			}
-		}
-
 		function goBack(parent) {
 			initList(parent);
-
 		}
 	</script>
 	<!-- Vendor -->