var _pageSize = 25;
var _blockSize = 10;
var _date = new Date();
var _localTimezoneOffset = _date.getTimezoneOffset();
var _localTimezone = -(_localTimezoneOffset / 60);
/**
* Page Navigation 그리기
*
* @param totCnt 총 건수
*/
function drawPaging(totCnt) {
pageNo = toInt($("#offset").val()) / toInt($("#limit").val()) + 1;
pageSize = toInt($("#limit").val());
var btnPagePrev2 = "btnPageLeft2";
var btnPagePrev2On = "btnPageLeft2";
var btnPagePrev1 = "btnPageLeft";
var btnPagePrev1On = "btnPageLeft";
var btnPageNext1 = "btnPageRight";
var btnPageNext1On = "btnPageRight";
var btnPageNext2 = "btnPageRight2";
var btnPageNext2On = "btnPageRight2";
var totPageCnt = toInt(totCnt / pageSize) + (totCnt % pageSize > 0 ? 1 : 0);
var totBlockCnt = toInt(totPageCnt / _blockSize) + (totPageCnt % _blockSize > 0 ? 1 : 0);
var blockNo = toInt(pageNo / _blockSize) + (pageNo % _blockSize > 0 ? 1 : 0);
var startPageNo = (blockNo - 1) * _blockSize + 1;
var endPageNo = blockNo * _blockSize;
//alert(totPageCnt + " / " + totBlockCnt + " / " + blockNo + " / " + startPageNo + " / " + endPageNo);
if (endPageNo > totPageCnt) {
endPageNo = totPageCnt;
}
var prevBlockPageNo = (blockNo - 1) * _blockSize;
var nextBlockPageNo = blockNo * _blockSize + 1;
var strHTML = "";
if (totPageCnt > 1 && pageNo != 1) {
strHTML += " ";
} else {
strHTML += " ";
}
if (pageNo > 1) {
strHTML += " ";
} else {
strHTML += " ";
}
var numberStyle = "", numberClass = "";
for (var i = startPageNo; i <= endPageNo; i++) {
numberStyle = (i == pageNo) ? "font-weight:bold; color:#3677b2; letter-spacing:-1px;" : "";
numberClass = (i == startPageNo) ? "first" : "";
numberClass = (i == endPageNo) ? "last" : numberClass;
numberClass = (i == startPageNo && i == endPageNo) ? "first last" : numberClass;
strHTML += "" + i + "";
}
if (totCnt == 0) {
strHTML += "1";
}
if (pageNo < totPageCnt) {
strHTML += " ";
} else {
strHTML += " ";
}
if (totPageCnt > 1 && pageNo != totPageCnt) {
strHTML += " ";
} else {
strHTML += " ";
}
$('#divPaging').html(strHTML);
$('.arrowBtn').bind({
mousedown: function() {
$(this).children("span").addClass('btnPress');
},
mouseup: function() {
$(this).children("span").removeClass('btnPress');
},
mouseleave: function() {
$(this).children("span").removeClass('btnPress');
}
});
}
/**
* Page Navigation 그리기
*
* @param totCnt 총 건수
*/
function drawTempPaging(targetId, totCnt, searchFunc) {
pageNo = toInt($("#temp_offset").val()) / toInt($("#temp_limit").val()) + 1;
pageSize = toInt($("#temp_limit").val());
var btnPagePrev2 = "btnPageLeft2";
var btnPagePrev2On = "btnPageLeft2";
var btnPagePrev1 = "btnPageLeft";
var btnPagePrev1On = "btnPageLeft";
var btnPageNext1 = "btnPageRight";
var btnPageNext1On = "btnPageRight";
var btnPageNext2 = "btnPageRight2";
var btnPageNext2On = "btnPageRight2";
var totPageCnt = toInt(totCnt / pageSize) + (totCnt % pageSize > 0 ? 1 : 0);
var totBlockCnt = toInt(totPageCnt / _blockSize) + (totPageCnt % _blockSize > 0 ? 1 : 0);
var blockNo = toInt(pageNo / _blockSize) + (pageNo % _blockSize > 0 ? 1 : 0);
var startPageNo = (blockNo - 1) * _blockSize + 1;
var endPageNo = blockNo * _blockSize;
//alert(totPageCnt + " / " + totBlockCnt + " / " + blockNo + " / " + startPageNo + " / " + endPageNo);
if (endPageNo > totPageCnt) {
endPageNo = totPageCnt;
}
var prevBlockPageNo = (blockNo - 1) * _blockSize;
var nextBlockPageNo = blockNo * _blockSize + 1;
var strHTML = "";
if (totPageCnt > 1 && pageNo != 1) {
strHTML += " ";
} else {
strHTML += " ";
}
if (pageNo > 1) {
strHTML += " ";
} else {
strHTML += " ";
}
var numberStyle = "", numberClass = "";
for (var i = startPageNo; i <= endPageNo; i++) {
numberStyle = (i == pageNo) ? "font-weight:bold; color:#3677b2; letter-spacing:-1px;" : "";
numberClass = (i == startPageNo) ? "first" : "";
numberClass = (i == endPageNo) ? "last" : numberClass;
numberClass = (i == startPageNo && i == endPageNo) ? "first last" : numberClass;
strHTML += "" + i + "";
}
if (totCnt == 0) {
strHTML += "1";
}
if (pageNo < totPageCnt) {
strHTML += " ";
} else {
strHTML += " ";
}
if (totPageCnt > 1 && pageNo != totPageCnt) {
strHTML += " ";
} else {
strHTML += " ";
}
$('#'+targetId).html(strHTML);
$('.arrowBtn').bind({
mousedown: function() {
$(this).children("span").addClass('btnPress');
},
mouseup: function() {
$(this).children("span").removeClass('btnPress');
},
mouseleave: function() {
$(this).children("span").removeClass('btnPress');
}
});
}
/**
* Page Navigation 그리기
*
* @param targetId 페이지 ID
* @param totCnt 총 건수
* @param searchFunc 페지지 검색 함수
* @param offset 시작 number
* @param limit 한페이지 사이즈
*/
function drawCustomPaging(targetId, totCnt, searchFunc, offset, limit) {
pageNo = toInt(offset) / toInt(limit) + 1;
pageSize = toInt(limit);
var totPageCnt = toInt(totCnt / pageSize) + (totCnt % pageSize > 0 ? 1 : 0);
var blockNo = toInt(pageNo / _blockSize) + (pageNo % _blockSize > 0 ? 1 : 0);
var startPageNo = (blockNo - 1) * _blockSize + 1;
var endPageNo = blockNo * _blockSize;
//alert(totPageCnt + " / " + totBlockCnt + " / " + blockNo + " / " + startPageNo + " / " + endPageNo);
if (endPageNo > totPageCnt) {
endPageNo = totPageCnt;
}
var strHTML = "";
if (totPageCnt > 1 && pageNo != 1) {
strHTML += "
";
} else {
strHTML += "
";
}
strHTML += "  ";
if (pageNo > 1) {
strHTML += "
";
} else {
strHTML += "
";
}
var numberClass = "";
strHTML += "";
for (var i = startPageNo; i <= endPageNo; i++) {
numberClass = (i == pageNo) ? "orange" : "";
if(i == pageNo){
strHTML += "" + i + "";
}else{
strHTML += "" + i + "";
}
}
strHTML += "";
if (totCnt == 0) {
strHTML += "1";
}
if (pageNo < totPageCnt) {
strHTML += "
";
} else {
strHTML += "
";
}
strHTML += "  ";
if (totPageCnt > 1 && pageNo != totPageCnt) {
strHTML += "
";
} else {
strHTML += "
";
}
$('#'+targetId).html(strHTML);
}
/**
* 검색 API offset parameter 값 계산
*
* @param pageNo 페이지번호
* @return offset
*/
function getSearchOffset(pageNo) {
return (pageNo - 1) * toInt($("#limit").val());
}
/**
* 검색 API offset parameter 값 계산 (삭제 or 변경된 항목 제외하고 재계산)
* @param pageNo : 페이지 번호
* @param totalCount
* @param exceptCount
* @returns {Number}
*/
function getSearchOffsetRe(pageNo, totalCount, exceptCount) {
var reOffset = 0;
if(pageNo > 1)
{
reOffset = (pageNo - 1) * toInt($("#limit").val());
if(reOffset >= (totalCount - exceptCount))
{
reOffset = (pageNo - 2) * toInt($("#limit").val());
}
return reOffset;
}else{
return (pageNo - 1) * toInt($("#limit").val());
}
}
/**
* offset&limit 값으로 pageNo 값 추출
* @param offset
* @returns {Number}
*/
function getPageNo(offset) {
return toInt(offset) / toInt($("#limit").val()) + 1;
}
/**
* 리스트 정렬
*
* @param titleId 헤드타이틀 ID
*/
function sort(titleId) {
$("#tempSort").val(titleId);
var isAsc = $("#sort_" + titleId).parents("button").hasClass("up");
if (isAsc) {
$("#tempOrder").val("desc");
} else {
$("#tempOrder").val("asc");
}
if ($("#tempSort").val() == "fullname") {
$("#sort").val("firstName,lastName");
if ($("#tempOrder").val() == "asc") {
$("#order").val("asc,asc");
}
else {
$("#order").val("desc,desc");
}
} else if ($("#tempSort").val() == "order_created") {
$("#sort").val("order,created");
if ($("#tempOrder").val() == "asc") {
$("#order").val("asc,asc");
} else {
$("#order").val("asc,desc");
}
} else if ($("#tempSort").val() == "order_name") {
$("#sort").val("order,created,name");
if ($("#tempOrder").val() == "asc") {
$("#order").val("asc,asc,desc");
} else {
$("#order").val("asc,asc,asc");
}
} else {
$("#sort").val($("#tempSort").val());
$("#order").val($("#tempOrder").val());
}
if($("#sort_" + $("#tempSort").val()).parents("button").hasClass("up"))
$("#sort_" + $("#tempSort").val()).parents("button").removeClass("up");
else
$("#sort_" + $("#tempSort").val()).parents("button").addClass("up");
search(1);
}
/**
* 리스트 정렬
*
* @param titleId 1st order 헤드타이틀 ID
* @param titleId2 2nd order 헤드타이틀 ID
*/
function sort2(titleId,titleId2) {
$("#tempSort").val(titleId+"_"+titleId2);
var isAsc = $("#sort_" + titleId+"_"+titleId2).parents("button").hasClass("up");
if (isAsc) {
$("#tempOrder").val("desc,asc");
} else {
$("#tempOrder").val("asc,asc");
}
if (titleId == "fullname") {
$("#sort").val("lastName,firstName"+","+titleId2);
if ($("#tempOrder").val() == "asc,asc") {
$("#order").val("asc,asc,asc");
}
else {
$("#order").val("desc,desc,asc");
}
} else if (titleId == "order_created") {
$("#sort").val("order,created"+","+titleId2);
if ($("#tempOrder").val() == "asc,asc") {
$("#order").val("asc,asc,asc");
} else {
$("#order").val("asc,desc,asc");
}
} else if (titleId == "order_name") {
$("#sort").val("order,created,name"+","+titleId2);
if ($("#tempOrder").val() == "asc,asc") {
$("#order").val("asc,asc,desc,asc");
} else {
$("#order").val("asc,asc,asc,asc");
}
} else {
$("#sort").val(titleId+","+titleId2);
$("#order").val($("#tempOrder").val());
}
if($("#sort_" + $("#tempSort").val()).parents("button").hasClass("up")){
$("#sort_" + $("#tempSort").val()).parents("button").removeClass("up");
}
else{
$("#sort_" + $("#tempSort").val()).parents("button").addClass("up");
}
search(1);
}
/**
* 리스트 정렬
*
* @param titleId 헤드타이틀 ID
*/
function customSort(titleId, sortId, orderId, tempSortId, tempOrderId, callback, callbackParams) {
$("#"+tempSortId).val(titleId);
var btn = $("#custom_sort_" + titleId).parents("button");
var sort = $("#"+sortId);
var order = $("#"+orderId);
var tmpSort = $("#"+tempSortId);
var tmpOrder = $("#"+tempOrderId);
var isAsc = btn.hasClass("up");
if (isAsc) {
tmpOrder.val("desc");
} else {
tmpOrder.val("asc");
}
btn.parent().parent().children("th").each(function(){
$(this).find("button").removeClass("up");
$(this).find("button").addClass("dim");
});
btn.removeClass("dim");
if(tmpOrder.val() == "asc") {
btn.addClass("up");
}
if (tmpSort.val() == "fullname") {
sort.val("lastName,firstName");
if (tmpOrder.val() == "asc") {
order.val("asc,asc");
}
else {
order.val("desc,desc");
}
} else if (tmpSort.val() == "order") {
sort.val("order,created");
if (tmpOrder.val() == "asc") {
order.val("asc,desc");
} else {
order.val("asc,asc");
}
} else {
sort.val(tmpSort.val());
order.val(tmpOrder.val());
}
if ( typeof callback == "function" ) {
callback(callbackParams);
}
else {
search(1);
}
}
function setSort() {
$("[id ^= 'sort_']").each(function() {
$(this).attr("class", "arrow");
if($(this).attr("id") == "sort_" + $("#tempSort").val())
{
$(this).parents("button").removeClass("dim");
}else{
if($(this).parents("button").hasClass("up"))
$(this).parents("button").removeClass("up");
$(this).parents("button").addClass("dim");
}
});
}
/**
* 로컬 브라우저의 timezone으로 변경
*
* @param strDate 날짜 (2012-06-27T00:00:00+0900 형식)
* @return 변경된 날짜 (Date type)
*/
function convertLocalTimezone(strDate) {
var serverTimezoneOffset = (toInt(strDate.substring(20, 22)) * 60 + toInt(strDate.substring(22, 24))) * (strDate.substring(19, 20) == "+" ? 1 : -1);
var offset = serverTimezoneOffset + _localTimezoneOffset;
var yyyy = toInt(strDate.substring(0, 4));
var mm = toInt(strDate.substring(5, 7)) - 1;
var dd = toInt(strDate.substring(8, 10));
var hh = toInt(strDate.substring(11, 13));
var mi = toInt(strDate.substring(14, 16));
var ss = toInt(strDate.substring(17, 19));
var d = new Date(yyyy, mm, dd, hh, mi, ss, 0);
var d2 = new Date(Date.parse(d) - offset * 60 * 1000);
return d2;
}
/**
* 날짜를 서버로 전송하기 위해 서버의 날짜 형식으로 변환
*
* @param {Object} strDate 날짜 (YYYYMMDD, YYYYMMDDHHMI, YYYYMMDDHHMISS)
* @return 서버 날짜 형식 (2012-01-01T00:00:00+0900)
*/
function converServerDateFormat(strDate) {
var result = "";
if (strDate == null) strDate = getCurrentTime();
if (strDate.length == 8) {
result += strDate.substring(0, 4) + "-" + strDate.substring(4, 6) + "-" + strDate.substring(6, 8);
result += "T00:00:00";
} else if (strDate.length == 12) {
result += strDate.substring(0, 4) + "-" + strDate.substring(4, 6) + "-" + strDate.substring(6, 8);
result += "T" + strDate.substring(8, 10) + ":" + strDate.substring(10, 12) + ":00";
} else if (strDate.length == 14) {
result += strDate.substring(0, 4) + "-" + strDate.substring(4, 6) + "-" + strDate.substring(6, 8);
result += "T" + strDate.substring(8, 10) + ":" + strDate.substring(10, 12) + ":" + strDate.substring(12, 14);
}
if (result != "") {
strOffset = (_localTimezone >= 0 ? "+" : "-") + lpad(_localTimezone + "", 2, "0") + "00";
result = result + strOffset;
}
return result;
}
/**
* 화면에 표시되는 시간 형식의 문자열로 변환
*
* @param strDate 날짜 (2012-06-27T00:00:00+0900 형식)
* @return 변경된 날짜 (국가/언어별 날짜 형식)
*/
function getDispTime(strDate) {
var d = convertLocalTimezone(strDate);
var formattedDate = "";
if (_clientLang == "en") {
formattedDate = "" + (d.getMonth() + 1) + "/" + d.getDate() + "/" + d.getFullYear() + " " + (d.getHours() + (d.getHours() > 12 ? -12 : 0)) + ":" + lpad(d.getMinutes(), 2, "0") + " " + (d.getHours() >= 12 ? "PM" : "AM");
} else if (_clientLang == "fr") {
formattedDate = "" + lpad(d.getDate(), 2, "0") + "/" + lpad(d.getMonth() + 1, 2, "0") + "/" + d.getFullYear() + " " + lpad(d.getHours(), 2, "0") + ":" + lpad(d.getMinutes(), 2, "0");
} else if (_clientLang == "de") {
formattedDate = "" + lpad(d.getDate(), 2, "0") + "." + lpad(d.getMonth() + 1, 2, "0") + "." + d.getFullYear() + " " + lpad(d.getHours(), 2, "0") + ":" + lpad(d.getMinutes(), 2, "0");
} else if (_clientLang == "it") {
formattedDate = "" + lpad(d.getDate(), 2, "0") + "/" + lpad(d.getMonth() + 1, 2, "0") + "/" + d.getFullYear() + " " + lpad(d.getHours(), 2, "0") + ":" + lpad(d.getMinutes(), 2, "0");
} else if (_clientLang == "es") {
formattedDate = "" + lpad(d.getDate(), 2, "0") + "/" + lpad(d.getMonth() + 1, 2, "0") + "/" + d.getFullYear() + " " + lpad(d.getHours(), 2, "0") + ":" + lpad(d.getMinutes(), 2, "0");
} else if (_clientLang == "zh") {
formattedDate = "" + d.getFullYear() + "-" + lpad(d.getMonth() + 1, 2, "0") + "-" + lpad(d.getDate(), 2, "0") + " " + lpad(d.getHours(), 2, "0") + ":" + lpad(d.getMinutes(), 2, "0");
} else if (_clientLang == "ja") {
formattedDate = "" + d.getFullYear() + "-" + lpad(d.getMonth() + 1, 2, "0") + "-" + lpad(d.getDate(), 2, "0") + " " + lpad(d.getHours(), 2, "0") + ":" + lpad(d.getMinutes(), 2, "0");
} else if (_clientLang == "ru") {
formattedDate = "" + lpad(d.getDate(), 2, "0") + "." + lpad(d.getMonth() + 1, 2, "0") + "." + d.getFullYear() + " " + lpad(d.getHours(), 2, "0") + ":" + lpad(d.getMinutes(), 2, "0");
} else if (_clientLang == "pt") {
formattedDate = "" + lpad(d.getDate(), 2, "0") + "-" + lpad(d.getMonth() + 1, 2, "0") + "-" + d.getFullYear() + " " + lpad(d.getHours(), 2, "0") + ":" + lpad(d.getMinutes(), 2, "0");
} else if (_clientLang == "hi") {
formattedDate = "" + lpad(d.getDate(), 2, "0") + "-" + lpad(d.getMonth() + 1, 2, "0") + "-" + d.getFullYear() + " " + lpad(d.getHours(), 2, "0") + ":" + lpad(d.getMinutes(), 2, "0");
} else {
formattedDate = "" + (d.getMonth() + 1) + "/" + d.getDate() + "/" + d.getFullYear() + " " + (d.getHours() + (d.getHours() > 12 ? -12 : 0)) + ":" + lpad(d.getMinutes(), 2, "0") + " " + (d.getHours() >= 12 ? "PM" : "AM");
}
return formattedDate;
}
/**
* 화면에 표시되는 시간 형식의 문자열로 변환 (날짜만)
*
* @param strDate 날짜 (2012-06-27T00:00:00+0900 형식)
* @return 변경된 날짜 (국가/언어별 날짜 형식)
*/
function getDispDate(strDate) {
var d = convertLocalTimezone(strDate);
var formattedDate = "";
if (_clientLang == "en") {
formattedDate = "" + (d.getMonth() + 1) + "/" + d.getDate() + "/" + d.getFullYear();
} else if (_clientLang == "fr") {
formattedDate = "" + lpad(d.getDate(), 2, "0") + "/" + lpad(d.getMonth() + 1, 2, "0") + "/" + d.getFullYear();
} else if (_clientLang == "de") {
formattedDate = "" + lpad(d.getDate(), 2, "0") + "." + lpad(d.getMonth() + 1, 2, "0") + "." + d.getFullYear();
} else if (_clientLang == "it") {
formattedDate = "" + lpad(d.getDate(), 2, "0") + "/" + lpad(d.getMonth() + 1, 2, "0") + "/" + d.getFullYear();
} else if (_clientLang == "es") {
formattedDate = "" + lpad(d.getDate(), 2, "0") + "/" + lpad(d.getMonth() + 1, 2, "0") + "/" + d.getFullYear();
} else if (_clientLang == "zh") {
formattedDate = "" + d.getFullYear() + "-" + lpad(d.getMonth() + 1, 2, "0") + "-" + lpad(d.getDate(), 2, "0");
} else if (_clientLang == "ja") {
formattedDate = "" + d.getFullYear() + "-" + lpad(d.getMonth() + 1, 2, "0") + "-" + lpad(d.getDate(), 2, "0");
} else if (_clientLang == "ru") {
formattedDate = "" + lpad(d.getDate(), 2, "0") + "." + lpad(d.getMonth() + 1, 2, "0") + "." + d.getFullYear();
} else if (_clientLang == "pt") {
formattedDate = "" + lpad(d.getDate(), 2, "0") + "-" + lpad(d.getMonth() + 1, 2, "0") + "-" + d.getFullYear();
} else if (_clientLang == "hi") {
formattedDate = "" + lpad(d.getDate(), 2, "0") + "-" + lpad(d.getMonth() + 1, 2, "0") + "-" + d.getFullYear();
} else {
formattedDate = "" + (d.getMonth() + 1) + "/" + d.getDate() + "/" + d.getFullYear();
}
return formattedDate;
}
/**
* 결과 값 중 날짜 등 형식을 변경
*
* @param data data
*/
function convertDispFormat(data) {
var reTimestamp = /[0-9]{4}[-][0-9]{2}[-][0-9]{2}[T][0-9]{2}[:][0-9]{2}[:][0-9]{2}[+][0-9]{4}/;
if (!data.result.length) {
for (var key in data.result) {
// 2012-06-27T00:00:00+0900
thisValue = data.result[key];
if (reTimestamp.test(thisValue)) {
eval("data.result." + key + "_tz = getDispTime(data.result[key]);");
eval("data.result." + key + "_tz_d = getDispDate(data.result[key]);");
}
//alert(data.result[key]+"//"+key);
}
} else {
for (var i = 0; data.result != null && i < data.result.length; i++) {
for (var key in data.result[i]) {
// 2012-06-27T00:00:00+0900
thisValue = data.result[i][key];
if (reTimestamp.test(thisValue)) {
eval("data.result[i]." + key + "_tz = getDispTime(data.result[i][key]);");
eval("data.result[i]." + key + "_tz_d = getDispDate(data.result[i][key]);");
}
//alert(data.result[i][key]+"//"+key);
}
}
}
return data;
}
/**
* 검색어 Highlight 처리
* @param data data
*/
function highlightKeyword(data) {
var keyword = $("#keyword").val();
var target = "," + $("#target").val() + ",";
for (var i = 0; data.result != null && i < data.result.length; i++) {
for (var key in data.result[i]) {
thisValue = data.result[i][key];
if (target.indexOf("," + key + ",") != -1) {
thisValue = thisValue.replace(keyword.toLowerCase(), "" + keyword.toLowerCase() + "");
thisValue = thisValue.replace(keyword.toUpperCase(), "" + keyword.toUpperCase() + "");
eval("data.result[i]." + key + "_kw = thisValue;");
}
}
// TODO : 확장의 여지가 있음
if (target.indexOf(",name,") != -1 && data.result[i]["firstName"] && data.result[i]["lastName"] ) {
thisValue = data.result[i]["firstName"] + " " + data.result[i]["lastName"];
thisValue = thisValue.replace(keyword.toLowerCase(), "" + keyword.toLowerCase() + "");
thisValue = thisValue.replace(keyword.toUpperCase(), "" + keyword.toUpperCase() + "");
data.result[i].name_kw = thisValue;
}
// TODO : 확장의 여지가 있음
if (target.indexOf(",firstName,lastName,") != -1 && data.result[i]["firstName"] && data.result[i]["lastName"] ) {
thisValue = data.result[i]["firstName"] + " " + data.result[i]["lastName"];
thisValue = thisValue.replace(keyword.toLowerCase(), "" + keyword.toLowerCase() + "");
thisValue = thisValue.replace(keyword.toUpperCase(), "" + keyword.toUpperCase() + "");
data.result[i].name_kw = thisValue;
}
}
return data;
}
/**
* 검색어 Highlight 처리
* @param data data
*/
function customHighlightKeyword(data, keywordId, targetId) {
var keyword = $("#"+keywordId).val();
var target = "," + $("#"+targetId).val() + ",";
for (var i = 0; data.result != null && i < data.result.length; i++) {
for (var key in data.result[i]) {
thisValue = data.result[i][key];
if (target.indexOf("," + key + ",") != -1) {
thisValue = thisValue.replace(keyword, "" + keyword + "");
eval("data.result[i]." + key + "_kw = thisValue;");
}
}
// TODO : 확장의 여지가 있음
if (target.indexOf(",name,") != -1 && data.result[i]["firstName"] && data.result[i]["lastName"] ) {
thisValue = data.result[i]["firstName"] + " " + data.result[i]["lastName"];
thisValue = thisValue.replace(keyword, "" + keyword + "");
data.result[i].name_kw = thisValue;
}
}
return data;
}
/**
* 검색어 highlight 처리
*/
function highlightKeyword3(keywordId) {
if ( keywordId ) {
$(".keyword").highlight($("#"+keywordId).val());
}
else {
$(".keyword").highlight($("#keyword").val());
}
}
/**
* List data를 jquery template에 setting
* @param tmplId 템플릿 ID
* @param targetId 템플릿이 위치할 target ID
* @param data response
* @param limit 목록 제한 개수
*/
function setListTemplete(tmplId, targetId, data, limit) {
if (limit == null) {
limit = $("#limit").val();
}
var listLength = 0;
if (limit != -1) {
listLength = limit - (data.result == null ? 0 : data.result.length);
}
$("#" + targetId).children().remove();
$("#" + tmplId).tmpl(data.result).appendTo("#" + targetId);
for (var i = 0; i < listLength; i++) {
$("#" + tmplId).tmpl(null).appendTo("#" + targetId);
}
}
/**
* 날짜를 입력받는 Datepicker 생성
*
* @param id Datepicker input object id
*/
function createDatepicker(id) {
$('#' + id).datepicker({
numberOfMonths: 3,
changeMonth: true,
showCurrentAtPos: 1,
showButtonPanel: true
});
$.datepicker.setDefaults($.datepicker.regional['default']);
$("#" + id).datepicker("option","dateFormat",store_nationality_dateFormat[_clientLang]);
}
/**
* 기간을 입력받는 Datepicker 생성
*
* @param fromId from Datepicker input object id
* @param toId to Datepicker input object id
*/
function createDatePickerRange(fromId, toId) {
$("#" + fromId).datepicker({
numberOfMonths: 3,
changeMonth: true,
showCurrentAtPos: 1,
showButtonPanel: true,
onSelect: function(selectedDate) {
$("#" + toId).datepicker("option", "minDate", selectedDate);
}
});
$("#" + toId).datepicker({
changeMonth: true,
numberOfMonths: 3,
showButtonPanel: true,
onSelect: function(selectedDate) {
$("#" + fromId).datepicker("option", "maxDate", selectedDate);
}
});
$.datepicker.setDefaults($.datepicker.regional['default']);
$("#" + fromId).datepicker("option","dateFormat",store_nationality_dateFormat[_clientLang]);
$("#" + toId).datepicker("option","dateFormat",store_nationality_dateFormat[_clientLang]);
}
/**
* alert 대체
* @param {Object} title 제목
* @param {Object} content 내용 (HTML 가능)
* @param {Object} btnTitle 확인 버튼 타이틀. 값이 null이면 'OK'
* @param {Object} w 창 가로길이
*/
var popalertStr = "";
function popAlert(title, content, btnTitle1, w) {
btnTitle1 = btnTitle1 == null ? "OK" : btnTitle1;
w = (w == null || w < 284) ? 284 : w;
var defer = $.Deferred();
$("#popAlertTitle").html(title);
$("#popAlertContent").html(content);
$("#popAlertTitleOK").html(btnTitle1);
$("#popAlertOK").bind("click", function() {
defer.resolve();
$.unblockUI();
$("#popAlert").remove();
$("#createAlert").html(popalertStr);
});
$("#popAlertClose").bind("click", function() {
//defer.resolve();
$.unblockUI();
$("#popAlert").remove();
$("#createAlert").html(popalertStr);
});
$("#popAlert").css("width", w + "px");
$.blockUI({
message: $('#popAlert'),
css: {
border: 'none',
top: ($(window).height() - $("#popAlert").height()) /2 + 'px',
left: ($(window).width() - w) /2 + 'px',
width: '0px',
height: '0px',
cursor:null
},
overlayCSS: {
backgroundColor: '#fff',
opacity: 0.6
}
});
$('.blockUI.blockOverlay').css("cursor","default");
// window resize 시 popup 위치 조정
$(window).resize(function(){
if($("#popAlert").length == 1 && $("#popAlert").is(":visible")) {
popupResize("popAlert");
}
});
return defer.promise();
}
/**
* confirm 대체
* @param {Object} title 제목
* @param {Object} content 내용 (HTML 가능)
* @param {Object} btnTitle1 확인 버튼 타이틀. 값이 null이면 'OK'
* @param {Object} btnTitle2 취소 버튼 타이틀. 값이 null이면 'Cancel'
* @param {Object} w 창 가로길이
*/
function popConfirm(title, content, btnTitle1, btnTitle2, w) {
btnTitle1 = btnTitle1 == null ? "OK" : btnTitle1;
btnTitle2 = btnTitle2 == null ? "Cancel" : btnTitle2;
w = (w == null || w < 284) ? 284 : w;
var defer = $.Deferred();
$("#popConfirmTitle").html(title);
$("#popConfirmContent").html(content);
$("#popConfirmTitleOK").html(btnTitle1);
$("#popConfirmTitleCancel").html(btnTitle2);
$("#popConfirmOK").bind("click", function() {
defer.resolve();
if($("#popAlert").is(":hidden")){$.unblockUI();}
//$.unblockUI();
});
$("#popConfirmCancel").bind("click", function() {
defer.reject();
//$.unblockUI();
if($("#popAlert").is(":hidden")){$.unblockUI();}
});
$("#popConfirmClose").bind("click", function() {
//defer.reject();
//$.unblockUI();
if($("#popAlert").is(":hidden")){$.unblockUI();}
});
$("#popConfirm").css("width", w + "px");
$.blockUI({
message: $('#popConfirm'),
css: {
border: 'none',
top: ($(window).height() - $("#popConfirm").height()) /2 + 'px',
left: ($(window).width() - w) /2 + 'px',
width: '0px',
height: '0px',
cursor:null
},
overlayCSS: {
backgroundColor: '#fff',
opacity: 0.6
}
});
$('.blockUI.blockOverlay').css("cursor","default");
// window resize 시 popup 위치 조정
$(window).resize(function(){
if($("#popConfirm").length == 1 && $("#popConfirm").is(":visible")) {
popupResize("popConfirm");
}
});
return defer.promise();
}
/**
* confirm 대체
* @param {Object} title 제목
* @param {Object} content 내용 (HTML 가능)
* @param {Object} btnTitle1 확인 버튼 타이틀. 값이 null이면 'OK'
* @param {Object} btnTitle2 취소 버튼 타이틀. 값이 null이면 'Cancel'
* @param {Object} w 창 가로길이
*/
function popConfirmMulti(title, content, btnTitle1, btnTitle2, w, isOkUnblock, isCancelUnblock) {
btnTitle1 = btnTitle1 == null ? "OK" : btnTitle1;
btnTitle2 = btnTitle2 == null ? "Cancel" : btnTitle2;
w = (w == null || w == 0) ? 284 : w;
var defer = $.Deferred();
$("#popConfirmTitle").html(title);
$("#popConfirmContent").html(content);
$("#popConfirmTitleOK").html(btnTitle1);
$("#popConfirmTitleCancel").html(btnTitle2);
$("#popConfirmOK").bind("click", function() {
defer.resolve();
if ( isOkUnblock ) {
$.unblockUI();
}
});
$("#popConfirmCancel").bind("click", function() {
defer.reject();
if ( isCancelUnblock ) {
$.unblockUI();
}
});
$("#popConfirmClose").bind("click", function() {
$.unblockUI();
});
$("#popConfirm").css("width", w + "px");
$.blockUI({
message: $('#popConfirm'),
css: {
border: 'none',
css: {padding:0, margin:0},
overlayCSS: {backgroundColor: '#00f'},
top: ($(window).height() - $("#popConfirm").height()) /2 + 'px',
left: ($(window).width() - w) /2 + 'px',
width: w + 'px',
height: $("#popConfirm").height() + 'px'
},
overlayCSS: {
backgroundColor: '#fff',
opacity: 0.6
}
});
return defer.promise();
}
/**
* alert 대체
* @param {Object} title 제목
* @param {Object} content 내용 (HTML 가능)
* @param {Object} btnTitle 확인 버튼 타이틀. 값이 null이면 'OK'
* @param {Object} w 창 가로길이
*/
function popAlertDiv(title, content, btnTitle1, w,zIndex) {
btnTitle1 = btnTitle1 == null ? "OK" : btnTitle1;
w = (w == null || w == 0) ? 284 : w;
var defer = $.Deferred();
$("#popAlertTitleDiv").html(title);
$("#popAlertContentDiv").html(content);
$("#popAlertTitleOKDiv").html(btnTitle1);
$("#popAlertOKDiv").bind("click", function() {
defer.resolve();
$("#popAlertDiv").hide();
});
$("#popAlertCloseDiv").bind("click", function() {
defer.resolve();
$("#popAlertDiv").hide();
});
$("#popAlertDiv").css("width", w + "px");
$("#popAlertDiv").css({
top: ($(window).height() - $("#popAlertDiv").height()) /2 + 'px',
left: ($(window).width() - w) /2 + 'px',
"z-index": zIndex ? zIndex : 9999,
position:"fixed"
});
$("#popAlertDiv").show();
// window resize 시 popup 위치 조정
$(window).resize(function(){
if($("#popAlertDiv").length == 1 && $("#popAlertDiv").is(":visible")) {
popupResize("popAlertDiv");
}
});
return defer.promise();
}
/**
* confirm 대체
* @param {Object} title 제목
* @param {Object} content 내용 (HTML 가능)
* @param {Object} btnTitle1 확인 버튼 타이틀. 값이 null이면 'OK'
* @param {Object} btnTitle2 취소 버튼 타이틀. 값이 null이면 'Cancel'
* @param {Object} w 창 가로길이
* @param {int} zIndex 레이어의 z-index
*/
function popConfirmDiv(title, content, btnTitle1, btnTitle2, w, zIndex) {
btnTitle1 = btnTitle1 == null ? "OK" : btnTitle1;
btnTitle2 = btnTitle2 == null ? "Cancel" : btnTitle2;
w = (w == null || w == 0) ? 284 : w;
var defer = $.Deferred();
$("#popConfirmTitle").html(title);
$("#popConfirmContent").html(content);
$("#popConfirmTitleOK").html(btnTitle1);
$("#popConfirmTitleCancel").html(btnTitle2);
$("#popConfirmOK").bind("click", function() {
defer.resolve();
if($("#popAlert").is(":hidden"))
$("#popConfirm").hide();
});
$("#popConfirmCancel").bind("click", function() {
defer.reject();
if($("#popAlert").is(":hidden"))
$("#popConfirm").hide();
});
$("#popConfirmClose").bind("click", function() {
defer.reject();
if($("#popAlert").is(":hidden"))
$("#popConfirm").hide();
});
$("#popConfirm").css("width", w + "px");
$("#popConfirm").css({
top: (($(window).height() - $("#popConfirm").height() ) /2) + 'px',
left: ($(window).width() - w) /2 + 'px',
"z-index": zIndex ? zIndex : 9999,
position:"fixed"
});
$("#popConfirm").show();
// window resize 시 popup 위치 조정
$(window).resize(function(){
if($("#popConfirm").length == 1 && $("#popConfirm").is(":visible")) {
popupResize("popConfirm");
}
});
return defer.promise();
}
function notService() {
alert(getMsg("inf_0017"));
}
/*
dateFormat: 'yymmdd', //데이터 포멧형식
changeMonth: true, //달별로 선택 할 수 있다.
changeYear: true, //년별로 선택 할 수 있다.
showOtherMonths: true, //이번달 달력안에 상/하 빈칸이 있을경우 전달/다음달 일로 채워준다.
selectOtherMonths: true,
showMonthAfterYear: true,
monthNamesShort: ['01','02','03','04','05','06','07','08','09','10','11','12'],
yearRange: '2011:c+4',
buttonImage: '/images/btn/btn_cal.png',
buttonImageOnly: true,
buttonText: '일자선택',
showOn: 'button',
dayNamesMin: ["S", "M", "T", "W", "T", "F", "S"],
minDate: new Date(2012, 1 - 1, 1),
maxDate: "+0D",
navigationAsDateFormat: true,
*/
/**
* Table Sort
* @param tableId : 테이블 ID
*/
function tableSort(tableId, tbodyId)
{
$("th", $("#"+tableId)).each(function(column){
if($(this).hasClass("sorting"))
{
var direction = -1;
$(this).find("span:eq(1)").addClass("arrow");
if(!$(this).find("button").hasClass("up"))
$(this).find("button").addClass("dim");
$(this).click(function(){
$("#"+tbodyId).removeData();
if($(this).find("button").hasClass("up"))
{
direction = -1;
}else{
direction = 1;
}
var rows = $("#"+tbodyId).find("tr").get();
rows.sort(function(a, b) {
var strA = $(a).children('td').eq(column).text();
var strB = $(b).children('td').eq(column).text();
return compareString(strA, strB)*direction;
});
$("#"+tableId).find("th:not(:eq("+column+")) button").removeClass("up");
$("#"+tableId).find("th:not(:eq("+column+")) button").addClass("dim");
$(this).find("button").removeClass("dim");
if($(this).find("button").hasClass("up"))
$(this).find("button").removeClass("up");
else
$(this).find("button").addClass("up");
$.each(rows, function(index, row) {
$("#"+tbodyId).append(row);
});
});
}
});
}
/**
* Popup Window를 화면의 중앙에 띄운다. 예) 아이디확인
*
* @param url URL
* @param winName popup window name
* @param w width
* @param h height
* @param scroll 스크롤 여부(yes/no)
*/
function popWin(url, winName, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
var win = popWinPosition(url, winName, w, h, winl, wint, scroll);
}
/**
* Popup Window를 지정한 위치에 띄운다. 예) 아이디확인
*
* @param url URL
* @param winName popup window name
* @param w width
* @param h height
* @param l left
* @param t top
* @param scroll 스크롤 여부(yes/no)
*/
function popWinPosition(url, winName, w, h, l, t, scroll) {
if (name == null) {
name = "_blank";
}
if (w == null) {
w = 400;
}
if (h == null) {
h = 300;
}
if (scroll == null) {
scroll = "yes";
}
var winl = l;
var wint = t;
winprops = 'height=' + h + ',width=' + w + ',top=' + wint + ',left=' + winl + ',scrollbars=' + scroll + ',resizable=yes,toolbar=no,location=no,directories=no,status=yes,menubar=no';
var win = window.open(url, winName, winprops);
if (parseInt(navigator.appVersion) >= 4) {
try {
win.window.focus();
} catch(e) {}
}
return win;
}
/**
* Vertical Middle, Horizontal Center Popup Layer Load
* @param url : Load Url
* @param width : Popup Layer width
* @param height : Popup Layer height
* @param changePosition : Window Resize Event 시에 위치 변경 여부
*/
function popLayer(url, width, height, changePosition)
{
if($("#popLayer").length == 0)
$("#contents").append("");
$("#popLayer").load(_context+url);
var offsetTop = ($(window).height() - height) /2;
var offsetLeft = ($(window).width() - width) /2;
offsetTop = (offsetTop > 0)? offsetTop:0;
offsetLeft = (offsetLeft > 0)? offsetLeft:0;
$.blockUI({
message: $('#popLayer'),
css: {
border: 'none',
top: offsetTop + 'px',
left: offsetLeft+ 'px',
width: '0px',
height: '0px',
cursor:null
},
overlayCSS: {
backgroundColor: '#fff',
opacity: 0.6
}
});
$("body").children().filter(".blockUI").css("cursor", "default");
if(changePosition)
{
$(window).resize(function(){
if($("#popLayer").length == 1 && $("#popLayer").is(":visible"))
{
popLayerResize();
}
});
}
}
/**
* Vertical Middle, Horizontal Center Popup Layer Load
* (페이지 내 DIV 영역을 popup으로 띄움)
* @param layerId : DIV id
* @param width : Popup Layer width
* @param height : Popup Layer height
* @param changePosition : Window Resize Event 시에 위치 변경 여부
*/
function popLayerDiv(layerId, width, height, changePosition)
{
var offsetTop = ($(window).height() - height) /2;
var offsetLeft = ($(window).width() - width) /2;
offsetTop = (offsetTop > 0)? offsetTop:0;
offsetLeft = (offsetLeft > 0)? offsetLeft:0;
$.blockUI({
message: $("#" + layerId),
css: {
border: 'none',
top: offsetTop + 'px',
left: offsetLeft+ 'px',
width: '0px',
height: '0px',
textAlign : "",
cursor:null
},
overlayCSS: {
backgroundColor: '#fff',
opacity: 0.6
}
});
$("body").children().filter(".blockUI").css("cursor", "default");
if(changePosition)
{
popupResize(layerId);
$(window).resize(function(){
if($("#" + layerId).length == 1 && $("#" + layerId).is(":visible"))
{
popupResize(layerId);
}
});
}
}
/**
* Window Resize Event 발생 시에 Popup Layer 위치 변경
*/
function popupResize(layerId) {
var wHeight = $(window).height();
var wWidth = $(window).width();
var sTop = document.body.scrollTop == 0 ? document.documentElement.scrollTop : document.body.scrollTop;
var sLeft = document.body.scrollLeft == 0 ? document.documentElement.scrollLeft : document.body.scrollLeft;
var offsetTop = (wHeight - $("#" + layerId).height()) /2 + sTop;
var offsetLeft = (wWidth - $("#" + layerId).width()) /2 + sLeft;
offsetTop = offsetTop > 0 ? offsetTop : 0;
offsetLeft = offsetLeft > 0 ? offsetLeft : 0;
$("#" + layerId).offset({
top: offsetTop,
left: offsetLeft
});
}
/**
* Window Resize Event 발생 시에 Popup Layer 위치 변경
*/
function popLayerResize() {
popupResize("popLayer");
}
/**
* Popup Layer 닫기
*/
function popLayerClose()
{
$.unblockUI();
}
/**
* 내용이 긴 컬럼인 경우 말줄임 & 툴팁 표시
* API 서버로부터 데이터를 가져와 화면에 display한 후 call
*/
function setTooltip(tagName) {
if ( !tagName ) {
tagName = "td";
}
var tooltipCell = $(tagName+".tooltipTd");
tooltipCell.wrapInner("");
tooltipCell.on({
mouseenter : function(e) {
var cellwidth = $(this).width();
var spanwidth = $(this).children().children().width();
if (spanwidth + 24 >= cellwidth) {
$(this).append("");
$(this).css("coursor","default");
$("div.tooltipBox").css("width", cellwidth + "px");
$("div.tooltipBox .customTooltipScrollV").text($(this).text());
$("div.tooltipBox").css("display","block");
$("div.tooltipBox .customTooltipScrollV").css("height", "auto");
$("div.tooltipBox .customTooltipScrollV").css("max-height", "160px");
/*
//Scroll
if($("div.tooltipBox .customTooltipScrollV").height() > 160)
{
$("div.tooltipBox").css("padding-right", "2px");
$("div.tooltipBox .customTooltipScrollV").css("height", "160");
$(".customTooltipScrollV").mCustomScrollbar({
scrollButtons:{
enable:true
}
});
}else{
$("div.tooltipBox").css("padding-right", "8px");
}*/
if($("div.tooltipBox .customTooltipScrollV").height() == 160)
{
$("div.tooltipBox .customTooltipScrollV").css("height", "160");
$("div.tooltipBox .customTooltipScrollV").dotdotdot({
"height":160,
"ellipsis":"...",
"wrap":"letter"
});
}
var isOverflow = false;
var offset = $(this).offset();
if (checkBrowser() == "Firefox") {
var offL = 0;
try {
offL = document.getElementById("wrap").offsetLeft;
} catch(e) {}
$("div.tooltipBox").css("left", (e.clientX - offL + 14) + "px");
$("div.tooltipBox").css("top", (offset.top - 61) + "px");
} else {
$("div.tooltipBox").css("left", (e.clientX + 14 - offset.left) + "px");
}
if($(window).height() < (e.clientY+$("div.tooltipBox").height()+11))
isOverflow = true;
if(isOverflow)
$("div.tooltipBox").css("top", $("div.tooltipBox").position().top-($("div.tooltipBox").height()+11) + "px");
}
},
mouseleave:function(){
$("div.tooltipBox").remove();
}
});
tooltipCell.each(function(index) {
cellwidth = $(this).width();
//console.log('cellwidth=' + cellwidth);
$(this).children().css("width", cellwidth);
//$(this).children().css("height", "28px");
});
}
function setColumnHead() {
$("th.columnHead").each(function(index) {
if ($(this).hasClass("textLeft")) {
$(this).children().css("text-align", "left");
}
});
}
function setTooltipHead() {
var tooltipCell = $("th.tooltipTh");
tooltipCell.on({
mouseenter : function(e) {
var cellwidth = $(this).width();
var spanwidth = $(this).children().children().width();
//console.log("spanwidth > cellwidth : " + spanwidth + " > " + cellwidth);
if (spanwidth + 21 >= cellwidth) {
$(this).append("");
$(this).css("coursor","default");
//console.log("e.clientX : " + e.clientX);
var offset = $(this).offset();
//console.log("td left : " + offset.left);
//alert("$(this).scrollLeft = " + $(this).offsetLeft);
$("div.tooltipBox").css("left", (e.clientX + 14 - offset.left) + "px");
$("div.tooltipBox").css("width", cellwidth + "px");
$("div.tooltipBox").css("display","block");
$("div.tooltipBox").text($(this).text());
}
},
mouseleave:function(){
$("div.tooltipBox").remove();
}
});
tooltipCell.each(function(index) {
$(this).children().children("[id ^= 'sort_']").addClass("sortArrow");
if ($(this).hasClass("textLeft")) {
$(this).children().children(".headTitle").css("text-align", "left");
}
cellwidth = $(this).width();
//console.log('cellwidth=' + cellwidth);
//$(this).children().children(".headTitle").css("width", cellwidth - 20);
//$(this).children().css("height", "28px");
});
var tooltipCell2 = $("th.columnHead");
tooltipCell2.each(function(index) {
if ($(this).hasClass("textLeft")) {
$(this).children().css("text-align", "left");
}
});
}
/**
* 내용이 긴 컬럼 말줄임.
* API 서버로부터 데이터를 가져와 화면에 display한 후 call
* @param tbodyId : 말줄임 할 tbody ID
*/
function setEllipsis(tbodyId)
{
var tbodyId = $("#"+tbodyId);
if($(tbodyId).find("td.tooltipTd").length == 0)
{
$(tbodyId).parents("table").addClass("fixedTable");
}
$(tbodyId).find("td").each(function(){
if(!$(this).hasClass("tooltipTd")
&& $(this).find("input").length == 0
&& $(this).find(".bagicButton").length == 0)
{
var afterOpt = "";
if($(this).find(".notice_clear").length > 0)
{
afterOpt = "span.notice_clear";
}else if($(this).find("img").length > 0){
afterOpt = "img";
}else{
afterOpt = "";
}
$(this).dotdotdot({
"height":20,
"ellipsis":"…",
"wrap":"letter",
"after":afterOpt
});
}
});
}
function blockProgress() {
blockProgressMsg("inf_0020");
}
function blockProgressMsg(msgCode) {
$("#blockProgress > p").html(getMsg(msgCode));
$.blockUI({
message: $('#blockProgress'),
css: {
border: 'none',
padding:0,
margin:0,
top: ($(window).height() - 150) /2 + 'px',
left: ($(window).width() - 300) /2 + 'px',
width: '300px',
height: '150px'
},
overlayCSS: {
backgroundColor: '#fff',
opacity: 0.6
}
});
$('.blockUI.blockOverlay').css("cursor","default");
}
function unblockProgress() {
$.unblockUI();
}
function blockDivProgress(obj) {
$(obj).block({
message: $('#blockProgress'),
css: {
border: 'none',
margin:30,
width: '300px',
height: '150px'
},
overlayCSS: {
backgroundColor: '#fff',
opacity: 0.6
}
});
}
function unblockDivProgress(obj) {
$(obj).unblock();
}
function popBlockDivProgress(obj) {
$(obj).block({
message: $('#blockProgress'),
css: {
border: 'none',
margin:0,
width: '300px',
height: '150px',
cursor:null
},
overlayCSS: {
backgroundColor: 'none',
opacity: 0.6
}
});
}
function popUnblockDivProgress(obj) {
$(obj).unblock();
}
/**
* 한글포함 글자 Byte 추출 함수
*
* @param lvStr : Byte환산 할 String
*/
function Byte_Length(lvStr){
var resultSize = 0;
if (lvStr == null) return 0;
for(var i=0; i 128) ? 2 : 1;
if (l > len) return str.substring(0,i);
}
return str;
}
function chr_byte(chr){
if(escape(chr).length > 4)
return 2;
else
return 1;
}
/**
* alert 대체
* @param {Object} title 제목
* @param {Object} content 내용 (HTML 가능)
* @param {Object} btnTitle 확인 버튼 타이틀. 값이 null이면 'OK'
* @param {Object} w 창 가로길이
*/
/**
* Vertical Middle, Horizontal Center Popup Layer Load
* (페이지 내 DIV 영역을 popup으로 띄움)
* @param layerId : DIV id
* @param width : Popup Layer width
* @param height : Popup Layer height
* @param changePosition : Window Resize Event 시에 위치 변경 여부
function SPStringDiv(layerId, width, height, changePosition)
{
var offsetTop = ($(window).height() - height) /2;
var offsetLeft = ($(window).width() - width) /2;
offsetTop = (offsetTop > 0)? offsetTop:0;
offsetLeft = (offsetLeft > 0)? offsetLeft:0;
$("#"+layerId).fadeIn("slow");
$("#"+layerId).css('border' ,"none");
if(changePosition)
{
popupResize1(layerId);
$(window).resize(function(){
if($("#" + layerId).length == 1 && $("#" + layerId).is(":visible"))
{
popupResize1(layerId);
}
});
}
} */
/**
* Window Resize Event 발생 시에 Popup Layer 위치 변경
function popupResize1(layerId) {
var wHeight = $(window).height();
var wWidth = $(window).width();
var sTop = document.body.scrollTop == 0 ? document.documentElement.scrollTop : document.body.scrollTop;
var sLeft = document.body.scrollLeft == 0 ? document.documentElement.scrollLeft : document.body.scrollLeft;
var offsetTop = (wHeight - $("#" + layerId).height()+5) /2 + sTop;
var offsetLeft = (wWidth - $("#" + layerId).width()+5) /2 + sLeft;
console.log(offsetTop);
console.log(offsetLeft);
offsetTop = offsetTop > 0 ? offsetTop : 0;
offsetLeft = offsetLeft > 0 ? offsetLeft+300 : 0;
offsetLeft = offsetLeft > 407 ? offsetLeft : 120;
$("#" + layerId).offset({
top: "376",
left: offsetLeft+92
});
} */
function formData(name, value){
var objMethod = document.createElement("input");
objMethod.type = "hidden";
objMethod.name = name;
objMethod.value = value;
document.getElementById("NoneForm").insertBefore(objMethod, null);
}
function formDataDelete(name){
$("#NoneForm input[name=\""+name+"\"]").remove();
}
function toInt(str) {
var n = null;
try {
n = parseInt(str, 10);
} catch (e) {}
return n;
}
/**
* ul 페이징 처리
* API 서버로부터 데이터를 가져와 화면에 display한 후 call
* @param tableId : 페이징처리할 할 tableId ID
* @param pagingNum : 페이징 시작 할 pagingNum
*/
function tablePaging(tableId, pagingNum, pagingId)
{
var viewListNum = 9;
var firstList = (pagingNum-1)*viewListNum;
var lastList = pagingNum*viewListNum;
var pagingTotal;
$("li", $("#"+tableId)).each(function(column){
$("#"+tableId).find("li:eq("+(column+1)+")").show();
if(!(column >= firstList && column < lastList)){
$("#"+tableId).find("li:eq("+(column+1)+")").hide();
}
pagingTotal = column;
});
drawCustomPaging(pagingId, pagingTotal , "tablePaging", tableId, firstList, viewListNum);
if(pagingTotal < viewListNum ){
$("#"+pagingId).hide();
}else{
$("#"+pagingId).show();
}
}
function innerTextArea( objName , txt ) {
var textAreaValue = $("#"+objName).val();
textAreaValue = textAreaValue + txt;
$("#"+objName).val(textAreaValue);
$("#text_byte").html(Byte_Length($("#sms_contents").val()));
/*eval("document.all." + objName + ".focus()");
var selRange = document.selection.createRange();
selRange.text = txt;*/
}