feat: 연감에 기존 세력도 기능 통합

This commit is contained in:
2022-02-23 23:46:40 +09:00
parent 9f84eb8d4d
commit a47669ff75
3 changed files with 80 additions and 61 deletions
+10 -11
View File
@@ -1,5 +1,7 @@
import $ from 'jquery';
import '@/map';
import { joinYearMonth } from './util/joinYearMonth';
import { parseYearMonth } from './util/parseYearMonth';
declare const startYear:number;
declare const startMonth:number;
@@ -13,28 +15,25 @@ declare const selectMonth: number;
$(function ($) {
let currYear = startYear;
let currMonth = startMonth;
const selectDate = joinYearMonth(selectYear, selectMonth);
const $yearMonth = $('#yearmonth');
let $elements = $();
const endDate = lastYear * 12 + lastMonth - 1;
let currDate = startYear * 12 + startMonth - 1;
const endDate = joinYearMonth(lastYear, lastMonth) + 1;//연감 마지막 + 1(현재)
let currDate = joinYearMonth(startYear, startMonth);
while (currDate <= endDate) {
const target = currYear * 100 + currMonth;
let sel = '';
if (currYear == selectYear && currMonth == selectMonth) {
if (currDate == selectDate) {
sel = 'selected="selected"';
}
const option = $(`<option value="${target}" ${sel} >${currYear}${currMonth}월</option>`);
const more = currDate == endDate? ' (현재)':'';
const option = $(`<option value="${currDate}" ${sel} >${currYear}${currMonth}${more}</option>`);
$elements = $elements.add(option);
currMonth += 1;
if (currMonth > 12) {
currYear += 1;
currMonth -= 12;
}
currDate += 1;
[currYear, currMonth] = parseYearMonth(currDate);
}
$yearMonth.empty();
$yearMonth.append($elements);