Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Commit

Permalink
Add halt function
Browse files Browse the repository at this point in the history
  • Loading branch information
CXZ7720 committed Jan 25, 2020
1 parent 57089b6 commit 921d726
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 3 deletions.
12 changes: 12 additions & 0 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,17 @@ function getDayKind() {

}

function isHalt(){
const haltList = data.calendar[4].halt;
console.log(haltList);
if(haltList.indexOf(now) !== -1){
return "halted"
} else {
return ""
}
}


module.exports.getDayKind = getDayKind
module.exports.getDateKind = getDateKind
module.exports.isHalt = isHalt
7 changes: 6 additions & 1 deletion router/giksa.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function urlParse (urlstr) {

var datekind = "";
var daykind = "";

var isHalt = "";


router.get('/', (req, res) => {
Expand All @@ -26,9 +26,11 @@ router.get('/', (req, res) => {
//Short Path 로 접근 한 경우
datekind = func.getDateKind();
daykind = func.getDayKind();
isHalt = func.isHalt();
}
console.log("Date Kind : " + datekind + "\n")
console.log("Day Kind : " + daykind + "\n");
console.log("isHalted : " + isHalt + "\n");

switch (datekind) {
case 'semester': // 학기중
Expand All @@ -55,6 +57,9 @@ router.get('/', (req, res) => {
default:
break
}
if (isHalt == "halted") {
return res.status(200).json({ status: "Halt" });
}

try {
var data = fs.readFileSync(jsonPath, 'UTF-8')
Expand Down
7 changes: 7 additions & 0 deletions router/shuttlecock_i.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function urlParse (urlstr) {

var datekind = "";
var daykind = "";
var isHalt = "";


router.get('/', (req, res) => {
Expand All @@ -24,10 +25,12 @@ router.get('/', (req, res) => {
if (urlArr.length == 2){ //Short Path 로 접근 한 경우
datekind = func.getDateKind()
daykind = func.getDayKind()
isHalt = func.isHalt()
}

console.log("Date Kind : " + datekind + "\n");
console.log("Day Kind : " + daykind + "\n");
console.log("isHalted : " + isHalt + "\n");

switch (datekind) {
case 'semester': // 학기중
Expand Down Expand Up @@ -55,6 +58,10 @@ router.get('/', (req, res) => {
break
}

if (isHalt == "halted") {
return res.status(200).json({ status: "Halt" });
}

try {
var data = fs.readFileSync(jsonPath, 'UTF-8')
} catch (err) {
Expand Down
6 changes: 6 additions & 0 deletions router/shuttlecock_o.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function urlParse (urlstr) {

var datekind = "";
var daykind = "";
var isHalt = "";


router.get('/', (req, res) => {
Expand All @@ -24,10 +25,12 @@ router.get('/', (req, res) => {
if (urlArr.length == 2){ //Short Path 로 접근 한 경우
datekind = func.getDateKind()
daykind = func.getDayKind()
isHalt = func.isHalt()
}

console.log("Date Kind : " + datekind + "\n");
console.log("Day Kind : " + daykind + "\n");
console.log("isHalted : " + isHalt + "\n");

switch (datekind) {
case 'semester': // 학기중
Expand All @@ -54,6 +57,9 @@ router.get('/', (req, res) => {
default:
break
}
if (isHalt == "halted") {
return res.status(200).json({ status: "Halt" });
}

try {
var data = fs.readFileSync(jsonPath, 'UTF-8')
Expand Down
7 changes: 6 additions & 1 deletion router/subway.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function urlParse (urlstr) {

var datekind = "";
var daykind = "";

var isHalt = "";


router.get('/', (req, res) => {
Expand All @@ -26,10 +26,12 @@ router.get('/', (req, res) => {
if (urlArr.length == 2){ //Short Path 로 접근 한 경우
datekind = func.getDateKind()
daykind = func.getDayKind()
isHalt = func.isHalt();
}

console.log("Date Kind : " + datekind + "\n");
console.log("Day Kind : " + daykind + "\n");
console.log("isHalted : " + isHalt + "\n");

switch (datekind) {
case 'semester': // 학기중
Expand All @@ -56,6 +58,9 @@ router.get('/', (req, res) => {
default:
break
}
if (isHalt == "halted") {
return res.status(200).json({ status: "Halt" });
}

try {
var data = fs.readFileSync(jsonPath, 'UTF-8')
Expand Down
7 changes: 6 additions & 1 deletion router/yesulin.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function urlParse (urlstr) {

var datekind = "";
var daykind = "";
var isHalt = "";


router.get('/', (req, res) => {
Expand All @@ -24,10 +25,12 @@ router.get('/', (req, res) => {
if (urlArr.length == 2){ //Short Path 로 접근 한 경우
datekind = func.getDateKind()
daykind = func.getDayKind()
isHalt = func.isHalt()
}

console.log("Date Kind : " + datekind + "\n");
console.log("Day Kind : " + daykind + "\n");
console.log("isHalted : " + isHalt + "\n");


switch (datekind) {
Expand Down Expand Up @@ -55,7 +58,9 @@ router.get('/', (req, res) => {
default:
break
}

if(isHalt == "halted"){
return res.status(200).json({status: "Halt" })
}
try {
var data = fs.readFileSync(jsonPath, 'UTF-8')
} catch (err) {
Expand Down
3 changes: 3 additions & 0 deletions settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
},
{
"holiday": ["2019-12-25", "2020-01-01", "2020-01-24", "2020-01-25", "2020-01-26", "2020-01-27", "2020-03-01", "2020-04-15", "2020-04-30", "2020-05-05", "2020-05-15","2020-06-06", "2020-08-15", "2020-09-30", "2020-10-01", "2020-10-02", "2020-10-03", "2020-10-09", "2020-12-25"]
},
{
"halt": ["2020-01-24", "2020-01-25", "2020-01-26", "2020-01-27"]
}
]
}

0 comments on commit 921d726

Please sign in to comment.