function getDataAsync(url, method, param, args, successFunc, errorFunc ) {
    $.ajax({
        url    : url,
        method : method,
        dataType : 'JSON',
        data : param,
        success : function (req) {
            if (successFunc) {
                successFunc(req, args);
            }
        },
        error : function (request, status, error) {
            if (errorFunc) {
                errorFunc(request, status, error);
            }
            else {
                console.log(error);
            }
        }
    });
}

function textFormat(text) {
    return isNull(text) ? '-' : text;
}

function isNull(value) {
    if (value === null || value === "" || value === undefined) {
        return true;
    }

    if (value.toString().trim() === "") {
        return true;
    }
    return false;
}

function moveNoticeView(boarNo, isAdmin) {
    getDataAsync("/api/notice/update-read-count/" +boarNo, "POST", null, null, (jsonData)=>{
        if (jsonData) {
            let page = '/notice/view/';
            if (isAdmin) page = '/phits/notice-view/';
            window.location.href = page + boarNo;
        }
        else {
            moveNoticeView(boarNo);
        }
    }, null);
}

function dateFormatter(date) {
    let year  = date.getFullYear().toString();
    let month = date.getMonth() + 1;
    let day   = date.getDate();
    month = month < 10 ? "0" + month : month;
    day   = day < 10 ? "0" + day : day;
    return year + month + day;
}