summaryrefslogtreecommitdiff
path: root/public/js/mv/main.js
diff options
context:
space:
mode:
authorFreeyorp <TheFreeYorp@NOSPAM.G.m.a.i.l.replace>2013-05-25 16:56:23 +1200
committerFreeyorp <TheFreeYorp@NOSPAM.G.m.a.i.l.replace>2013-05-25 16:56:23 +1200
commit9d5f56cff3e8f6b7f4a425414815b4de49244d00 (patch)
treecbff3a4372d0fdef41c609865163da9ba192fe6f /public/js/mv/main.js
parentad1610280117aaeba51b71fa8e66e15c0bbadac2 (diff)
downloadmanavis-9d5f56cff3e8f6b7f4a425414815b4de49244d00.tar.gz
manavis-9d5f56cff3e8f6b7f4a425414815b4de49244d00.tar.bz2
manavis-9d5f56cff3e8f6b7f4a425414815b4de49244d00.tar.xz
manavis-9d5f56cff3e8f6b7f4a425414815b4de49244d00.zip
Allow loading of zip files
.zip must be at the end of the file name. Progress bars are not fully descriptive in this mode yet This also alters the mv.loader interface. The onprogress callback now takes current and total. The each callback is now passed an after parameter, to be called when it's done.
Diffstat (limited to 'public/js/mv/main.js')
-rw-r--r--public/js/mv/main.js116
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 || {});