File: TrackHubsDynamic.html

package info (click to toggle)
igv 2.18.5%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 174,428 kB
  • sloc: java: 121,493; xml: 10,326; sh: 184; ansic: 92; javascript: 54; makefile: 19
file content (80 lines) | stat: -rw-r--r-- 2,047 bytes parent folder | download | duplicates (4)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Track Hub links</title>
</head>
<body>

<div>
    <h2>Hubs</h2>
    <div id="hub_message"></div>
    <ul id="hub_list"></ul>
</div>


<script type="module">

    const hubs = new Map([
        ["African ostritch", "https://hgdownload.soe.ucsc.edu/hubs/GCF/000/698/965/GCF_000698965.1/hub.txt"],
        ["African hunting dog", "https://hgdownload.soe.ucsc.edu/hubs/GCA/001/887/905/GCA_001887905.1/hub.txt"]
    ])

    const igvIsRunning = await igvRunning()
    
    for (let key of hubs.keys()) {
        const div = document.createElement("div")
        div.innerText = key
        div.dataset.hubUrl = hubs.get(key)
        div.addEventListener("click", loadIGV)
        div.style = "cursor:pointer;color:blue;text-decoration:underline;"

        const li = document.createElement("li")
        li.appendChild(div)

        document.getElementById("hub_list").appendChild(li)
    }


    async function loadIGV(e) {
        if (igvIsRunning) {
            const url = `http://localhost:60151?hubURL=${e.currentTarget.dataset.hubUrl}`
            return fetch(url)
        } else {
            alert("You must start IGV 3.0 or later to enable links.")
        }
    }

    async function igvRunning() {
        try {
            const igvResponse = await fetch("http://localhost:60151/version")
            if (igvResponse.ok) {
                const text = await igvResponse.text()
                return text.length > 0 && Number.parseInt(text.charAt(0)) >= 3
            } else {
                return false
            }
        } catch (e) {
            return false
        }
    }


</script>

<!--<script type="module">-->

<!--  let igvDesktopIsResponding-->
<!--  try {-->
<!--    const igvResponse = await fetch("http://localhost:60151/ping")-->
<!--    igvDesktopIsResponding = igvResponse.ok-->
<!--  } catch (e) {-->
<!--    igvDesktopIsResponding = false-->
<!--  }-->

<!--  console.log(igvDesktopIsResponding);-->

<!--</script>-->

</body>
</html>