Skip to content

Commit

Permalink
feat: 個人修課明細增加學期選項
Browse files Browse the repository at this point in the history
利用下拉式選單更改學期觀看不同學期的修課明細
  • Loading branch information
Chinlinlee committed Jan 27, 2021
1 parent 95d9046 commit 54f8641
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 60 deletions.
14 changes: 8 additions & 6 deletions routes/api/Course/controller/get_Course.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const myFunc = require("../../../My_Func");
const fetch = require('node-fetch');
const _ = require("lodash");
const { isUndefined } = require("lodash");

//const QueryParams = require("../../../models/common/httparams.js");

Expand All @@ -18,10 +19,11 @@ module.exports = async function (req, res) {
return res.send(result);
}
async function getCourse(req) {
if (req.session.Course.length > 0) {
/*if (req.session.Course.length > 0) {
return Promise.resolve(req.session.Course);
}
let courseJson = await getCourseJson(req);
}*/
let semno = req.query.semno;
let courseJson = await getCourseJson(req , semno);
if (!courseJson) {
return Promise.resolve(false);
}
Expand All @@ -30,15 +32,15 @@ async function getCourse(req) {
}

async function getCourseJson (req , semno) {
if (isUndefined(semno)) {
semno = req.session.stuInfo.lastSem;
}
let parameter = new URLSearchParams({
st_no : req.session.STNO ,
sem_no : semno ,
size : 100 ,
action : "LoadJSon"
});
if (!semno) {
parameter.delete('sem_no');
}
let courses_URL = new URL("http://system8.ntunhs.edu.tw/myNTUNHS_student/Modules/Profile/qry/Profile_qry_14.aspx");
courses_URL.search = parameter;
let reqOption = {
Expand Down
56 changes: 28 additions & 28 deletions views/atm/Course.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@

<link rel="stylesheet" href="../externals/jqueryui/jquery-ui.min.css">
<link rel="stylesheet" href="../externals/Bootstrap/bootstrap.min.css">
<link href="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/css/bootstrap4-toggle.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/css/bootstrap4-toggle.min.css"
rel="stylesheet">
<link rel="stylesheet" href="/atm/css/rwd-table.css">
<link rel="stylesheet" href="../externals/jqueryui/jquery-ui.min.css">
<link href="https://fonts.googleapis.com/css?family=Noto+Serif+TC:300,500,600,700,900&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Noto+Serif+TC:300,500,600,700,900&display=swap"
rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="/atm/css/main.css">
<link rel="stylesheet" href="/atm/css/dark.css">
Expand All @@ -24,26 +26,35 @@
<body ng-controller="CourseCtrl">
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<a class="navbar-brand" href="/Today_Schedule">今日課表</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<nav-normal-item class="navbar-nav"></nav-normal-item>
</ul>
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<span><span style="font-size:25px">🌞 </span><input type="checkbox" data-toggle="toggle" data-onstyle="info" data-offstyle="light" id="darkModeSwitch"><span style="font-size:25px"> 🌛</span></span>
<span><span style="font-size:25px">🌞 </span><input type="checkbox" data-toggle="toggle"
data-onstyle="info" data-offstyle="light" id="darkModeSwitch"><span style="font-size:25px">
🌛</span></span>
</li>
<div ng-include="'navRight.html'"></div>
</ul>
</div>
</nav>
<div class="container" style="width:100%">
<div class="form-group row">
<label class="col-2 mt-1" for="select-sem">學期:</label>
<select class="col-10 custom-select" name="select-sem" id="select-sem" ng-model="selectedSem"
ng-options="c for c in Currentuser.allSemno">
</select>
</div>
<div dw-loading="DataList" dw-loading-options="{text: '載入清單...'}">
<table id="setting" class="table table-bordered table-striped table-rwd">
<thead class="thead-dark">
<tr >
<tr>
<th>課程名稱</th>
<th>教室</th>
<th>星期</th>
Expand All @@ -55,7 +66,8 @@
</thead>
<tbody>
<tr name="DataList" ng-repeat="Item in DataList">
<td class="table-th" data-th="課程名稱" id="{{Item.Name}}" onclick='Item_Visible_Control(this.id+"_content" , this.id , true)'>{{Item.Name}}</td>
<td class="table-th" data-th="課程名稱" id="{{Item.Name}}"
onclick='Item_Visible_Control(this.id+"_content" , this.id , true)'>{{Item.Name}}</td>
<td data-th="教室" id="{{Item.Name}}_content">
{{Item.Place}}
<span ng-show="!Item.Place">
Expand All @@ -69,7 +81,7 @@
<td data-th="任課教師" id="{{Item.Name}}_content">{{Item.Teacher}}</td>
</tr>
</tbody>
</table>
</table>
</div>
</div>
</body>
Expand All @@ -78,6 +90,7 @@
<script src="../externals/angularjs/angular.min.js"></script>
<script src="../externals/jquery/jquery-1.11.1.min.js"></script>
<script src="../externals/jqueryui/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.blockUI/2.70/jquery.blockUI.min.js"></script>
<script src="..//externals/jqueryui/datepicker-zh-TW.js"></script>
<script src="/atm/scripts/rwd-td.js"></script>
<script src="/atm/scripts/Common.js"></script>
Expand All @@ -89,40 +102,27 @@
<script src="https://cdn.jsdelivr.net/npm/darkmode-js@1.5.6/lib/darkmode-js.min.js"></script>

<script>
window.onload = async function() {
window.onload = async function () {
window.originH = $(window).height();
window.originW = $(window).width();
commonFunc.myDarkModeInit();
await sleep(100);
angular.element(document.getElementById('setting')).scope().Query();
var width = (window.innerWidth > 0) ? window.innerWidth : screen.width;
await sleep(500);
if (width <= 736)
{
HideTd('content');
$(`.table-th`).addClass("table-th-show");
}
};
window.onresize = async function () {
var width = (window.innerWidth > 0) ? window.innerWidth : screen.width;
let height = $(window).height();
if (width == window.originW && height ==window.originH) {
if (width == window.originW && height == window.originH) {
return;
}
if (width <= 736)
{
if (width <= 736) {
$("#setting").addClass("table-rwd");
TdDisplay('content');
$(".table-th").each(function() {
$(".table-th").each(function () {
let id = $(this).attr('id');
Item_Visible_Control(id+"_content" , id , true);
Item_Visible_Control(id + "_content", id, true);
});
}
else
{
} else {
$("#setting").removeClass("table-rwd");
TdDisplayNoneRWD('content');
}
}

</script>
</script>
66 changes: 40 additions & 26 deletions views/atm/scripts/Course.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,72 @@


var CourseApp = angular.module("CourseApp" ,["commonApp"]);
CourseApp.controller("CourseCtrl" , function($scope , CourseService , commonService)
{
var CourseApp = angular.module("CourseApp", ["commonApp"]);
CourseApp.controller("CourseCtrl", function ($scope, CourseService, commonService) {
$scope.DataList = [];
$scope.Currentuser = "";

$scope.selectedSem = "";

commonService.user.getStuInfo().then(function (res) {
$scope.Currentuser = res.data;
$scope.selectedSem = $scope.Currentuser.allSemno[$scope.Currentuser.allSemno.length - 1];
//angular.element(document.getElementById('setting')).scope().Query();
});
$scope.Query = function ()
{

CourseService.Get_data($scope.Currentuser).then((function(res)
{
if (res.data == null)
{

$scope.$watch("selectedSem", async function (newValue, oldValue) {
if (newValue) {
$scope.Query();
}
});
$scope.Query = function () {
commonFunc.blockUI();
CourseService.Get_data($scope.selectedSem).then((function (res) {
if (res.data == null || res.data.length <= 0) {
$scope.DataList = [];
$.unblockUI();
}
else
{
var Courses = res.data
else {
let Courses = res.data
$scope.DataList = Courses;
let checkContentExist = setInterval(function () {
if ($('[id*="content"]').length) {
let width = $(window).width();
if (width <= 736) {
HideTd('content');
$(`.table-th`).addClass("table-th-show");
}
clearInterval(checkContentExist);
$.unblockUI();
}
}, 100);
}
}))
}));
}
});

CourseApp.service("CourseService" , function($http)
{
CourseApp.service("CourseService", function ($http) {
return (
{
Get_data : Get_data
Get_data: Get_data
}
);
function Get_data(Querykey)
{
function Get_data(Querykey) {
var request = $http(
{
method: "GET",
url : "api/Course",
params :
url: "api/Course",
params:
{
User : Querykey
semno: Querykey
}
}
);
return (request.then(handleSuccess , handleError));
return (request.then(handleSuccess, handleError));
}
function handleSuccess(response) {
return (response);
}
function handleError(response) {

function handleError(response) {
return (response);
}
});

0 comments on commit 54f8641

Please sign in to comment.