Merge branch 'master' into feature-octal

feature-extract-files
Matt C 2017-03-27 18:50:42 +00:00
commit 497824ff21
7 changed files with 63 additions and 41 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1060,20 +1060,37 @@ var Utils = {
}; };
var formatFile = function(file, i) { var formatFile = function(file, i) {
var blob = new Blob(
[new Uint8Array(file.bytes)],
{type: "octet/stream"}
);
var blobUrl = URL.createObjectURL(blob);
var downloadAnchorElem = "<a href='" + blobUrl + "' " +
"title='Download " + Utils.escapeHtml(file.fileName) + "' " +
"download='" + Utils.escapeHtml(file.fileName) + "'>\u21B4</a>";
var expandFileContentsElem = "<a href='#collapse" + i + "' " +
"class='collapsed' " +
"data-toggle='collapse' " +
"aria-expanded='true' " +
"aria-controls='collapse" + i + "' " +
"title=\"Show/hide contents of '" + Utils.escapeHtml(file.fileName) + "'\">&#x1F50D</a>";
var html = "<div class='panel panel-default'>" + var html = "<div class='panel panel-default'>" +
"<div class='panel-heading' role='tab' id='heading" + i + "'>" + "<div class='panel-heading' role='tab' id='heading" + i + "'>" +
"<h4 class='panel-title'>" + "<h4 class='panel-title'>" +
"<a class='collapsed' role='button' data-toggle='collapse' " + "<div>" +
"href='#collapse" + i + "' " + Utils.escapeHtml(file.fileName) +
"aria-expanded='true' aria-controls='collapse" + i +"'>" + " " + expandFileContentsElem +
file.fileName + " " + downloadAnchorElem +
"<span class='pull-right'>" + "<span class='pull-right'>" +
// These are for formatting when stripping HTML // These are for formatting when stripping HTML
"<span style='display: none'>\n</span>" + "<span style='display: none'>\n</span>" +
file.size.toLocaleString() + " bytes" + file.size.toLocaleString() + " bytes" +
"<span style='display: none'>\n</span>" + "<span style='display: none'>\n</span>" +
"</span>" + "</span>" +
"</a>" + "</div>" +
"</h4>" + "</h4>" +
"</div>" + "</div>" +
"<div id='collapse" + i + "' class='panel-collapse collapse' " + "<div id='collapse" + i + "' class='panel-collapse collapse' " +

View File

@ -103,7 +103,7 @@ var Base64 = {
enc3 = (chr2 >> 1) & 31; enc3 = (chr2 >> 1) & 31;
enc4 = ((chr2 & 1) << 4) | (chr3 >> 4); enc4 = ((chr2 & 1) << 4) | (chr3 >> 4);
enc5 = ((chr3 & 15) << 1) | (chr4 >> 7); enc5 = ((chr3 & 15) << 1) | (chr4 >> 7);
enc6 = (chr4 >> 2) & 63; enc6 = (chr4 >> 2) & 31;
enc7 = ((chr4 & 3) << 3) | (chr5 >> 5); enc7 = ((chr4 & 3) << 3) | (chr5 >> 5);
enc8 = chr5 & 31; enc8 = chr5 & 31;

View File

@ -309,9 +309,8 @@ var Compress = {
files = []; files = [];
filenames.forEach(function(fileName) { filenames.forEach(function(fileName) {
var contents = unzip.decompress(fileName); var bytes = unzip.decompress(fileName);
var contents = Utils.byteArrayToUtf8(bytes);
contents = Utils.byteArrayToUtf8(contents);
var file = { var file = {
fileName: fileName, fileName: fileName,
@ -320,6 +319,7 @@ var Compress = {
var isDir = contents.length === 0 && fileName.endsWith("/"); var isDir = contents.length === 0 && fileName.endsWith("/");
if (!isDir) { if (!isDir) {
file.bytes = bytes;
file.contents = contents; file.contents = contents;
} }
@ -477,6 +477,13 @@ var Compress = {
this.position = 0; this.position = 0;
}; };
Stream.prototype.getBytes = function(bytesToGet) {
var newPosition = this.position + bytesToGet;
var bytes = this.bytes.slice(this.position, newPosition);
this.position = newPosition;
return bytes;
};
Stream.prototype.readString = function(numBytes) { Stream.prototype.readString = function(numBytes) {
var result = ""; var result = "";
for (var i = this.position; i < this.position + numBytes; i++) { for (var i = this.position; i < this.position + numBytes; i++) {
@ -535,11 +542,9 @@ var Compress = {
endPosition += 512 - (file.size % 512); endPosition += 512 - (file.size % 512);
} }
file.contents = ""; file.bytes = stream.getBytes(file.size);
file.contents = Utils.byteArrayToUtf8(file.bytes);
while (stream.position < endPosition) { stream.position = endPosition;
file.contents += stream.readString(512);
}
} else if (file.type === "5") { } else if (file.type === "5") {
// Directory // Directory
files.push(file); files.push(file);

View File

@ -1,9 +1,9 @@
215 source files 215 source files
117391 lines 117429 lines
4.4M size 4.4M size
145 JavaScript source files 145 JavaScript source files
108190 lines 108228 lines
3.8M size 3.8M size
84 third party JavaScript source files 84 third party JavaScript source files
@ -11,11 +11,11 @@
3.1M size 3.1M size
61 first party JavaScript source files 61 first party JavaScript source files
20773 lines 20811 lines
776K size 776K size
3.5M uncompressed JavaScript size 3.5M uncompressed JavaScript size
compressed JavaScript size 1.9M compressed JavaScript size
15 categories 15 categories
177 operations 177 operations