-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex2.html
137 lines (85 loc) · 3.14 KB
/
index2.html
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<!DOCTYPE html>
<html>
<head lang="en">
<!-- this example demonstrates how to include karyotypesvg by importing karyotypesvg.dbg.js !-->
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Karyotypejs demo file 2</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src='js/vendor/jquery-2.0.2.min.js'></script>
<script src='js/vendor/bootstrap-3.3.4.min.js'></script>
<script src="build/karyotypesvg.dbg.js"></script>
</head>
<body>
<div class="container-fluid">
<div class="jumbotron">
<h1>KaryotypeSVG demo 2</h1>
</div>
<!-- a dropdown menu to switch between chromosomes -->
<div id="dropdownMain" class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true">
Select Chromosome
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
</ul>
</div>
<p />
<!-- The actual SVG graphics will be in this container -->
<div id="karyotypeView"></div>
</div>
<script>
var karyotypesvg ;
require(['karyotype'], function(KT) {
karyotypesvg = KT;
$(document).ready(function () {
var chr = "chr1";
var kt = new karyotypesvg.Karyotype();
kt.init();
kt.showThumb(true);
kt.setParent("#karyotypeView");
kt.addListener('viewerReady', function () {
kt.update(chr,60800000, 68500000);
kt.updateScale();
console.log(kt.getSVG());
});
kt.addListener('bandClicked', function (event) {
console.log(event);
kt.update(event.chr, event.min, event.max);
});
kt.addListener('sliderMoved', function (event) {
console.log(event);
});
kt.addListener('viewerReady', function(event) {
updateUI(kt);
});
});
});
$(function() { $("[data-toggle='tooltip']").tooltip();});
function updateUI(kt){
// add a dropdown that allows to switch between chromosomes.
var chromosomes = kt.getChromosomeList();
var chr = "";
for ( var i = 0 ; i< chromosomes.length ; i++){
//console.log(bands[i]);
var currentChr = chromosomes[i];
if ( currentChr !== chr){
// add a new dropdown;
if ( currentChr.indexOf('_') > -1) {
continue;
}
$('#dropdownMain ul').append('<li role="presentation"><a role="menuitem" tabindex="-1" href="#">'+currentChr+'</a></li>');
}
chr = currentChr;
}
$(".dropdown-menu li a").click(function(){
var chr = $(this).text();
//console.log($(this).text());
kt.update(chr);
});
}
</script>
</body>
</html>