forked from eliotstock/memory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
786 lines (617 loc) · 21.8 KB
/
index.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<!--
Copyright 2014 Eliot Stock
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<style>
body { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 12px; text-align: center; }
.chart { display: block; margin: auto; }
rect { stroke: #EEEEEE; fill: #AAAAAA; fill-opacity: 0.8; }
rect.parent { cursor: pointer; fill: steelblue; }
text { pointer-events: none; }
</style>
<body>
<p>
Select an ld *.map file: <input id="file" type="file"/>
</p>
<p id="error"> </p>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js" type="text/javascript"></script>
<script src="https://d3js.org/d3.v3.min.js" type="text/javascript"></script>
<script>
var SORT_CHUNKS_BY_SIZE = false;
var FILL_IN_BLANK_SPACE_BETWEEN_REGIONS = false;
var w = 1120,
h = 680,
x = d3.scale.linear().range([0, w]),
y = d3.scale.linear().range([0, h]);
var reader = new FileReader();
var vis = d3.select("body").append("div")
.attr("class", "chart")
.style("width", w + "px")
.style("height", h + "px")
.append("svg:svg")
.attr("width", w)
.attr("height", h);
// The "size" property of each node gives d3 its drawn height.
// Don't sort by size, just use the order in the child arrays.
var partition = d3.layout.partition()
.value(function(d) { return d.size; })
.sort(null);
var checkForHtml5FileApis = function() {
if (window.File && window.FileReader) {
console.log("HTML5 File APIs supported.");
}
else {
$("p#error").html("HTML5 File APIs NOT supported. Can't continue. Please use a modern,"
+ " desktop web browser.");
$("p#error").show();
}
};
$("#file").change(function(e) {
var files = e.target.files;
if (files.length != 1) {
return error("Please select one and only one file.");
}
// We could throw an error here if files[0].type !== "text/plain", but it would
// only be any good on Mac. Windows doesn't get a file type at all.
// Calls back to reader.onload() below.
console.log("Reading file: " + files[0].name);
reader.readAsText(files[0]);
});
reader.onload = function(e) {
var inputFile = e.target.result;
// Windows: CRLF \r\n
// Unix, inc. Mac OS: LF \n
// Excel for Mac "Save As CSV": CR \r
var lines = inputFile.split(/\r\n?|\n/); // Any of the above
var root = {"name": "Memory", "children": []};
var memoryTop = 0;
var regionsLines = getRegionsLines(lines);
// console.log("regions lines from *.Map file:");
// console.log(regionsLines);
parseMemoryConfig(regionsLines, root);
// Regions are not necessarily in order. Sort them by origin.
root.children.sort(sortByOrigin);
// On the Nordic, space within flash would be nice to see, and within RAM, but not between the
// end of flash and the start of RAM. That's all too messy and Nordic-specific to do, so just
// switch this on and off as you see fit.
if (FILL_IN_BLANK_SPACE_BETWEEN_REGIONS) {
fillInBlankSpaceBetweenRegions(root);
}
// console.log("Memory regions:");
// console.log(root.children);
var memoryMapLines = getMemoryMapLines(lines);
// console.log("sections lines from *.Map file:");
// console.log(sectionsLines);
parseMemory(memoryMapLines, root);
fillInBlankSpaceWithinRegions(root);
// The root node needs an origin and an end as well
root.origin = root.children[0].origin;
root.end = root.children[root.children.length - 1].end;
// Reverse the order of regions so that we're drawing 0x0 at the bottom of the screen. Within
// regions though, sections fill up from bottom to top.
root.children.reverse();
console.log("root:");
console.log(root);
// Don't let any node at the region level get smaller than what we can click on.
// Probably not a good idea.
// enlargeTinyRegions(root);
display(root);
// Blank out the file chooser field. If we don't do this, choosing the same file again
// after editing doesn't change the value and the change() handler is never called.
$("#file").val("");
};
// Pull out just the interesting lines from the "Memory Configuration" part of the *.Map file,
// which looks like this:
//
// Name Origin Length Attributes
// FLASH 0x0000000000016000 0x000000000002a000 xr
// RAM 0x0000000020002000 0x0000000000002000 xrw
// *default* 0x0000000000000000 0xffffffffffffffff
var getRegionsLines = function(lines) {
var inMemoryConfig = false;
var relevantLines = [];
for (var l = 0; l < lines.length; l++) {
var line = lines[l];
if (line.indexOf("Name") != -1
&& line.indexOf("Origin") != -1
&& line.indexOf("Length") != -1) {
// We're interested in the next line onwards.
inMemoryConfig = true;
continue;
}
if (inMemoryConfig) {
var words = line.trim().split(/\s+/);
// We know we're done with the memory configuration section when we see a blank line.
if (words.length == 1 && words[0] == "") {
break;
}
relevantLines.push(line);
}
}
return relevantLines;
}
var getMemoryMapLines = function(lines) {
var inMemoryMap = false;
var seenLinkerScriptHeading = false;
var blankLinesSinceLinkerScriptHeading = 0;
var relevantLines = [];
for (var l = 0; l < lines.length; l++) {
var line = lines[l];
if (line == "Linker script and memory map") {
seenLinkerScriptHeading = true;
continue;
}
if (seenLinkerScriptHeading) {
if (line == "") {
blankLinesSinceLinkerScriptHeading++;
}
}
if (blankLinesSinceLinkerScriptHeading == 2) {
inMemoryMap = true;
}
if (inMemoryMap) {
// We're done once we reach the end of the stack. Ignore debug symbols and so on.
if (line.indexOf("OUTPUT") == 0) {
break;
}
relevantLines.push(line);
}
}
// Long section names will force the linker to break the line into two. Unbreak these so
// they're easier to handle below. Any single word lines followed by a line with two or more
// words should be joined up.
var unbrokenLines = [];
var singleWordLine = null;
for (var l = 0; l < relevantLines.length; l++) {
var line = relevantLines[l];
if (line == "") continue;
var words = line.trim().split(/\s+/);
if (words.length == 1) {
// Remember this word and read the next line.
singleWordLine = words[0];
continue;
}
if (singleWordLine != null && words.length >= 2) {
// Last line was a single word and this line has two or more. Join them.
var unbrokenLine = singleWordLine + line;
unbrokenLines.push(unbrokenLine);
singleWordLine = null;
continue;
}
unbrokenLines.push(line);
}
return unbrokenLines;
}
var parseMemoryConfig = function(lines, root) {
for (var l = 0; l < lines.length; l++) {
var line = lines[l];
// Split line into cells based on any whitespace.
var cells = line.trim().split(/\s+/);
var name = cells[0];
var origin = parseInt(removeLeading0x(cells[1]), 16);
var declaredSize = parseInt(removeLeading0x(cells[2]), 16);
var end = origin + declaredSize;
// Ignore a line like:
// *default* 0x0000000000000000 0xffffffffffffffff
if (name == "*default*") {
continue;
}
var region = {"name": name,
"declaredSize": declaredSize,
"origin": origin,
"end": end,
"children": []};
root.children.push(region);
}
};
var fillInBlankSpaceBetweenRegions = function(root) {
// Let d3 calculate the size of each node based on the sum of its children.
var nodes = partition.nodes(root);
// Figure out where the top of our memory is.
memoryTop = 0;
for (var i = 0; i < root.children.length; i++) {
var region = root.children[i];
if (region.end > memoryTop) {
memoryTop = region.end;
}
}
console.log("Top of memory: " + toHex(memoryTop));
// Figure out the average size of a declared memory region.
var averageRegionSize = 0;
var totalRegionMemory = 0;
for (var i = 0; i < root.children.length; i++) {
var region = root.children[i];
if (typeof(region.declaredSize) == "undefined") {
continue;
}
totalRegionMemory += region.declaredSize;
}
averageRegionSize = totalRegionMemory / root.children.length;
console.log("Average declared region size: " + toHex(averageRegionSize));
// If the first region doesn't start at zero, put some free space in before it. Because free
// space can be thousands of times larger than the regions it surrounds, don't draw this to
// scale. Just make it about the same size as everything else.
if (typeof root.children !== 'undefined' && root.children.length > 0) {
var firstRegion = root.children[0];
if (firstRegion.origin != 0) {
var initialFreeSpace = {"name": "FREE",
"children": [],
"origin": 0,
"size": averageRegionSize,
"sizeForLabel": firstRegion.origin,
"end": firstRegion.origin - 1};
console.log("Adding free space before first declared region: " + toHex(firstRegion.origin));
// console.log(initialFreeSpace);
root.children.push(initialFreeSpace);
root.children.sort(sortByOrigin);
nodes = partition.nodes(root);
}
}
// Fill in the blank space between regions. Because free space can be thousands of times larger
// than the regions it surrounds, don't draw this to scale. Just make it about the same size as
// everything else.
for (var i = 0; i < root.children.length; i++) {
var thisRegion = root.children[i];
var nextRegion = root.children[i + 1];
if (typeof nextRegion == "undefined") {
// End of regions. Done.
break;
}
var spaceBetween = nextRegion.origin - thisRegion.end;
if (spaceBetween > 1) {
var freeSpace = {"name": "FREE",
"children": [],
"origin": thisRegion.end,
"size": averageRegionSize,
"sizeForLabel": spaceBetween,
"end": thisRegion.end + spaceBetween};
console.log("Region " + thisRegion.name + " ends at " + toHex(thisRegion.end)
+ " and the next one, " + nextRegion.name + ", starts at "
+ toHex(nextRegion.origin) + ". Adding free space between regions: "
+ toHex(spaceBetween));
// console.log(freeSpace);
root.children.push(freeSpace);
root.children.sort(sortByOrigin);
nodes = partition.nodes(root);
}
}
// Let d3 process the nodes again now that the free space is there.
nodes = partition.nodes(root);
};
var fillInBlankSpaceWithinRegions = function(root) {
// Let d3 calculate the size of each node based on the sum of its children.
var nodes = partition.nodes(root);
// Create nodes for left over free space inside each region. This is to scale.
for (var i = 0; i < root.children.length; i++) {
var region = root.children[i];
if (region.value < region.declaredSize) {
var freeSpace = {"name": "FREE",
"children": [],
"size": (region.declaredSize - region.value)};
if (typeof region.children == "undefined") {
region.children = [];
}
region.children.push(freeSpace);
}
}
// Let d3 process the nodes again now that the free space is there.
nodes = partition.nodes(root);
};
var parseMemory = function(lines, root) {
var sectionCount = 0;
var chunkCount = 0;
var section = null;
for (var l = 0; l < lines.length; l++) {
var line = lines[l];
// Split line into words based on any whitespace.
var cells = line.trim().split(/\s+/);
if (!isSectionLine(cells) && !isSourceLine(cells)) {
continue;
}
// Memory section, eg. .text, .data., .bss.
// This is also often something like ".text._scanf_float", which should be treated as
// section ".text", and NOT ".text._scanf_float".
var sectionName = cells[0];
if (sectionName == "*fill*") {
// eg. " *fill* 0x0000000000041d3c 0x4 "
// Ignore these. They look like sections but are reallt symbol-level stuff.
continue;
}
// Start address in memory, eg. 0x000000002000210c, as integer.
var startAddress = parseInt(removeLeading0x(cells[1]), 16);
// Size of this section or chunk of memory, eg. 0x1f4, as integer.
var size = parseInt(removeLeading0x(cells[2]), 16);
// Ignore anything with size zero.
if (size == 0) {
continue;
}
// Section lines are not indented and have three words.
// eg. ".text 0x0000000000038000 0x102ec"
if (isSectionLine(cells)) {
section = addSection(root, sectionName, startAddress, size);
sectionCount++;
}
// Source lines are indented one space and have four words.
// eg. " .Vectors 0x0000000000038000 0xc0 _build/gcc_startup_nrf51.os"
// The section this chunk goes into depends on it's start address and NOT on the section
// name on this line, since that's often something like ".text._scanf_float".
if (isSourceLine(cells)) {
// C or assembler source file for this chunk of memory.
var sourceFile = filenameFromPath(cells[3]);
if (section == null) {
console.log("Source file " + sourceFile + " has no enclosing section. Skipping.");
continue;
}
// Don't bother with an "end" field on chunks.
var chunk = {"name": sourceFile,
"origin": startAddress,
"size": size};
section.children.push(chunk);
// If we don't sort by size, the chunks stay in the order they appear in the map file.
if (SORT_CHUNKS_BY_SIZE) {
section.children.sort(sortBySize);
}
chunkCount++;
}
}
console.log("Found " + chunkCount + " chunks of memory across " + sectionCount + " sections.");
};
var addSection = function(root, sectionName, startAddress, size) {
// Find the first region of memory that this start address falls within.
var region = null;
for (var i = 0; i < root.children.length; i++) {
var b = root.children[i];
if (startAddress >= b.origin && startAddress < b.end) {
region = b;
break;
}
}
if (region == null) {
console.log("Can't find which region of memory" + startAddress + " is in. Ignoring section "
+ sectionName);
return;
}
// Seems that d3 removes the children array when it's empty.
if (typeof(region.children) == "undefined") {
region.children = [];
}
// There shouldn't already be a section by this name in this region. Warn if so.
var section = region.children.filter(function(child) {
return child.name == sectionName;
})[0];
if (section != null) {
console.log("Replacing existing section " + sectionName + " in region " + region.name);
var index = region.children.indexOf(section);
region.children.splice(index, 1);
}
section = {"name": sectionName,
"children": [],
"origin": startAddress,
"size": size,
"end": (startAddress + size)};
region.children.push(section);
return section;
};
var reverseChildren = function(node) {
if (!node || !node.children || node.children.length <= 1) return;
node.children.reverse();
for (var i = 0; i < node.children.length; i++) {
var child = node.children[i];
reverseChildren(child);
}
};
var enlargeTinyRegions = function(root) {
var minimumRegionValue = Math.round(memoryTop / 100000);
for (var i = 0; i < root.children.length; i++) {
var region = root.children[i];
// By now, every region either has a size, calculated by d3, or a declared size from
// the .Map file.
var effectiveSize = region.size ? region.size : region.declaredSize;
if (effectiveSize < minimumRegionValue) {
console.log("Enlarging tiny region " + region.name + " from " + toHex(effectiveSize)
+ " to " + toHex(minimumRegionValue) + ".");
region.size = minimumregionValue;
}
}
nodes = partition.nodes(root);
};
var display = function(root) {
nodes = partition.nodes(root);
var g = vis.selectAll("g")
.data(nodes)
.enter().append("svg:g")
.attr("transform", function(d) { return "translate(" + x(d.y) + "," + y(d.x) + ")"; })
.on("click", click);
var kx = w / root.dx,
ky = h / 1;
var nodeLabel = function(d) {
// Don't label the root node.
if (d.depth == 0) {
return "";
}
var label = d.name;
if (typeof(d.origin) == "number" && typeof(d.end) == "number") {
// Label based on origin and end.
label += ": ";
var realSize = d.end - d.origin;
if (d.value > d.declaredSize) {
label += "Overflowed from " + toHex(d.declaredSize) + " (" + toReadbleBytes(d.declaredSize)
+ ") to " + toHex(d.value) + " (" + toReadbleBytes(d.value) + ")";
}
else {
label += toHex(realSize) + " (" + toReadbleBytes(realSize) + ")";
}
}
else if (typeof(d.size) == "number") {
// Label based on size.
label += ": " + toHex(d.size) + " (" + toReadbleBytes(d.size) + ")";
}
return label;
};
g.append("svg:rect")
.attr("width", root.dy * kx)
.attr("height", function(d) { return d.dx * ky; })
.attr("class", function(d) { return d.children ? "parent" : "child"; });
// End, top left
g.append("svg:text")
.attr("class", "end")
.attr("transform", function(d) { return "translate(4,10)"; })
.attr("dy", ".35em")
.style("opacity", function(d) { return d.dx * ky > 12 ? 1 : 0; })
.style("font-size", function(d) { if (d.depth <= 1) {return "1em";} else {return "0.6em";} })
.text(function(d) { return toHex(d.end); });
// Label, middle
g.append("svg:text")
.attr("class", "label")
.attr("transform", function(d) { return "translate(16," + d.dx * ky / 2 + ")"; })
.attr("dy", ".35em")
.style("opacity", function(d) { return d.dx * ky > 12 ? 1 : 0; })
.style("font-weight", function(d) { if (d.value > d.declaredSize) { return "bold"; } else { return "normal"; }})
.style("font-size", "1em")
.text(nodeLabel);
// Origin, bottom left
g.append("svg:text")
.attr("class", "origin")
.attr("transform", function(d) { return "translate(4," + ((d.dx * ky) - 10) + ")"; })
.attr("dy", ".35em")
.style("opacity", function(d) { return d.dx * ky > 12 ? 1 : 0; })
.style("font-size", function(d) { if (d.depth <= 1) {return "1em"; } else {return "0.6em"; }})
.text(function(d) { return toHex(d.origin); });
d3.select(window)
.on("click", function() { click(root); });
// On clicking a node, redo the layout with that node as the root.
function click(d) {
if (!d.children) return;
// Leave a margin of 40 on the left so we can click back
kx = (d.y ? w - 40 : w) / (1 - d.y);
ky = h / d.dx;
x.domain([d.y, 1]).range([d.y ? 40 : 0, w]);
y.domain([d.x, d.x + d.dx]);
var t = g.transition()
.duration(d3.event.altKey ? 7500 : 750)
.attr("transform", function(d) { return "translate(" + x(d.y) + "," + y(d.x) + ")"; });
t.select("rect")
.attr("width", d.dy * kx)
.attr("height", function(d) { return d.dx * ky; });
// End, top left
t.select("text.end")
.attr("transform", function(d) { return "translate(4,10)"; })
.style("opacity", function(d) { return d.dx * ky > 12 ? 1 : 0; });
// Label, middle
t.select("text.label")
.attr("transform", function(d) { return "translate(16," + d.dx * ky / 2 + ")"; })
.style("opacity", function(d) { return d.dx * ky > 12 ? 1 : 0; });
// Origin, bottom left
t.select("text.origin")
.attr("transform", function(d) { return "translate(4," + ((d.dx * ky) - 10) + ")"; })
.style("opacity", function(d) { return d.dx * ky > 12 ? 1 : 0; });
d3.event.stopPropagation();
}
};
// Section lines have three words. They're also NOT indented, but we don't check for that.
// eg. ".text 0x0000000000038000 0x102ec"
var isSectionLine = function(words) {
if (words == null) return false;
if (words.length === undefined) return false;
if (words.length != 3) return false;
// Second word must start with 0x
if (words[1].indexOf("0x") != 0) return false;
// Third word must also start with 0x
if (words[2].indexOf("0x") != 0) return false;
return true;
}
// Source lines have four words. They're also indented one space, but we don't check for that.
// eg. " .Vectors 0x0000000000038000 0xc0 _build/gcc_startup_nrf51.os"
var isSourceLine = function(words) {
if (words == null) return false;
if (words.length === undefined) return false;
if (words.length != 4) return false;
// Second word must start with 0x
if (words[1].indexOf("0x") != 0) return false;
// Third word must also start with 0x
if (words[2].indexOf("0x") != 0) return false;
return true;
};
var removeLeading0x = function(value) {
if (!value) return value;
if (value.indexOf("0x") != 0) {
return value;
}
return value.substring(2, value.length);
};
var toHex = function(value) {
if (!value) return value;
if (isNaN(value)) return value;
return "0x" + value.toString(16).toUpperCase();
};
var toReadbleBytes = function(value) {
if (!value) return value;
if (isNaN(value)) return value;
var bytes = "";
if (value >= 1024 * 1024 * 1024) {
bytes = (value / (1024 * 1024 * 1024)).toFixed(0) + ' GB';
}
else if (value >= 1024 * 1024) {
bytes = (value / (1024 * 1024)).toFixed(0) + ' MB';
}
else if (value >= 1024) {
bytes = (value / 1024).toFixed(0) + ' KB';
}
else if (value > 1) {
bytes = value + ' bytes';
}
else if (value == 1) {
bytes = '1 byte';
}
else {
bytes = '0 bytes';
}
return bytes;
};
var sortByOrigin = function(a, b) {
if (!a || !b) return 0;
if (typeof a.origin == "undefined" || typeof b.origin == "undefined") return 0;
if (a.origin == b.origin) {
return 0;
}
else if (a.origin > b.origin) {
return 1;
}
else {
return -1;
}
};
var sortBySize = function(a, b) {
if (!a || !b) return 0;
if (typeof a.origin == "undefined" || typeof b.origin == "undefined") return 0;
if (a.size == b.size) {
return 0;
}
else if (a.size > b.size) {
return 1;
}
else {
return -1;
}
};
var filenameFromPath = function(value) {
var lastSlash = value.lastIndexOf("/");
return value.substring(lastSlash + 1, value.length);
};
$(document).ready(function() {
checkForHtml5FileApis();
});
</script>
</html>