Pārlūkot izejas kodu

Merge branch 'Dev' of http://10.1.1.202:3030/steve07s/BIM-Monitor into Dev

manto07m 3 gadi atpakaļ
vecāks
revīzija
d65b905249
2 mainītis faili ar 114 papildinājumiem un 6 dzēšanām
  1. 52 0
      script/php/video/getDir.php
  2. 62 6
      video-list.php

+ 52 - 0
script/php/video/getDir.php

@@ -0,0 +1,52 @@
+<?php
+if(isset($_POST["dir"])){
+    include("../connectSQL_Component.php");
+
+    $tables = [];
+    $file_tables = [];
+    $dir_tables = [];
+    $dir = $_POST["dir"];
+
+    $sql = "SELECT [title], [file_path] FROM [BIMComponents].[dbo].[Video_Table] WHERE dir_name = '".$dir."'";
+    $fetchResult = sqlsrv_query($conn, $sql);
+    while ($row = sqlsrv_fetch_array($fetchResult)) {
+        array_push($file_tables,$row);
+    }
+
+    $sql = "SELECT [dir_name] FROM [BIMComponents].[dbo].[Video_Node] WHERE parent = '".$dir."'";
+    $fetchResult = sqlsrv_query($conn, $sql);
+    while ($row = sqlsrv_fetch_array($fetchResult)) {
+        array_push($dir_tables,$row);
+    }
+
+    echo json_encode($dir_tables);
+
+    sqlsrv_close($conn);
+}
+
+/*
+    foreach($tables as $table){
+
+            $rootpath = $rootpath."/".$table["dir_name"];
+            $sql = "IF EXISTS(SELECT * FROM [BIMComponents].[dbo].[Video_Table] WHERE dir_name = '".$table["dir_name"]."')
+            BEGIN
+                SELECT * FROM [BIMComponents].[dbo].[Video_Table] WHERE dir_name = '".$table["dir_name"]."'
+            END
+            ELSE
+            BEGIN
+                SELECT * FROM [BIMComponents].[dbo].[Video_Node] WHERE parent = '".$table["dir_name"]."'
+            END";
+            $fetchResult = sqlsrv_query($conn, $sql);
+            while ($row = sqlsrv_fetch_array($fetchResult)) {
+                if(isset($row["file_path"])){
+                    echo "video listing"."<br>";
+                    echo json_encode($row["file_path"],JSON_UNESCAPED_UNICODE)."<br>";
+                }else{
+                    echo "<p>";
+                    echo "<a href='#'><i class='fa fa-folder'></i>" . $row["title"] . "</a>";
+                    echo "</p>";
+                }
+            }
+    }
+*/
+    

+ 62 - 6
video-list.php

@@ -199,13 +199,12 @@ if (!isset($_SESSION['loggedin'])) {
 				<div class="row">
 					<div class="col-md-6">
 						<section class="panel">
-							<div class="panel-body">
-								<p><a href="#" onclick="getVideo('1','模型基本操作瀏覽');"><i class="fa fa-video-camera"></i>1-模型基本操作瀏覽</a></p>
-								<p><a href="#" onclick="getVideo('2','建築模型基礎課程');"><i class="fa fa-video-camera"></i>2-建築模型基礎課程</a></p>
-								<p><a href="#" onclick="getVideo('3','建築模型進階課程');"><i class="fa fa-video-camera"></i>3-建築模型進階課程</a></p>
-								<p><a href="#" onclick="getVideo('4','建築模型敷地課程');"><i class="fa fa-video-camera"></i>4-建築模型敷地課程</a></p>
-								<img class="thumbnails" id="myImg" src="./assets/videos/教育訓練/108年Revit上課影音檔/1-模型基本操作瀏覽.jpg" />
+							<button type="button" onclick="goBack()">回上層</button>
+							<div class="panel-body" id="video-list">
+
 							</div>
+
+							<img class="thumbnails" id="myImg" src="./assets/videos/教育訓練/108年Revit上課影音檔/1-模型基本操作瀏覽.jpg" />
 						</section>
 					</div>
 
@@ -220,6 +219,7 @@ if (!isset($_SESSION['loggedin'])) {
 	</div>
 	<script>
 		$(document).ready(function() {
+
 			$("#myImg").hover(
 				function() {
 					$(this).attr("src", "./assets/videos/教育訓練/108年Revit上課影音檔/1-模型基本操作瀏覽.gif");
@@ -228,8 +228,49 @@ if (!isset($_SESSION['loggedin'])) {
 					$(this).attr("src", "./assets/videos/教育訓練/108年Revit上課影音檔/1-模型基本操作瀏覽.jpg");
 				}
 			);
+			initList(".");
+
 		});
 
+		var dirList = [];
+		var count = 0;
+
+		function initList(dir) {
+
+			removeChild();
+
+			$.ajax({
+				url: "./script/php/video/getDir.php",
+				type: "POST",
+				data: {
+					dir: dir,
+				},
+				dataType: "json"
+			}).done(function(data) {
+
+				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);
+
+				}
+
+			}).error(function(error) {
+				console.log(error);
+			});
+		}
+
 		function getVideo(id, name) {
 			$.redirect('./video-play.php', {
 				'id': id,
@@ -237,6 +278,21 @@ if (!isset($_SESSION['loggedin'])) {
 
 			});
 		}
+
+		function removeChild() {
+			var parent = document.getElementById("video-list");
+			while (parent.firstChild) {
+				if (parent.firstChild.innerText != undefined) {
+					//dirList[count++] = [parent.firstChild.innerText];
+				}
+				parent.removeChild(parent.firstChild);
+			}
+		}
+
+		function goBack() {
+			console.log(dirList, count);
+
+		}
 	</script>
 	<!-- Vendor -->
 	<script src="assets/vendor/jquery-browser-mobile/jquery.browser.mobile.js"></script>