Code cleaning
code cosmetics deleted unused file caliBlur fixed custom error page
This commit is contained in:
parent
fa3426aa08
commit
3b40c83314
File diff suppressed because it is too large
Load Diff
|
@ -277,8 +277,6 @@ bitjs.archive = bitjs.archive || {};
|
||||||
if (e.type === bitjs.archive.UnarchiveEvent.Type.FINISH) {
|
if (e.type === bitjs.archive.UnarchiveEvent.Type.FINISH) {
|
||||||
this.worker_.terminate();
|
this.worker_.terminate();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
console.log(e);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -292,15 +290,11 @@ bitjs.archive = bitjs.archive || {};
|
||||||
this.worker_ = new Worker(scriptFileName);
|
this.worker_ = new Worker(scriptFileName);
|
||||||
|
|
||||||
this.worker_.onerror = function(e) {
|
this.worker_.onerror = function(e) {
|
||||||
console.log("Worker error: message = " + e.message);
|
|
||||||
throw e;
|
throw e;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.worker_.onmessage = function(e) {
|
this.worker_.onmessage = function(e) {
|
||||||
if (typeof e.data === "string") {
|
if (typeof e.data !== "string") {
|
||||||
// Just log any strings the workers pump our way.
|
|
||||||
console.log(e.data);
|
|
||||||
} else {
|
|
||||||
// Assume that it is an UnarchiveEvent. Some browsers preserve the 'type'
|
// Assume that it is an UnarchiveEvent. Some browsers preserve the 'type'
|
||||||
// so that instanceof UnarchiveEvent returns true, but others do not.
|
// so that instanceof UnarchiveEvent returns true, but others do not.
|
||||||
me.handleWorkerEvent_(e.data);
|
me.handleWorkerEvent_(e.data);
|
||||||
|
|
|
@ -105,7 +105,7 @@ $(function() {
|
||||||
var buttonText = $this.html();
|
var buttonText = $this.html();
|
||||||
$this.html("...");
|
$this.html("...");
|
||||||
$("#update_error").addClass("hidden");
|
$("#update_error").addClass("hidden");
|
||||||
if($("#message").length){
|
if ($("#message").length){
|
||||||
$("#message").alert("close");
|
$("#message").alert("close");
|
||||||
}
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -114,8 +114,8 @@ $(function() {
|
||||||
success: function success(data) {
|
success: function success(data) {
|
||||||
$this.html(buttonText);
|
$this.html(buttonText);
|
||||||
|
|
||||||
var cssClass = '';
|
var cssClass = "";
|
||||||
var message = ''
|
var message = "";
|
||||||
|
|
||||||
if (data.success === true) {
|
if (data.success === true) {
|
||||||
if (data.update === true) {
|
if (data.update === true) {
|
||||||
|
@ -125,19 +125,20 @@ $(function() {
|
||||||
.removeClass("hidden")
|
.removeClass("hidden")
|
||||||
.find("span").html(data.commit);
|
.find("span").html(data.commit);
|
||||||
|
|
||||||
data.history.reverse().forEach(function(entry, index) {
|
data.history.reverse().forEach(function(entry) {
|
||||||
$("<tr><td>" + entry[0] + "</td><td>" + entry[1] + "</td></tr>").appendTo($("#update_table"));
|
$("<tr><td>" + entry[0] + "</td><td>" + entry[1] + "</td></tr>").appendTo($("#update_table"));
|
||||||
});
|
});
|
||||||
cssClass = 'alert-warning';
|
cssClass = "alert-warning";
|
||||||
} else {
|
} else {
|
||||||
cssClass = 'alert-success';
|
cssClass = "alert-success";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cssClass = 'alert-danger';
|
cssClass = "alert-danger";
|
||||||
}
|
}
|
||||||
|
|
||||||
message = '<div id="message" class="alert ' + cssClass
|
message = "<div id=\"message\" class=\"alert " + cssClass
|
||||||
+ ' fade in"><a href="#" class="close" data-dismiss="alert">×</a>' + data.message + '</div>';
|
+ " fade in\"><a href=\"#\" class=\"close\" data-dismiss=\"alert\">×</a>"
|
||||||
|
+ data.message + "</div>";
|
||||||
|
|
||||||
$(message).insertAfter($("#update_table"));
|
$(message).insertAfter($("#update_table"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
$("#domain_submit").click(function(event){
|
$("#domain_submit").click(function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$("#domain_add").ajaxForm();
|
$("#domain_add").ajaxForm();
|
||||||
$(this).closest("form").submit();
|
$(this).closest("form").submit();
|
||||||
|
@ -14,44 +14,45 @@ $(function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$('#domain-table').bootstrapTable({
|
$("#domain-table").bootstrapTable({
|
||||||
formatNoMatches: function () {
|
formatNoMatches: function () {
|
||||||
return '';
|
return "";
|
||||||
},
|
},
|
||||||
striped: false
|
striped: false
|
||||||
});
|
});
|
||||||
$("#btndeletedomain").click(function() {
|
$("#btndeletedomain").click(function() {
|
||||||
//get data-id attribute of the clicked element
|
//get data-id attribute of the clicked element
|
||||||
var domainId = $(this).data('domainId');
|
var domainId = $(this).data("domainId");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method:"post",
|
method:"post",
|
||||||
url: window.location.pathname + "/../../ajax/deletedomain",
|
url: window.location.pathname + "/../../ajax/deletedomain",
|
||||||
data: {"domainid":domainId}
|
data: {"domainid":domainId}
|
||||||
});
|
});
|
||||||
$('#DeleteDomain').modal('hide');
|
$("#DeleteDomain").modal("hide");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method:"get",
|
method:"get",
|
||||||
url: window.location.pathname + "/../../ajax/domainlist",
|
url: window.location.pathname + "/../../ajax/domainlist",
|
||||||
async: true,
|
async: true,
|
||||||
timeout: 900,
|
timeout: 900,
|
||||||
success:function(data){
|
success:function(data){
|
||||||
$('#domain-table').bootstrapTable("load", data);
|
$("#domain-table").bootstrapTable("load", data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
//triggered when modal is about to be shown
|
//triggered when modal is about to be shown
|
||||||
$('#DeleteDomain').on('show.bs.modal', function(e) {
|
$("#DeleteDomain").on("show.bs.modal" function(e) {
|
||||||
//get data-id attribute of the clicked element and store in button
|
//get data-id attribute of the clicked element and store in button
|
||||||
var domainId = $(e.relatedTarget).data('domain-id');
|
var domainId = $(e.relatedTarget).data("domain-id");
|
||||||
$(e.currentTarget).find("#btndeletedomain").data('domainId',domainId);
|
$(e.currentTarget).find("#btndeletedomain").data("domainId", domainId);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function TableActions (value, row, index) {
|
function TableActions (value, row, index) {
|
||||||
return [
|
return [
|
||||||
'<a class="danger remove" data-toggle="modal" data-target="#DeleteDomain" data-domain-id="'+row.id+'" title="Remove">',
|
"<a class=\"danger remove\" data-toggle=\"modal\" data-target=\"#DeleteDomain\" data-domain-id=\"" + row.id
|
||||||
'<i class="glyphicon glyphicon-trash"></i>',
|
+ "\" title=\"Remove\">",
|
||||||
'</a>'
|
"<i class=\"glyphicon glyphicon-trash\"></i>",
|
||||||
].join('');
|
"</a>"
|
||||||
|
].join("");
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,7 +269,7 @@ var RD = { //rep decode
|
||||||
var rBuffer;
|
var rBuffer;
|
||||||
|
|
||||||
// read in Huffman tables for RAR
|
// read in Huffman tables for RAR
|
||||||
function RarReadTables(bstream) {
|
function rarReadTables(bstream) {
|
||||||
var BitLength = new Array(rBC),
|
var BitLength = new Array(rBC),
|
||||||
Table = new Array(rHuffTableSize);
|
Table = new Array(rHuffTableSize);
|
||||||
var i;
|
var i;
|
||||||
|
@ -480,7 +480,7 @@ function Unpack20(bstream) { //, Solid) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (num < 270) {
|
if (num < 270) {
|
||||||
var Distance = rSDDecode[num -= 261] + 1;
|
Distance = rSDDecode[num -= 261] + 1;
|
||||||
if ((Bits = rSDBits[num]) > 0) {
|
if ((Bits = rSDBits[num]) > 0) {
|
||||||
Distance += bstream.readBits(Bits);
|
Distance += bstream.readBits(Bits);
|
||||||
}
|
}
|
||||||
|
@ -513,9 +513,9 @@ function rarReadTables20(bstream) {
|
||||||
var BitLength = new Array(rBC20);
|
var BitLength = new Array(rBC20);
|
||||||
var Table = new Array(rMC20 * 4);
|
var Table = new Array(rMC20 * 4);
|
||||||
var TableSize, N, I;
|
var TableSize, N, I;
|
||||||
|
var i;
|
||||||
bstream.readBits(1);
|
bstream.readBits(1);
|
||||||
if (!bstream.readBits(1)) {
|
if (!bstream.readBits(1)) {
|
||||||
var i;
|
|
||||||
for (i = UnpOldTable20.length; i--;) UnpOldTable20[i] = 0;
|
for (i = UnpOldTable20.length; i--;) UnpOldTable20[i] = 0;
|
||||||
}
|
}
|
||||||
TableSize = rNC20 + rDC20 + rRC20;
|
TableSize = rNC20 + rDC20 + rRC20;
|
||||||
|
@ -553,25 +553,26 @@ function rarReadTables20(bstream) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function Unpack29(bstream, Solid) {
|
function Unpack29(bstream) {
|
||||||
// lazy initialize rDDecode and rDBits
|
// lazy initialize rDDecode and rDBits
|
||||||
|
|
||||||
var DDecode = new Array(rDC);
|
var DDecode = new Array(rDC);
|
||||||
var DBits = new Array(rDC);
|
var DBits = new Array(rDC);
|
||||||
|
var Distance = 0;
|
||||||
|
var Length = 0;
|
||||||
var Dist = 0, BitLength = 0, Slot = 0;
|
var Dist = 0, BitLength = 0, Slot = 0;
|
||||||
var I;
|
var I;
|
||||||
for (I = 0; I < rDBitLengthCounts.length; I++,BitLength++) {
|
for (I = 0; I < rDBitLengthCounts.length; I++, BitLength++) {
|
||||||
for (var J = 0; J < rDBitLengthCounts[I]; J++,Slot++,Dist+=(1<<BitLength)) {
|
for (var J = 0; J < rDBitLengthCounts[I]; J++, Slot++, Dist += (1 << BitLength)) {
|
||||||
DDecode[Slot]=Dist;
|
DDecode[Slot] = Dist;
|
||||||
DBits[Slot]=BitLength;
|
DBits[Slot] = BitLength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var Bits;
|
var Bits;
|
||||||
//tablesRead = false;
|
//tablesRead = false;
|
||||||
|
|
||||||
rOldDist = [0, 0, 0, 0]
|
rOldDist = [0, 0, 0, 0];
|
||||||
|
|
||||||
lastDist = 0;
|
lastDist = 0;
|
||||||
lastLength = 0;
|
lastLength = 0;
|
||||||
|
@ -579,7 +580,7 @@ function Unpack29(bstream, Solid) {
|
||||||
for (i = UnpOldTable.length; i--;) UnpOldTable[i] = 0;
|
for (i = UnpOldTable.length; i--;) UnpOldTable[i] = 0;
|
||||||
|
|
||||||
// read in Huffman tables
|
// read in Huffman tables
|
||||||
RarReadTables(bstream);
|
rarReadTables(bstream);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
var num = rarDecodeNumber(bstream, LD);
|
var num = rarDecodeNumber(bstream, LD);
|
||||||
|
@ -589,12 +590,12 @@ function Unpack29(bstream, Solid) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (num >= 271) {
|
if (num >= 271) {
|
||||||
var Length = rLDecode[num -= 271] + 3;
|
Length = rLDecode[num -= 271] + 3;
|
||||||
if ((Bits = rLBits[num]) > 0) {
|
if ((Bits = rLBits[num]) > 0) {
|
||||||
Length += bstream.readBits(Bits);
|
Length += bstream.readBits(Bits);
|
||||||
}
|
}
|
||||||
var DistNumber = rarDecodeNumber(bstream, DD);
|
var DistNumber = rarDecodeNumber(bstream, DD);
|
||||||
var Distance = DDecode[DistNumber]+1;
|
Distance = DDecode[DistNumber] + 1;
|
||||||
if ((Bits = DBits[DistNumber]) > 0) {
|
if ((Bits = DBits[DistNumber]) > 0) {
|
||||||
if (DistNumber > 9) {
|
if (DistNumber > 9) {
|
||||||
if (Bits > 4) {
|
if (Bits > 4) {
|
||||||
|
@ -625,19 +626,19 @@ function Unpack29(bstream, Solid) {
|
||||||
Length++;
|
Length++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RarInsertOldDist(Distance);
|
rarInsertOldDist(Distance);
|
||||||
RarInsertLastMatch(Length, Distance);
|
rarInsertLastMatch(Length, Distance);
|
||||||
rarCopyString(Length, Distance);
|
rarCopyString(Length, Distance);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (num === 256) {
|
if (num === 256) {
|
||||||
if (!RarReadEndOfBlock(bstream)) break;
|
if (!rarReadEndOfBlock(bstream)) break;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (num === 257) {
|
if (num === 257) {
|
||||||
//console.log("READVMCODE");
|
//console.log("READVMCODE");
|
||||||
if (!RarReadVMCode(bstream)) break;
|
if (!rarReadVMCode(bstream)) break;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (num === 258) {
|
if (num === 258) {
|
||||||
if (lastLength != 0) {
|
if (lastLength != 0) {
|
||||||
|
@ -647,29 +648,29 @@ function Unpack29(bstream, Solid) {
|
||||||
}
|
}
|
||||||
if (num < 263) {
|
if (num < 263) {
|
||||||
var DistNum = num - 259;
|
var DistNum = num - 259;
|
||||||
var Distance = rOldDist[DistNum];
|
Distance = rOldDist[DistNum];
|
||||||
|
|
||||||
for (var I = DistNum; I > 0; I--) {
|
for (var I = DistNum; I > 0; I--) {
|
||||||
rOldDist[I] = rOldDist[I-1];
|
rOldDist[I] = rOldDist[I - 1];
|
||||||
}
|
}
|
||||||
rOldDist[0] = Distance;
|
rOldDist[0] = Distance;
|
||||||
|
|
||||||
var LengthNumber = rarDecodeNumber(bstream, RD);
|
var LengthNumber = rarDecodeNumber(bstream, RD);
|
||||||
var Length = rLDecode[LengthNumber] + 2;
|
Length = rLDecode[LengthNumber] + 2;
|
||||||
if ((Bits = rLBits[LengthNumber]) > 0) {
|
if ((Bits = rLBits[LengthNumber]) > 0) {
|
||||||
Length += bstream.readBits(Bits);
|
Length += bstream.readBits(Bits);
|
||||||
}
|
}
|
||||||
RarInsertLastMatch(Length, Distance);
|
rarInsertLastMatch(Length, Distance);
|
||||||
rarCopyString(Length, Distance);
|
rarCopyString(Length, Distance);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (num < 272) {
|
if (num < 272) {
|
||||||
var Distance = rSDDecode[num -= 263] + 1;
|
Distance = rSDDecode[num -= 263] + 1;
|
||||||
if ((Bits = rSDBits[num]) > 0) {
|
if ((Bits = rSDBits[num]) > 0) {
|
||||||
Distance += bstream.readBits(Bits);
|
Distance += bstream.readBits(Bits);
|
||||||
}
|
}
|
||||||
RarInsertOldDist(Distance);
|
rarInsertOldDist(Distance);
|
||||||
RarInsertLastMatch(2, Distance);
|
rarInsertLastMatch(2, Distance);
|
||||||
rarCopyString(2, Distance);
|
rarCopyString(2, Distance);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -677,9 +678,9 @@ function Unpack29(bstream, Solid) {
|
||||||
rarUpdateProgress()
|
rarUpdateProgress()
|
||||||
}
|
}
|
||||||
|
|
||||||
function RarReadEndOfBlock(bstream) {
|
function rarReadEndOfBlock(bstream) {
|
||||||
|
|
||||||
rarUpdateProgress()
|
rarUpdateProgress();
|
||||||
|
|
||||||
var NewTable = false, NewFile = false;
|
var NewTable = false, NewFile = false;
|
||||||
if (bstream.readBits(1)) {
|
if (bstream.readBits(1)) {
|
||||||
|
@ -689,11 +690,11 @@ function RarReadEndOfBlock(bstream) {
|
||||||
NewTable = !!bstream.readBits(1);
|
NewTable = !!bstream.readBits(1);
|
||||||
}
|
}
|
||||||
//tablesRead = !NewTable;
|
//tablesRead = !NewTable;
|
||||||
return !(NewFile || NewTable && !RarReadTables(bstream));
|
return !(NewFile || NewTable && !rarReadTables(bstream));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function RarReadVMCode(bstream) {
|
function rarReadVMCode(bstream) {
|
||||||
var FirstByte = bstream.readBits(8);
|
var FirstByte = bstream.readBits(8);
|
||||||
var Length = (FirstByte & 7) + 1;
|
var Length = (FirstByte & 7) + 1;
|
||||||
if (Length === 7) {
|
if (Length === 7) {
|
||||||
|
@ -717,12 +718,12 @@ function RarAddVMCode(firstByte, vmCode, length) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function RarInsertLastMatch(length, distance) {
|
function rarInsertLastMatch(length, distance) {
|
||||||
lastDist = distance;
|
lastDist = distance;
|
||||||
lastLength = length;
|
lastLength = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
function RarInsertOldDist(distance) {
|
function rarInsertOldDist(distance) {
|
||||||
rOldDist.splice(3,1);
|
rOldDist.splice(3,1);
|
||||||
rOldDist.splice(0,0,distance);
|
rOldDist.splice(0,0,distance);
|
||||||
}
|
}
|
||||||
|
@ -768,7 +769,7 @@ function unpack(v) {
|
||||||
break;
|
break;
|
||||||
case 29: // rar 3.x compression
|
case 29: // rar 3.x compression
|
||||||
case 36: // alternative hash
|
case 36: // alternative hash
|
||||||
Unpack29(bstream, Solid);
|
Unpack29(bstream);
|
||||||
break;
|
break;
|
||||||
} // switch(method)
|
} // switch(method)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
* ZIP format: http://www.pkware.com/documents/casestudies/APPNOTE.TXT
|
* ZIP format: http://www.pkware.com/documents/casestudies/APPNOTE.TXT
|
||||||
* DEFLATE format: http://tools.ietf.org/html/rfc1951
|
* DEFLATE format: http://tools.ietf.org/html/rfc1951
|
||||||
*/
|
*/
|
||||||
/* global bitjs */
|
/* global bitjs, importScripts, Uint8Array*/
|
||||||
|
|
||||||
// This file expects to be invoked as a Worker (see onmessage below).
|
// This file expects to be invoked as a Worker (see onmessage below).
|
||||||
importScripts("io.js");
|
importScripts("io.js");
|
||||||
|
@ -44,12 +44,10 @@ var zLocalFileHeaderSignature = 0x04034b50;
|
||||||
var zArchiveExtraDataSignature = 0x08064b50;
|
var zArchiveExtraDataSignature = 0x08064b50;
|
||||||
var zCentralFileHeaderSignature = 0x02014b50;
|
var zCentralFileHeaderSignature = 0x02014b50;
|
||||||
var zDigitalSignatureSignature = 0x05054b50;
|
var zDigitalSignatureSignature = 0x05054b50;
|
||||||
var zEndOfCentralDirSignature = 0x06064b50;
|
|
||||||
var zEndOfCentralDirLocatorSignature = 0x07064b50;
|
|
||||||
|
|
||||||
// takes a ByteStream and parses out the local file information
|
// takes a ByteStream and parses out the local file information
|
||||||
var ZipLocalFile = function(bstream) {
|
var ZipLocalFile = function(bstream) {
|
||||||
if (typeof bstream != typeof {} || !bstream.readNumber || typeof bstream.readNumber != typeof function(){}) {
|
if (typeof bstream != typeof {} || !bstream.readNumber || typeof bstream.readNumber != typeof function() {}) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +110,7 @@ ZipLocalFile.prototype.unzip = function() {
|
||||||
|
|
||||||
// Zip Version 1.0, no compression (store only)
|
// Zip Version 1.0, no compression (store only)
|
||||||
if (this.compressionMethod == 0 ) {
|
if (this.compressionMethod == 0 ) {
|
||||||
info("ZIP v"+this.version+", store only: " + this.filename + " (" + this.compressedSize + " bytes)");
|
info("ZIP v" + this.version + ", store only: " + this.filename + " (" + this.compressedSize + " bytes)");
|
||||||
currentBytesUnarchivedInFile = this.compressedSize;
|
currentBytesUnarchivedInFile = this.compressedSize;
|
||||||
currentBytesUnarchived += this.compressedSize;
|
currentBytesUnarchived += this.compressedSize;
|
||||||
}
|
}
|
||||||
|
@ -158,7 +156,7 @@ var unzip = function(arrayBuffer) {
|
||||||
totalFilesInArchive = localFiles.length;
|
totalFilesInArchive = localFiles.length;
|
||||||
|
|
||||||
// got all local files, now sort them
|
// got all local files, now sort them
|
||||||
localFiles.sort(function(a,b) {
|
localFiles.sort(function(a, b) {
|
||||||
var aname = a.filename.toLowerCase();
|
var aname = a.filename.toLowerCase();
|
||||||
var bname = b.filename.toLowerCase();
|
var bname = b.filename.toLowerCase();
|
||||||
return aname > bname ? 1 : -1;
|
return aname > bname ? 1 : -1;
|
||||||
|
@ -239,7 +237,7 @@ var unzip = function(arrayBuffer) {
|
||||||
postProgress();
|
postProgress();
|
||||||
postMessage(new bitjs.archive.UnarchiveFinishEvent());
|
postMessage(new bitjs.archive.UnarchiveFinishEvent());
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// returns a table of Huffman codes
|
// returns a table of Huffman codes
|
||||||
// each entry's index is its code and its value is a JavaScript object
|
// each entry's index is its code and its value is a JavaScript object
|
||||||
|
@ -253,7 +251,7 @@ function getHuffmanCodes(bitLengths) {
|
||||||
|
|
||||||
// Reference: http://tools.ietf.org/html/rfc1951#page-8
|
// Reference: http://tools.ietf.org/html/rfc1951#page-8
|
||||||
var numLengths = bitLengths.length,
|
var numLengths = bitLengths.length,
|
||||||
bl_count = [],
|
blCount = [],
|
||||||
MAX_BITS = 1;
|
MAX_BITS = 1;
|
||||||
|
|
||||||
// Step 1: count up how many codes of each length we have
|
// Step 1: count up how many codes of each length we have
|
||||||
|
@ -265,22 +263,22 @@ function getHuffmanCodes(bitLengths) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// increment the appropriate bitlength count
|
// increment the appropriate bitlength count
|
||||||
if (bl_count[length] == undefined) bl_count[length] = 0;
|
if (blCount[length] == undefined) blCount[length] = 0;
|
||||||
// a length of zero means this symbol is not participating in the huffman coding
|
// a length of zero means this symbol is not participating in the huffman coding
|
||||||
if (length > 0) bl_count[length]++;
|
if (length > 0) blCount[length]++;
|
||||||
|
|
||||||
if (length > MAX_BITS) MAX_BITS = length;
|
if (length > MAX_BITS) MAX_BITS = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2: Find the numerical value of the smallest code for each code length
|
// Step 2: Find the numerical value of the smallest code for each code length
|
||||||
var next_code = [],
|
var nextCode = [],
|
||||||
code = 0;
|
code = 0;
|
||||||
for (var bits = 1; bits <= MAX_BITS; ++bits) {
|
for (var bits = 1; bits <= MAX_BITS; ++bits) {
|
||||||
var length = bits-1;
|
var length = bits - 1;
|
||||||
// ensure undefined lengths are zero
|
// ensure undefined lengths are zero
|
||||||
if (bl_count[length] == undefined) bl_count[length] = 0;
|
if (blCount[length] == undefined) blCount[length] = 0;
|
||||||
code = (code + bl_count[bits-1]) << 1;
|
code = (code + blCount[bits - 1]) << 1;
|
||||||
next_code[bits] = code;
|
nextCode [bits] = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 3: Assign numerical values to all codes
|
// Step 3: Assign numerical values to all codes
|
||||||
|
@ -288,9 +286,9 @@ function getHuffmanCodes(bitLengths) {
|
||||||
for (var n = 0; n < numLengths; ++n) {
|
for (var n = 0; n < numLengths; ++n) {
|
||||||
var len = bitLengths[n];
|
var len = bitLengths[n];
|
||||||
if (len != 0) {
|
if (len != 0) {
|
||||||
table[next_code[len]] = { length: len, symbol: n }; //, bitstring: binaryValueToString(next_code[len],len) };
|
table[nextCode [len]] = { length: len, symbol: n }; //, bitstring: binaryValueToString(nextCode [len],len) };
|
||||||
tableLength++;
|
tableLength++;
|
||||||
next_code[len]++;
|
nextCode [len]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
table.maxLength = tableLength;
|
table.maxLength = tableLength;
|
||||||
|
@ -321,7 +319,8 @@ function getFixedLiteralTable() {
|
||||||
// create once
|
// create once
|
||||||
if (!fixedHCtoLiteral) {
|
if (!fixedHCtoLiteral) {
|
||||||
var bitlengths = new Array(288);
|
var bitlengths = new Array(288);
|
||||||
for (var i = 0; i <= 143; ++i) bitlengths[i] = 8;
|
var i;
|
||||||
|
for (i = 0; i <= 143; ++i) bitlengths[i] = 8;
|
||||||
for (i = 144; i <= 255; ++i) bitlengths[i] = 9;
|
for (i = 144; i <= 255; ++i) bitlengths[i] = 9;
|
||||||
for (i = 256; i <= 279; ++i) bitlengths[i] = 7;
|
for (i = 256; i <= 279; ++i) bitlengths[i] = 7;
|
||||||
for (i = 280; i <= 287; ++i) bitlengths[i] = 8;
|
for (i = 280; i <= 287; ++i) bitlengths[i] = 8;
|
||||||
|
@ -335,7 +334,9 @@ function getFixedDistanceTable() {
|
||||||
// create once
|
// create once
|
||||||
if (!fixedHCtoDistance) {
|
if (!fixedHCtoDistance) {
|
||||||
var bitlengths = new Array(32);
|
var bitlengths = new Array(32);
|
||||||
for (var i = 0; i < 32; ++i) { bitlengths[i] = 5; }
|
for (var i = 0; i < 32; ++i) {
|
||||||
|
bitlengths[i] = 5;
|
||||||
|
}
|
||||||
|
|
||||||
// get huffman code table
|
// get huffman code table
|
||||||
fixedHCtoDistance = getHuffmanCodes(bitlengths);
|
fixedHCtoDistance = getHuffmanCodes(bitlengths);
|
||||||
|
@ -347,13 +348,12 @@ function getFixedDistanceTable() {
|
||||||
// then return that symbol
|
// then return that symbol
|
||||||
function decodeSymbol(bstream, hcTable) {
|
function decodeSymbol(bstream, hcTable) {
|
||||||
var code = 0, len = 0;
|
var code = 0, len = 0;
|
||||||
var match = false;
|
|
||||||
|
|
||||||
// loop until we match
|
// loop until we match
|
||||||
for (;;) {
|
for (;;) {
|
||||||
// read in next bit
|
// read in next bit
|
||||||
var bit = bstream.readBits(1);
|
var bit = bstream.readBits(1);
|
||||||
code = (code<<1) | bit;
|
code = (code << 1) | bit;
|
||||||
++len;
|
++len;
|
||||||
|
|
||||||
// check against Huffman Code table and break if found
|
// check against Huffman Code table and break if found
|
||||||
|
@ -372,47 +372,47 @@ function decodeSymbol(bstream, hcTable) {
|
||||||
|
|
||||||
|
|
||||||
var CodeLengthCodeOrder = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
|
var CodeLengthCodeOrder = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
|
||||||
/*
|
/*
|
||||||
Extra Extra Extra
|
Extra Extra Extra
|
||||||
Code Bits Length(s) Code Bits Lengths Code Bits Length(s)
|
Code Bits Length(s) Code Bits Lengths Code Bits Length(s)
|
||||||
---- ---- ------ ---- ---- ------- ---- ---- -------
|
---- ---- ------ ---- ---- ------- ---- ---- -------
|
||||||
257 0 3 267 1 15,16 277 4 67-82
|
257 0 3 267 1 15,16 277 4 67-82
|
||||||
258 0 4 268 1 17,18 278 4 83-98
|
258 0 4 268 1 17,18 278 4 83-98
|
||||||
259 0 5 269 2 19-22 279 4 99-114
|
259 0 5 269 2 19-22 279 4 99-114
|
||||||
260 0 6 270 2 23-26 280 4 115-130
|
260 0 6 270 2 23-26 280 4 115-130
|
||||||
261 0 7 271 2 27-30 281 5 131-162
|
261 0 7 271 2 27-30 281 5 131-162
|
||||||
262 0 8 272 2 31-34 282 5 163-194
|
262 0 8 272 2 31-34 282 5 163-194
|
||||||
263 0 9 273 3 35-42 283 5 195-226
|
263 0 9 273 3 35-42 283 5 195-226
|
||||||
264 0 10 274 3 43-50 284 5 227-257
|
264 0 10 274 3 43-50 284 5 227-257
|
||||||
265 1 11,12 275 3 51-58 285 0 258
|
265 1 11,12 275 3 51-58 285 0 258
|
||||||
266 1 13,14 276 3 59-66
|
266 1 13,14 276 3 59-66
|
||||||
|
|
||||||
*/
|
*/
|
||||||
var LengthLookupTable = [
|
var LengthLookupTable = [
|
||||||
[0,3], [0,4], [0,5], [0,6],
|
[0,3], [0,4], [0,5], [0,6],
|
||||||
[0,7], [0,8], [0,9], [0,10],
|
[0,7], [0,8], [0,9], [0,10],
|
||||||
[1,11], [1,13], [1,15], [1,17],
|
[1,11], [1,13], [1,15], [1,17],
|
||||||
[2,19], [2,23], [2,27], [2,31],
|
[2,19], [2,23], [2,27], [2,31],
|
||||||
[3,35], [3,43], [3,51], [3,59],
|
[3,35], [3,43], [3,51], [3,59],
|
||||||
[4,67], [4,83], [4,99], [4,115],
|
[4,67], [4,83], [4,99], [4,115],
|
||||||
[5,131], [5,163], [5,195], [5,227],
|
[5,131], [5,163], [5,195], [5,227],
|
||||||
[0,258]
|
[0,258]
|
||||||
];
|
];
|
||||||
/*
|
/*
|
||||||
Extra Extra Extra
|
Extra Extra Extra
|
||||||
Code Bits Dist Code Bits Dist Code Bits Distance
|
Code Bits Dist Code Bits Dist Code Bits Distance
|
||||||
---- ---- ---- ---- ---- ------ ---- ---- --------
|
---- ---- ---- ---- ---- ------ ---- ---- --------
|
||||||
0 0 1 10 4 33-48 20 9 1025-1536
|
0 0 1 10 4 33-48 20 9 1025-1536
|
||||||
1 0 2 11 4 49-64 21 9 1537-2048
|
1 0 2 11 4 49-64 21 9 1537-2048
|
||||||
2 0 3 12 5 65-96 22 10 2049-3072
|
2 0 3 12 5 65-96 22 10 2049-3072
|
||||||
3 0 4 13 5 97-128 23 10 3073-4096
|
3 0 4 13 5 97-128 23 10 3073-4096
|
||||||
4 1 5,6 14 6 129-192 24 11 4097-6144
|
4 1 5,6 14 6 129-192 24 11 4097-6144
|
||||||
5 1 7,8 15 6 193-256 25 11 6145-8192
|
5 1 7,8 15 6 193-256 25 11 6145-8192
|
||||||
6 2 9-12 16 7 257-384 26 12 8193-12288
|
6 2 9-12 16 7 257-384 26 12 8193-12288
|
||||||
7 2 13-16 17 7 385-512 27 12 12289-16384
|
7 2 13-16 17 7 385-512 27 12 12289-16384
|
||||||
8 3 17-24 18 8 513-768 28 13 16385-24576
|
8 3 17-24 18 8 513-768 28 13 16385-24576
|
||||||
9 3 25-32 19 8 769-1024 29 13 24577-32768
|
9 3 25-32 19 8 769-1024 29 13 24577-32768
|
||||||
*/
|
*/
|
||||||
var DistLookupTable = [
|
var DistLookupTable = [
|
||||||
[0,1], [0,2], [0,3], [0,4],
|
[0,1], [0,2], [0,3], [0,4],
|
||||||
[1,5], [1,7],
|
[1,5], [1,7],
|
||||||
|
@ -446,10 +446,9 @@ function inflateBlockData(bstream, hcLiteralTable, hcDistanceTable, buffer) {
|
||||||
stream, and copy length bytes from this
|
stream, and copy length bytes from this
|
||||||
position to the output stream.
|
position to the output stream.
|
||||||
*/
|
*/
|
||||||
var numSymbols = 0, blockSize = 0;
|
var blockSize = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
var symbol = decodeSymbol(bstream, hcLiteralTable);
|
var symbol = decodeSymbol(bstream, hcLiteralTable);
|
||||||
++numSymbols;
|
|
||||||
if (symbol < 256) {
|
if (symbol < 256) {
|
||||||
// copy literal byte to output
|
// copy literal byte to output
|
||||||
buffer.insertByte(symbol);
|
buffer.insertByte(symbol);
|
||||||
|
@ -461,7 +460,7 @@ function inflateBlockData(bstream, hcLiteralTable, hcDistanceTable, buffer) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var lengthLookup = LengthLookupTable[symbol-257],
|
var lengthLookup = LengthLookupTable[symbol - 257],
|
||||||
length = lengthLookup[1] + bstream.readBits(lengthLookup[0]),
|
length = lengthLookup[1] + bstream.readBits(lengthLookup[0]),
|
||||||
distLookup = DistLookupTable[decodeSymbol(bstream, hcDistanceTable)],
|
distLookup = DistLookupTable[decodeSymbol(bstream, hcDistanceTable)],
|
||||||
distance = distLookup[1] + bstream.readBits(distLookup[0]);
|
distance = distLookup[1] + bstream.readBits(distLookup[0]);
|
||||||
|
@ -479,13 +478,13 @@ function inflateBlockData(bstream, hcLiteralTable, hcDistanceTable, buffer) {
|
||||||
// loop for each character
|
// loop for each character
|
||||||
var ch = buffer.ptr - distance;
|
var ch = buffer.ptr - distance;
|
||||||
blockSize += length;
|
blockSize += length;
|
||||||
if(length > distance) {
|
if (length > distance) {
|
||||||
var data = buffer.data;
|
var data = buffer.data;
|
||||||
while (length--) {
|
while (length--) {
|
||||||
buffer.insertByte(data[ch++]);
|
buffer.insertByte(data[ch++]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
buffer.insertBytes(buffer.data.subarray(ch, ch + length))
|
buffer.insertBytes(buffer.data.subarray(ch, ch + length));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // length-distance pair
|
} // length-distance pair
|
||||||
|
@ -516,11 +515,11 @@ function inflate(compressedData, numDecompressedBytes) {
|
||||||
if (bType == 0) {
|
if (bType == 0) {
|
||||||
// skip remaining bits in this byte
|
// skip remaining bits in this byte
|
||||||
while (bstream.bitPtr != 0) bstream.readBits(1);
|
while (bstream.bitPtr != 0) bstream.readBits(1);
|
||||||
var len = bstream.readBits(16),
|
var len = bstream.readBits(16);
|
||||||
nlen = bstream.readBits(16);
|
bstream.readBits(16);
|
||||||
// TODO: check if nlen is the ones-complement of len?
|
// TODO: check if nlen is the ones-complement of len?
|
||||||
|
|
||||||
if(len > 0) buffer.insertBytes(bstream.readBytes(len));
|
if (len > 0) buffer.insertBytes(bstream.readBytes(len));
|
||||||
blockSize = len;
|
blockSize = len;
|
||||||
}
|
}
|
||||||
// fixed Huffman codes
|
// fixed Huffman codes
|
||||||
|
@ -593,9 +592,8 @@ function inflate(compressedData, numDecompressedBytes) {
|
||||||
var hcLiteralTable = getHuffmanCodes(literalCodeLengths),
|
var hcLiteralTable = getHuffmanCodes(literalCodeLengths),
|
||||||
hcDistanceTable = getHuffmanCodes(distanceCodeLengths);
|
hcDistanceTable = getHuffmanCodes(distanceCodeLengths);
|
||||||
blockSize = inflateBlockData(bstream, hcLiteralTable, hcDistanceTable, buffer);
|
blockSize = inflateBlockData(bstream, hcLiteralTable, hcDistanceTable, buffer);
|
||||||
}
|
} else {
|
||||||
// error
|
// error
|
||||||
else {
|
|
||||||
err("Error! Encountered deflate block of type 3");
|
err("Error! Encountered deflate block of type 3");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
<link href="{{ url_for('static', filename='css/libs/bootstrap.min.css') }}" rel="stylesheet" media="screen">
|
<link href="{{ url_for('static', filename='css/libs/bootstrap.min.css') }}" rel="stylesheet" media="screen">
|
||||||
<link href="{{ url_for('static', filename='css/style.css') }}" rel="stylesheet" media="screen">
|
<link href="{{ url_for('static', filename='css/style.css') }}" rel="stylesheet" media="screen">
|
||||||
{% if g.user.get_theme == 1 %}
|
{% if g.user.get_theme == 1 %}
|
||||||
<link href="{{ url_for('static', filename='css/caliBlur-style.css') }}" rel="stylesheet" media="screen">
|
<link href="{{ url_for('static', filename='css/caliBlur.min.css') }}" rel="stylesheet" media="screen">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
14
cps/web.py
14
cps/web.py
|
@ -944,14 +944,14 @@ def check_valid_domain(domain_text):
|
||||||
return len(result)
|
return len(result)
|
||||||
|
|
||||||
|
|
||||||
''' POST /post
|
|
||||||
name: 'username', //name of field (column in db)
|
|
||||||
pk: 1 //primary key (record id)
|
|
||||||
value: 'superuser!' //new value'''
|
|
||||||
@app.route("/ajax/editdomain", methods=['POST'])
|
@app.route("/ajax/editdomain", methods=['POST'])
|
||||||
@login_required
|
@login_required
|
||||||
@admin_required
|
@admin_required
|
||||||
def edit_domain():
|
def edit_domain():
|
||||||
|
''' POST /post
|
||||||
|
name: 'username', //name of field (column in db)
|
||||||
|
pk: 1 //primary key (record id)
|
||||||
|
value: 'superuser!' //new value'''
|
||||||
vals = request.form.to_dict()
|
vals = request.form.to_dict()
|
||||||
answer = ub.session.query(ub.Registration).filter(ub.Registration.id == vals['pk']).first()
|
answer = ub.session.query(ub.Registration).filter(ub.Registration.id == vals['pk']).first()
|
||||||
# domain_name = request.args.get('domain')
|
# domain_name = request.args.get('domain')
|
||||||
|
@ -1061,7 +1061,7 @@ def get_authors_json():
|
||||||
json_dumps = json.dumps([dict(name=r.name.replace('|',',')) for r in entries])
|
json_dumps = json.dumps([dict(name=r.name.replace('|',',')) for r in entries])
|
||||||
return json_dumps
|
return json_dumps
|
||||||
|
|
||||||
|
|
||||||
@app.route("/get_publishers_json", methods=['GET', 'POST'])
|
@app.route("/get_publishers_json", methods=['GET', 'POST'])
|
||||||
@login_required_if_no_ano
|
@login_required_if_no_ano
|
||||||
def get_publishers_json():
|
def get_publishers_json():
|
||||||
|
@ -1160,8 +1160,8 @@ def get_update_status():
|
||||||
r = requests.get(repository_url + '/git/refs/heads/master')
|
r = requests.get(repository_url + '/git/refs/heads/master')
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
commit = r.json()
|
commit = r.json()
|
||||||
except requests.exceptions.HTTPError as ex:
|
except requests.exceptions.HTTPError as e:
|
||||||
status['message'] = _(u'HTTP Error') + ' ' + str(ex)
|
status['message'] = _(u'HTTP Error') + ' ' + str(e)
|
||||||
except requests.exceptions.ConnectionError:
|
except requests.exceptions.ConnectionError:
|
||||||
status['message'] = _(u'Connection error')
|
status['message'] = _(u'Connection error')
|
||||||
except requests.exceptions.Timeout:
|
except requests.exceptions.Timeout:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user