diff options
Diffstat (limited to 'public/js/mv/main.js')
-rw-r--r-- | public/js/mv/main.js | 116 |
1 files changed, 67 insertions, 49 deletions
diff --git a/public/js/mv/main.js b/public/js/mv/main.js index 34a6c00..e5b74bf 100644 --- a/public/js/mv/main.js +++ b/public/js/mv/main.js @@ -1,16 +1,22 @@ "use strict"; var mv = function(mv) { - mv.init = function() { - 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(); + /* Set up common variables for the loading bars */ + var loadbar = progress('loadbar'); + var filesbar = progress('filesbar'); + var lbase = loadbar.label; + var fbase = filesbar.label; + var name = ""; + loadbar.label = function() { + return lbase() == '100%' ? "Loaded '" + name + "' - Done!" : "Loading '" + name + "' - " + lbase(); + }; + filesbar.label = function () { + return fbase() == '100%' ? "Loaded " + mv.loader.numfiles() + " file(s) - Done!" : "Loading file " + mv.loader.curfile() + " of " + mv.loader.numfiles() + " - " + fbase(); + }; } + /* Initialise modules that require initialisation */ + mv.init = function() { + /* Loader module */ + /* Callbacks for loading files from the filesystem */ mv.loader.onbulkstart = function(fevt) { loadbar.show(); filesbar.show(); @@ -19,47 +25,59 @@ var mv = function(mv) { 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.onprogress = function(current, total) { + loadbar.update(current, total); }; mv.loader.init(handleFile, postLoading); - function handleFile(data, curFileNum, numFiles) { - loadbar.complete(); - if (mv.loader.filenames()[curFileNum].indexOf("scrubbed") != -1) { - /* Scrubbed data! */ - mv.parser.parseScrubbed(data); - } else { - /* Raw logs. */ - 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.parser.postProcessing(); - 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(); - if (document.getElementById("connect-option").checked) { - mv.connect.connect(); - } - }, 2000); - } + mv.loader.setname = function(n) { name = n; }; + /* Set zip.js worker path */ + zip.workerScriptsPath = "/js/zip/WebContent/"; + status.text("Ready"); }; + /* When a file has finished loading, handle it. */ + function handleFile(data, name, after) { + loadbar.complete(); + if (name.indexOf("scrubbed") != -1) { + /* Scrubbed data! */ + mv.parser.parseScrubbed(data); + } else { + /* Raw logs. */ + mv.parser.parseRecords(data); + } + after(); + } + /* When everything has finished loading, handle that, then show everything. */ + function postLoading() { + filesbar.complete(); + /* TODO: This is still a total mess that doesn't really transition properly */ + setTimeout(function() { + loadbar.hide(); + }, 2000); + /* Second pass to apply future information to previously unascertainable records */ + mv.parser.postProcessing(); + /* Start up crossfilter */ + mv.heap.init(); + /* Give the UI space to catch up for a bit. May need a few more of these breaks. */ + setTimeout(function() { + filesbar.hide(); + /* Remove the mask hiding the chart view */ + d3.select("#mask") + .transition() + .style("opacity", 0) + .remove(); + /* Show the chart view */ + d3.selectAll(".vis-hide") + .style("display", "inline") + .transition() + .style("opacity", 1) + ; + /* Render the charts */ + mv.charter.init(); + /* If the user wishes to connect, then connect them. */ + if (document.getElementById("connect-option").checked) { + mv.connect.connect(); + } + }, 2000); + } return mv; }(mv || {}); |