Skip to content

Commit 5f444b3

Browse files
committed
UI
1 parent c38cf2e commit 5f444b3

File tree

4 files changed

+64
-30
lines changed

4 files changed

+64
-30
lines changed

common/jquery.droppable.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
if (!STYLING_EVENTS_BINDED) {
1717
$(window).on('dragenter', function () {
18-
$("." + DROPPABLE_CLASSNAME).css({
19-
background: "orange"
18+
$("." + DROPPABLE_CLASSNAME).addClass("active").css({
19+
height: $(window).innerHeight()
2020
});
2121
});
2222
STYLING_EVENTS_BINDED = true;

common/styles.css

+13-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,23 @@
22
border: 1px solid lightgray;
33
}
44

5-
#drop {
5+
.droppable {
6+
position: absolute;
7+
top: 0;
8+
height: 500px;
9+
width: 100%;
10+
display: none;
611
text-align: center;
712
z-index: 1;
813
font-size: 1.5em;
9-
border-bottom-left-radius: 10px;
10-
border-bottom-right-radius: 10px;
1114
margin: -2px 0 10px;
15+
line-height: 500px;
16+
}
17+
18+
.droppable.active {
19+
display: block;
20+
background: orange;
21+
color: white;
1222
}
1323

1424
body {

cpuprofile_topology/index.html

+10-9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<script src="../common/jquery.droppable.js"></script>
1212
<script src="../common/track_progress.js"></script>
1313
<link rel="stylesheet" href="../common/styles.css"/>
14+
<link rel="stylesheet" href="//apps.bdimg.com/libs/fontawesome/4.2.0/css/font-awesome.css"/>
1415
<script>
1516
var _hmt = _hmt || [];
1617
(function () {
@@ -38,9 +39,7 @@
3839
if (data.head) {
3940
if (data.samples) {
4041
draw(data);
41-
$("#drop").css({
42-
background: "white"
43-
})
42+
$("#drop").removeClass('active')
4443
$("#drop").text(file.name + " " + (Math.floor(file.size / 1024) + " KB"));
4544

4645
_hmt && _hmt.push(['_trackEvent', "events", 'draw_success', file.name, file.size]);
@@ -51,6 +50,7 @@
5150
throw new Error("格式不支持");
5251
}
5352
} catch (e) {
53+
$("#drop").removeClass('active')
5454
alert(e.message);
5555
_hmt && _hmt.push(['_trackEvent', "events", 'draw_error', file.name, file.size]);
5656
}
@@ -198,7 +198,7 @@
198198

199199
var options = {
200200
width: "95%",
201-
height: (window.innerHeight - $("#drop").outerHeight() - $("#control").outerHeight() - 40) + "px",
201+
height: (window.innerHeight - $("#control").outerHeight() - 40) + "px",
202202
layout: {
203203
hierarchical: {
204204
enabled: true
@@ -243,15 +243,16 @@
243243
</script>
244244
<div id="control">
245245
<form>
246-
<button id="prev">prev</button>
247-
<button id="next">next</button>
246+
<button id="prev"><i class="fa fa-step-backward"></i></button>
247+
<button id="next"><i class="fa fa-step-forward"></i></button>
248248
<span id="time_text"></span>
249249
<input id="time" type="range" step="1" style="width: 98%"/>
250250
</form>
251251
<footer>
252-
2015 MIT License <a target="_blank"
253-
href="https://github.com/wyvernnot/javascript_performance_measurement/tree/gh-pages/cpuprofile_topology">OneProfile
254-
on Github</a>
252+
<a target="_blank"
253+
href="https://github.com/wyvernnot/javascript_performance_measurement/tree/gh-pages/cpuprofile_topology">
254+
<i class="fa fa-github"></i>
255+
</a>
255256
</footer>
256257
</div>
257258

heap_snapshot/index.html

+39-16
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@
88
<link rel="stylesheet" href="../common/styles.css"/>
99
<link rel="stylesheet" href="//apps.bdimg.com/libs/fontawesome/4.2.0/css/font-awesome.css"/>
1010
<style>
11-
#root {
12-
height: 600px;
13-
border: 1px solid;
11+
@media (max-width: 414px) {
12+
label span {
13+
display: none;
14+
}
15+
16+
input[type=file] {
17+
display: none;
18+
}
1419
}
1520
</style>
1621
<script>
@@ -28,36 +33,39 @@
2833
把 .heapsnapshot 文件拖到这里<br/>
2934
</div>
3035
<div>
31-
鼠标模式:
36+
<label>
37+
<span>鼠标模式:</span>
38+
</label>
3239
<label>
3340
<input type="radio" name="mode" checked>
3441
默认
3542
</label>
3643

3744
<label>
3845
<input type="radio" name="mode" value="from">
39-
<i class="fa fa-expand"></i>起点
46+
<i class="fa fa-expand"></i><span>起点</span>
4047
</label>
4148

4249
<label>
4350
<input type="radio" name="mode" value="to">
44-
<i class="fa fa-compress"></i>汇入
51+
<i class="fa fa-compress"></i><span>汇入</span>
4552
</label>
4653

4754
<label>
4855
<input type="radio" name="mode" value="fix">
49-
<i class="fa fa-anchor"></i>固定
56+
<i class="fa fa-anchor"></i><span>固定</span>
5057
</label>
5158

5259
<label>
5360
<input type="radio" name="mode" value="unchain">
54-
<i class="fa fa-chain-broken"></i>断开
61+
<i class="fa fa-chain-broken"></i><span>断开</span>
5562
</label>
5663

5764
<label>
5865
<input type="radio" name="mode" value="remove">
59-
<i class="fa fa-trash-o"></i>删除
66+
<i class="fa fa-trash-o"></i><span>删除</span>
6067
</label>
68+
<input id="file" type="file">
6169
</div>
6270
<div id="root"></div>
6371
<footer>
@@ -77,21 +85,17 @@
7785
var data = JSON.parse(result);
7886
if (data.snapshot) {
7987
draw(data);
80-
81-
$("#drop")
82-
.css({
83-
background: "white"
84-
})
85-
.text(file.name + " " + (Math.floor(file.size / 1024) + " KB"));
88+
$("#drop").removeClass('active');
89+
$("#drop").text(file.name + " " + (Math.floor(file.size / 1024) + " KB"));
8690

8791
_hmt && _hmt.push(['_trackEvent', "events", 'draw_success', file.name, file.size]);
8892

8993
} else {
9094
throw new Error("格式不支持");
9195
}
9296
} catch (e) {
97+
$("#drop").removeClass('active');
9398
alert(e.message);
94-
9599
_hmt && _hmt.push(['_trackEvent', "events", 'draw_error']);
96100
}
97101
})
@@ -256,6 +260,7 @@
256260
* weak: "6"
257261
*/
258262
var options = {
263+
height: ($(window).innerHeight() - 80) + "px",
259264
nodes: {
260265
size: 10,
261266
shape: "dot"
@@ -393,6 +398,24 @@
393398
});
394399
}
395400

401+
$('#file')[0].addEventListener('change', function () {
402+
403+
var reader = new FileReader();
404+
var file = this.files[0];
405+
406+
reader.onload = function () {
407+
try {
408+
var data = JSON.parse(reader.result);
409+
draw(data);
410+
} catch (e) {
411+
alert(e.message);
412+
}
413+
414+
};
415+
416+
reader.readAsText(file);
417+
})
418+
396419
}
397420

398421
</script>

0 commit comments

Comments
 (0)