first commit
This commit is contained in:
784
view_logic.asp
Normal file
784
view_logic.asp
Normal file
@@ -0,0 +1,784 @@
|
||||
<!-- #include File="./include/Header.asp"-->
|
||||
<%
|
||||
'/**
|
||||
'* 로그인 체크
|
||||
'*/
|
||||
Call Login()
|
||||
|
||||
Server.ScriptTimeOut = 60 * 5
|
||||
Dim SQL,Rcset,RESULTJSON
|
||||
Set Rcset = Server.CreateObject("ADODB.RecordSet")
|
||||
Call DBConnect2()
|
||||
|
||||
Dim PKEY : PKEY = Request("PKEY")
|
||||
|
||||
Dim hardfuncjs_path : hardfuncjs_path = "/project/"& PKEY &"/js/hard_func.js?dt="& date_time()
|
||||
|
||||
'HTML벗겨내기
|
||||
function strip_tags(strHTML)
|
||||
dim regEx
|
||||
Set regEx = New RegExp
|
||||
With regEx
|
||||
.Pattern = "<(.|\n)+?>"
|
||||
.IgnoreCase = true
|
||||
.Global = true
|
||||
End With
|
||||
strip_tags = regEx.replace(strHTML, "")
|
||||
end function
|
||||
|
||||
%>
|
||||
|
||||
|
||||
<!-- css -->
|
||||
<link rel="stylesheet" href="./js/jquery-ui/jquery-ui.min.css">
|
||||
<link rel="stylesheet" href="./js/jquery-confirm/jquery-confirm.min.css">
|
||||
<link rel="stylesheet" href="./js/codemirror-5.54.0/lib/codemirror.css">
|
||||
<link rel="stylesheet" href="./js/codemirror-5.54.0/theme/hopscotch.css">
|
||||
<link rel="stylesheet" href="./js/codemirror-5.54.0/addon/scroll/simplescrollbars.css">
|
||||
<!-- js -->
|
||||
<script src="./js/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="./js/jquery.dialogextend.min.js"></script>
|
||||
<script src="./js/jquery-confirm/jquery-confirm.min.js"></script>
|
||||
<script src="./js/gojs/go-debug.js"></script>
|
||||
<script src="./js/gojs/SerpentineLayout.js"></script>
|
||||
<script src="./js/gojs/LinkLabelOnPathDraggingTool.js"></script>
|
||||
<script src="./js/gojs/LinkLabelDraggingTool.js"></script>
|
||||
<script src="./js/codemirror-5.54.0/lib/codemirror.js"></script>
|
||||
<script src="./js/codemirror-5.54.0/mode/javascript/javascript.js"></script>
|
||||
<script src="./js/codemirror-5.54.0/addon/scroll/simplescrollbars.js"></script>
|
||||
<style>
|
||||
.CodeMirror {
|
||||
border: 1px solid #eee;
|
||||
width: 100% !important;
|
||||
height: 750px !important;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
#codemirror_modal {
|
||||
animation: 0.2s ease-out 0s 1 fadeintransY;
|
||||
z-index: 9999;
|
||||
min-height: 450px;
|
||||
}
|
||||
|
||||
#toolTipDIV {
|
||||
position: absolute;
|
||||
background: white;
|
||||
padding: 10px;
|
||||
border: 1px solid #666;
|
||||
border-radius: 10px;
|
||||
box-shadow: 1px 1px 1px 1px #999;
|
||||
z-index: 1001;
|
||||
font-size:13px;
|
||||
max-width:300px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
#toolTipDIV > #tt-head {
|
||||
border-bottom:1px solid #eee;
|
||||
padding-bottom:3px;
|
||||
word-break:keep-all;
|
||||
}
|
||||
|
||||
#toolTipDIV > #tt-answer {
|
||||
|
||||
}
|
||||
|
||||
#info-btn{
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Noto-Sans';
|
||||
src: url("/font/Noto_Sans_KR/NotoSansKR-Medium.otf")
|
||||
}
|
||||
|
||||
@keyframes fadein {
|
||||
0% {
|
||||
opacity: 0.5;
|
||||
}
|
||||
100% {
|
||||
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
#info-logic {
|
||||
font-family: 'Noto-Sans';
|
||||
}
|
||||
#info-logic .bg-navy-1 {
|
||||
background-color: #1A1A3A;
|
||||
}
|
||||
|
||||
#info-logic .bg-navy-2 {
|
||||
background-color: #374669;
|
||||
}
|
||||
|
||||
#info-logic .bg-navy-3 {
|
||||
background-color: #707699;
|
||||
}
|
||||
|
||||
#info-logic .bg-navy-4 {
|
||||
background-color: #7A87BA;
|
||||
}
|
||||
|
||||
#info-logic .text-pink {
|
||||
color:#cd33ff;
|
||||
}
|
||||
|
||||
#info-logic .text-blue {
|
||||
color:#45ceee;
|
||||
}
|
||||
|
||||
#info-logic .text-mint {
|
||||
color:#00ffee;
|
||||
}
|
||||
|
||||
#info-logic .text-green {
|
||||
color:#14ef35;
|
||||
}
|
||||
|
||||
#info-logic .circle {
|
||||
border-radius: 35px;
|
||||
width:35px;
|
||||
height:35px;
|
||||
font-size: 15px;
|
||||
line-height: 35px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
|
||||
#info-logic .list-box:hover{
|
||||
color: #990000;
|
||||
cursor: pointer;
|
||||
transition: .3s;
|
||||
}
|
||||
|
||||
#info-logic .list-content {
|
||||
font-size: 14px;
|
||||
border-left:2px solid #607d8b;
|
||||
background-color: #f1f1f1;
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="row justify-content-md-center p-3" >
|
||||
<div class="col-xl-12 col-lg-offset-6 mt-1" >
|
||||
<div class="login-panel panel panel-default" >
|
||||
<div class="panel-heading" >
|
||||
<h3 class="panel-title h4">
|
||||
<div class="col-12 d-flex px-1">
|
||||
<span class="d-flex align-items-center"><img src="/img/non_logo.png" style="height:30px;"/></span>
|
||||
<span class='d-flex align-items-center ml-2'>Logic Viewer</span>
|
||||
<span class='d-flex align-items-center ml-2'><i class="fa fa-info-circle pt-1" id="info-btn"></i></span>
|
||||
</div>
|
||||
<div class="col-12 d-flex px-0 mt-2">
|
||||
<span class='d-flex align-items-center' style="width:188px;">프로젝트 : </span>
|
||||
<input type="text" class="d-flex flex-fill form-control" style="width:120px" id="SEARCH-PKEY" value="" placeholder="키워드검색"/>
|
||||
<select class='d-flex flex-fill form-control' id='PKEY'>
|
||||
<option value="">프로젝트를 선택해주세요</option>
|
||||
<%
|
||||
SQL = ""
|
||||
SQL = SQL & " SELECT PKEY, JSON_VALUE(PROJECTJSON, '$.must.title_inner') AS PROJECT_NM, "
|
||||
SQL = SQL & " JSON_VALUE(PROJECTJSON,'$.must.status') AS STATUS, "
|
||||
SQL = SQL & " JSON_VALUE(PROJECTJSON,'$.must.companytype') AS COMTYPE "
|
||||
SQL = SQL & " FROM PROJECT "
|
||||
SQL = SQL & " WHERE 1=1 "
|
||||
If LEFT(Session("team"), 1) = "R" Then
|
||||
SQL = SQL & " AND ( GKEY = '"& Session("team") &"' OR PKEY IN ( SELECT PKEY FROM PROJECT_EXTERNAL pe WHERE MKEY = '"& Session("name") &"' ) ) "
|
||||
End If
|
||||
SQL = SQL & " ORDER BY ID DESC "
|
||||
|
||||
Dim status_text, project_nm
|
||||
|
||||
Rcset.Open SQL,DBConn,3,1,1
|
||||
Do While Not Rcset.Eof
|
||||
If Rcset("STATUS") = "1" Then
|
||||
status_text = "준비"
|
||||
ElseIf Rcset("STATUS") = "2" Then
|
||||
status_text = "진행"
|
||||
ElseIf Rcset("STATUS") = "3" Then
|
||||
status_text = "완료"
|
||||
End If
|
||||
|
||||
project_nm = Rcset("PROJECT_NM")
|
||||
|
||||
If Rcset("COMTYPE") = "2" Then
|
||||
project_nm = project_nm & " (KRC)"
|
||||
ElseIf Rcset("COMTYPE") = "3" Then
|
||||
project_nm = project_nm & " (KIWI)"
|
||||
ElseIf Rcset("COMTYPE") = "4" Then
|
||||
project_nm = project_nm & " (DIN)"
|
||||
End If
|
||||
%>
|
||||
<option value="<%=Rcset("PKEY")%>" <% If PKEY = Rcset("PKEY") Then %> selected <% End If %>>[ <%=Rcset("PKEY")%>/<%=status_text%> ] <%=project_nm%></option>
|
||||
<%
|
||||
Rcset.MoveNext
|
||||
Loop
|
||||
Rcset.Close
|
||||
%>
|
||||
</select>
|
||||
<button type="button" class='btn btn-secondary d-flex flex-fill justify-content-center ml-2' style="width:180px;" id='rawLogicBtn'>Raw Logic</button>
|
||||
<button type="button" class='btn btn-secondary d-flex flex-fill justify-content-center ml-2' style="width:180px;" id='hardcodingBtn'>하드코딩</button>
|
||||
</div>
|
||||
<div class="col-12 px-0 mt-2 d-none" id="idkeyDiv">
|
||||
<span class='d-flex align-items-center' style="width:157px;">IDKEY : </span>
|
||||
<input type="text" class="d-flex flex-fill form-control" style="width:120px" id="SEARCH-IDKEY" value="" placeholder="키워드검색"/>
|
||||
<select class='d-flex flex-fill form-control' id='IDKEY'>
|
||||
<option value="">IDKEY를 선택해주세요</option>
|
||||
<%
|
||||
SQL = ""
|
||||
SQL = SQL & " SELECT IDKEY, S_DATE, SURVEY_TYPE, "
|
||||
SQL = SQL & " CASE Status WHEN '10' THEN '완료' "
|
||||
SQL = SQL & " WHEN '98' THEN '쿼터' "
|
||||
SQL = SQL & " WHEN '99' THEN '스크린' "
|
||||
SQL = SQL & " WHEN '1' THEN '미완료' "
|
||||
SQL = SQL & " WHEN '999' THEN '삭제' END AS STATUS "
|
||||
SQL = SQL & " FROM [DATA] WITH(NOLOCK) "
|
||||
SQL = SQL & " CROSS APPLY( "
|
||||
SQL = SQL & " SELECT MAX(value) AS S_DATE FROM OPENJSON(survey_date) "
|
||||
SQL = SQL & " )SD "
|
||||
SQL = SQL & " WHERE PKEY='"& PKEY &"' "
|
||||
SQL = SQL & " ORDER BY S_DATE DESC "
|
||||
|
||||
Rcset.Open SQL,DBConn,3,1,1
|
||||
Do While Not Rcset.Eof
|
||||
%>
|
||||
<option value="<%=Rcset("IDKEY")%>">[<%=Rcset("S_DATE")%>] <%=Rcset("IDKEY")%> (<%=Rcset("STATUS")%>) -- <%=Rcset("SURVEY_TYPE")%></option>
|
||||
<%
|
||||
Rcset.MoveNext
|
||||
Loop
|
||||
Rcset.Close
|
||||
%>
|
||||
</select>
|
||||
</div>
|
||||
</h3>
|
||||
</div>
|
||||
<div class="p-3 border rounded shadow-sm">
|
||||
<div class="w-100" id="myDiagramDiv" style="min-height:740px;"></div>
|
||||
<div id="toolTipDIV"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="codemirror_modal" class="position-absolute ui-widget-content bg-white border rounded shadow-sm p-2" style="top:2%;left:2%;width:96%;display:none;">
|
||||
<small class="p-2 rounded shadow-sm bg-primary text-white float-left m-1" id="codemirror-qid"></small>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger float-right m-1" id="codemirror-close">닫기</button>
|
||||
<textarea id="for_codemirror" style="min-height: 380px;"></textarea>
|
||||
</div>
|
||||
<div class="pl-1" id="info-logic">
|
||||
<div class="d-flex flex-column">
|
||||
<div class="d-flex flex-row">
|
||||
<span class="circle text-white bg-navy-4 text-center">1</span>
|
||||
<div class='list-box text-dark-50 w-100 pl-1 d-flex flex-row align-items-center'>프로젝트 선택</div>
|
||||
</div>
|
||||
<div class="ml-3 mt-1 p-1 list-content shadow-sm">
|
||||
<ul class="m-0">
|
||||
<li class="mb-3"><strong class='text-success'>"[ 프로젝트코드/상태 ] 프로젝트명 (회사구분)"</strong>으로 구성</li>
|
||||
<li class="mb-0">좌측 <strong class='text-primary'>[키워드검색]</strong> 기능을 통해 프로젝트 목록을 검색할 수 있음</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="d-flex flex-row mt-3">
|
||||
<span class="circle text-white bg-navy-4 text-center">2</span>
|
||||
<div class='list-box text-dark-50 w-100 pl-1 d-flex flex-row align-items-center'>IDKEY 선택</div>
|
||||
</div>
|
||||
<div class="ml-3 mt-1 p-1 list-content shadow-sm">
|
||||
<ul class="m-0">
|
||||
<li class="mb-3"><strong class='text-success'>"[최종입력일시] IDKEY (상태) -- SURVEYTYPE"</strong> 으로 구성</li>
|
||||
<li class="mb-3">좌측 <strong class='text-primary'>[키워드검색]</strong> 기능을 통해 IDKEY 목록을 검색할 수 있음</li>
|
||||
<li class="mb-0">선택한 IDKEY의 응답값과 응답값 기준의 로직이 적용된 설문 경로를 표시</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="d-flex flex-row mt-3">
|
||||
<span class="circle text-white bg-navy-4 text-center">3</span>
|
||||
<div class='list-box text-dark-50 w-100 pl-1 d-flex flex-row align-items-center'>하드코딩 확인</div>
|
||||
</div>
|
||||
<div class="ml-3 mt-1 p-1 list-content shadow-sm">
|
||||
<ul class="m-0">
|
||||
<li class="mb-3">화면 우측 상단 <strong class='text-primary'>하드코딩</strong> 버튼 클릭 시 hard_func.js 파일 내용을 볼 수 있음</li>
|
||||
<li class="mb-0">각 문항의 하드코딩은 문항을 <strong class='text-warning'>더블 클릭</strong> 시 확인 (하드코딩 설정된 문항은 <strong class='text-pink'>핑크색</strong>으로 표시)</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="d-flex flex-row mt-3">
|
||||
<span class="circle text-white bg-navy-4 text-center">4</span>
|
||||
<div class='list-box text-dark-50 w-100 pl-1 d-flex flex-row align-items-center'>문항 로직</div>
|
||||
</div>
|
||||
<div class="ml-3 mt-1 p-1 list-content shadow-sm">
|
||||
<ul class="m-0">
|
||||
<li class="mb-3"><strong class="text-info">INDEX</strong> 부터 <strong class="text-info">END</strong> 까지 문항 기본 순서로 연결되어 있음</li>
|
||||
<li class="mb-3">문항의 기본 형태는 <strong class="text-info">문항명 [QID] 문항타입</strong></li>
|
||||
<li class="mb-3">문항 <strong class='text-warning'>마우스오버</strong> 시 <strong class="text-info">문항 타이틀(질문 내용)</strong> 표시 (IDKEY 선택 시 타이틀 + 응답값)</li>
|
||||
<li class="mb-3">IDKEY 선택 시 응답값이 존재하는 경우 <strong class='text-blue'>파란색</strong>으로 표시<br>
|
||||
(하드코딩 설정된 문항은 <strong class='text-blue'>파란색 배경</strong> + <strong class='text-pink'>핑크 테두리</strong>)</li>
|
||||
<li class="mb-3">로직(하드코딩 X)이 설정된 문항은 <strong class='text-success'>점선</strong>과 <strong class='text-success'>조건</strong>으로 표시<br>
|
||||
(사전로직은 <strong class='text-mint'>민트색</strong> 배경으로 문항 상단기준, 사후로직은 <strong class='text-green'>연두색</strong> 배경으로 문항 하단기준)</li>
|
||||
<li class="mb-3">로직 조건 또는 문항 경로가 겹쳐서 보이지 않는 경우 <strong class='text-warning'>드래그</strong>를 통해 움직일 수 있음</li>
|
||||
<li class="mb-0">IDKEY 선택 시 응답값 기준으로 문항 로직 흐름을 <strong class='text-danger'>빨간색</strong>으로 표시<br>
|
||||
(하드코딩 로직인 경우는 별도 확인)</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<%
|
||||
SQL = " SELECT QID "
|
||||
SQL = SQL & " , QORDER "
|
||||
SQL = SQL & " , JSON_VALUE(QUESTIONJSON,'$.title') as title "
|
||||
SQL = SQL & " , JSON_VALUE(QUESTIONJSON,'$.variable') as variable "
|
||||
SQL = SQL & " , JSON_VALUE(QUESTIONJSON,'$.explain') as explain "
|
||||
SQL = SQL & " , JSON_VALUE(QUESTIONJSON,'$.qtype') as qtype "
|
||||
SQL = SQL & " , JSON_VALUE(QUESTIONJSON,'$.qgroup') as qgroup "
|
||||
SQL = SQL & " , JSON_VALUE(QUESTIONJSON,'$.rota') as rota "
|
||||
SQL = SQL & " , LOGICJSON as logic "
|
||||
SQL = SQL & " FROM QUESTION WITH(NOLOCK) "
|
||||
SQL = SQL & " WHERE PKEY = '"& PKEY &"' "
|
||||
SQL = SQL & " ORDER BY QORDER "
|
||||
|
||||
Rcset.Open SQL,DBConn,3,1,1
|
||||
RESULTJSON = RecordToJSON(Rcset)
|
||||
Rcset.Close
|
||||
%>
|
||||
<script>
|
||||
var qListJson = <%=RESULTJSON %>;
|
||||
var code = "<%=PKEY %>"; // 설문 코드
|
||||
var hard_func_js_val = "";
|
||||
var myDiagram = null;
|
||||
|
||||
var infoDialog = $("#info-logic").dialog({
|
||||
title: "Logic Viewer Info",
|
||||
autoOpen: false,
|
||||
resizable: false,
|
||||
height: 820,
|
||||
width: 680,
|
||||
modal: true,
|
||||
}).dialogExtend({
|
||||
"minimizable": true,
|
||||
"collapsable": true,
|
||||
"dblclick": "collapse"
|
||||
});
|
||||
|
||||
function make_code_mirror(){
|
||||
var codemirror = document.getElementById("for_codemirror")
|
||||
var myCoedMirror = CodeMirror.fromTextArea(codemirror,
|
||||
{
|
||||
lineNumbers: true,
|
||||
autoRefresh:true,
|
||||
indentWithTabs: true,
|
||||
lineWrapping: true,
|
||||
smartIndent: true,
|
||||
matchBrackets: true,
|
||||
readOnly: true,
|
||||
mode: "text/javascript",
|
||||
theme: "hopscotch",
|
||||
scrollbarStyle: "overlay"
|
||||
}
|
||||
);
|
||||
|
||||
$(".CodeMirror-sizer").css("margin-left", "29px");
|
||||
return myCoedMirror
|
||||
}
|
||||
|
||||
var comirr = make_code_mirror();
|
||||
|
||||
$(function(){
|
||||
$.loadScript("<%=hardfuncjs_path%>", function (e) {
|
||||
hard_func_js_val = e.split(/\n/g);
|
||||
});
|
||||
|
||||
$("#PKEY").on("change", function(){
|
||||
var selPKEY = $(this).children("option:selected").val();
|
||||
location.href="./view_logic.asp?PKEY="+selPKEY;
|
||||
});
|
||||
|
||||
$("#SEARCH-PKEY").on("keyup", function(){
|
||||
var keyword = $(this).val();
|
||||
$("#PKEY").children("option").hide();
|
||||
$("#PKEY").children("option").filter(function(){ return $(this).text().toLowerCase().indexOf(keyword.toLowerCase()) > -1 }).show();
|
||||
});
|
||||
|
||||
$("#IDKEY").on("change", function(){
|
||||
var selIDKEY = $(this).children("option:selected").val();
|
||||
var param = setparam("s", "USER_DATA_ONE", { "PKEY": code, "IDKEY": selIDKEY });
|
||||
var retVal = ajax_returnData("./include/ajax_crud.asp", param);
|
||||
var ansObj = {};
|
||||
$.each(Object.keys(retVal), function(idx, key){
|
||||
ansObj = Object.assign(ansObj, retVal[key]);
|
||||
});
|
||||
$.each(Object.keys(ansObj), function(idx, key){
|
||||
if(left(key, 2) == "TQ"){
|
||||
ansObj[right(key, key.length-1) + "T"] = ansObj[key];
|
||||
delete ansObj[key];
|
||||
}
|
||||
});
|
||||
if(JSON.stringify(ansObj) != "{}"){
|
||||
init(ansObj);
|
||||
}else{
|
||||
init();
|
||||
}
|
||||
});
|
||||
|
||||
$("#SEARCH-IDKEY").on("keyup", function(){
|
||||
var keyword = $(this).val();
|
||||
$("#IDKEY").children("option").hide();
|
||||
$("#IDKEY").children("option").filter(function(){ return $(this).text().toLowerCase().indexOf(keyword.toLowerCase()) > -1 }).show();
|
||||
});
|
||||
|
||||
$("#rawLogicBtn").on("click", function(){
|
||||
if(code == "") {
|
||||
$.alert("프로젝트를 선택하세요");
|
||||
return false;
|
||||
}
|
||||
|
||||
window.open("view_logic_raw.asp?pkey=" + encodeURIComponent(code), "_blank")
|
||||
});
|
||||
|
||||
$("#hardcodingBtn").on("click", function(){
|
||||
if(code == "") {
|
||||
$.alert("프로젝트를 선택하세요");
|
||||
return false;
|
||||
}
|
||||
|
||||
window.open("<%=hardfuncjs_path%>", "_blank");
|
||||
});
|
||||
|
||||
$("#codemirror-close").on("click", function (e) {
|
||||
$("#codemirror_modal").css("display", "none")
|
||||
})
|
||||
|
||||
$("#codemirror_modal").draggable();
|
||||
|
||||
if(code){
|
||||
$("#idkeyDiv").removeClass("d-none").addClass("d-flex");
|
||||
init();
|
||||
}
|
||||
|
||||
$("#info-btn").on("click", function(){
|
||||
infoDialog.dialog("open");
|
||||
});
|
||||
|
||||
$(".list-box").click(function(e){
|
||||
var $target = $(e.target);
|
||||
var $next = $target.parent().next();
|
||||
|
||||
if($next.attr("data-show") == "true"){
|
||||
$next.attr("data-show","false").toggle(130);
|
||||
}else{
|
||||
$next.animate({
|
||||
height:"toggle"
|
||||
}, 150 ,"linear", function(){
|
||||
$next.attr("data-show","true")
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function init(userdata) {
|
||||
if(myDiagram) myDiagram.div = null;
|
||||
var $ = go.GraphObject.make;
|
||||
|
||||
myDiagram = $(go.Diagram, "myDiagramDiv",
|
||||
{
|
||||
//isReadOnly: true,
|
||||
scrollMode: go.Diagram.InfiniteScroll,
|
||||
isTreePathToChildren: false,
|
||||
layout : $(SerpentineLayout, { spacing: new go.Size(80, 80), wrap: 800 })
|
||||
});
|
||||
|
||||
myDiagram.toolManager.mouseMoveTools.insertAt(0, new LinkLabelOnPathDraggingTool());
|
||||
myDiagram.toolManager.hoverDelay = 0;
|
||||
myDiagram.nodeTemplate = $(go.Node, "Auto", { },
|
||||
$(go.Shape, "RoundedRectangle", { strokeWidth: 1, height:68 }, new go.Binding("stroke", "scolor"), new go.Binding("strokeWidth", "swidth"), new go.Binding("fill", "color")),
|
||||
$(go.TextBlock, { margin: 3, font: "13px 'malgun gothic'", textAlign: "center" }, new go.Binding("text", "text")),
|
||||
{
|
||||
toolTip: $(go.HTMLInfo, {
|
||||
show: showToolTip,
|
||||
hide: hideToolTip
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
myDiagram.groupTemplate = $(go.Group, "Vertical",
|
||||
$(go.Panel, "Auto",
|
||||
$(go.Shape, "RoundedRectangle", { parameter1: 14, fill: "rgba(128,128,128,0.33)" }),
|
||||
$(go.Placeholder, { padding: 5})
|
||||
),
|
||||
$(go.TextBlock, { alignment: go.Spot.Bottom, font: "bold 14px 'malgun gothic'" }, new go.Binding("text", "text"))
|
||||
);
|
||||
|
||||
myDiagram.linkTemplate = $(go.Link, { routing: go.Link.AvoidsNodes, corner: 10 },
|
||||
$(go.Shape, new go.Binding("stroke", "stroke"), new go.Binding("strokeWidth", "strokeWidth")),
|
||||
$(go.Shape, { toArrow: "Standard" })
|
||||
);
|
||||
|
||||
myDiagram.linkTemplateMap.add("logic",
|
||||
$(go.Link, { curve: go.Link.Bezier, fromSpot: go.Spot.Top, toSpot: go.Spot.Top },
|
||||
new go.Binding("fromEndSegmentLength", "fromLength"),
|
||||
new go.Binding("toEndSegmentLength", "toLength"),
|
||||
new go.Binding("fromSpot", "fromSpot", go.Spot.parse),
|
||||
new go.Binding("toSpot", "toSpot", go.Spot.parse),
|
||||
$(go.Shape, { strokeDashArray: [2] }, new go.Binding("stroke", "stroke"), new go.Binding("strokeWidth", "strokeWidth")),
|
||||
$(go.Shape, { toArrow: "Standard" }),
|
||||
$(go.Panel, "Auto", { cursor: "move", _isLinkLabel: true, segmentIndex: NaN, segmentFraction: .5 },
|
||||
$(go.Shape, "Rectangle", { }, new go.Binding("fill", "color")),
|
||||
$(go.TextBlock, { textAlign: "center", font: "11px 'malgun gothic'", margin: 3 }, new go.Binding("text", "text")),
|
||||
new go.Binding("segmentOffset", "segmentOffset", go.Point.parse).makeTwoWay(go.Point.stringify)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
var models = jQuery.map(qListJson, function(obj){ return {"key":obj.QID, "text":obj.variable + "\n[" + obj.QID + "]\n\n" + obj.qtype, "color":"#e6f0ff", "group":(obj.qgroup != "" ? "g"+obj.qgroup : (obj.rota != "" ? "r"+obj.rota : "")), "title":removeTags(obj.title), "answer":"" }; });
|
||||
models.unshift({"key":"Q0", "text":"INDEX", "color":"#ffd358", "group":"", "title":"INDEX", "answer":"" });
|
||||
models.push({"key":"END", "text":"END", "color":"#c19090", "group":"", "title":"END", "answer":"" });
|
||||
var groups = jQuery.unique(jQuery.map(qListJson, function(obj, idx){ if(obj.qgroup != "") return obj.qgroup } )).map(function(o){ return {"key":"g"+o, "text":"Group"+o, isGroup:true}; });
|
||||
var rotas = jQuery.unique(jQuery.map(qListJson, function(obj, idx){ if(obj.rota != "") return obj.rota } )).map(function(o){ return {"key":"r"+o, "text":"Rota"+o, isGroup:true}; });
|
||||
var qidToGrp = JSON.parse("{"+jQuery.map(qListJson, function(obj){ if(obj.qgroup != "" || obj.rota != "") return "\""+obj.QID+"\":\""+(obj.qgroup != "" ? "g"+obj.qgroup : (obj.rota != "" ? "r"+obj.rota : ""))+"\""; }).join(",")+"}");
|
||||
|
||||
jQuery.each(groups, function(idx, obj){
|
||||
var fi = models.findIndex(function(o){return o.group == obj.key; })
|
||||
models.splice(fi, 0, obj);
|
||||
});
|
||||
jQuery.each(rotas, function(idx, obj){
|
||||
var fi = models.findIndex(function(o){return o.group == obj.key; })
|
||||
models.splice(fi, 0, obj);
|
||||
});
|
||||
|
||||
var tmpQlist = jQuery.unique(jQuery.map(models, function(obj, idx){ return (obj.group != "" ? obj.group : obj.key); }))
|
||||
var fromTo = jQuery.map(tmpQlist, function(obj, idx){ if(idx > 0) return {"from":tmpQlist[idx-1], "to":obj}; });
|
||||
var logicArr = jQuery.map(qListJson, function(obj){ if(obj.logic != "") return {"QID":(obj.qgroup != "" ? "g"+obj.qgroup : (obj.rota != "" ? "r"+obj.rota : obj.QID)), "logic":JSON.parse(obj.logic.replace(/˝/g, "\"")) }; });
|
||||
jQuery.each(logicArr, function(idx, obj){
|
||||
if(obj.logic.n.length > 0){
|
||||
jQuery.each(obj.logic.n, function(ix, tmpObj){
|
||||
var tmpLogic = jQuery.map(tmpObj.condition, function(o){ return (o.cd ? o.cd+"\n" : "") + o.va + " " + o.op + " " + o.co + " "; }).join("").trim();
|
||||
fromTo.push({"from":obj.QID, "to":qidToGrp[tmpObj.nextpage] ? qidToGrp[tmpObj.nextpage] : tmpObj.nextpage, "color":"#14ef35", "text":tmpLogic, "category":"logic", "fromLength":40, "toLength":40, "fromSpot":"Bottom", "toSpot":"Bottom", "logic_type":"n"});
|
||||
});
|
||||
}
|
||||
if(obj.logic.p.length > 0){
|
||||
jQuery.each(obj.logic.p, function(ix, tmpObj){
|
||||
var tmpLogic = jQuery.map(tmpObj.condition, function(o){ return (o.cd ? o.cd+"\n" : "") + o.va + " " + o.op + " " + o.co + " "; }).join("").trim();
|
||||
fromTo.push({"from":obj.QID, "to":qidToGrp[tmpObj.nextpage] ? qidToGrp[tmpObj.nextpage] : tmpObj.nextpage, "color":"#00ffee", "text":tmpLogic, "category":"logic", "fromLength":40, "toLength":40, "fromSpot":"Top", "toSpot":"Top", "logic_type":"p"});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
jQuery.each(models, function(idx, obj){
|
||||
if(hard_code_yn(obj.key)){
|
||||
obj.scolor = "#cd33ff";
|
||||
obj.swidth = 2;
|
||||
obj.color = "#ffdeff";
|
||||
}
|
||||
if(userdata){
|
||||
var ans = jQuery.grep(Object.keys(userdata), function(o){ return o.split("_")[0] == obj.key; });
|
||||
if(ans.length > 0){
|
||||
obj.color = "#55deff";
|
||||
var tmpTxt = "";
|
||||
obj.answer = jQuery.map(ans, function(o){ return o + " = " + userdata[o]; }).join("<br>");
|
||||
}
|
||||
}
|
||||
});
|
||||
if(userdata){
|
||||
userdata = Object.assign(userdata, JSON.parse("{" + jQuery.map(qListJson, function(obj){ if(obj.qtype == "description") return "\""+obj.QID+"\":\"안내문\""; }).join(",") + "}"));
|
||||
var lnPage = ""
|
||||
jQuery.each(fromTo, function(idx, obj){
|
||||
if(obj.category == undefined && (obj.from == lnPage || lnPage == "")){
|
||||
var pLogicChk = false;
|
||||
var nLogicChk = false;
|
||||
var logicChk = jQuery.grep(logicArr, function(o){ return o.QID == obj.from; });
|
||||
var nPage = obj.to;
|
||||
|
||||
if(logicChk.length > 0){
|
||||
if(logicChk[0].logic.p.length > 0){
|
||||
var logicRes = logic_chk(userdata, logicChk[0].logic, nPage, "p");
|
||||
nPage = logicRes.nextpage;
|
||||
nPage = qidToGrp[nPage] ? qidToGrp[nPage] : nPage;
|
||||
pLogicChk = logicRes.logic;
|
||||
}
|
||||
if(pLogicChk == false && logicChk[0].logic.n.length > 0){
|
||||
var logicRes = logic_chk(userdata, logicChk[0].logic, nPage, "n");
|
||||
nPage = logicRes.nextpage;
|
||||
nPage = qidToGrp[nPage] ? qidToGrp[nPage] : nPage;
|
||||
nLogicChk = logicRes.logic;
|
||||
}
|
||||
}
|
||||
lnPage = nPage;
|
||||
|
||||
if(pLogicChk){
|
||||
var realLogic = jQuery.grep(fromTo, function(o){ return o.from == obj.from && o.to == nPage && o.category == "logic" && o.logic_type == "p"; });
|
||||
if(realLogic.length > 0){
|
||||
realLogic[0].stroke = "#ff0000";
|
||||
realLogic[0].strokeWidth = 3;
|
||||
}
|
||||
}else if(nLogicChk){
|
||||
var realLogic = jQuery.grep(fromTo, function(o){ return o.from == obj.from && o.to == nPage && o.category == "logic" && o.logic_type == "n"; });
|
||||
if(realLogic.length > 0){
|
||||
realLogic[0].stroke = "#ff0000";
|
||||
realLogic[0].strokeWidth = 3;
|
||||
}
|
||||
}else{
|
||||
var realLogic = jQuery.grep(fromTo, function(o){ return o.from == obj.from && o.to == nPage && o.category != "logic"; });
|
||||
if(realLogic.length > 0){
|
||||
realLogic[0].stroke = "#ff0000";
|
||||
realLogic[0].strokeWidth = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
myDiagram.model = new go.GraphLinksModel(models, fromTo);
|
||||
|
||||
myDiagram.addDiagramListener("ObjectDoubleClicked", qClickEvent);
|
||||
}
|
||||
|
||||
function showToolTip(obj, diagram, tool) {
|
||||
var pt = diagram.lastInput.viewPoint;
|
||||
$('#toolTipDIV').css({"left":(pt.x) + "px", "top":(pt.y + 180) + "px"});
|
||||
$('#toolTipDIV').html("");
|
||||
var tmpHTML = "";
|
||||
tmpHTML += "<div id='tt-head'>"+ obj.data.title +"</div>";
|
||||
if(obj.data.answer) tmpHTML += "<div id='tt-ans'>"+ obj.data.answer +"</div>";
|
||||
$('#toolTipDIV').html(tmpHTML);
|
||||
$('#toolTipDIV').show();
|
||||
}
|
||||
|
||||
function hideToolTip(diagram, tool) {
|
||||
$('#toolTipDIV').hide();
|
||||
}
|
||||
|
||||
function hard_code_yn(QID){
|
||||
var retVal = false;
|
||||
var trim_text = hard_func_js_val.map(function (v) { return v.trim() });
|
||||
if(QID == "Q0" || QID == "INDEX" || QID == "ALL"){
|
||||
var checkIdx = trim_text.indexOf("if(qid === \"INDEX\"){");
|
||||
if(checkIdx > 0){
|
||||
retVal = true;
|
||||
}
|
||||
checkIdx = trim_text.indexOf("if(qid === \"ALL\"){");
|
||||
if(checkIdx > 0){
|
||||
retVal = true;
|
||||
}
|
||||
}else if(QID == "END"){
|
||||
var checkIdx = trim_text.indexOf("if(qid === \"END\"){");
|
||||
if(checkIdx > 0){
|
||||
retVal = true;
|
||||
}
|
||||
}else{
|
||||
var checkIdx = trim_text.indexOf("case \"" + QID + "\" :");
|
||||
if(checkIdx > 0){
|
||||
retVal = true;
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
function qClickEvent(e){
|
||||
var QID = e.subject ? e.subject.part.data.key : e;
|
||||
if(!hard_code_yn(QID)){
|
||||
$.alert("선택하신 문항은 하드코딩이 없습니다.");
|
||||
return false;
|
||||
}
|
||||
if(QID == "Q0") {
|
||||
$.confirm({
|
||||
title:"",
|
||||
content: "확인하실 하드코딩을 선택해주세요.",
|
||||
columnClass:"small",
|
||||
buttons:{
|
||||
"INDEX":function(){
|
||||
qClickEvent("INDEX");
|
||||
},
|
||||
"전체문항":function(){
|
||||
qClickEvent("ALL");
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
var retCodes = "";
|
||||
var trim_text = hard_func_js_val.map(function (v) { return v.trim() });
|
||||
|
||||
if(QID == "INDEX" || QID == "ALL" || QID == "END"){
|
||||
var iStIdx = trim_text.indexOf("if(qid === \"" + QID + "\"){");
|
||||
if(iStIdx > 0){
|
||||
var iEdIdx = trim_text.indexOf("}// " + QID + "");
|
||||
retCodes = hard_func_js_val.slice(iStIdx + 1, iEdIdx).join("\n");
|
||||
}
|
||||
}else{
|
||||
var iStIdx = trim_text.indexOf("case \"" + QID + "\" :");
|
||||
if (iStIdx > 0) {
|
||||
var iEdIdx = trim_text.indexOf("break;//" + QID, iStIdx + 1);
|
||||
retCodes = hard_func_js_val.slice(iStIdx + 1, iEdIdx).join("\n");
|
||||
}
|
||||
}
|
||||
|
||||
if(retCodes == ""){
|
||||
$.alert("하드코딩이 비어있습니다.");
|
||||
return false;
|
||||
}
|
||||
|
||||
$("#codemirror_modal").css({ "display": "inline-block", "resize": "none", "overflow": "auto" });
|
||||
|
||||
comirr.setValue(retCodes);
|
||||
|
||||
$("#codemirror-qid").text(QID);
|
||||
$("#codemirror_modal").draggable("option", "disabled", false);
|
||||
}
|
||||
|
||||
function logic_chk(data, logic, nextpage, types) {
|
||||
var retVal = {"nextpage":nextpage, "logic":false};
|
||||
if (logic) {
|
||||
var logictarget = types === "n" ? logic.n : logic.p;
|
||||
if (logictarget.length > 0) {
|
||||
logictarget.some(function (l) {
|
||||
var boolean = false;
|
||||
l.condition.forEach(function (e) {
|
||||
if (e.cd) {
|
||||
if (e.cd === "or")
|
||||
boolean = boolean || boolean_Expression(data, e.va, e.op, e.co);
|
||||
else
|
||||
boolean = boolean && boolean_Expression(data, e.va, e.op, e.co);
|
||||
} else {
|
||||
boolean = boolean_Expression(data, e.va, e.op, e.co);
|
||||
}
|
||||
})
|
||||
|
||||
if (boolean) {
|
||||
retVal.nextpage = l.nextpage;
|
||||
retVal.logic = true;
|
||||
return true;
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
return retVal;
|
||||
}
|
||||
|
||||
function boolean_Expression(data, va, op, co) {
|
||||
var bools = false;
|
||||
if (!data[va] && (op !== "=" && op !== "!=" ))
|
||||
return false;
|
||||
|
||||
switch (op) {
|
||||
case "=": bools = (data[va] || "") == co; break;
|
||||
case ">": bools = +data[va] > +co; break;
|
||||
case "<": bools = +data[va] < +co; break;
|
||||
case ">=": bools = +data[va] >= +co; break;
|
||||
case "<=": bools = +data[va] <= +co; break;
|
||||
case "!=": bools = (data[va] || "") != co; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return bools;
|
||||
}
|
||||
|
||||
function removeTags(str) {
|
||||
if((str===null) || (str==='')){
|
||||
return false;
|
||||
}else{
|
||||
str = str.toString();
|
||||
str = str.replace( /(<([^>]+)>)/ig, '');
|
||||
return str.replace(/ /g, " ");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<!-- #include Virtual="/include/footer.asp" -->
|
||||
Reference in New Issue
Block a user