Skip to content

Commit

Permalink
Category.js added interval illegal argument function
Browse files Browse the repository at this point in the history
  • Loading branch information
lani009 committed May 29, 2021
1 parent 5686492 commit 6b20051
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 21 deletions.
50 changes: 38 additions & 12 deletions jmt_webapp/src/main/webapp/category_interval.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
<div id="intervalFromPanel">
<div id="fromYearPanel">
<select name="yearFromSelector">
<option>
전체
</option>
<option>2015</option>
<option>2016</option>
<option>2017</option>
<option>2018</option>
<option>2019</option>
<option>2020</option>
<option>2021</option>
</select>
</div>
</select>
<div id="fromMonthPanel">
<select name="monthFromSelector">
<option>
전체
</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>
</div>
Expand All @@ -22,18 +35,31 @@
<div id="intervalToPanel">
<div id="toYearPanel">
<select name="yearToSelector">
<option>
전체
</option>
<option>2015</option>
<option>2016</option>
<option>2017</option>
<option>2018</option>
<option>2019</option>
<option>2020</option>
<option>2021</option>
</select>
</div>
</select>
<div id="toMonthPanel">
<select name="monthToSelector">
<option>
전체
</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>
</div>
Expand Down
38 changes: 29 additions & 9 deletions jmt_webapp/src/main/webapp/payload/js/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,35 @@ function initIntervalButton() {

function initSubmitButton() {
$("#submitButton").click(function (ev) {
var selectedDeptDiv = document.getElementsByName("deptDivSelector")[0].selectedOptions[0].value;
var selectedGovofcDiv = document.getElementsByName("govofcDivSelector")[0].selectedOptions[0].value;
var selectedHgdeptDiv = document.getElementsByName("hgdeptDivSelector")[0].selectedOptions[0].value;
var selectedDept = document.getElementsByName("deptSelector")[0].selectedOptions[0].value;
selectedDeptDiv = selectedDeptDiv == "전체" ? null : selectedDeptDiv;
selectedGovofcDiv = selectedGovofcDiv == "전체" ? null : selectedGovofcDiv;
selectedHgdeptDiv = selectedHgdeptDiv == "전체" ? null : selectedHgdeptDiv;
selectedDept = selectedDept == "전체" ? null : selectedDept;
location.href="result.html?deptDiv="+selectedDeptDiv+"&govofcDiv="+selectedGovofcDiv+"&hgdeptDiv="+selectedHgdeptDiv+"&dept="+selectedDept;
var intervalQuery = "";
var isIllegalArgument = false;
if (document.querySelector('input[name="setIntervalSelection"]:checked').value === "checkInterval") {
var fromYear = document.getElementsByName("yearFromSelector")[0].selectedOptions[0].value;
var fromMonth = document.getElementsByName("monthFromSelector")[0].selectedOptions[0].value;

var toYear = document.getElementsByName("yearToSelector")[0].selectedOptions[0].value;
var toMonth = document.getElementsByName("monthToSelector")[0].selectedOptions[0].value;

if (new Date(fromYear+"-"+fromMonth) > new Date(toYear+"-"+toMonth)) {
alert("검색기간이 잘못되었습니다! 다시 입력해 주세요");
isIllegalArgument = true;
}
intervalQuery += "&startDate=" + fromYear + "-" + fromMonth + "&endDate" + toYear + "-" + toMonth;
}

if (!isIllegalArgument) {
var selectedDeptDiv = document.getElementsByName("deptDivSelector")[0].selectedOptions[0].value;
var selectedGovofcDiv = document.getElementsByName("govofcDivSelector")[0].selectedOptions[0].value;
var selectedHgdeptDiv = document.getElementsByName("hgdeptDivSelector")[0].selectedOptions[0].value;
var selectedDept = document.getElementsByName("deptSelector")[0].selectedOptions[0].value;
selectedDeptDiv = selectedDeptDiv == "전체" ? null : selectedDeptDiv;
selectedGovofcDiv = selectedGovofcDiv == "전체" ? null : selectedGovofcDiv;
selectedHgdeptDiv = selectedHgdeptDiv == "전체" ? null : selectedHgdeptDiv;
selectedDept = selectedDept == "전체" ? null : selectedDept;

var hrefLink = "result.html?deptDiv="+selectedDeptDiv+"&govofcDiv="+selectedGovofcDiv+"&hgdeptDiv="+selectedHgdeptDiv+"&dept="+selectedDept;
location.href = hrefLink + intervalQuery;
}
});
}

Expand Down

0 comments on commit 6b20051

Please sign in to comment.