//////////////////////////////////////////////////////////////////////////////////////// //Const //////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////// //인증관련 공통 변수 //////////////////////////////////////////////////////////////////////////////////////// let userName; let userJti; let fullName; let userApplicationRoles; let userAttributes; let userEnabled; let userGroups; let userID; let userRealmRoles; let permissions; let userEmail; let scrollPos = 0; let currentLanguagePack = { language: null, languagePack: null }; //////////////////////////////////////////////////////////////////////////////////////// //Document Ready //////////////////////////////////////////////////////////////////////////////////////// $(function () { var str = window.location.href; if (str.indexOf("landing_") > 0) { console.table("313DEVGRP 커뮤니티에 오신것을 환영합니다."); $("div.content.container").removeClass("content"); $(".content-footer").addClass("glass"); runScript(); } else { authUserCheck(); } }); function runScript() { // Page load & 상단 페이지 로드 프로그래스바 topbarConfig(); topbar.show(); setTimeout(function () { $(".container").fadeIn("slow"); topbar.hide(); }, 2000); /* 맨위로 아이콘 */ rightBottomTopForwardIcon(); var urlParams = new URL(location.href).searchParams; var onlyContents = urlParams.get("withoutLayer"); if (isEmpty(onlyContents)) { $("body").removeAttr("class"); } else { $("body").addClass("sidebar-hidden"); $("header.page-header").hide(); } $(window).on("scroll", function (event) { var scroll = $(event.target).scrollTop(); var $navbar = $(".navbar"); if (scroll >= 10) { $navbar.addClass("has-scroll"); } else { $navbar.removeClass("has-scroll"); } }); $(document) .on("shown.bs.tab", "a[data-toggle='tab']", function () { window.dispatchEvent(new Event("resize")); }) .on("click", "[data-help]", function () { var contentsId = $(this).data("help"); var contentsType = $(this).data("help-type"); console.log(contentsId); $("#quickstart_overlay").removeClass("hidden"); $("body").addClass("modal-open"); if (contentsType === "page") { return setPageManual(contentsId); } setSectionManual(contentsId); }); $("#quickstart_overlay").on("click", function (event) { var $target = $(event.target); if (!$target.closest(".mn-close").length && $target.closest(".mn-modal").length) { return; } $(this).addClass("hidden"); $("body").removeClass("modal-open"); }); if (ajax_setup()) { $(".loader").removeClass("hide"); var page = urlParams.get("page"); if (isEmpty(page)) { page = "index"; } if (includeLayout(page)) { loadTheme(); $.getScript("js/" + page + ".js", function () { /* 로그인 인증 여부 체크 함수 */ execDocReady(); dwr_login(userName, userName); menu_setting(); }); } } } function setPageManual(help) { var contentArea = $("#content_area"); contentArea.removeClass("mn-modal--section").find(".mn-close").siblings().remove(); var manualDataPath = "./help/full-page/" + (getCookie("locale") || "ko") + "/" + help + ".json"; $.getJSON(manualDataPath, function (data) { var meta = data.meta; var titles = ["Product", "Requirement", "Management"]; var left = $("
"); var pad = $("").append($("").text("Quickstart Guide")); var flowDiagram = $(""); var flowNav = $("").append( titles.map(function (title, index) { var fragment = $(document.createDocumentFragment()); var current = title === meta.l1; fragment.append( $("") .addClass(current ? "active" : "") .append($("").text(title).append("")) ); if (index < titles.length - 1) { fragment.append($("")); } return fragment; }) ); var flow = data.flow; var flows = [ { title: "Product", contents: function (current, label) { return $("") .append( $("") .addClass(current && label === "Status" ? "main" : "") .text("Product") ) .append( $("") .append($("").text(flow.product[0])) .append($("")) .append($("").text(flow.product[1])) ) .append( $("") .addClass(current && ["Host", "Application", "Database", "Interface"].includes(label) ? "main" : "") .text("Version") ); } }, { title: "Requirement", contents: function (current, label) { return $("") .append( $("") .addClass(current && ["Application", "Database", "Interview", "Service"].includes(label) ? "main" : "") .text("Requirement") ) .append( $("") .append($("").text(flow.requirement[0])) .append($("")) .append($("").text(flow.requirement[1])) ) .append( $("") .addClass(current && label === "Migration" ? "main" : "") .text("Issue(ALM)") ); } }, { title: "Management", contents: function (current, label) { return $(document.createDocumentFragment()).append( $("").append( $.map(["Time", "Scope", "Resource", "Cost"], function (item) { return $("") .text(item) .addClass(current && item === label ? "main" : ""); }) ) ); } } ]; var flowRow = $("").append( $.map(flows, function (flow, index) { var fragment = $(document.createDocumentFragment()); var current = flow.title === meta.l1; fragment.append( $("") .addClass(current ? "highlighted" : "") .append(flow.contents(current, meta.l2)) ); if (index < titles.length - 1) { fragment.append($("").text(contentDesc)); }) ); }); }) ); var descArea = $("
").text(contentDesc));
})
);
contentArea.append(header, imageArea, navArea, descArea);
});
}
function menu_setting() {
console.log("롤에 의한 메뉴를 설정합니다.");
var role_user = "ROLE_USER";
var role_manager = "ROLE_MANAGER";
var role_admin = "ROLE_ADMIN";
if (isEmpty(permissions) == false && permissions.indexOf(role_user) != -1) {
console.log("user 권한의 메뉴를 표현합니다.");
$("#menu_login").addClass("hide");
$("#menu_dashboard").removeClass("hide");
$("#menu_detail").removeClass("hide");
}
if (isEmpty(permissions) == false && permissions.indexOf(role_manager) != -1) {
console.log("manager 권한의 메뉴를 표현합니다.");
$("#menu_login").addClass("hide");
$("#menu_dashboard").removeClass("hide");
$("#menu_detail").addClass("hide");
$("#menu_product").removeClass("hide");
$("#menu_alm").removeClass("hide");
$("#menu_requirement").removeClass("hide");
}
if (isEmpty(permissions) == false && permissions.indexOf(role_admin) != -1) {
console.log("admin 권한의 메뉴를 표현합니다.");
$("#menu_login").addClass("hide");
$("#menu_dashboard").removeClass("hide");
$("#menu_detail").addClass("hide");
$("#menu_product").removeClass("hide");
$("#menu_alm").removeClass("hide");
$("#menu_requirement").removeClass("hide");
$("#menu_analysis").removeClass("hide");
$("#menu_report").removeClass("hide");
}
if ($("#menu_login").hasClass("hide") === false) {
console.log("class가 존재함. 로그인이 안됬다는 의미.");
// 현재 페이지의 URL 가져오기
var href = window.location.href;
// 현재 페이지의 origin 가져오기
var origin = window.location.origin;
// origin을 제외한 URL 경로 얻기
var path = href.replace(origin, "");
console.log(path);
if (path == "/php/gnuboard5/" || path == "/php/gnuboard5/index.php") {
const indexPHPTG = new tourguide.TourGuideClient({
// 상세 정보 투어 가이드
exitOnClickOutside: true,
autoScroll: false,
hidePrev: true,
hideNext: true,
showStepDots: false,
showStepProgress: false,
steps: TgGroup.indexPHPStep()
});
indexPHPTG.start();
}
}
}
function widgsterWrapper() {
$.fn.widgster.Constructor.prototype.fullscreen = function () {
var self = this.$element;
var $widget = $("#widget-fullscreen");
var url = self.data("layout");
var functionName = self.data("validate");
if (functionName && typeof window[functionName] === "function") {
var response = window[functionName]();
if (response === false) {
console.log("[common :: widgsterWrapper] :: Function call returned false, aborting fullscreen.");
return false;
}
}
if (url) {
$widget.load(url, function () {
$widget.show();
$widget.addClass("expandModalDarkBack");
$widget.find("[data-widgster='restore']").show();
$("body").css("overflow", "hidden");
self.trigger($.Event("fullscreened.widgster"));
widgsterDocReady();
});
} else {
console.log("[common :: widgsterWrapper] :: fullscreen layout 이 없습니다.");
}
return false;
};
$.fn.widgster.Constructor.prototype.restore = function () {
var $widget = $("#widget-fullscreen");
$widget.empty();
$widget.hide();
$widget.removeClass("expandModalDarkBack");
$widget.find("[data-widgster='restore']").hide();
$("body").css("overflow", "");
this.$element.trigger($.Event("restored.widgster"));
return false;
};
}
function 로드_완료_이후_실행_함수() {
톱니바퀴_초기설정();
loadLocale();
widgsterWrapper();
검색_이벤트_트리거();
우측_상단_사용자_정보_설정();
(function initNavigation($) {
//theme
let theme = getCookie("theme");
console.log("로드_완료_이후_실행_함수. theme =>", theme);
if (theme === "dark") {
$("#theme-toggle label:first-child").addClass("active");
} else {
$("#theme-toggle label:last-child").addClass("active");
}
$("#theme-toggle .btn").click(function () {
let $active_label = $(this).find("input").val();
console.log("common.js :: $active_label =>", $active_label);
if ($active_label === "light") {
$("body").addClass("light-theme");
setTheme("light");
} else {
$("body").removeClass("light-theme");
setTheme("dark");
}
});
$(".sign-out").click(function (event) {
event.preventDefault();
event.stopPropagation();
$.ajax({
url: "/logout",
type: "post",
contentType: "application/json;charset=UTF-8",
statusCode: {
200: function (data) {
location.href = "/";
}
},
beforeSend: function () {
//$("#regist-pdService").hide(); 버튼 감추기
},
complete: function () {
//$("#regist-pdService").show(); 버튼 보이기
}
});
});
})(jQuery);
(function ($) {
var COLOR_VALUES = [
"#408C83",
"#4F928A",
"#5E9892",
"#6D9E99",
"#7CA4A0",
"#8BAAA7",
"#9AB0AF",
"#A9B6B6"
];
var COLOR_EMPTY = "#555B6B";
$.COLOR_VALUES = COLOR_VALUES;
$.COLOR_EMPTY = COLOR_EMPTY;
})(jQuery);
}
////////////////////////////////////////////////////////////////////////////////////////
// 우측_상단_사용자_정보_설정
////////////////////////////////////////////////////////////////////////////////////////
function 우측_상단_사용자_정보_설정() {
var str = window.location.href;
if (str.indexOf("php") > 0) {
var account_html = "not supported";
$("#mobile_login_id").append(account_html);
$("#login_id").append(account_html);
} else {
var account_html = "\"" + userName + '"';
$("#mobile_login_id").append(account_html);
$("#login_id").append(account_html);
}
}
////////////////////////////////////////////////////////////////////////////////////////
// 플러그인 로드 모듈 ( 병렬 시퀀스 )
////////////////////////////////////////////////////////////////////////////////////////
function loadPlugin(url) {
return new Promise(function (resolve, reject) {
if (isJavaScriptFile(url)) {
$(".spinner").html(
' ' +
getFileNameFromURL(url) +
{
ko: " 자바스크립트를 다운로드 중입니다...",
en: " JavaScript is downloading...",
jp: " JavaScriptをダウンロード中です..."
}[getCookie("locale") || "ko"]
);
$.ajax({
url: url,
dataType: "script",
cache: true,
success: function () {
// The request was successful
console.log("[ common :: loadPlugin ] :: url = " + url + " 자바 스크립트 플러그인 로드 성공");
resolve(); // Promise를 성공 상태로 변경
},
error: function () {
// The request failed
console.error("[ common :: loadPlugin ] :: url = " + url + " 플러그인 로드 실패");
reject(); // Promise를 실패 상태로 변경
}
});
} else {
$(".spinner").html(
' ' +
getFileNameFromURL(url) +
{
ko: " 스타일시트를 다운로드 중입니다...",
en: " Downloading stylesheet...",
jp: " スタイルシートをダウンロード中です..."
}[getCookie("locale") || "ko"]
);
$("", {
rel: "stylesheet",
type: "text/css",
href: url
}).appendTo("head");
console.log("[ common :: loadPlugin ] :: url = " + url + " 스타일시트 플러그인 로드 성공");
resolve();
}
});
}
function getFileNameFromURL(url) {
var parts = url.split("/");
return parts[parts.length - 1];
}
function isJavaScriptFile(filename) {
return filename.endsWith(".js");
}
function loadPluginGroupSequentially(group) {
return group.reduce(function (promise, url) {
return promise.then(function () {
return loadPlugin(url);
});
}, Promise.resolve());
}
function loadPluginGroupsParallelAndSequential(groups) {
var promises = groups.map(function (group) {
return loadPluginGroupSequentially(group);
});
return Promise.all(promises).then(function () {
로드_완료_이후_실행_함수();
});
}
////////////////////////////////////////////////////////////////////////////////////////
// include 레이아웃 html 파일을 로드하는 함수
////////////////////////////////////////////////////////////////////////////////////////
function includeLayout(page) {
var includeArea = $("[data-include]");
var str = window.location.href;
$.each(includeArea, function () {
var self = $(this);
var url = self.data("include");
console.log("[ common :: includeLayout ] url = " + url);
var hrefLink = window.location.href;
var urlParams = new URL(location.href).searchParams;
var mode = urlParams.get("mode");
if (url.indexOf("page-navigation") !== -1) {
if (str.indexOf("landing_") > 0) {
url = "/arms/html/template/landing-navigation.html";
self.load(url, function () {
self.removeAttr("data-include");
});
} else {
url = "/arms/html/template/page-navigation.html";
self.load(url, function () {
self.removeAttr("data-include");
});
}
} else if (url.indexOf("content-header") !== -1) {
url = "html/" + page + "/content-header.html";
self.load(url, function () {
includeContents(self);
self.removeAttr("data-include");
});
} else if (url.indexOf("content-container") !== -1) {
url = "html/" + page + "/content-container.html";
self.load(url, function () {
includeContents(self);
self.removeAttr("data-include");
});
} else if (url.indexOf("page-sidebar") !== -1) {
if (mode == "detail" || hrefLink.indexOf("detail.html") > 0) {
url = "/arms/html/detail/page-sidebar.html";
self.load(url, function () {
self.removeAttr("data-include");
});
} else if (str.indexOf("backoffice") > 0) {
url = "/backoffice/html/template/page-sidebar.html";
self.load(url, function () {
self.removeAttr("data-include");
});
} else {
url = "/arms/html/template/page-sidebar.html";
self.load(url, function () {
self.removeAttr("data-include");
});
}
} else if (url.indexOf("content-footer") !== -1) {
if (str.indexOf("landing_") > 0) {
url = "/arms/html/template/landing-footer.html";
self.load(url, function () {
self.removeAttr("data-include");
});
} else {
url = "/arms/html/template/content-footer.html";
self.load(url, function () {
self.removeAttr("data-include");
});
}
} else {
self.load(url, function () {
self.removeAttr("data-include");
});
}
});
return true;
}
////////////////////////////////////////////////
// content-container 내부 첨부한 html include
////////////////////////////////////////////////
function includeContents(contentContainer) {
var includeArea = contentContainer.find("[data-include]");
$.each(includeArea, function () {
var self = $(this);
var url = self.data("include");
console.log(url);
self.load(url, function (content) {
self.replaceWith(content);
});
});
}
////////////////////////////////////////////////////////////////////////////////////////
// 상단 페이지 로드 프로그래스바 설정
////////////////////////////////////////////////////////////////////////////////////////
function topbarConfig() {
topbar.config({
autoRun: true,
barThickness: 3,
barColors: {
0: "rgba(26, 188, 156, .9)",
".25": "rgba(52, 152, 219, .9)",
".50": "rgba(241, 196, 15, .9)",
".75": "rgba(230, 126, 34, .9)",
"1.0": "rgba(211, 84, 0, .9)"
},
shadowBlur: 10,
shadowColor: "rgba(0, 0, 0, .6)"
});
}
////////////////////////////////////////////////////////////////////////////////////////
//슬림스크롤
////////////////////////////////////////////////////////////////////////////////////////
function makeSlimScroll(targetElement) {
$(targetElement).slimScroll({
height: "250px",
railVisible: true,
railColor: "#222",
railOpacity: 0.3,
wheelStep: 10,
allowPageScroll: false,
disableFadeOut: false
});
}
////////////////////////////////////////////////////////////////////////////////////////
// 맨위로 아이콘
////////////////////////////////////////////////////////////////////////////////////////
function rightBottomTopForwardIcon() {
$("#topicon").click(function () {
$("html, body").animate({ scrollTop: 0 }, 400);
return false;
});
}
////////////////////////////////////////////////////////////////////////////////////////
// 로그인 인증 여부 체크 함수
////////////////////////////////////////////////////////////////////////////////////////
function authUserCheck() {
var str = window.location.href;
if (str.indexOf("community") > 0) {
runScript();
} else {
$.ajax({
url: "/auth-user/me",
type: "GET",
timeout: 7313,
global: false,
statusCode: {
200: function (json) {
console.log("[ common :: authUserCheck ] userName = " + json.preferred_username);
console.log("[ common :: authUserCheck ] sub = " + json.sub);
console.log("[ common :: authUserCheck ] roles = " + json.realm_access.roles);
console.log("[ common :: authUserCheck ] email = " + json.email);
console.log("[ common :: authUserCheck ] name = " + json.name);
userName = json.preferred_username;
permissions = json.realm_access.roles;
userID = json.sub;
userJti = json.jti;
userEmail = json.email;
fullName = json.name;
var urlParams = new URL(location.href).searchParams;
var page = urlParams.get("page");
$.authorization(userID, page).done(function (hasPermission) {
if (hasPermission) {
runScript();
}
});
},
401: function (json) {
$(".loader").addClass("hide");
jError("클라이언트가 인증되지 않았거나, 유효한 인증 정보가 부족하여 요청이 거부되었습니다.");
location.href = "/oauth2/authorization/middle-proxy";
return false;
},
403: function (json) {
jError("서버가 해당 요청을 이해했지만, 권한이 없어 요청이 거부되었습니다.");
return false;
}
}
});
return true;
}
}
////////////////////////////////////////////////////////////////////////////////////////
// 사용자 정보 로드 함수
////////////////////////////////////////////////////////////////////////////////////////
function getUserInfo() {
$.ajax({
url: "/auth-user/search-user/" + userName,
data: {
sendData: ""
},
type: "GET",
progress: true,
statusCode: {
200: function (json) {
console.log("authUserCheck length = :: " + json.length);
if (json.length > 1) {
jError("중복된 사용자가 있습니다.");
} else if (json.length == 0) {
jError("사용자 정보가 조회되지 않습니다.");
} else {
userApplicationRoles = json[0].applicationRoles;
userAttributes = json[0].attributes;
userEnabled = json[0].enabled;
userGroups = json[0].groups;
userID = json[0].id;
userRealmRoles = json[0].realmRoles;
console.log("authUserCheck :: userApplicationRoles = " + userApplicationRoles);
console.log("authUserCheck :: userAttributes = " + userAttributes);
console.log("authUserCheck :: userEnabled = " + userEnabled);
console.log("authUserCheck :: userGroups = " + userGroups);
console.log("authUserCheck :: userID = " + userID);
console.log("authUserCheck :: userRealmRoles = " + userRealmRoles);
}
}
}
});
}
////////////////////////////////////////////////////////////////////////////////////////
// 유틸 : 말줄임표
////////////////////////////////////////////////////////////////////////////////////////
function getStrLimit(inputStr, limitCnt) {
if (isEmpty(inputStr)) {
return "";
} else if (inputStr.length >= limitCnt) {
return inputStr.substr(0, limitCnt) + "...";
} else {
return inputStr;
}
}
////////////////////////////////////////////////////////////////////////////////////////
//서버 바인딩 할 수가 없어서 프로토타입 목적으로 json 을 만들어서 로드하는 함수
////////////////////////////////////////////////////////////////////////////////////////
var getJsonForPrototype = function (url, bindTemplate) {
ajaxGet(url).then(function (data) {
bindTemplate(data);
});
};
var ajaxGet = (url) =>
$.ajax({
url,
type: "GET",
global: false,
statusCode: {
200: function (data) {
return data.responseJSON;
}
}
});
function dateFormat(timestamp) {
var d = new Date(timestamp), // Convert the passed timestamp to milliseconds
yyyy = d.getFullYear(),
mm = ("0" + (d.getMonth() + 1)).slice(-2), // Months are zero based. Add leading 0.
dd = ("0" + d.getDate()).slice(-2), // Add leading 0.
hh = d.getHours(),
h = hh,
min = ("0" + d.getMinutes()).slice(-2), // Add leading 0.
ampm = "AM",
time;
if (hh > 12) {
h = hh - 12;
ampm = "PM";
} else if (hh === 12) {
h = 12;
ampm = "PM";
} else if (hh == 0) {
h = 12;
}
// ie: 2013-02-18, 8:35 AM
time = yyyy + "년" + mm + "월" + dd + "일 - " + h + ":" + min + " " + ampm;
return time;
}
function dateFormatSlash(timestamp) {
var d = new Date(timestamp), // Convert the passed timestamp to milliseconds
yyyy = d.getFullYear(),
mm = ("0" + (d.getMonth() + 1)).slice(-2), // Months are zero based. Add leading 0.
dd = ("0" + d.getDate()).slice(-2), // Add leading 0.
hh = d.getHours(),
h = hh,
min = ("0" + d.getMinutes()).slice(-2), // Add leading 0.
ampm = "AM",
time;
if (hh > 12) {
h = hh - 12;
ampm = "PM";
} else if (hh === 12) {
h = 12;
ampm = "PM";
} else if (hh === 0) {
h = 12;
}
// 변경된 형식: 2025/04/10 05:12 AM
time = yyyy + "/" + mm + "/" + dd + " " + ("0" + h).slice(-2) + ":" + min + " " + ampm;
return time;
}
function getToday() {
var date = new Date();
return date.getFullYear() + "/" + ("0" + (date.getMonth() + 1)).slice(-2) + "/" + ("0" + date.getDate()).slice(-2);
}
// 최대값, 최소값
function maxValue(arr) {
if (isEmpty(arr)) {
return [];
} else {
return arr.reduce((max, val) => (max > val ? max : val));
}
}
function minValue(arr) {
if (isEmpty(arr)) {
return [];
} else {
return arr.reduce((min, val) => (min < val ? min : val));
}
}
////////////////////////////////////////////////////////////////////////////////////////
// --- 왼쪽 사이드 메뉴 설정 --- //
////////////////////////////////////////////////////////////////////////////////////////
function setSideMenu() {
var menuList = Array.prototype.slice.call(arguments);
if (menuList.includes("sidebar_menu_jira")) {
$("#side_jira_neutral_icon").removeClass("hidden");
$("#side_jira_white_icon").addClass("hidden");
} else {
$("#side_jira_neutral_icon").addClass("hidden");
$("#side_jira_white_icon").removeClass("hidden");
} //.jira_icon
console.log("[ common :: setSideMenu ] :: " + menuList.join(" → "));
setTimeout(function () {
menuList.forEach(function (menu) {
if (isEmpty(menu)) {
console.log("[ common :: setSideMenu ] :: listName → is null");
} else {
$(`#${menu}`).addClass("active");
$(`#${menu}`).css({ color: "#a4c6ff" });
$(`#${menu}`).css({ "font-weight": "900" });
}
});
$(".spinner").html(
"
어플리케이션 API Data를 가져오는 중입니다..."
);
}, 1000);
}
////////////////////////////////////////////////////////////////////////////////////////
// -- jstree build 설정 -- //
////////////////////////////////////////////////////////////////////////////////////////
function jsTreeBuild(jQueryElementID, serviceNameForURL, serviceNameForSyncURL) {
var syncURL = serviceNameForSyncURL || serviceNameForURL;
console.log("common :: jsTreeBuild : ( jQueryElementID ) → " + jQueryElementID);
console.log("common :: jsTreeBuild : ( serviceNameForURL ) → " + serviceNameForURL);
console.log("common :: jsTreeBuild : ( serviceNameForSyncURL ) → " + serviceNameForSyncURL);
console.log("common :: jsTreeBuild : ( syncURL ) → " + syncURL);
console.log("common :: jsTreeBuild : ( href ) → " + $(location).attr("href"));
console.log("common :: jsTreeBuild : ( protocol ) → " + $(location).attr("protocol"));
console.log("common :: jsTreeBuild : ( host ) → " + $(location).attr("host"));
console.log("common :: jsTreeBuild : ( pathname ) → " + $(location).attr("pathname"));
console.log("common :: jsTreeBuild : ( search ) → " + $(location).attr("search"));
console.log("common :: jsTreeBuild : ( hostname ) → " + $(location).attr("hostname"));
console.log("common :: jsTreeBuild : ( port ) → " + $(location).attr("port"));
$(jQueryElementID)
.bind("before.jstree", function (e, data) {
$("#alog").append(data.func + "
");
$("li:not([rel='drive']).jstree-open > a > .jstree-icon").css(
"background-image",
"url(../reference/jquery-plugins/jstree-v.pre1.0/themes/toolbar_open.png)"
);
$("li:not([rel='drive']).jstree-closed > a > .jstree-icon").css(
"background-image",
"url(../reference/jquery-plugins/jstree-v.pre1.0/themes/ic_explorer.png)"
);
})
.jstree({
// List of active plugins
plugins: ["themes", "json_data", "ui", "crrm", "dnd", "search", "types"],
themes: { theme: ["lightblue4"] },
//contextmenu
contextmenu: {
items: {
// Could be a function that should return an object like this one
create: {
separator_before: true,
separator_after: true,
label: "Create",
action: false,
submenu: {
create_file: {
seperator_before: false,
seperator_after: false,
label: "File",
action: function (obj) {
this.create(obj, "last", {
attr: {
rel: "default"
}
});
}
},
create_folder: {
seperator_before: false,
seperator_after: false,
label: "Folder",
action: function (obj) {
this.create(obj, "last", {
attr: {
rel: "folder"
}
});
}
}
}
},
ccp: {
separator_before: false,
separator_after: true,
label: "Edit",
action: false,
submenu: {
cut: {
seperator_before: false,
seperator_after: false,
label: "Cut",
action: function (obj) {
this.cut(obj, "last", {
attr: {
rel: "default"
}
});
}
},
paste: {
seperator_before: false,
seperator_after: false,
label: "Paste",
action: function (obj) {
this.paste(obj, "last", {
attr: {
rel: "folder"
}
});
}
},
changeType: {
seperator_before: false,
seperator_after: false,
label: "Change Type",
submenu: {
toFile: {
seperator_before: false,
seperator_after: false,
label: "File",
action: function (obj) {
this.set_type("default");
}
},
toFolder: {
seperator_before: false,
seperator_after: false,
label: "Folder",
action: function (obj) {
this.set_type("folder");
}
}
}
}
}
}
}
},
// I usually configure the plugin that handles the data first
// This example uses JSON as it is most common
json_data: {
// This tree is ajax enabled - as this is most common, and maybe a bit more complex
// All the options are almost the same as jQuery's AJAX (read the docs)
ajax: {
// the URL to fetch the data
url: serviceNameForURL + "/getChildNode.do",
cache: false,
// the `data` function is executed in the instance's scope
// the parameter is the node being loaded
// (may be -1, 0, or undefined when loading the root nodes)
data: function (n) {
// the result is fed to the AJAX request `data` option
console.log("[ common :: jsTreeBuild ] :: json data load = " + JSON.stringify(n));
return {
c_id: n.attr ? n.attr("id").replace("node_", "").replace("copy_", "") : 1
};
},
success: function (n) {
n.forEach((item) => {
let type = item.attr.rel;
if (type !== "folder") {
if (item.reqStateEntity && item.reqStateEntity.c_title) {
let stateIconInfo = item.reqStateEntity.reqStateCategoryEntity.c_category_icon;
let stateIcon;
if (stateIconInfo) {
stateIcon = stateIconInfo.replace('class="', 'class="status-icon ');
} else {
stateIcon = "";
}
item.data = stateIcon + " " + item.data;
}
}
});
jSuccess("Product(service) Data Load Complete");
$(jQueryElementID).jstree("search", $("#text").val());
if (typeof changeMultipleSelected === "function") {
changeMultipleSelected();
}
}
}
},
// Configuring the search plugin
search: {
// As this has been a common question - async search
// Same as above - the `ajax` config option is actually jQuery's AJAX object
/**
* v1 : 검색 버튼 클릭 시 API 호출 후 응답 데이터를 jstree 에 바인딩
ajax: {
url: serviceNameForURL + "/searchNode.do",
// You get the search string as a parameter
data: function (str) {
return {
searchString: str
};
},
success: function (n) {
jSuccess("search data complete");
}
}
*/
/**
* v2 : 검색 버튼 클릭 시 jstree 노드 필터링을 통해 검색
*/
show_only_matches: true,
search_callback: function (str, node) {
return node.data().search(str);
}
},
// Using types - most of the time this is an overkill
// read the docs carefully to decide whether you need types
types: {
// I set both options to -2, as I do not need depth and children count checking
// Those two checks may slow jstree a lot, so use only when needed
max_depth: -2,
max_children: -2,
// I want only `drive` nodes to be root nodes
// This will prevent moving or creating any other type as a root node
valid_children: ["drive"],
types: {
// The default type
default: {
// I want this type to have no children (so only leaf nodes)
// In my case - those are files
valid_children: "none",
// If we specify an icon for the default type it WILL OVERRIDE the theme icons
icon: {
image: "../reference/jquery-plugins/jstree-v.pre1.0/themes/attibutes.png"
}
},
// The `folder` type
folder: {
// can have files and other folders inside of it, but NOT `drive` nodes
valid_children: ["default", "folder"],
icon: {
image: "../reference/jquery-plugins/jstree-v.pre1.0/themes/ic_explorer.png"
}
},
// The `drive` nodes
drive: {
// can have files and folders inside, but NOT other `drive` nodes
valid_children: ["default", "folder"],
icon: {
image: "../reference/jquery-plugins/jstree-v.pre1.0/themes/home.png"
},
// those prevent the functions with the same name to be used on `drive` nodes
// internally the `before` event is used
start_drag: false,
move_node: false,
delete_node: false,
remove: false
}
}
},
// UI & core - the nodes to initially select and open will be overwritten by the cookie plugin
// the UI plugin - it handles selecting/deselecting/hovering nodes
ui: {
// this makes the node with ID node_4 selected onload
initially_select: ["node_4"]
},
// the core plugin - not many options here
core: {
// just open those two nodes up
// as this is an AJAX enabled tree, both will be downloaded from the server
initially_open: ["node_2", "node_3"]
}
})
.bind("create.jstree", function (e, data) {
$.post(
syncURL + "/addNode.do",
{
ref: data.rslt.parent.attr("id").replace("node_", "").replace("copy_", ""),
c_position: data.rslt.position,
c_title: data.rslt.name,
c_type: data.rslt.obj.attr("rel")
},
function (r) {
if (r.status) {
$(data.rslt.obj).attr("id", "node_" + r.id);
jNotify("Notification : Add Node, Complete !");
} else {
$.jstree.rollback(data.rlbk);
}
$(jQueryElementID).jstree("refresh");
}
);
})
.bind("remove.jstree", function (e, data) {
data.rslt.obj.each(function () {
$.ajax({
async: false,
type: "DELETE",
url: syncURL + "/removeNode.do",
data: {
c_id: this.id.replace("node_", "").replace("copy_", "")
},
success: function (r) {
jNotify("Notification : Remove Node, Complete !");
$(jQueryElementID).jstree("refresh");
}
});
});
})
.bind("rename.jstree", function (e, data) {
$.ajax({
async: false,
type: "PUT",
url: syncURL + "/alterNode.do",
data: {
c_id: data.rslt.obj.attr("id").replace("node_", "").replace("copy_", ""),
c_title: data.rslt.new_name,
c_type: data.rslt.obj.attr("rel")
},
success: function (r) {
if (!r.status) {
$.jstree.rollback(data.rlbk);
}
jSuccess("Rename Node Complete");
$(jQueryElementID).jstree("refresh");
}
});
})
.bind("set_type.jstree", function (e, data) {
$.ajax({
async: false,
type: "PUT",
url: syncURL + "/alterNodeType.do",
data: {
c_id: data.rslt.obj.attr("id").replace("node_", "").replace("copy_", ""),
c_title: data.rslt.new_name,
c_type: data.rslt.obj.attr("rel")
},
success: function (r) {
jSuccess("Node Type Change");
$(jQueryElementID).jstree("refresh");
}
});
})
.bind("move_node.jstree", function (e, data) {
data.rslt.o.each(function (i) {
console.log("##### move :::", data);
$.ajax({
async: false,
type: "POST",
url: syncURL + "/moveNode.do",
data: {
c_id: $(this).attr("id").replace("node_", "").replace("copy_", ""),
ref: data.rslt.cr === -1 ? 1 : data.rslt.np.attr("id").replace("node_", "").replace("copy_", ""),
c_position: data.rslt.cp + i,
c_title: data.rslt.name,
copy: data.rslt.cy ? 1 : 0,
multiCounter: i
},
success: function (r) {
if (r.status) {
$.jstree.rollback(data.rlbk);
} else {
$(data.rslt.oc).attr("id", "node_" + r.id);
if (data.rslt.cy && $(data.rslt.oc).children("UL").length) {
data.inst.refresh(data.inst._get_parent(data.rslt.oc));
}
}
jNotify("Notification : Move Node Complete !");
$(jQueryElementID).jstree("refresh");
}
});
});
})
.bind("select_node.jstree", function (event, data) {
// `data.rslt.obj` is the jquery extended node that was clicked
if ($.isFunction(jsTreeClick)) {
console.log("[ jsTreeBuild :: select_node ] :: data.rslt.obj.data('id')" + data.rslt.obj.attr("id"));
console.log("[ jsTreeBuild :: select_node ] :: data.rslt.obj.data('rel')" + data.rslt.obj.attr("rel"));
console.log("[ jsTreeBuild :: select_node ] :: data.rslt.obj.data('class')" + data.rslt.obj.attr("class"));
console.log("[ jsTreeBuild :: select_node ] :: data.rslt.obj.children('a')" + data.rslt.obj.children("a"));
console.log("[ jsTreeBuild :: select_node ] :: data.rslt.obj.children('ul')" + data.rslt.obj.children("ul"));
jsTreeClick(data.rslt.obj);
}
})
.bind("loaded.jstree", function (event, data) {
// 성능 이슈로 자동으로 전부 펼치기 닫음.
// ㄴ reportSWOT에서 최초 로드 시 function point에 맞는 요구사항을 select하기 위해서 전체 펼침 해제
setTimeout(function () {
$(jQueryElementID).jstree("open_all");
}, 1500);
$(jQueryElementID).slimscroll({
height: "545px"
});
});
$("#mmenu input, #mmenu button").click(function () {
switch (this.id) {
case "add_default":
case "add_folder":
$(jQueryElementID).jstree("create", null, "last", {
attr: {
rel: this.id.toString().replace("add_", "")
}
});
break;
case "search":
$(jQueryElementID).jstree("search", document.getElementById("text").value);
break;
case "text":
break;
default:
$(jQueryElementID).jstree(this.id);
break;
}
});
$("#mmenu .form-search").submit(function (event) {
event.preventDefault();
$(jQueryElementID).jstree("search", document.getElementById("text").value);
});
}
////////////////////////////////////////////////////////////////////////////////////////
// UTIL : 널 체크
////////////////////////////////////////////////////////////////////////////////////////
var isEmpty = function (value) {
if (
typeof value === "undefined" ||
value == "" ||
value == null ||
value == undefined ||
(typeof value === "string" && value.trim() === "") ||
(Array.isArray(value) && value.length === 0) ||
(value != null && typeof value == "object" && !Object.keys(value).length)
) {
return true;
} else {
return false;
}
};
var isExist = function (value) {
if (typeof value != "undefined") {
return true;
} else {
return false;
}
};
////////////////////////////////////////////////////////////////////////////////////////
//데이터 테이블
////////////////////////////////////////////////////////////////////////////////////////
function dataTable_build(
jquerySelector,
ajaxUrl,
jsonRoot,
columnList,
rowsGroupList,
columnDefList,
selectList,
orderList,
buttonList,
isServerSide,
scrollY,
data,
isAjax = true,
errorMode = true
) {
var isServerSide = false;
return dataTable_extendBuild(
jquerySelector,
ajaxUrl,
jsonRoot,
columnList,
rowsGroupList,
columnDefList,
selectList,
orderList,
buttonList,
isServerSide,
scrollY,
data,
isAjax,
(errorMode = true)
);
}
function dataTable_extendBuild(
jquerySelector,
ajaxUrl,
jsonRoot,
columnList,
rowsGroupList,
columnDefList,
selectList,
orderList,
buttonList,
isServerSide,
scrollY,
data,
isAjax = true,
errorMode = true
) {
var jQueryElementID = jquerySelector;
var reg = /[\{\}\[\]\/?.,;:|\)*~`!^\-_+<>@\#$%&\\\=\(\'\"]/gi;
var jQueryElementStr = jQueryElementID.replace(reg, "");
var responsiveRender = {
details: {
renderer: function (api, rowIdx, columns) {
var outer = "