// Generated by CoffeeScript 1.12.7
/**
* Volume zip
* @mixin volume/zip
*/
'use strict';
var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
app.controller('volume/zip', [
'$location', '$scope', 'constantService', 'displayService', 'volume', 'slot', function($location, $scope, constants, display, volume, slot) {
var RSet, a, ai, c, ci, d, excl, filt, incl, k, ref, ref1, ref2, t, v, z;
filt = false;
RSet = (function(superClass) {
var make, parse;
extend(RSet, superClass);
make = function(arg) {
var l, u;
l = arg[0], u = arg[1];
return {
l: l,
u: u != null ? u : l
};
};
parse = function(x) {
return make(x.split('-', 2));
};
function RSet() {
if (arguments.length) {
this.push(make(arguments));
}
return;
}
RSet.prototype.add = function(x) {
filt = true;
return this.push.apply(this, x.split(',').map(parse));
};
RSet.prototype.member = function(x) {
var i, len, r, ref;
ref = this;
for (i = 0, len = ref.length; i < len; i++) {
r = ref[i];
if (r.l <= x && x <= r.u) {
return true;
}
}
};
return RSet;
})(Array);
if (slot) {
display.title = slot.displayName + ".zip";
$scope.slot = slot;
$scope.volume = slot.volume;
$scope.containers = [slot];
} else {
display.title = volume.name + ".zip";
$scope.volume = volume;
incl = void 0;
excl = new RSet(volume.top.id);
ref = $location.search();
for (k in ref) {
v = ref[k];
if ("include".startsWith(k)) {
incl || (incl = new RSet());
incl.add(v);
} else if ("exclude".startsWith(k)) {
excl.add(v);
}
}
incl || (incl = new RSet(-2e308, 2e308));
$scope.containers = (function() {
var ref1, results;
ref1 = volume.containers;
results = [];
for (ci in ref1) {
c = ref1[ci];
if (incl.member(c.id) && !excl.member(c.id)) {
results.push(c);
}
}
return results;
})();
$scope.filtered = filt;
}
t = 0;
d = 0;
z = 0;
$scope.filesInSession = {};
ref1 = $scope.containers;
for (ci in ref1) {
c = ref1[ci];
$scope.filesInSession[ci] = Object.keys(c.assets).length;
ref2 = c.assets;
for (ai in ref2) {
a = ref2[ai];
t++;
if (a.size) {
d++;
z += a.size;
}
}
}
$scope.assetTotal = t;
$scope.assetDownload = d;
$scope.assetSize = Math.ceil(z / (1024 * 1024 * 1024));
$scope.close = function() {
window.history.back();
};
}
]);
//# sourceMappingURL=zip.js.map