Add: maestro_available_date.js
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
function MaestroAvailableDate() {
|
||||
this.today = new Date();
|
||||
|
||||
this.endDate = null;
|
||||
this.endDay = null;
|
||||
}
|
||||
|
||||
|
||||
MaestroAvailableDate.prototype.setEndDate = function(endDate) {
|
||||
this.endDate = endDate;
|
||||
this.endDay = new Date(this.endDate);
|
||||
}
|
||||
|
||||
MaestroAvailableDate.prototype.setEndDateTime = function(endDateTime) {
|
||||
var endDateArray = endDateTime.split(" ");
|
||||
this.setEndDate(endDateArray[0]); // "YY-MM_DD"
|
||||
}
|
||||
|
||||
MaestroAvailableDate.prototype.getDiffDay = function() {
|
||||
var diffDay = (this.endDay.getTime() - this.today.getTime()) / (1000 * 60 * 60 * 24);
|
||||
return Math.ceil(diffDay);
|
||||
}
|
||||
|
||||
MaestroAvailableDate.prototype.getNewAvailableDate = function(diffDay) {
|
||||
var newDate = null;
|
||||
if(diffDay < 0) // end date is over
|
||||
newDate = new Date(new Date().setFullYear(this.today.getFullYear() + 1));
|
||||
else
|
||||
newDate = new Date(new Date().setFullYear(this.endDay.getFullYear() + 1));
|
||||
|
||||
var year2Digits = newDate.getFullYear();
|
||||
var month2Digits = ("0"+(newDate.getMonth()+1)).slice(-2);
|
||||
var day2Digits = ("0" + newDate.getDate()).slice(-2);
|
||||
|
||||
return year2Digits+ "-" + month2Digits + "-" + day2Digits;
|
||||
}
|
||||
|
||||
MaestroAvailableDate.prototype.showMaestroExtensionMessage = function(maestroName) {
|
||||
var diffDay = this.getDiffDay();
|
||||
|
||||
if(diffDay > 30)
|
||||
return;
|
||||
|
||||
$("#maestro_extension").removeClass("d-none");
|
||||
|
||||
var message = "";
|
||||
if(diffDay > 0)
|
||||
message = "<span class='font-weight-bold'>" + maestroName + "</span> 계정의 유효기간이 얼마 남지 않았습니다.<br/>1년 더 사용을 원하신다면 우측의 [유효기간 연장] 버튼을 눌러주세요.";
|
||||
else
|
||||
message = "<span class='font-weight-bold'>" + maestroName + "</span> 계정의 유효기간이 지났습니다. 등록된 학생들의 정보는 유지되지만, 로그인이 제한됩니다.<br/>유효기간 연장을 하시면 다시 로그인하고 사용할 수 있게 됩니다.";
|
||||
|
||||
$("#maestro_extension_message").html(message);
|
||||
}
|
||||
|
||||
|
||||
MaestroAvailableDate.prototype.showEndDate = function() {
|
||||
var diffDay = this.getDiffDay();
|
||||
|
||||
var newAvailableDate = this.getNewAvailableDate(diffDay);
|
||||
|
||||
$("#end_day").html(this.endDate);
|
||||
|
||||
if(diffDay < 0) {
|
||||
$("#maestro_count_down_date").html("유효 기간 : ~ " + this.endDate + " <span id='countdown_day'>(" + Math.abs(diffDay) + "일 경과) </span>");
|
||||
|
||||
$("#countdown_day").addClass("bg-danger font-weight-bold text-light");
|
||||
}
|
||||
else {
|
||||
$("#maestro_count_down_date").html("유효 기간 : ~ " + this.endDate + " <span id='countdown_day'>(남은 기간 : " + diffDay + "일)</span>");
|
||||
|
||||
if(diffDay < 10)
|
||||
$("#countdown_day").addClass("bg-danger text-light");
|
||||
else if(diffDay < 30)
|
||||
$("#countdown_day").addClass("text-danger");
|
||||
else
|
||||
$("#countdown_day").addClass("text-primary");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user