diff options
Diffstat (limited to 'js/mv/main.js')
-rw-r--r-- | js/mv/main.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/js/mv/main.js b/js/mv/main.js new file mode 100644 index 0000000..51d1dae --- /dev/null +++ b/js/mv/main.js @@ -0,0 +1,57 @@ +var mv = function(mv) { + mv.init = function() { + console.log("Initialising"); + var loadbar = progress('loadbar'); + var filesbar = progress('filesbar'); + var lbase = loadbar.label; + loadbar.label = function() { + return lbase() == '100%' ? "Loaded '" + mv.loader.filenames()[mv.loader.curfile()]+ "' - Done!" : "Loading '" + mv.loader.filenames()[mv.loader.curfile()] + "' - " + lbase(); + }; + var fbase = filesbar.label; + filesbar.label = function () { + return fbase() == '100%' ? "Loaded " + mv.loader.numfiles() + " file(s) - Done!" : "Loading file " + mv.loader.curfile() + " of " + mv.loader.numfiles() + " - " + fbase(); + } + loadbar.show(); + filesbar.show(); + mv.loader.onbulkstart = function(fevt) { + loadbar.show(); + filesbar.show(); + }; + mv.loader.onloadstart = function(evt) { + filesbar.update(mv.loader.curfile(), mv.loader.numfiles()); + loadbar.reset(); + }; + mv.loader.onprogress = function(evt) { + if (evt.lengthComputable) { + loadbar.update(evt.loaded, evt.total); + } + }; + mv.loader.init(handleFile, postLoading); + function handleFile(data, curFileNum, numFiles) { + loadbar.complete(); + mv.parser.parseRecords(data); + } + function postLoading() { + filesbar.complete(); + /* TODO: This is still a total mess that doesn't really transition properly */ + setTimeout(function() { + loadbar.hide(); + }, 2000); + mv.heap.init(); + setTimeout(function() { + filesbar.hide(); + d3.select("#mask") + .transition() + .style("opacity", 0) + .remove(); + d3.selectAll(".vis-hide") + .style("display", "inline") + .transition() + .style("opacity", 1) + ; + mv.charter.init(); + }, 2000); + } + }; + return mv; +}(mv || {}); |