view_sot_dg.html 1.56 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<html>

<body>
   <script src="https://github.com/mdaines/viz.js/releases/download/v2.1.2/viz.js"></script>
   <script src="https://github.com/mdaines/viz.js/releases/download/v2.1.2/full.render.js"></script>
   <script>
     function renderDOTFile() {
       var fileInputElement = document.getElementById("fileInputElement");
     
       var reader = new FileReader();
       var graphtextres = ""
       reader.onloadend = function(e) {
          graphtextres = e.target.result
          var viz = new Viz();

          viz.renderSVGElement(graphtextres)
          .then(function(element) {

            elementToRemove=document.getElementById("displaysvgzone")
            if (elementToRemove != null)
            {
             document.body.removeChild(elementToRemove)
            }
            document.body.appendChild(element)
            element.id="displaysvgzone"
         })
         .catch(error => {
          // Create a new Viz instance (@see Caveats page for more info)
          viz = new Viz();
     
          // Possibly display the error
          console.error(error);
          });
        }
       reader.readAsText(fileInputElement.files[0]);
     };


   </script>
   <input type="file" id="fileInputElement">   
   <input id="Rendering" type="button" value="Rendering" onclick="renderDOTFile();" />
   <script>
     var el = document.getElementById("Rendering");
     if (el.addEventListener)
       el.addEventListener("click", renderDOTFile, false);
     else if (el.attachEvent)
       el.attachEvent('onclick', renderDOTFile);
   </script>
</body>

</html>