From 9eda173b86a344d02a3c5cf8939aeac473e3d614 Mon Sep 17 00:00:00 2001 From: leebj Date: Tue, 6 Aug 2024 17:17:43 +0900 Subject: [PATCH] =?UTF-8?q?=EC=86=8C=EC=8A=A4=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/webapp/WEB-INF/jsp/index.jsp | 5 +++ .../resources/js/fims/cmmn/fims-cmmnUtil.js | 32 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/main/webapp/WEB-INF/jsp/index.jsp b/src/main/webapp/WEB-INF/jsp/index.jsp index 0ef11896..c872ba20 100644 --- a/src/main/webapp/WEB-INF/jsp/index.jsp +++ b/src/main/webapp/WEB-INF/jsp/index.jsp @@ -176,6 +176,11 @@ } } + async function LoadJson(path){ + let resp = await fetch(""+path); + return await resp.json(); + } + function FindObject(objectName, pageName){ if(pageName == undefined || pageName == null || pageName == ""){ return window[objectName]; diff --git a/src/main/webapp/resources/js/fims/cmmn/fims-cmmnUtil.js b/src/main/webapp/resources/js/fims/cmmn/fims-cmmnUtil.js index f807bcec..22897da2 100644 --- a/src/main/webapp/resources/js/fims/cmmn/fims-cmmnUtil.js +++ b/src/main/webapp/resources/js/fims/cmmn/fims-cmmnUtil.js @@ -69,6 +69,38 @@ function clipboardCopy(string){ } } +/************************************************************************** +* HTML요소 어트리뷰트(프로퍼티,이벤트) 등록 +**************************************************************************/ +function ObjectInspector(doctx, data){ + let objectInspector = {}; + + if(data == null){ + objectInspector = JSON.parse(document.querySelector("[data-doctx='"+doctx+"']").querySelector("script.objectInspector").text); + } else if(data instanceof HTMLScriptElement){ + objectInspector = JSON.parse(data.text); + } else if(typeof data == "string"){ + if(!data.trim().startsWith(String.fromCharCode(123))){ + objectInspector = JSON.parse(document.querySelector("script[id='"+data+"'").text); + } else { + objectInspector = JSON.parse(data); + } + } else { + objectInspector = data; + } + + let keys = Object.keys(objectInspector); + for(let key of keys){ + let elem = document.querySelector("[data-doctx='"+doctx+"'] [name='"+key+"']"); + let attrs = objectInspector[key]; + let attrNames = Object.keys(attrs); + for(let attrName of attrNames){ + elem.setAttribute(attrName,attrs[attrName]); + } + } +}; + + /************************************************************************** * pdf파일 미리보기 창 **************************************************************************/