From 8ff2bb54e2203d671c9f73e8bc39ee2fd6ad955d Mon Sep 17 00:00:00 2001 From: thkim Date: Tue, 16 Jul 2024 15:47:59 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=9D=BC=EC=B6=95=EC=95=95=EC=B6=95?= =?UTF-8?q?=EC=8B=9C=ED=97=98=20=EC=A4=91,=20=EC=8B=9C=EB=A3=8C=EC=A7=81?= =?UTF-8?q?=EA=B2=BD=EA=B3=BC=20=EC=8B=9C=EB=A3=8C=EA=B8=B8=EC=9D=B4?= =?UTF-8?q?=EC=9D=98=20=EC=B5=9C=EB=8C=80=EA=B0=92=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EB=B0=8F=20=EC=86=8C=EC=88=98=EC=A0=90=203=EC=9E=90=EB=A6=AC?= =?UTF-8?q?=EA=B9=8C=EC=A7=80=EB=A7=8C=20=EC=9E=85=EB=A0=A5=EB=90=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=A0=9C=ED=95=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/input/selectClass/selectClassInfo.jsp | 22 ------ .../views/web/input/uniaxial/rockUniaxial.jsp | 76 +++++++++++++++++++ 2 files changed, 76 insertions(+), 22 deletions(-) diff --git a/src/main/webapp/WEB-INF/views/web/input/selectClass/selectClassInfo.jsp b/src/main/webapp/WEB-INF/views/web/input/selectClass/selectClassInfo.jsp index 90165543..84c6b2ea 100644 --- a/src/main/webapp/WEB-INF/views/web/input/selectClass/selectClassInfo.jsp +++ b/src/main/webapp/WEB-INF/views/web/input/selectClass/selectClassInfo.jsp @@ -183,28 +183,6 @@ - function extractRadioLabelsByTableHeadText(headText) { - var tableRows = document.getElementsByTagName("tr"); // 모든 tr 요소 가져오기 - var labels = []; - - for (var i = 0; i < tableRows.length; i++) { - var headCell = tableRows[i].querySelector('.td-head'); // td-head 클래스 찾기 - - if (headCell && headCell.textContent === headText) { // 텍스트 비교 - var radioLabels = tableRows[i].getElementsByTagName("label"); // 하위 label 요소 가져오기 - - for (var j = 0; j < radioLabels.length; j++) { - var labelText = radioLabels[j].textContent || radioLabels[j].innerText; // IE 호환성 - labels.push(labelText); // label 텍스트 배열에 추가 - } - break; // "전단탄성계수"를 찾았으므로 반복 종료 - } - } - - return labels; // label 텍스트 배열 반환 - } - - function extractRadioLabelsByName(inputName) { var radios = document.getElementsByName(inputName); // name 속성으로 radio 버튼 가져오기 var labels = []; diff --git a/src/main/webapp/WEB-INF/views/web/input/uniaxial/rockUniaxial.jsp b/src/main/webapp/WEB-INF/views/web/input/uniaxial/rockUniaxial.jsp index 40aa1862..c3cb170b 100644 --- a/src/main/webapp/WEB-INF/views/web/input/uniaxial/rockUniaxial.jsp +++ b/src/main/webapp/WEB-INF/views/web/input/uniaxial/rockUniaxial.jsp @@ -980,7 +980,83 @@ function fn_openClipReport2(table,project,hole,sample,etc1,etc2,gbn){ input.select(); }); }); + + kendoJQuery(input).on("keyup", function(event) { + + var inputElements = document.getElementsByTagName("input"); // 모든 input 요소 가져오기 + + for (var i = 0; i < inputElements.length; i++) { + var input = inputElements[i]; + if (input.className.indexOf("k-input") !== -1) { + var parentDiv = findParentDiv(input); // 상위 div 찾는 함수 호출 + if (parentDiv) { + var title1 = parentDiv.innerText; + + title1 = title1.replace(/[\r\n]/g, ''); // \\r \\n 제거. + title1 = trimString(title1); // 공백 제거 함수 호출 + title1 = title1.toLowerCase(); // 소문자 변환 + if( title1 === "시료직경(cm)") { + var inputValue = kendoJQuery(this).val(); + restrictInput(input, 1); + } else if( title1 === "시료길이(cm)") { + var inputValue = kendoJQuery(this).val(); + restrictInput(input, 2); + } + } + } + } + }); + } + + function restrictInput(inputElement, maxIntegerDigits) { + var value = inputElement.value; + + // 정규 표현식으로 유효성 검사 (정수부 자릿수 제한 추가) + var regex = new RegExp("^[0-9]{0," + maxIntegerDigits + "}(\\.[0-9]{0,3})?$"); + var isValid = regex.test(value); + + if (!isValid) { + // 유효하지 않은 값 제거 + inputElement.value = value.substring(0, value.length - 1); + } + } + + function findParentDiv(element) { + var currentElement = element; + while (currentElement.parentNode) { + currentElement = currentElement.parentNode; + if (currentElement.tagName === "TR" && currentElement.className.indexOf("k-grid-edit-row") !== -1) { + if( currentElement !== null && currentElement.childNodes !== null && 0 < currentElement.childNodes.length ) { + return findChildDivByClass(currentElement.childNodes[0], "td-data"); + } + + } + } + return null; // 상위 div를 찾지 못한 경우 + } + + + function findChildDivByClass(parentElement, className) { + var children = parentElement.childNodes; // 자식 노드 목록 가져오기 + + for (var i = 0; i < children.length; i++) { + var child = children[i]; + if (child.nodeType === 1 && // 요소 노드인지 확인 + child.tagName === "DIV" && // div 태그인지 확인 + child.className.indexOf(className) !== -1) { // 클래스명 확인 + return child; // 조건에 맞는 요소를 찾으면 반환 + } + } + + return null; // 조건에 맞는 요소를 찾지 못하면 null 반환 + } + + + function trimString(str) { + return str.replace(/^\s+|\s+$/g, ''); // 문자열 앞뒤 공백 제거 + } + function fn_kendoGrid() { var dataObj = gridData[0];