Sfoglia il codice sorgente

Merge pull request #84 from visuddhinanda/master

课程内容多的时候显示滚动条
visuddhinanda 5 anni fa
parent
commit
8c17f683b3
4 ha cambiato i file con 212 aggiunte e 26 eliminazioni
  1. 14 10
      app/calendar/index1.html
  2. 18 16
      app/course/course.php
  3. 167 0
      app/course/lesson.php
  4. 13 0
      app/course/lesson_get.php

+ 14 - 10
app/calendar/index1.html

@@ -474,6 +474,7 @@
         if (curr_position) {
         if (curr_position) {
             g_coordinate_this.AT = curr_position.split("#")[0];
             g_coordinate_this.AT = curr_position.split("#")[0];
             g_coordinate_this.LT = curr_position.split("#")[1];
             g_coordinate_this.LT = curr_position.split("#")[1];
+            g_coordinate_this.height = curr_position.split("#")[2];
             if (g_coordinate_this.AT >= 0) {
             if (g_coordinate_this.AT >= 0) {
                 var AT_string = angle_trans(g_coordinate_this.AT) + "N";
                 var AT_string = angle_trans(g_coordinate_this.AT) + "N";
             }
             }
@@ -486,7 +487,8 @@
             else {
             else {
                 var LT_string = angle_trans(g_coordinate_this.LT) + "W";
                 var LT_string = angle_trans(g_coordinate_this.LT) + "W";
             }
             }
-            $("#selected_position_string").html(AT_string + " " + LT_string);
+            let height_string = g_coordinate_this.height + "M"
+            $("#selected_position_string").html(AT_string + " " + LT_string + " " + height_string);
 
 
         }
         }
         else {
         else {
@@ -522,7 +524,7 @@
             console.log(full_list)//输出到控制台
             console.log(full_list)//输出到控制台
             lunar_phase_list_refresh()
             lunar_phase_list_refresh()
 
 
-            sun_times = SunCalc.getTimes(today, g_coordinate_this.AT, g_coordinate_this.LT, 0);
+            sun_times = SunCalc.getTimes(today, g_coordinate_this.AT, g_coordinate_this.LT, g_coordinate_this.height / 1000);
             sun_position = SunCalc.getPosition(today, g_coordinate_this.AT, g_coordinate_this.LT);
             sun_position = SunCalc.getPosition(today, g_coordinate_this.AT, g_coordinate_this.LT);
             moon_position = SunCalc.getMoonPosition(today, g_coordinate_this.AT, g_coordinate_this.LT);
             moon_position = SunCalc.getMoonPosition(today, g_coordinate_this.AT, g_coordinate_this.LT);
             moon_Illumination = SunCalc.getMoonIllumination(today)
             moon_Illumination = SunCalc.getMoonIllumination(today)
@@ -558,7 +560,7 @@
                 output += "<td class='table_column'>"
                 output += "<td class='table_column'>"
                 output += i_month + 1
                 output += i_month + 1
                 output += "</td>"
                 output += "</td>"
-                if (SunCalc.getTimes(last_list[i_month], g_coordinate_this.AT, g_coordinate_this.LT, 0).dawn - last_list[i_month] <= 0) {//如果在破晓之后,不修正
+                if (SunCalc.getTimes(last_list[i_month], g_coordinate_this.AT, g_coordinate_this.LT, g_coordinate_this.height / 1000).dawn - last_list[i_month] <= 0) {//如果在破晓之后,不修正
                     output += "<td class='table_column' title='" + last_list[i_month].toLocaleTimeString() + "'>"
                     output += "<td class='table_column' title='" + last_list[i_month].toLocaleTimeString() + "'>"
                     output += last_list[i_month].toLocaleDateString()
                     output += last_list[i_month].toLocaleDateString()
                     output += "</td>"
                     output += "</td>"
@@ -570,7 +572,7 @@
                     output += temp_date.toLocaleDateString()
                     output += temp_date.toLocaleDateString()
                     output += "</td>"
                     output += "</td>"
                 }
                 }
-                if (SunCalc.getTimes(new_list[i_month], g_coordinate_this.AT, g_coordinate_this.LT, 0).dawn - new_list[i_month] <= 0) {//如果在破晓之后,不修正
+                if (SunCalc.getTimes(new_list[i_month], g_coordinate_this.AT, g_coordinate_this.LT, g_coordinate_this.height / 1000).dawn - new_list[i_month] <= 0) {//如果在破晓之后,不修正
                     output += "<td class='table_column' title='" + new_list[i_month].toLocaleTimeString() + "'>"
                     output += "<td class='table_column' title='" + new_list[i_month].toLocaleTimeString() + "'>"
                     output += new_list[i_month].toLocaleDateString()
                     output += new_list[i_month].toLocaleDateString()
                     output += "</td>"
                     output += "</td>"
@@ -582,7 +584,7 @@
                     output += temp_date.toLocaleDateString()
                     output += temp_date.toLocaleDateString()
                     output += "</td>"
                     output += "</td>"
                 }
                 }
-                if (SunCalc.getTimes(first_list[i_month], g_coordinate_this.AT, g_coordinate_this.LT, 0).dawn - first_list[i_month] <= 0) {//如果在破晓之后,不修正
+                if (SunCalc.getTimes(first_list[i_month], g_coordinate_this.AT, g_coordinate_this.LT, g_coordinate_this.height / 1000).dawn - first_list[i_month] <= 0) {//如果在破晓之后,不修正
                     output += "<td class='table_column' title='" + first_list[i_month].toLocaleTimeString() + "'>"
                     output += "<td class='table_column' title='" + first_list[i_month].toLocaleTimeString() + "'>"
                     output += first_list[i_month].toLocaleDateString()
                     output += first_list[i_month].toLocaleDateString()
                     output += "</td>"
                     output += "</td>"
@@ -594,7 +596,7 @@
                     output += temp_date.toLocaleDateString()
                     output += temp_date.toLocaleDateString()
                     output += "</td>"
                     output += "</td>"
                 }
                 }
-                if (SunCalc.getTimes(full_list[i_month], g_coordinate_this.AT, g_coordinate_this.LT, 0).dawn - full_list[i_month] <= 0) {//如果在破晓之后,不修正
+                if (SunCalc.getTimes(full_list[i_month], g_coordinate_this.AT, g_coordinate_this.LT, g_coordinate_this.height / 1000).dawn - full_list[i_month] <= 0) {//如果在破晓之后,不修正
                     output += "<td class='table_column' title='" + full_list[i_month].toLocaleTimeString() + "'>"
                     output += "<td class='table_column' title='" + full_list[i_month].toLocaleTimeString() + "'>"
                     output += full_list[i_month].toLocaleDateString()
                     output += full_list[i_month].toLocaleDateString()
                     output += "</td>"
                     output += "</td>"
@@ -620,9 +622,10 @@
         }
         }
         function showPosition(position) {
         function showPosition(position) {
             alert("get cordinate success");
             alert("get cordinate success");
-            g_coordinate_this.AT = position.coords.latitude;
-            g_coordinate_this.LT = position.coords.longitude;
-            let position_string = g_coordinate_this.AT + "#" + g_coordinate_this.LT
+            g_coordinate_this.AT = position.coords.latitude;//纬度
+            g_coordinate_this.LT = position.coords.longitude;//经度
+            g_coordinate_this.height = position.coords.altitude;//海拔高度
+            let position_string = g_coordinate_this.AT + "#" + g_coordinate_this.LT + "#" + g_coordinate_this.height
             localStorage.setItem("local_position", position_string);
             localStorage.setItem("local_position", position_string);
 
 
             if (g_coordinate_this.AT >= 0) {
             if (g_coordinate_this.AT >= 0) {
@@ -637,7 +640,8 @@
             else {
             else {
                 var LT_string = angle_trans(g_coordinate_this.LT) + "W";
                 var LT_string = angle_trans(g_coordinate_this.LT) + "W";
             }
             }
-            $("#selected_position_string").html(AT_string + " " + LT_string);
+            let height_string = g_coordinate_this.height + "KM"
+            $("#selected_position_string").html(AT_string + " " + LT_string + " " + height_string);
 
 
         }
         }
         function showError(error) {
         function showError(error) {

+ 18 - 16
app/course/course.php

@@ -64,12 +64,7 @@ echo '<div class="card" style="margin:1em;">';
 echo '</div>';
 echo '</div>';
 
 
 echo "<div id='lesson_list'>";
 echo "<div id='lesson_list'>";
-//课程视频
-$query = "select * from lesson where course_id = '{$_GET["id"]}'   limit 0,100";
-$fAllLesson = PDO_FetchAll($query);
-foreach($fAllLesson as $row){
 
 
-}
 
 
 echo "</div>";
 echo "</div>";
 
 
@@ -89,9 +84,10 @@ echo "</div>";
     for(const lesson of  arrLesson){
     for(const lesson of  arrLesson){
         html+= '<div class="card" style="display:flex;margin:1em;padding:10px;">';
         html+= '<div class="card" style="display:flex;margin:1em;padding:10px;">';
 
 
-        html+= '<div style="flex:7;max-width: 80%;">';
+        html+= '<div style="flex:7;">';
         html+= '<div class="pd-10">';
         html+= '<div class="pd-10">';
-        html+= '<div class="title" style="padding-bottom:5px;font-size:100%;font-weight:600;">'+lesson["title"]+'</div>';
+        html+= '<div class="title" style="padding-bottom:5px;font-size:100%;font-weight:600;"><a href="../course/lesson.php?id='+lesson["id"]+'">'+lesson["title"]+'</a></div>';
+        html += '<div style="overflow-y: scroll;max-height: 20em;">';
         let summary = "";
         let summary = "";
         try{
         try{
             summary = marked(lesson["summary"]);
             summary = marked(lesson["summary"]);
@@ -125,22 +121,28 @@ echo "</div>";
         }
         }
         html+= '<div class="summary"  style="padding-bottom:5px;">'+attachment+'</div>';
         html+= '<div class="summary"  style="padding-bottom:5px;">'+attachment+'</div>';
         html+= '</div>'; 
         html+= '</div>'; 
+        html+= '</div>'; 
         html+= '</div>';
         html+= '</div>';
 
 
         html+= '<div style="flex:3;max-width:15em;">';
         html+= '<div style="flex:3;max-width:15em;">';
-        /*
-        html+= '<div >开始:'+date("Y/m/d h:ia",lesson["date"]/1000) +'</div>';
+        let d = new Date();
+        d.setTime(lesson["date"]);
+        let strData = d.toLocaleDateString();
+        let strTime = d.toLocaleTimeString();
+         html+= '<div >开始日期:'+strData +'</div>';
+         html+= '<div >开始时间:'+strTime +'</div>';
         let dt = lesson["duration"]/60;
         let dt = lesson["duration"]/60;
-        let dt sdt = "";
+        let sdt = "";
         if(dt>59){
         if(dt>59){
-            sdt .= floor(dt/60)."小时";
+            sdt += Math.floor(dt/60)+"小时";
         }
         }
-        let m = (dt %60);
+        let m = (dt % 60);
         if(m>0){
         if(m>0){
-            sdt .=(dt %60)."分钟";
+            sdt +=(dt % 60)+"分钟";
         }
         }
-        html+= "<div >持续:{$sdt}</div>";
-        let now = mTime();
+        html+= "<div >持续时间:"+sdt+"</div>";        
+        let now = new Date(); 
+
         let lesson_time="";
         let lesson_time="";
         if(now<lesson["date"]){
         if(now<lesson["date"]){
             lesson_time = "尚未开始";
             lesson_time = "尚未开始";
@@ -152,7 +154,7 @@ echo "</div>";
             lesson_time = "已经结束";
             lesson_time = "已经结束";
         }
         }
         html+= '<div ><span class="lesson_status">'+lesson_time+'</span></div>';
         html+= '<div ><span class="lesson_status">'+lesson_time+'</span></div>';
-*/        
+      
         html+= '</div>';
         html+= '</div>';
 
 
         html+= '</div>';
         html+= '</div>';

+ 167 - 0
app/course/lesson.php

@@ -0,0 +1,167 @@
+<?PHP
+include "../pcdl/html_head.php";
+?>
+<body>
+
+<?php
+    require_once("../pcdl/head_bar.php");
+?>
+
+<style>
+    #main_video_win iframe{
+        width:100%;
+        height:100%;
+    }
+</style>
+<?php
+//
+
+require_once "../path.php";
+require_once "../public/_pdo.php";
+require_once '../ucenter/function.php';
+require_once '../public/function.php';
+
+global $PDO;
+PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+$query = "select * from lesson where id = '{$_GET["id"]}'   limit 0,1";
+$Fetch = PDO_FetchAll($query);
+if(count($Fetch)==0)
+{
+    echo "无法找到此课程。可能该课程已经被拥有者删除。";
+    exit;
+}
+$lesson_info = $Fetch[0];
+
+$query = "select * from course where id = '{$lesson_info["course_id"]}'   limit 0,1";
+$Fetch = PDO_FetchAll($query);
+if(count($Fetch)==0)
+{
+    echo "无法找到此课程。可能该课程已经被拥有者删除。";
+    exit;
+}
+$course_info = $Fetch[0];
+
+echo "<div id='course_head_bar' style='background-color:var(--tool-bg-color1);padding:1em 10px 10px 10px;'>";
+echo "<div class='index_inner '>";
+echo "<div style='font-size:140%'>";
+echo "<a href='../uhome/course.php?userid={$course_info["teacher"]}'>";
+echo ucenter_getA($course_info["teacher"]);
+echo "</a>";
+echo " > ";
+echo "<a href='../course/course.php?id={$course_info["id"]}'>";
+echo $course_info["title"];
+echo "</a>";
+echo " > ";
+echo $lesson_info["title"];
+echo "</div>";
+echo '<div class="summary"  style="padding-bottom:5px;">'.$course_info["subtitle"].'</div>';
+echo '<div class="summary"  style=""><button>关注</button><button>报名</button><button>分享</button></div>';
+echo "</div>";
+echo '</div>';
+
+echo "<div  class='index_inner'>";
+
+
+
+echo "<div id='lesson_list'>";
+
+echo "</div>";
+
+?>
+</div>
+<script src="../public/js/marked.js"></script>
+<script>
+    $("#main_video_win").height($("#main_video_win").width()*9/16);
+
+    $.get("../course/lesson_get.php",
+  {
+    id:"<?php echo $_GET["id"]; ?>"
+  },
+  function(data,status){
+      let arrLesson = JSON.parse(data);
+      let html="";
+    for(const lesson of  arrLesson){
+        html+= '<div class="card" style="display:flex;margin:1em;padding:10px;">';
+
+        html+= '<div style="flex:7;">';
+        html+= '<div class="pd-10">';
+        html+= '<div class="title" style="padding-bottom:5px;font-size:100%;font-weight:600;">'+lesson["title"]+'</div>';
+        html += '<div style="">';
+        let summary = "";
+        try{
+            summary = marked(lesson["summary"]);
+        }
+        catch{
+
+        }
+        html+= '<div class="summary"  style="padding-bottom:5px;">'+summary+'</div>';
+        let live = "";
+        try{
+            live = marked(lesson["live"]);
+        }
+        catch{
+
+        }
+        html+= '<div class="summary"  style="padding-bottom:5px;">'+live+'</div>';
+        let replay = "";
+        try{
+            replay = marked(lesson["replay"]);
+        }
+        catch{
+
+        }
+        html+= '<div class="summary"  style="padding-bottom:5px;">'+replay+'</div>';
+        let attachment = "";
+        try{
+            attachment = marked(lesson["attachment"]);
+        }
+        catch{
+
+        }
+        html+= '<div class="summary"  style="padding-bottom:5px;">'+attachment+'</div>';
+        html+= '</div>'; 
+        html+= '</div>'; 
+        html+= '</div>';
+
+        html+= '<div style="flex:3;max-width:15em;">';
+        let d = new Date();
+        d.setTime(lesson["date"]);
+        let strData = d.toLocaleDateString();
+        let strTime = d.toLocaleTimeString();
+         html+= '<div >开始日期:'+strData +'</div>';
+         html+= '<div >开始时间:'+strTime +'</div>';
+        let dt = lesson["duration"]/60;
+        let sdt = "";
+        if(dt>59){
+            sdt += Math.floor(dt/60)+"小时";
+        }
+        let m = (dt % 60);
+        if(m>0){
+            sdt +=(dt % 60)+"分钟";
+        }
+        html+= "<div >持续时间:"+sdt+"</div>";        
+        let now = new Date(); 
+
+        let lesson_time="";
+        if(now<lesson["date"]){
+            lesson_time = "尚未开始";
+        }
+        else if(now>lesson["date"] && now<(lesson["date"]+dt*1000)){
+            lesson_time = "正在进行";
+        }
+        else{
+            lesson_time = "已经结束";
+        }
+        html+= '<div ><span class="lesson_status">'+lesson_time+'</span></div>';
+      
+        html+= '</div>';
+
+        html+= '</div>';
+
+    }
+    $("#lesson_list").html(html);
+  });
+</script>
+<?php
+include "../pcdl/html_foot.php";
+?>

+ 13 - 0
app/course/lesson_get.php

@@ -0,0 +1,13 @@
+<?php
+//
+
+require_once "../path.php";
+require_once "../public/_pdo.php";
+
+global $PDO;
+PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+$query = "select * from lesson where id = '{$_GET["id"]}'   limit 0,1";
+$fAllLesson = PDO_FetchAll($query);
+echo json_encode($fAllLesson, JSON_UNESCAPED_UNICODE);
+
+?>