feat: 연감에 기존 세력도 기능 통합
This commit is contained in:
+10
-11
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user