"틀:SemanticGraph"의 두 판 사이의 차이

광주문화예술인문스토리플랫폼
이동: 둘러보기, 검색
10번째 줄: 10번째 줄:
 
   var iframe = document.getElementById('semantic-graph-iframe');
 
   var iframe = document.getElementById('semantic-graph-iframe');
 
   var container = document.getElementById('semantic-graph-container');
 
   var container = document.getElementById('semantic-graph-container');
 +
  var iframeSrc = iframe.src;
 
    
 
    
   iframe.addEventListener('load', function() {
+
   // API 엔드포인트로 데이터 존재 여부 확인
     setTimeout(function() {
+
  fetch(iframeSrc.replace('/story01?', '/api/check?'))
       try {
+
     .then(function(response) {
        var iframeDoc = iframe.contentDocument {{!}}{{!}} iframe.contentWindow.document;
+
       return response.text();
        var bodyContent = iframeDoc.body.innerHTML;
+
    })
       
+
    .then(function(data) {
        // HTML 길이가 짧거나 특정 패턴이 있으면 에러로 간주
+
      // 응답이 비어있거나 에러면 숨김
        if (bodyContent.length < 500 {{!}}{{!}}
+
      if (!data {{!}}{{!}} data.length < 100) {
            bodyContent.includes('Simple Ontology Visualization') {{!}}{{!}}
+
        hideGraphSection();
            bodyContent.includes('vis.js Network')) {
 
          hideGraphSection();
 
        }
 
      } catch(e) {
 
        // Cross-origin인 경우 접근 불가
 
        console.log('iframe cross-origin');
 
 
       }
 
       }
     }, 1000);
+
     })
  });
+
    .catch(function(error) {
 
+
      console.log('fetch error:', error);
  iframe.addEventListener('error', function() {
+
      // fetch 실패시에도 숨기지 않음 (네트워크 오류일 수 있음)
    hideGraphSection();
+
    });
  });
 
 
    
 
    
 
   function hideGraphSection() {
 
   function hideGraphSection() {
53번째 줄: 47번째 줄:
 
}}
 
}}
 
</onlyinclude>
 
</onlyinclude>
 +
  
  

2026년 1월 12일 (월) 09:37 판




사용방법

시맨틱 데이터베이스의 특정 노드를 중심으로 하는 네트워크 그래프를 출력하는 틀입니다

{{SemanticGraph | key = }}