122 lines
3.8 KiB
JavaScript
122 lines
3.8 KiB
JavaScript
|
|
/*
|
|
*
|
|
* NLIB 공통 JavaScript
|
|
*
|
|
*
|
|
*/
|
|
|
|
var CONTEXT_PATH = "/nlib";
|
|
|
|
// 팝업으로 비밀번호를 입력받아서 콜백함수에 전달한다.
|
|
function fn_promptPassword(msg, placeholder, callbackFucName) {
|
|
var options = "top=200, left=200, width=300, height=200, status=no, menubar=no, toolbar=yes, resizable=no";
|
|
var thePrompt = window.open("", "_NLIB_POMPT_PASSWORD", options);
|
|
var theHTML = "<html><head><title>" + placeholder + "</title><style type='text/css'> body { background-color: #ffd; } button { margin: 10px; }</style></head><body>";
|
|
|
|
theHTML += "<p>" + msg + "</p>";
|
|
theHTML += "<br/>";
|
|
theHTML += "비밀번호: <input type='text' id='thePass' placeholder='" + placeholder + "'/>";
|
|
theHTML += " <br />";
|
|
theHTML += " <br />";
|
|
theHTML += "<button title='확인' id='thePromptOk' onclick='opener.parent." + callbackFucName + "("
|
|
+ "document.getElementById(\"thePass\").value); window.close();'>확인</button>";
|
|
theHTML += "<button title='취소' id='thePromptClose' onclick='window.close();'>취소</button>";
|
|
theHTML += "</body></html>";
|
|
|
|
thePrompt.document.body.innerHTML = theHTML;
|
|
}
|
|
|
|
/**
|
|
* ID를 name 으로 하는 객체의 값을 숫자(10진수)로 변환하여 리턴한다.
|
|
* 값이 적절하지 않은 경우, defaultValue를 리턴한다.
|
|
*
|
|
* @param name
|
|
* @param defaultValue
|
|
* @returns
|
|
*/
|
|
function fn_getIntValue(name, defaultValue) {
|
|
var val = $("#" + name).val();
|
|
try {
|
|
return parseInt(val, 10);
|
|
} catch(error) {
|
|
console.error(error);
|
|
return defaultValue;
|
|
}
|
|
}
|
|
|
|
|
|
const POPUP_DEFAULT_WIDTH = 600; // 팝업 기본 창 가로 크기
|
|
const POPUP_DEFAULT_HEIGHT = 600; // 팝업 기본 창 세로 크기
|
|
|
|
/**
|
|
* 팝업을 생성하고 해당 URL로 접속한다.
|
|
*
|
|
* @param url
|
|
* @param popName
|
|
* @param width 생략 시 POPUP_DEFAULT_WIDTH
|
|
* @param height 생략 시 POPUP_DEFAULT_HEIGHT
|
|
* @returns
|
|
*/
|
|
function openPopup(url, popName, width, height) {
|
|
var options = "top=10, left=10, width=" + (width?width:POPUP_DEFAULT_WIDTH) + ", height=" + (height?height:POPUP_DEFAULT_HEIGHT) + ", status=no, menubar=no, toolbar=yes, resizable=no";
|
|
window.open(url, popName, options);
|
|
}
|
|
|
|
function validEmail(email) {
|
|
if(!email) return false;
|
|
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
return re.test(String(email).toLowerCase());
|
|
}
|
|
|
|
function fn_openLayerPopup(title, content, linkName, linkUrl) {
|
|
|
|
var layerPopupHtml =
|
|
"<h2>" + title + "</h2><br/>" +
|
|
"<div>" + content + "</div><br/>" +
|
|
"<br/> " +
|
|
"<div style='text-align:center;'><a href='#' onclick='fn_closeLayerPopup()'>[확인]</a>";
|
|
|
|
if(linkUrl != null) {
|
|
layerPopupHtml += " <a href='" + linkUrl + "'>[" + linkName + "]</a>";
|
|
}
|
|
layerPopupHtml += "</div>";
|
|
$(layerPopupHtml).appendTo("#NLIB_LAYER_POPUP");
|
|
$("#NLIB_LAYER_POPUP").show();
|
|
console.log(layerPopupHtml);
|
|
}
|
|
|
|
function fn_closeLayerPopup() {
|
|
$("#NLB_LAYER_POPUP").html("");
|
|
$("#NLIB_LAYER_POPUP").hide();
|
|
|
|
}
|
|
|
|
function fn_myAlert(newAlertNum) {
|
|
if(newAlertNum == "undefined" || newAlertNum == null || newAlertNum < 1) {
|
|
return;
|
|
}
|
|
|
|
fn_openLayerPopup("알림", "아직 확인하지 않은 새로운 알림이 " + newAlertNum + "건 있습니다", "알림 목록으로", CONTEXT_PATH + "/cmm/listNotifications.do");
|
|
}
|
|
|
|
function fn_layerPop(url) {
|
|
$("#NLIB_LAYER_POPUP").load(url);
|
|
$("#NLIB_LAYER_POPUP").show();
|
|
}
|
|
|
|
function fn_layerPopFormSubmit(formName) {
|
|
var dataList = $("#" + formName).serialize();
|
|
var url = $("#" + formName).attr('action');
|
|
|
|
$("#NLIB_LAYER_POPUP").show();
|
|
|
|
$.ajax({
|
|
type: "post",
|
|
url: url,
|
|
data: dataList
|
|
}).done(function(response){
|
|
$("#" + formName).html(response);
|
|
});
|
|
}
|