mirror of
https://github.com/gchq/CyberChef
synced 2024-12-27 04:53:16 +00:00
Updated eslint whitespace rules
This commit is contained in:
parent
ebf2258715
commit
e803d208e8
51 changed files with 801 additions and 793 deletions
|
@ -135,7 +135,7 @@ module.exports = function(grunt) {
|
|||
"src/js/lib/Sortable.js",
|
||||
"src/js/lib/bootstrap-colorpicker.js",
|
||||
"src/js/lib/xpath.js",
|
||||
|
||||
|
||||
// Custom libraries
|
||||
"src/js/lib/canvas_components.js",
|
||||
|
||||
|
|
|
@ -45,9 +45,7 @@
|
|||
"comma-spacing": "error",
|
||||
"comma-style": "error",
|
||||
"computed-property-spacing": "error",
|
||||
"no-trailing-spaces": ["warn", {
|
||||
"skipBlankLines": true
|
||||
}],
|
||||
"no-trailing-spaces": "warn",
|
||||
"eol-last": "error",
|
||||
"func-call-spacing": "error",
|
||||
"indent": ["error", 4, {
|
||||
|
@ -70,7 +68,19 @@
|
|||
"ClassDeclaration": true,
|
||||
"ArrowFunctionExpression": true
|
||||
}
|
||||
}]
|
||||
}],
|
||||
"keyword-spacing": ["error", {
|
||||
"before": true,
|
||||
"after": true
|
||||
}],
|
||||
"no-multiple-empty-lines": ["warn", {
|
||||
"max": 2,
|
||||
"maxEOF": 1,
|
||||
"maxBOF": 0
|
||||
}],
|
||||
"no-whitespace-before-property": "error",
|
||||
"operator-linebreak": ["error", "after"],
|
||||
"space-in-parens": "error"
|
||||
},
|
||||
"globals": {
|
||||
/* core/* */
|
||||
|
|
|
@ -113,7 +113,7 @@ Chef.prototype.silentBake = function(recipeConfig) {
|
|||
|
||||
try {
|
||||
recipe.execute(dish);
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
// Suppress all errors
|
||||
}
|
||||
return new Date().getTime() - startTime;
|
||||
|
|
|
@ -100,7 +100,7 @@ Dish.enumLookup = function(typeEnum) {
|
|||
Dish.prototype.set = function(value, type) {
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
|
||||
|
||||
if (!this.valid()) {
|
||||
var sample = Utils.truncate(JSON.stringify(this.value), 13);
|
||||
throw "Data is not a valid " + Dish.enumLookup(type) + ": " + sample;
|
||||
|
@ -145,7 +145,7 @@ Dish.prototype.translate = function(toType) {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Convert from byteArray to toType
|
||||
switch (toType) {
|
||||
case Dish.STRING:
|
||||
|
@ -175,7 +175,7 @@ Dish.prototype.valid = function() {
|
|||
if (!(this.value instanceof Array)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Check that every value is a number between 0 - 255
|
||||
for (var i = 0; i < this.value.length; i++) {
|
||||
if (typeof this.value[i] != "number" ||
|
||||
|
|
|
@ -24,7 +24,7 @@ var FlowControl = {
|
|||
* @default
|
||||
*/
|
||||
FORK_IGNORE_ERRORS: false,
|
||||
|
||||
|
||||
/**
|
||||
* Fork operation.
|
||||
*
|
||||
|
@ -45,10 +45,10 @@ var FlowControl = {
|
|||
ignoreErrors = ings[2],
|
||||
subOpList = [],
|
||||
inputs = [];
|
||||
|
||||
|
||||
if (input)
|
||||
inputs = input.split(splitDelim);
|
||||
|
||||
|
||||
// Create subOpList for each tranche to operate on
|
||||
// (all remaining operations unless we encounter a Merge)
|
||||
for (var i = state.progress + 1; i < opList.length; i++) {
|
||||
|
@ -58,19 +58,19 @@ var FlowControl = {
|
|||
subOpList.push(opList[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var recipe = new Recipe(),
|
||||
output = "",
|
||||
progress = 0;
|
||||
|
||||
|
||||
recipe.addOperations(subOpList);
|
||||
|
||||
|
||||
// Run recipe over each tranche
|
||||
for (i = 0; i < inputs.length; i++) {
|
||||
var dish = new Dish(inputs[i], inputType);
|
||||
try {
|
||||
progress = recipe.execute(dish, 0);
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
if (!ignoreErrors) {
|
||||
throw err;
|
||||
}
|
||||
|
@ -78,13 +78,13 @@ var FlowControl = {
|
|||
}
|
||||
output += dish.get(outputType) + mergeDelim;
|
||||
}
|
||||
|
||||
|
||||
state.dish.set(output, outputType);
|
||||
state.progress += progress;
|
||||
return state;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Merge operation.
|
||||
*
|
||||
|
@ -99,8 +99,8 @@ var FlowControl = {
|
|||
// merge when it sees this operation.
|
||||
return state;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -111,7 +111,7 @@ var FlowControl = {
|
|||
* @default
|
||||
*/
|
||||
MAX_JUMPS: 10,
|
||||
|
||||
|
||||
/**
|
||||
* Jump operation.
|
||||
*
|
||||
|
@ -126,18 +126,18 @@ var FlowControl = {
|
|||
var ings = state.opList[state.progress].getIngValues(),
|
||||
jumpNum = ings[0],
|
||||
maxJumps = ings[1];
|
||||
|
||||
|
||||
if (state.numJumps >= maxJumps) {
|
||||
state.progress++;
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
state.progress += jumpNum;
|
||||
state.numJumps++;
|
||||
return state;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Conditional Jump operation.
|
||||
*
|
||||
|
@ -154,21 +154,21 @@ var FlowControl = {
|
|||
regexStr = ings[0],
|
||||
jumpNum = ings[1],
|
||||
maxJumps = ings[2];
|
||||
|
||||
|
||||
if (state.numJumps >= maxJumps) {
|
||||
state.progress++;
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
if (regexStr !== "" && dish.get(Dish.STRING).search(regexStr) > -1) {
|
||||
state.progress += jumpNum;
|
||||
state.numJumps++;
|
||||
}
|
||||
|
||||
|
||||
return state;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return operation.
|
||||
*
|
||||
|
@ -182,5 +182,5 @@ var FlowControl = {
|
|||
state.progress = state.opList.length;
|
||||
return state;
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@ var Ingredient = function(ingredientConfig) {
|
|||
this.name = "";
|
||||
this.type = "";
|
||||
this.value = null;
|
||||
|
||||
|
||||
if (ingredientConfig) {
|
||||
this._parseConfig(ingredientConfig);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ var Operation = function(operationName, operationConfig) {
|
|||
this.breakpoint = false;
|
||||
this.disabled = false;
|
||||
this.ingList = [];
|
||||
|
||||
|
||||
if (operationConfig) {
|
||||
this._parseConfig(operationConfig);
|
||||
}
|
||||
|
@ -57,16 +57,16 @@ Operation.prototype._parseConfig = function(operationConfig) {
|
|||
*/
|
||||
Operation.prototype.getConfig = function() {
|
||||
var ingredientConfig = [];
|
||||
|
||||
|
||||
for (var o = 0; o < this.ingList.length; o++) {
|
||||
ingredientConfig.push(this.ingList[o].getConfig());
|
||||
}
|
||||
|
||||
|
||||
var operationConfig = {
|
||||
"op": this.name,
|
||||
"args": ingredientConfig
|
||||
};
|
||||
|
||||
|
||||
return operationConfig;
|
||||
};
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*/
|
||||
var Recipe = function(recipeConfig) {
|
||||
this.opList = [];
|
||||
|
||||
|
||||
if (recipeConfig) {
|
||||
this._parseConfig(recipeConfig);
|
||||
}
|
||||
|
@ -43,11 +43,11 @@ Recipe.prototype._parseConfig = function(recipeConfig) {
|
|||
*/
|
||||
Recipe.prototype.getConfig = function() {
|
||||
var recipeConfig = [];
|
||||
|
||||
|
||||
for (var o = 0; o < this.opList.length; o++) {
|
||||
recipeConfig.push(this.opList[o].getConfig());
|
||||
}
|
||||
|
||||
|
||||
return recipeConfig;
|
||||
};
|
||||
|
||||
|
@ -123,13 +123,13 @@ Recipe.prototype.containsFlowControl = function() {
|
|||
Recipe.prototype.lastOpIndex = function(startIndex) {
|
||||
var i = startIndex + 1 || 0,
|
||||
op;
|
||||
|
||||
|
||||
for (; i < this.opList.length; i++) {
|
||||
op = this.opList[i];
|
||||
if (op.isDisabled()) return i-1;
|
||||
if (op.isBreakpoint()) return i-1;
|
||||
}
|
||||
|
||||
|
||||
return i-1;
|
||||
};
|
||||
|
||||
|
@ -144,7 +144,7 @@ Recipe.prototype.lastOpIndex = function(startIndex) {
|
|||
Recipe.prototype.execute = function(dish, startFrom) {
|
||||
startFrom = startFrom || 0;
|
||||
var op, input, output, numJumps = 0;
|
||||
|
||||
|
||||
for (var i = startFrom; i < this.opList.length; i++) {
|
||||
op = this.opList[i];
|
||||
if (op.isDisabled()) {
|
||||
|
@ -153,10 +153,10 @@ Recipe.prototype.execute = function(dish, startFrom) {
|
|||
if (op.isBreakpoint()) {
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
input = dish.get(op.inputType);
|
||||
|
||||
|
||||
if (op.isFlowControl()) {
|
||||
// Package up the current state
|
||||
var state = {
|
||||
|
@ -165,7 +165,7 @@ Recipe.prototype.execute = function(dish, startFrom) {
|
|||
"opList" : this.opList,
|
||||
"numJumps" : numJumps
|
||||
};
|
||||
|
||||
|
||||
state = op.run(state);
|
||||
i = state.progress;
|
||||
numJumps = state.numJumps;
|
||||
|
@ -184,11 +184,11 @@ Recipe.prototype.execute = function(dish, startFrom) {
|
|||
} else {
|
||||
e.displayStr = op.name + " - " + (e.displayStr || e.message);
|
||||
}
|
||||
|
||||
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return this.opList.length;
|
||||
};
|
||||
|
||||
|
|
|
@ -922,8 +922,8 @@ var Utils = {
|
|||
* @returns {Object}
|
||||
*/
|
||||
extend: function(a, b){
|
||||
for(var key in b)
|
||||
if(b.hasOwnProperty(key))
|
||||
for (var key in b)
|
||||
if (b.hasOwnProperty(key))
|
||||
a[key] = b[key];
|
||||
return a;
|
||||
},
|
||||
|
@ -1169,7 +1169,6 @@ String.prototype.count = function(chr) {
|
|||
};
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Library overrides ///////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -14,7 +14,7 @@ var Base = {
|
|||
* @default
|
||||
*/
|
||||
DEFAULT_RADIX: 36,
|
||||
|
||||
|
||||
/**
|
||||
* To Base operation.
|
||||
*
|
||||
|
@ -32,8 +32,8 @@ var Base = {
|
|||
}
|
||||
return input.toString(radix);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* From Base operation.
|
||||
*
|
||||
|
@ -48,5 +48,5 @@ var Base = {
|
|||
}
|
||||
return parseInt(input.replace(/\s/g, ""), radix);
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -28,7 +28,7 @@ var BitwiseOp = {
|
|||
x = null,
|
||||
k = null,
|
||||
o = null;
|
||||
|
||||
|
||||
for (var i = 0; i < input.length; i++) {
|
||||
k = key[i % key.length];
|
||||
o = input[i];
|
||||
|
@ -45,11 +45,11 @@ var BitwiseOp = {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -65,7 +65,7 @@ var BitwiseOp = {
|
|||
* @default
|
||||
*/
|
||||
KEY_FORMAT: ["Hex", "Base64", "UTF8", "UTF16", "UTF16LE", "UTF16BE", "Latin1"],
|
||||
|
||||
|
||||
/**
|
||||
* XOR operation.
|
||||
*
|
||||
|
@ -77,13 +77,13 @@ var BitwiseOp = {
|
|||
var key = Utils.format[args[0].option].parse(args[0].string || ""),
|
||||
scheme = args[1],
|
||||
nullPreserving = args[2];
|
||||
|
||||
|
||||
key = Utils.wordArrayToByteArray(key);
|
||||
|
||||
|
||||
return BitwiseOp._bitOp(input, key, BitwiseOp._xor, nullPreserving, scheme);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -109,7 +109,7 @@ var BitwiseOp = {
|
|||
* @default
|
||||
*/
|
||||
XOR_BRUTE_OUTPUT_HEX: false,
|
||||
|
||||
|
||||
/**
|
||||
* XOR Brute Force operation.
|
||||
*
|
||||
|
@ -127,18 +127,18 @@ var BitwiseOp = {
|
|||
printKey = args[6],
|
||||
outputHex = args[7],
|
||||
regex;
|
||||
|
||||
|
||||
var output = "",
|
||||
result,
|
||||
resultUtf8;
|
||||
|
||||
|
||||
input = input.slice(sampleOffset, sampleOffset + sampleLength);
|
||||
|
||||
|
||||
if (crib !== "") {
|
||||
regex = new RegExp(crib, "im");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
for (var key = 1, l = Math.pow(256, keyLength); key < l; key++) {
|
||||
result = BitwiseOp._bitOp(input, Utils.hexToByteArray(key.toString(16)), BitwiseOp._xor, nullPreserving, differential);
|
||||
resultUtf8 = Utils.byteArrayToUtf8(result);
|
||||
|
@ -152,8 +152,8 @@ var BitwiseOp = {
|
|||
}
|
||||
return output;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* NOT operation.
|
||||
*
|
||||
|
@ -164,8 +164,8 @@ var BitwiseOp = {
|
|||
runNot: function (input, args) {
|
||||
return BitwiseOp._bitOp(input, null, BitwiseOp._not);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* AND operation.
|
||||
*
|
||||
|
@ -176,11 +176,11 @@ var BitwiseOp = {
|
|||
runAnd: function (input, args) {
|
||||
var key = Utils.format[args[0].option].parse(args[0].string || "");
|
||||
key = Utils.wordArrayToByteArray(key);
|
||||
|
||||
|
||||
return BitwiseOp._bitOp(input, key, BitwiseOp._and);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* OR operation.
|
||||
*
|
||||
|
@ -191,11 +191,11 @@ var BitwiseOp = {
|
|||
runOr: function (input, args) {
|
||||
var key = Utils.format[args[0].option].parse(args[0].string || "");
|
||||
key = Utils.wordArrayToByteArray(key);
|
||||
|
||||
|
||||
return BitwiseOp._bitOp(input, key, BitwiseOp._or);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* ADD operation.
|
||||
*
|
||||
|
@ -206,11 +206,11 @@ var BitwiseOp = {
|
|||
runAdd: function (input, args) {
|
||||
var key = Utils.format[args[0].option].parse(args[0].string || "");
|
||||
key = Utils.wordArrayToByteArray(key);
|
||||
|
||||
|
||||
return BitwiseOp._bitOp(input, key, BitwiseOp._add);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* SUB operation.
|
||||
*
|
||||
|
@ -221,11 +221,11 @@ var BitwiseOp = {
|
|||
runSub: function (input, args) {
|
||||
var key = Utils.format[args[0].option].parse(args[0].string || "");
|
||||
key = Utils.wordArrayToByteArray(key);
|
||||
|
||||
|
||||
return BitwiseOp._bitOp(input, key, BitwiseOp._sub);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* XOR bitwise calculation.
|
||||
*
|
||||
|
@ -237,8 +237,8 @@ var BitwiseOp = {
|
|||
_xor: function (operand, key) {
|
||||
return operand ^ key;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* NOT bitwise calculation.
|
||||
*
|
||||
|
@ -249,8 +249,8 @@ var BitwiseOp = {
|
|||
_not: function (operand, _) {
|
||||
return ~operand & 0xff;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* AND bitwise calculation.
|
||||
*
|
||||
|
@ -262,8 +262,8 @@ var BitwiseOp = {
|
|||
_and: function (operand, key) {
|
||||
return operand & key;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* OR bitwise calculation.
|
||||
*
|
||||
|
@ -276,7 +276,7 @@ var BitwiseOp = {
|
|||
return operand | key;
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* ADD bitwise calculation.
|
||||
*
|
||||
|
@ -289,7 +289,7 @@ var BitwiseOp = {
|
|||
return (operand + key) % 256;
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* SUB bitwise calculation.
|
||||
*
|
||||
|
|
|
@ -16,7 +16,7 @@ var CharEnc = {
|
|||
* @default
|
||||
*/
|
||||
IO_FORMAT: ["UTF8", "UTF16", "UTF16LE", "UTF16BE", "Latin1", "Windows-1251", "Hex", "Base64"],
|
||||
|
||||
|
||||
/**
|
||||
* Text encoding operation.
|
||||
*
|
||||
|
@ -27,14 +27,14 @@ var CharEnc = {
|
|||
run: function(input, args) {
|
||||
var inputFormat = args[0],
|
||||
outputFormat = args[1];
|
||||
|
||||
|
||||
if (inputFormat === "Windows-1251") {
|
||||
input = Utils.win1251ToUnicode(input);
|
||||
input = CryptoJS.enc.Utf8.parse(input);
|
||||
} else {
|
||||
input = Utils.format[inputFormat].parse(input);
|
||||
}
|
||||
|
||||
|
||||
if (outputFormat === "Windows-1251") {
|
||||
input = CryptoJS.enc.Utf8.stringify(input);
|
||||
return Utils.unicodeToWin1251(input);
|
||||
|
@ -42,5 +42,5 @@ var CharEnc = {
|
|||
return Utils.format[outputFormat].stringify(input);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -19,12 +19,12 @@ var Checksum = {
|
|||
runFletcher8: function(input, args) {
|
||||
var a = 0,
|
||||
b = 0;
|
||||
|
||||
|
||||
for (var i = 0; i < input.length; i++) {
|
||||
a = (a + input[i]) % 0xf;
|
||||
b = (b + a) % 0xf;
|
||||
}
|
||||
|
||||
|
||||
return Utils.hex(((b << 4) | a) >>> 0, 2);
|
||||
},
|
||||
|
||||
|
@ -39,12 +39,12 @@ var Checksum = {
|
|||
runFletcher16: function(input, args) {
|
||||
var a = 0,
|
||||
b = 0;
|
||||
|
||||
|
||||
for (var i = 0; i < input.length; i++) {
|
||||
a = (a + input[i]) % 0xff;
|
||||
b = (b + a) % 0xff;
|
||||
}
|
||||
|
||||
|
||||
return Utils.hex(((b << 8) | a) >>> 0, 4);
|
||||
},
|
||||
|
||||
|
@ -59,12 +59,12 @@ var Checksum = {
|
|||
runFletcher32: function(input, args) {
|
||||
var a = 0,
|
||||
b = 0;
|
||||
|
||||
|
||||
for (var i = 0; i < input.length; i++) {
|
||||
a = (a + input[i]) % 0xffff;
|
||||
b = (b + a) % 0xffff;
|
||||
}
|
||||
|
||||
|
||||
return Utils.hex(((b << 16) | a) >>> 0, 8);
|
||||
},
|
||||
|
||||
|
@ -79,16 +79,16 @@ var Checksum = {
|
|||
runFletcher64: function(input, args) {
|
||||
var a = 0,
|
||||
b = 0;
|
||||
|
||||
|
||||
for (var i = 0; i < input.length; i++) {
|
||||
a = (a + input[i]) % 0xffffffff;
|
||||
b = (b + a) % 0xffffffff;
|
||||
}
|
||||
|
||||
|
||||
return Utils.hex(b >>> 0, 8) + Utils.hex(a >>> 0, 8);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adler-32 Checksum operation.
|
||||
*
|
||||
|
@ -100,19 +100,19 @@ var Checksum = {
|
|||
var MOD_ADLER = 65521,
|
||||
a = 1,
|
||||
b = 0;
|
||||
|
||||
|
||||
for (var i = 0; i < input.length; i++) {
|
||||
a += input[i];
|
||||
b += a;
|
||||
}
|
||||
|
||||
|
||||
a %= MOD_ADLER;
|
||||
b %= MOD_ADLER;
|
||||
|
||||
|
||||
return Utils.hex(((b << 16) | a) >>> 0, 8);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* CRC-32 Checksum operation.
|
||||
*
|
||||
|
@ -123,15 +123,15 @@ var Checksum = {
|
|||
runCRC32: function(input, args) {
|
||||
var crcTable = window.crcTable || (window.crcTable = Checksum._genCRCTable()),
|
||||
crc = 0 ^ (-1);
|
||||
|
||||
|
||||
for (var i = 0; i < input.length; i++) {
|
||||
crc = (crc >>> 8) ^ crcTable[(crc ^ input[i]) & 0xff];
|
||||
}
|
||||
|
||||
|
||||
return Utils.hex((crc ^ (-1)) >>> 0);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* TCP/IP Checksum operation.
|
||||
*
|
||||
|
@ -151,9 +151,9 @@ var Checksum = {
|
|||
*/
|
||||
runTCPIP: function(input, args) {
|
||||
var csum = 0;
|
||||
|
||||
|
||||
for (var i = 0; i < input.length; i++) {
|
||||
if(i % 2 === 0) {
|
||||
if (i % 2 === 0) {
|
||||
csum += (input[i] << 8);
|
||||
} else {
|
||||
csum += input[i];
|
||||
|
@ -164,8 +164,8 @@ var Checksum = {
|
|||
|
||||
return Utils.hex(0xffff - csum);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generates a CRC table for use with CRC checksums.
|
||||
*
|
||||
|
@ -175,7 +175,7 @@ var Checksum = {
|
|||
_genCRCTable: function() {
|
||||
var c,
|
||||
crcTable = [];
|
||||
|
||||
|
||||
for (var n = 0; n < 256; n++) {
|
||||
c = n;
|
||||
for (var k = 0; k < 8; k++) {
|
||||
|
@ -183,7 +183,7 @@ var Checksum = {
|
|||
}
|
||||
crcTable[n] = c;
|
||||
}
|
||||
|
||||
|
||||
return crcTable;
|
||||
},
|
||||
|
||||
|
|
|
@ -460,7 +460,7 @@ var Cipher = {
|
|||
msgIndex = alphabet.indexOf(input[i]);
|
||||
// Subtract indexes from each other, add 26 just in case the value is negative,
|
||||
// modulo to remove if neccessary
|
||||
output += alphabet[(msgIndex - keyIndex + alphabet.length ) % 26];
|
||||
output += alphabet[(msgIndex - keyIndex + alphabet.length) % 26];
|
||||
} else if (alphabet.indexOf(input[i].toLowerCase()) >= 0) {
|
||||
chr = key[(i - fail) % key.length].toLowerCase();
|
||||
keyIndex = alphabet.indexOf(chr);
|
||||
|
@ -546,7 +546,7 @@ var Cipher = {
|
|||
|
||||
// Calculates modular inverse of a
|
||||
aModInv = Utils.modInv(a, 26);
|
||||
|
||||
|
||||
for (var i = 0; i < input.length; i++) {
|
||||
if (alphabet.indexOf(input[i]) >= 0) {
|
||||
// Uses the affine decode function (y-b * A') % m = x (where m is length of the alphabet and A' is modular inverse)
|
||||
|
|
|
@ -244,7 +244,7 @@ var Code = {
|
|||
var i = 0,
|
||||
level = 0;
|
||||
while (i < code.length) {
|
||||
switch(code[i]) {
|
||||
switch (code[i]) {
|
||||
case "{":
|
||||
level++;
|
||||
break;
|
||||
|
|
|
@ -40,7 +40,7 @@ var Compress = {
|
|||
"Dynamic Huffman Coding" : Zlib.RawDeflate.CompressionType.DYNAMIC,
|
||||
"None (Store)" : Zlib.RawDeflate.CompressionType.NONE,
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Raw Deflate operation.
|
||||
*
|
||||
|
@ -54,8 +54,8 @@ var Compress = {
|
|||
});
|
||||
return Array.prototype.slice.call(deflate.compress());
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -84,7 +84,7 @@ var Compress = {
|
|||
"Adaptive" : Zlib.RawInflate.BufferType.ADAPTIVE,
|
||||
"Block" : Zlib.RawInflate.BufferType.BLOCK,
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Raw Inflate operation.
|
||||
*
|
||||
|
@ -103,7 +103,7 @@ var Compress = {
|
|||
verify: args[4]
|
||||
}),
|
||||
result = Array.prototype.slice.call(inflate.decompress());
|
||||
|
||||
|
||||
// Raw Inflate somethimes messes up and returns nonsense like this:
|
||||
// ]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]...
|
||||
// e.g. Input data of [8b, 1d, dc, 44]
|
||||
|
@ -117,7 +117,7 @@ var Compress = {
|
|||
valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!valid) {
|
||||
throw "Error: Unable to inflate data";
|
||||
}
|
||||
|
@ -125,8 +125,8 @@ var Compress = {
|
|||
// Trust me, this is the easiest way...
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -136,7 +136,7 @@ var Compress = {
|
|||
"Dynamic Huffman Coding" : Zlib.Deflate.CompressionType.DYNAMIC,
|
||||
"None (Store)" : Zlib.Deflate.CompressionType.NONE,
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Zlib Deflate operation.
|
||||
*
|
||||
|
@ -150,8 +150,8 @@ var Compress = {
|
|||
});
|
||||
return Array.prototype.slice.call(deflate.compress());
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -160,7 +160,7 @@ var Compress = {
|
|||
"Adaptive" : Zlib.Inflate.BufferType.ADAPTIVE,
|
||||
"Block" : Zlib.Inflate.BufferType.BLOCK,
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Zlib Inflate operation.
|
||||
*
|
||||
|
@ -180,14 +180,14 @@ var Compress = {
|
|||
});
|
||||
return Array.prototype.slice.call(inflate.decompress());
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
GZIP_CHECKSUM: false,
|
||||
|
||||
|
||||
/**
|
||||
* Gzip operation.
|
||||
*
|
||||
|
@ -206,7 +206,7 @@ var Compress = {
|
|||
fhcrc: args[3]
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
if (filename.length) {
|
||||
options.flags.fname = true;
|
||||
options.filename = filename;
|
||||
|
@ -215,12 +215,12 @@ var Compress = {
|
|||
options.flags.fcommenct = true;
|
||||
options.comment = comment;
|
||||
}
|
||||
|
||||
|
||||
var gzip = new Zlib.Gzip(input, options);
|
||||
return Array.prototype.slice.call(gzip.compress());
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gunzip operation.
|
||||
*
|
||||
|
@ -234,8 +234,8 @@ var Compress = {
|
|||
var gunzip = new Zlib.Gunzip(input);
|
||||
return Array.prototype.slice.call(gunzip.decompress());
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -258,7 +258,7 @@ var Compress = {
|
|||
"Unix" : Zlib.Zip.OperatingSystem.UNIX,
|
||||
"Macintosh" : Zlib.Zip.OperatingSystem.MACINTOSH
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Zip operation.
|
||||
*
|
||||
|
@ -278,20 +278,20 @@ var Compress = {
|
|||
},
|
||||
},
|
||||
zip = new Zlib.Zip();
|
||||
|
||||
|
||||
if (password.length)
|
||||
zip.setPassword(password);
|
||||
zip.addFile(input, options);
|
||||
return Array.prototype.slice.call(zip.compress());
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
PKUNZIP_VERIFY: false,
|
||||
|
||||
|
||||
/**
|
||||
* Unzip operation.
|
||||
*
|
||||
|
@ -308,9 +308,9 @@ var Compress = {
|
|||
unzip = new Zlib.Unzip(input, options),
|
||||
filenames = unzip.getFilenames(),
|
||||
output = "<div style='padding: 5px;'>" + filenames.length + " file(s) found</div>\n";
|
||||
|
||||
|
||||
output += "<div class='panel-group' id='zip-accordion' role='tablist' aria-multiselectable='true'>";
|
||||
|
||||
|
||||
window.uzip = unzip;
|
||||
for (var i = 0; i < filenames.length; i++) {
|
||||
file = Utils.byteArrayToUtf8(unzip.decompress(filenames[i]));
|
||||
|
@ -324,11 +324,11 @@ var Compress = {
|
|||
"<div class='panel-body'>" +
|
||||
Utils.escapeHtml(file) + "</div></div></div>";
|
||||
}
|
||||
|
||||
|
||||
return output + "</div>";
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Bzip2 Decompress operation.
|
||||
*
|
||||
|
@ -340,10 +340,10 @@ var Compress = {
|
|||
var compressed = new Uint8Array(input),
|
||||
bzip2Reader,
|
||||
plain = "";
|
||||
|
||||
|
||||
bzip2Reader = bzip2.array(compressed);
|
||||
plain = bzip2.simple(bzip2Reader);
|
||||
return plain;
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -10,13 +10,13 @@
|
|||
* @namespace
|
||||
*/
|
||||
var DateTime = {
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
UNITS: ["Seconds (s)", "Milliseconds (ms)", "Microseconds (μs)", "Nanoseconds (ns)"],
|
||||
|
||||
|
||||
/**
|
||||
* From UNIX Timestamp operation.
|
||||
*
|
||||
|
@ -27,9 +27,9 @@ var DateTime = {
|
|||
runFromUnixTimestamp: function(input, args) {
|
||||
var units = args[0],
|
||||
d;
|
||||
|
||||
|
||||
input = parseFloat(input);
|
||||
|
||||
|
||||
if (units === "Seconds (s)") {
|
||||
d = moment.unix(input);
|
||||
return d.tz("UTC").format("ddd D MMMM YYYY HH:mm:ss") + " UTC";
|
||||
|
@ -46,8 +46,8 @@ var DateTime = {
|
|||
throw "Unrecognised unit";
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* To UNIX Timestamp operation.
|
||||
*
|
||||
|
@ -58,7 +58,7 @@ var DateTime = {
|
|||
runToUnixTimestamp: function(input, args) {
|
||||
var units = args[0],
|
||||
d = moment(input);
|
||||
|
||||
|
||||
if (units === "Seconds (s)") {
|
||||
return d.unix();
|
||||
} else if (units === "Milliseconds (ms)") {
|
||||
|
@ -71,8 +71,8 @@ var DateTime = {
|
|||
throw "Unrecognised unit";
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -122,7 +122,7 @@ var DateTime = {
|
|||
* @default
|
||||
*/
|
||||
TIMEZONES: ["UTC"].concat(moment.tz.names()),
|
||||
|
||||
|
||||
/**
|
||||
* Translate DateTime Format operation.
|
||||
*
|
||||
|
@ -140,14 +140,14 @@ var DateTime = {
|
|||
try {
|
||||
date = moment.tz(input, inputFormat, inputTimezone);
|
||||
if (!date || date.format() === "Invalid date") throw Error;
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
return "Invalid format.\n\n" + DateTime.FORMAT_EXAMPLES;
|
||||
}
|
||||
|
||||
|
||||
return date.tz(outputTimezone).format(outputFormat);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parse DateTime operation.
|
||||
*
|
||||
|
@ -160,14 +160,14 @@ var DateTime = {
|
|||
inputTimezone = args[2],
|
||||
date,
|
||||
output = "";
|
||||
|
||||
|
||||
try {
|
||||
date = moment.tz(input, inputFormat, inputTimezone);
|
||||
if (!date || date.format() === "Invalid date") throw Error;
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
return "Invalid format.\n\n" + DateTime.FORMAT_EXAMPLES;
|
||||
}
|
||||
|
||||
|
||||
output += "Date: " + date.format("dddd Do MMMM YYYY") +
|
||||
"\nTime: " + date.format("HH:mm:ss") +
|
||||
"\nPeriod: " + date.format("A") +
|
||||
|
@ -179,11 +179,11 @@ var DateTime = {
|
|||
"\n\nDay of year: " + date.dayOfYear() +
|
||||
"\nWeek number: " + date.weekYear() +
|
||||
"\nQuarter: " + date.quarter();
|
||||
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
*/
|
||||
|
@ -450,5 +450,5 @@ var DateTime = {
|
|||
</tbody>\
|
||||
</table>",
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* @namespace
|
||||
*/
|
||||
var Endian = {
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -24,7 +24,7 @@ var Endian = {
|
|||
* @default
|
||||
*/
|
||||
PAD_INCOMPLETE_WORDS: true,
|
||||
|
||||
|
||||
/**
|
||||
* Swap endianness operation.
|
||||
*
|
||||
|
@ -41,11 +41,11 @@ var Endian = {
|
|||
words = [],
|
||||
i = 0,
|
||||
j = 0;
|
||||
|
||||
|
||||
if (wordLength <= 0) {
|
||||
return "Word length must be greater than 0";
|
||||
}
|
||||
|
||||
|
||||
// Convert input to raw data based on specified data format
|
||||
switch (dataFormat) {
|
||||
case "Hex":
|
||||
|
@ -57,21 +57,21 @@ var Endian = {
|
|||
default:
|
||||
data = input;
|
||||
}
|
||||
|
||||
|
||||
// Split up into words
|
||||
for (i = 0; i < data.length; i += wordLength) {
|
||||
var word = data.slice(i, i + wordLength);
|
||||
|
||||
|
||||
// Pad word if too short
|
||||
if (padIncompleteWords && word.length < wordLength){
|
||||
for (j = word.length; j < wordLength; j++) {
|
||||
word.push(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
words.push(word);
|
||||
}
|
||||
|
||||
|
||||
// Swap endianness and flatten
|
||||
for (i = 0; i < words.length; i++) {
|
||||
j = words[i].length;
|
||||
|
@ -79,7 +79,7 @@ var Endian = {
|
|||
result.push(words[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Convert data back to specified data format
|
||||
switch (dataFormat) {
|
||||
case "Hex":
|
||||
|
@ -90,5 +90,5 @@ var Endian = {
|
|||
return result;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
* @namespace
|
||||
*/
|
||||
var Entropy = {
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
CHUNK_SIZE: 1000,
|
||||
|
||||
|
||||
/**
|
||||
* Entropy operation.
|
||||
*
|
||||
|
@ -26,7 +26,7 @@ var Entropy = {
|
|||
var chunkSize = args[0],
|
||||
output = "",
|
||||
entropy = Entropy._calcEntropy(input);
|
||||
|
||||
|
||||
output += "Shannon entropy: " + entropy + "\n" +
|
||||
"<br><canvas id='chart-area'></canvas><br>\n" +
|
||||
"- 0 represents no randomness (i.e. all the bytes in the data have the same value) whereas 8, the maximum, represents a completely random string.\n" +
|
||||
|
@ -54,7 +54,7 @@ var Entropy = {
|
|||
}\
|
||||
]);\
|
||||
</script>";
|
||||
|
||||
|
||||
var chunkEntropy = 0;
|
||||
if (chunkSize !== 0) {
|
||||
for (var i = 0; i < input.length; i += chunkSize) {
|
||||
|
@ -64,17 +64,17 @@ var Entropy = {
|
|||
} else {
|
||||
output += "Chunk size cannot be 0.";
|
||||
}
|
||||
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
FREQ_ZEROS: false,
|
||||
|
||||
|
||||
/**
|
||||
* Frequency distribution operation.
|
||||
*
|
||||
|
@ -84,29 +84,29 @@ var Entropy = {
|
|||
*/
|
||||
runFreqDistrib: function (input, args) {
|
||||
if (!input.length) return "No data";
|
||||
|
||||
|
||||
var distrib = new Array(256),
|
||||
percentages = new Array(256),
|
||||
len = input.length,
|
||||
showZeroes = args[0];
|
||||
|
||||
|
||||
// Initialise distrib to 0
|
||||
for (var i = 0; i < 256; i++) {
|
||||
distrib[i] = 0;
|
||||
}
|
||||
|
||||
|
||||
// Count bytes
|
||||
for (i = 0; i < len; i++) {
|
||||
distrib[input[i]]++;
|
||||
}
|
||||
|
||||
|
||||
// Calculate percentages
|
||||
var repr = 0;
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (distrib[i] > 0) repr++;
|
||||
percentages[i] = distrib[i] / len * 100;
|
||||
}
|
||||
|
||||
|
||||
// Print
|
||||
var output = "<canvas id='chart-area'></canvas><br>" +
|
||||
"Total data length: " + len +
|
||||
|
@ -123,7 +123,7 @@ var Entropy = {
|
|||
\
|
||||
CanvasComponents.drawBarChart(canvas, scores, 'Byte', 'Frequency %', 16, 6);\
|
||||
</script>";
|
||||
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (distrib[i] || showZeroes) {
|
||||
output += " " + Utils.hex(i, 2) + " (" +
|
||||
|
@ -131,11 +131,11 @@ var Entropy = {
|
|||
Array(Math.ceil(percentages[i])+1).join("|") + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Calculates the Shannon entropy for a given chunk of data.
|
||||
*
|
||||
|
@ -147,19 +147,19 @@ var Entropy = {
|
|||
var prob = [],
|
||||
uniques = data.unique(),
|
||||
str = Utils.byteArrayToChars(data);
|
||||
|
||||
|
||||
for (var i = 0; i < uniques.length; i++) {
|
||||
prob.push(str.count(Utils.chr(uniques[i])) / data.length);
|
||||
}
|
||||
|
||||
|
||||
var entropy = 0,
|
||||
p;
|
||||
|
||||
|
||||
for (i = 0; i < prob.length; i++) {
|
||||
p = prob[i];
|
||||
entropy += p * Math.log(p) / Math.log(2);
|
||||
}
|
||||
|
||||
|
||||
return -entropy;
|
||||
},
|
||||
|
||||
|
|
|
@ -24,17 +24,17 @@ var Extract = {
|
|||
var output = "",
|
||||
total = 0,
|
||||
match;
|
||||
|
||||
|
||||
while ((match = searchRegex.exec(input))) {
|
||||
if (removeRegex && removeRegex.test(match[0]))
|
||||
continue;
|
||||
total++;
|
||||
output += match[0] + "\n";
|
||||
}
|
||||
|
||||
|
||||
if (includeTotal)
|
||||
output = "Total found: " + total + "\n\n" + output;
|
||||
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
@ -49,7 +49,7 @@ var Extract = {
|
|||
* @default
|
||||
*/
|
||||
DISPLAY_TOTAL: false,
|
||||
|
||||
|
||||
/**
|
||||
* Strings operation.
|
||||
*
|
||||
|
@ -62,11 +62,11 @@ var Extract = {
|
|||
displayTotal = args[1],
|
||||
strings = "[A-Z\\d/\\-:.,_$%'\"()<>= !\\[\\]{}@]",
|
||||
regex = new RegExp(strings + "{" + minLen + ",}", "ig");
|
||||
|
||||
|
||||
return Extract._search(input, regex, null, displayTotal);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -82,7 +82,7 @@ var Extract = {
|
|||
* @default
|
||||
*/
|
||||
REMOVE_LOCAL: false,
|
||||
|
||||
|
||||
/**
|
||||
* Extract IP addresses operation.
|
||||
*
|
||||
|
@ -98,7 +98,7 @@ var Extract = {
|
|||
ipv4 = "(?:(?:\\d|[01]?\\d\\d|2[0-4]\\d|25[0-5])\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d|\\d)(?:\\/\\d{1,2})?",
|
||||
ipv6 = "((?=.*::)(?!.*::.+::)(::)?([\\dA-F]{1,4}:(:|\\b)|){5}|([\\dA-F]{1,4}:){6})((([\\dA-F]{1,4}((?!\\3)::|:\\b|(?![\\dA-F])))|(?!\\2\\3)){2}|(((2[0-4]|1\\d|[1-9])?\\d|25[0-5])\\.?\\b){4})",
|
||||
ips = "";
|
||||
|
||||
|
||||
if (includeIpv4 && includeIpv6) {
|
||||
ips = ipv4 + "|" + ipv6;
|
||||
} else if (includeIpv4) {
|
||||
|
@ -106,10 +106,10 @@ var Extract = {
|
|||
} else if (includeIpv6) {
|
||||
ips = ipv6;
|
||||
}
|
||||
|
||||
|
||||
if (ips) {
|
||||
var regex = new RegExp(ips, "ig");
|
||||
|
||||
|
||||
if (removeLocal) {
|
||||
var ten = "10\\..+",
|
||||
oneninetwo = "192\\.168\\..+",
|
||||
|
@ -117,7 +117,7 @@ var Extract = {
|
|||
onetwoseven = "127\\..+",
|
||||
removeRegex = new RegExp("^(?:" + ten + "|" + oneninetwo +
|
||||
"|" + oneseventwo + "|" + onetwoseven + ")");
|
||||
|
||||
|
||||
return Extract._search(input, regex, removeRegex, displayTotal);
|
||||
} else {
|
||||
return Extract._search(input, regex, null, displayTotal);
|
||||
|
@ -126,8 +126,8 @@ var Extract = {
|
|||
return "";
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Extract email addresses operation.
|
||||
*
|
||||
|
@ -138,11 +138,11 @@ var Extract = {
|
|||
runEmail: function(input, args) {
|
||||
var displayTotal = args[0],
|
||||
regex = /\w[-.\w]*@[-\w]+(?:\.[-\w]+)*\.[A-Z]{2,4}/ig;
|
||||
|
||||
|
||||
return Extract._search(input, regex, null, displayTotal);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Extract MAC addresses operation.
|
||||
*
|
||||
|
@ -153,11 +153,11 @@ var Extract = {
|
|||
runMac: function(input, args) {
|
||||
var displayTotal = args[0],
|
||||
regex = /[A-F\d]{2}(?:[:-][A-F\d]{2}){5}/ig;
|
||||
|
||||
|
||||
return Extract._search(input, regex, null, displayTotal);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Extract URLs operation.
|
||||
*
|
||||
|
@ -171,14 +171,14 @@ var Extract = {
|
|||
hostname = "[-\\w]+(?:\\.\\w[-\\w]*)+",
|
||||
port = ":\\d+",
|
||||
path = "/[^.!,?;\"'<>()\\[\\]{}\\s\\x7F-\\xFF]*";
|
||||
|
||||
|
||||
path += "(?:[.!,?]+[^.!,?;\"'<>()\\[\\]{}\\s\\x7F-\\xFF]+)*";
|
||||
var regex = new RegExp(protocol + hostname + "(?:" + port +
|
||||
")?(?:" + path + ")?", "ig");
|
||||
return Extract._search(input, regex, null, displayTotal);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Extract domains operation.
|
||||
*
|
||||
|
@ -192,11 +192,11 @@ var Extract = {
|
|||
hostname = "[-\\w\\.]+",
|
||||
tld = "\\.(?:com|net|org|biz|info|co|uk|onion|int|mobi|name|edu|gov|mil|eu|ac|ae|af|de|ca|ch|cn|cy|es|gb|hk|il|in|io|tv|me|nl|no|nz|ro|ru|tr|us|az|ir|kz|uz|pk)+",
|
||||
regex = new RegExp("(?:" + protocol + ")?" + hostname + tld, "ig");
|
||||
|
||||
|
||||
return Extract._search(input, regex, null, displayTotal);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -207,7 +207,7 @@ var Extract = {
|
|||
* @default
|
||||
*/
|
||||
INCLUDE_UNIX_PATH: true,
|
||||
|
||||
|
||||
/**
|
||||
* Extract file paths operation.
|
||||
*
|
||||
|
@ -226,7 +226,7 @@ var Extract = {
|
|||
"(?:\\." + winExt + ")?",
|
||||
unixPath = "(?:/[A-Z\\d.][A-Z\\d\\-.]{0,61})+",
|
||||
filePaths = "";
|
||||
|
||||
|
||||
if (includeWinPath && includeUnixPath) {
|
||||
filePaths = winPath + "|" + unixPath;
|
||||
} else if (includeWinPath) {
|
||||
|
@ -234,7 +234,7 @@ var Extract = {
|
|||
} else if (includeUnixPath) {
|
||||
filePaths = unixPath;
|
||||
}
|
||||
|
||||
|
||||
if (filePaths) {
|
||||
var regex = new RegExp(filePaths, "ig");
|
||||
return Extract._search(input, regex, null, displayTotal);
|
||||
|
@ -242,8 +242,8 @@ var Extract = {
|
|||
return "";
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Extract dates operation.
|
||||
*
|
||||
|
@ -257,11 +257,11 @@ var Extract = {
|
|||
date2 = "(?:0[1-9]|[12][0-9]|3[01])[- /.](?:0[1-9]|1[012])[- /.](?:19|20)\\d\\d", // dd/mm/yyyy
|
||||
date3 = "(?:0[1-9]|1[012])[- /.](?:0[1-9]|[12][0-9]|3[01])[- /.](?:19|20)\\d\\d", // mm/dd/yyyy
|
||||
regex = new RegExp(date1 + "|" + date2 + "|" + date3, "ig");
|
||||
|
||||
|
||||
return Extract._search(input, regex, null, displayTotal);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Extract all identifiers operation.
|
||||
*
|
||||
|
@ -273,22 +273,22 @@ var Extract = {
|
|||
var output = "";
|
||||
output += "IP addresses\n";
|
||||
output += Extract.runIp(input, [true, true, false]);
|
||||
|
||||
|
||||
output += "\nEmail addresses\n";
|
||||
output += Extract.runEmail(input, []);
|
||||
|
||||
|
||||
output += "\nMAC addresses\n";
|
||||
output += Extract.runMac(input, []);
|
||||
|
||||
|
||||
output += "\nURLs\n";
|
||||
output += Extract.runUrls(input, []);
|
||||
|
||||
|
||||
output += "\nDomain names\n";
|
||||
output += Extract.runDomains(input, []);
|
||||
|
||||
|
||||
output += "\nFile paths\n";
|
||||
output += Extract.runFilePaths(input, [true, true]);
|
||||
|
||||
|
||||
output += "\nDates\n";
|
||||
output += Extract.runDates(input, []);
|
||||
return output;
|
||||
|
|
|
@ -243,7 +243,6 @@ var HTML = {
|
|||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Converts an HSL color value to RGB. Conversion formula
|
||||
* adapted from http://en.wikipedia.org/wiki/HSL_colorSpace.
|
||||
|
@ -309,7 +308,7 @@ var HTML = {
|
|||
} else {
|
||||
var d = max - min;
|
||||
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
||||
switch(max) {
|
||||
switch (max) {
|
||||
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
|
||||
case g: h = (b - r) / d + 2; break;
|
||||
case b: h = (r - g) / d + 4; break;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* @namespace
|
||||
*/
|
||||
var HTTP = {
|
||||
|
||||
|
||||
/**
|
||||
* Strip HTTP headers operation.
|
||||
*
|
||||
|
@ -21,11 +21,11 @@ var HTTP = {
|
|||
runStripHeaders: function(input, args) {
|
||||
var headerEnd = input.indexOf("\r\n\r\n") +
|
||||
(headerEnd < 0) ? input.indexOf("\n\n") + 2 : headerEnd + 4;
|
||||
|
||||
|
||||
return (headerEnd < 2) ? input : input.slice(headerEnd, input.length);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parse User Agent operation.
|
||||
*
|
||||
|
@ -35,7 +35,7 @@ var HTTP = {
|
|||
*/
|
||||
runParseUserAgent: function(input, args) {
|
||||
var ua = UAS_parser.parse(input); // eslint-disable-line camelcase
|
||||
|
||||
|
||||
return "Type: " + ua.type + "\n" +
|
||||
"Family: " + ua.uaFamily + "\n" +
|
||||
"Name: " + ua.uaName + "\n" +
|
||||
|
|
|
@ -34,7 +34,7 @@ var Hash = {
|
|||
return Utils.toHexFast(CryptoApi.hash("md4", input, {}));
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* MD5 operation.
|
||||
*
|
||||
|
@ -58,8 +58,8 @@ var Hash = {
|
|||
runSHA0: function (input, args) {
|
||||
return Utils.toHexFast(CryptoApi.hash("sha0", input, {}));
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* SHA1 operation.
|
||||
*
|
||||
|
@ -72,7 +72,7 @@ var Hash = {
|
|||
return CryptoJS.SHA1(input).toString(CryptoJS.enc.Hex);
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* SHA224 operation.
|
||||
*
|
||||
|
@ -84,8 +84,8 @@ var Hash = {
|
|||
input = CryptoJS.enc.Latin1.parse(input);
|
||||
return CryptoJS.SHA224(input).toString(CryptoJS.enc.Hex);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* SHA256 operation.
|
||||
*
|
||||
|
@ -97,8 +97,8 @@ var Hash = {
|
|||
input = CryptoJS.enc.Latin1.parse(input);
|
||||
return CryptoJS.SHA256(input).toString(CryptoJS.enc.Hex);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* SHA384 operation.
|
||||
*
|
||||
|
@ -110,8 +110,8 @@ var Hash = {
|
|||
input = CryptoJS.enc.Latin1.parse(input);
|
||||
return CryptoJS.SHA384(input).toString(CryptoJS.enc.Hex);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* SHA512 operation.
|
||||
*
|
||||
|
@ -123,14 +123,14 @@ var Hash = {
|
|||
input = CryptoJS.enc.Latin1.parse(input);
|
||||
return CryptoJS.SHA512(input).toString(CryptoJS.enc.Hex);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
SHA3_LENGTH: ["512", "384", "256", "224"],
|
||||
|
||||
|
||||
/**
|
||||
* SHA3 operation.
|
||||
*
|
||||
|
@ -146,8 +146,8 @@ var Hash = {
|
|||
};
|
||||
return CryptoJS.SHA3(input, options).toString(CryptoJS.enc.Hex);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* RIPEMD-160 operation.
|
||||
*
|
||||
|
@ -160,13 +160,13 @@ var Hash = {
|
|||
return CryptoJS.RIPEMD160(input).toString(CryptoJS.enc.Hex);
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
HMAC_FUNCTIONS: ["MD5", "SHA1", "SHA224", "SHA256", "SHA384", "SHA512", "SHA3", "RIPEMD-160"],
|
||||
|
||||
|
||||
/**
|
||||
* HMAC operation.
|
||||
*
|
||||
|
@ -189,8 +189,8 @@ var Hash = {
|
|||
};
|
||||
return execute[hashFunc].toString(CryptoJS.enc.Hex);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generate all hashes operation.
|
||||
*
|
||||
|
@ -221,11 +221,11 @@ var Hash = {
|
|||
"\nFletcher-64: " + Checksum.runFletcher64(byteArray, []) +
|
||||
"\nAdler-32: " + Checksum.runAdler32(byteArray, []) +
|
||||
"\nCRC-32: " + Checksum.runCRC32(byteArray, []);
|
||||
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Analyse hash operation.
|
||||
*
|
||||
|
@ -235,21 +235,21 @@ var Hash = {
|
|||
*/
|
||||
runAnalyse: function(input, args) {
|
||||
input = input.replace(/\s/g, "");
|
||||
|
||||
|
||||
var output = "",
|
||||
byteLength = input.length / 2,
|
||||
bitLength = byteLength * 8,
|
||||
possibleHashFunctions = [];
|
||||
|
||||
|
||||
if (!/^[a-f0-9]+$/i.test(input)) {
|
||||
return "Invalid hash";
|
||||
}
|
||||
|
||||
|
||||
output += "Hash length: " + input.length + "\n" +
|
||||
"Byte length: " + byteLength + "\n" +
|
||||
"Bit length: " + bitLength + "\n\n" +
|
||||
"Based on the length, this hash could have been generated by one of the following hashing functions:\n";
|
||||
|
||||
|
||||
switch (bitLength) {
|
||||
case 4:
|
||||
possibleHashFunctions = [
|
||||
|
@ -376,8 +376,8 @@ var Hash = {
|
|||
];
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return output + possibleHashFunctions.join("\n");
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -26,7 +26,7 @@ var Hexdump = {
|
|||
* @default
|
||||
*/
|
||||
INCLUDE_FINAL_LENGTH: false,
|
||||
|
||||
|
||||
/**
|
||||
* To Hexdump operation.
|
||||
*
|
||||
|
@ -38,7 +38,7 @@ var Hexdump = {
|
|||
var length = args[0] || Hexdump.WIDTH;
|
||||
var upperCase = args[1];
|
||||
var includeFinalLength = args[2];
|
||||
|
||||
|
||||
var output = "", padding = 2;
|
||||
for (var i = 0; i < input.length; i += length) {
|
||||
var buff = input.slice(i, i+length);
|
||||
|
@ -46,27 +46,27 @@ var Hexdump = {
|
|||
for (var j = 0; j < buff.length; j++) {
|
||||
hexa += Utils.hex(buff[j], padding) + " ";
|
||||
}
|
||||
|
||||
|
||||
var lineNo = Utils.hex(i, 8);
|
||||
|
||||
|
||||
if (upperCase) {
|
||||
hexa = hexa.toUpperCase();
|
||||
lineNo = lineNo.toUpperCase();
|
||||
}
|
||||
|
||||
|
||||
output += lineNo + " " +
|
||||
Utils.padRight(hexa, (length*(padding+1))) +
|
||||
" |" + Utils.padRight(Utils.printable(Utils.byteArrayToChars(buff)), buff.length) + "|\n";
|
||||
|
||||
|
||||
if (includeFinalLength && i+buff.length === input.length) {
|
||||
output += Utils.hex(i+buff.length, 8) + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return output.slice(0, -1);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* From Hexdump operation.
|
||||
*
|
||||
|
@ -78,7 +78,7 @@ var Hexdump = {
|
|||
var output = [],
|
||||
regex = /^\s*(?:[\dA-F]{4,16}:?)?\s*((?:[\dA-F]{2}\s){1,8}(?:\s|[\dA-F]{2}-)(?:[\dA-F]{2}\s){1,8}|(?:[\dA-F]{2}\s|[\dA-F]{4}\s)+)/igm,
|
||||
block, line;
|
||||
|
||||
|
||||
while ((block = regex.exec(input))) {
|
||||
line = Utils.fromHex(block[1].replace(/-/g, " "));
|
||||
for (var i = 0; i < line.length; i++) {
|
||||
|
@ -94,8 +94,8 @@ var Hexdump = {
|
|||
}
|
||||
return output;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Highlight to hexdump
|
||||
*
|
||||
|
@ -113,9 +113,9 @@ var Hexdump = {
|
|||
offset = pos[0].start % w,
|
||||
start = 0,
|
||||
end = 0;
|
||||
|
||||
|
||||
pos[0].start = line*width + 10 + offset*3;
|
||||
|
||||
|
||||
line = Math.floor(pos[0].end / w);
|
||||
offset = pos[0].end % w;
|
||||
if (offset === 0) {
|
||||
|
@ -123,11 +123,11 @@ var Hexdump = {
|
|||
offset = w;
|
||||
}
|
||||
pos[0].end = line*width + 10 + offset*3 - 1;
|
||||
|
||||
|
||||
// Set up multiple selections for bytes
|
||||
var startLineNum = Math.floor(pos[0].start / width);
|
||||
var endLineNum = Math.floor(pos[0].end / width);
|
||||
|
||||
|
||||
if (startLineNum === endLineNum) {
|
||||
pos.push(pos[0]);
|
||||
} else {
|
||||
|
@ -142,7 +142,7 @@ var Hexdump = {
|
|||
pos.push({ start: start, end: end });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set up multiple selections for ASCII
|
||||
var len = pos.length, lineNum = 0;
|
||||
start = 0;
|
||||
|
@ -155,8 +155,8 @@ var Hexdump = {
|
|||
}
|
||||
return pos;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Highlight from hexdump
|
||||
*
|
||||
|
@ -169,10 +169,10 @@ var Hexdump = {
|
|||
highlightFrom: function(pos, args) {
|
||||
var w = args[0] || 16;
|
||||
var width = 14 + (w*4);
|
||||
|
||||
|
||||
var line = Math.floor(pos[0].start / width);
|
||||
var offset = pos[0].start % width;
|
||||
|
||||
|
||||
if (offset < 10) { // In line number section
|
||||
pos[0].start = line*w;
|
||||
} else if (offset > 10+(w*3)) { // In ASCII section
|
||||
|
@ -180,10 +180,10 @@ var Hexdump = {
|
|||
} else { // In byte section
|
||||
pos[0].start = line*w + Math.floor((offset-10)/3);
|
||||
}
|
||||
|
||||
|
||||
line = Math.floor(pos[0].end / width);
|
||||
offset = pos[0].end % width;
|
||||
|
||||
|
||||
if (offset < 10) { // In line number section
|
||||
pos[0].end = line*w;
|
||||
} else if (offset > 10+(w*3)) { // In ASCII section
|
||||
|
@ -191,8 +191,8 @@ var Hexdump = {
|
|||
} else { // In byte section
|
||||
pos[0].end = line*w + Math.ceil((offset-10)/3);
|
||||
}
|
||||
|
||||
|
||||
return pos;
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -26,7 +26,7 @@ var IP = {
|
|||
* @default
|
||||
*/
|
||||
ALLOW_LARGE_LIST: false,
|
||||
|
||||
|
||||
/**
|
||||
* Parse IP range operation.
|
||||
*
|
||||
|
@ -38,14 +38,14 @@ var IP = {
|
|||
var includeNetworkInfo = args[0],
|
||||
enumerateAddresses = args[1],
|
||||
allowLargeList = args[2];
|
||||
|
||||
|
||||
// Check what type of input we are looking at
|
||||
var ipv4CidrRegex = /^\s*((?:\d{1,3}\.){3}\d{1,3})\/(\d\d?)\s*$/,
|
||||
ipv4RangeRegex = /^\s*((?:\d{1,3}\.){3}\d{1,3})\s*-\s*((?:\d{1,3}\.){3}\d{1,3})\s*$/,
|
||||
ipv6CidrRegex = /^\s*(((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\4)::|:\b|(?![\dA-F])))|(?!\3\4)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4}))\/(\d\d?\d?)\s*$/i,
|
||||
ipv6RangeRegex = /^\s*(((?=.*::)(?!.*::[^-]+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\4)::|:\b|(?![\dA-F])))|(?!\3\4)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4}))\s*-\s*(((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\17)::|:\b|(?![\dA-F])))|(?!\16\17)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4}))\s*$/i,
|
||||
match;
|
||||
|
||||
|
||||
if ((match = ipv4CidrRegex.exec(input))) {
|
||||
return IP._ipv4CidrRange(match, includeNetworkInfo, enumerateAddresses, allowLargeList);
|
||||
} else if ((match = ipv4RangeRegex.exec(input))) {
|
||||
|
@ -58,8 +58,8 @@ var IP = {
|
|||
return "Invalid input.\n\nEnter either a CIDR range (e.g. 10.0.0.0/24) or a hyphenated range (e.g. 10.0.0.0 - 10.0.1.0). IPv6 also supported.";
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -70,7 +70,7 @@ var IP = {
|
|||
* @default
|
||||
*/
|
||||
IPV6_REGEX: /^\s*(((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\4)::|:\b|(?![\dA-F])))|(?!\3\4)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4}))\s*$/i,
|
||||
|
||||
|
||||
/**
|
||||
* Parse IPv6 address operation.
|
||||
*
|
||||
|
@ -81,14 +81,14 @@ var IP = {
|
|||
runParseIpv6: function (input, args) {
|
||||
var match,
|
||||
output = "";
|
||||
|
||||
|
||||
if ((match = IP.IPV6_REGEX.exec(input))) {
|
||||
var ipv6 = IP._strToIpv6(match[1]),
|
||||
longhand = IP._ipv6ToStr(ipv6),
|
||||
shorthand = IP._ipv6ToStr(ipv6, true);
|
||||
|
||||
|
||||
output += "Longhand: " + longhand + "\nShorthand: " + shorthand + "\n";
|
||||
|
||||
|
||||
// Detect reserved addresses
|
||||
if (shorthand === "::") {
|
||||
// Unspecified address
|
||||
|
@ -131,34 +131,34 @@ var IP = {
|
|||
flagRandom1 = (ipv6[4] >>> 10) & 15,
|
||||
flagUg = (ipv6[4] >>> 8) & 3,
|
||||
flagRandom2 = ipv6[4] & 255;
|
||||
|
||||
|
||||
output += "\nServer IPv4 address: " + IP._ipv4ToStr(serverIpv4) +
|
||||
"\nClient IPv4 address: " + IP._ipv4ToStr(clientIpv4) +
|
||||
"\nClient UDP port: " + udpPort +
|
||||
"\nFlags:" +
|
||||
"\n\tCone: " + flagCone;
|
||||
|
||||
|
||||
if (flagCone) {
|
||||
output += " (Client is behind a cone NAT)";
|
||||
} else {
|
||||
output += " (Client is not behind a cone NAT)";
|
||||
}
|
||||
|
||||
|
||||
output += "\n\tR: " + flagR;
|
||||
|
||||
|
||||
if (flagR) {
|
||||
output += " Error: This flag should be set to 0. See RFC 5991 and RFC 4380.";
|
||||
}
|
||||
|
||||
|
||||
output += "\n\tRandom1: " + Utils.bin(flagRandom1, 4) +
|
||||
"\n\tUG: " + Utils.bin(flagUg, 2);
|
||||
|
||||
|
||||
if (flagUg) {
|
||||
output += " Error: This flag should be set to 00. See RFC 4380.";
|
||||
}
|
||||
|
||||
|
||||
output += "\n\tRandom2: " + Utils.bin(flagRandom2, 8);
|
||||
|
||||
|
||||
if (!flagR && !flagUg && flagRandom1 && flagRandom2) {
|
||||
output += "\n\nThis is a valid Teredo address which complies with RFC 4380 and RFC 5991.";
|
||||
} else if (!flagR && !flagUg) {
|
||||
|
@ -186,12 +186,12 @@ var IP = {
|
|||
// 6to4
|
||||
output += "\n6to4 transition IPv6 address detected. See RFC 3056 for more details." +
|
||||
"\n6to4 prefix range: 2002::/16";
|
||||
|
||||
|
||||
var v4Addr = IP._ipv4ToStr((ipv6[1] << 16) + ipv6[2]),
|
||||
slaId = ipv6[3],
|
||||
interfaceIdStr = ipv6[4].toString(16) + ipv6[5].toString(16) + ipv6[6].toString(16) + ipv6[7].toString(16),
|
||||
interfaceId = new BigInteger(interfaceIdStr, 16);
|
||||
|
||||
|
||||
output += "\n\nEncapsulated IPv4 address: " + v4Addr +
|
||||
"\nSLA ID: " + slaId +
|
||||
"\nInterface ID (base 16): " + interfaceIdStr +
|
||||
|
@ -214,14 +214,14 @@ var IP = {
|
|||
}
|
||||
return output;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
IP_FORMAT_LIST: ["Dotted Decimal", "Decimal", "Hex"],
|
||||
|
||||
|
||||
/**
|
||||
* Change IP format operation.
|
||||
*
|
||||
|
@ -235,17 +235,17 @@ var IP = {
|
|||
lines = input.split("\n"),
|
||||
output = "",
|
||||
j = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
if (lines[i] === "") continue;
|
||||
var baIp = [];
|
||||
|
||||
|
||||
if (inFormat === outFormat) {
|
||||
output += lines[i] + "\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Convert to byte array IP from input format
|
||||
switch (inFormat) {
|
||||
case "Dotted Decimal":
|
||||
|
@ -267,7 +267,7 @@ var IP = {
|
|||
default:
|
||||
throw "Unsupported input IP format";
|
||||
}
|
||||
|
||||
|
||||
// Convert byte array IP to output format
|
||||
switch (outFormat) {
|
||||
case "Dotted Decimal":
|
||||
|
@ -292,11 +292,11 @@ var IP = {
|
|||
throw "Unsupported output IP format";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return output.slice(0, output.length-1);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -312,7 +312,7 @@ var IP = {
|
|||
* @default
|
||||
*/
|
||||
GROUP_ONLY_SUBNET: false,
|
||||
|
||||
|
||||
/**
|
||||
* Group IP addresses operation.
|
||||
*
|
||||
|
@ -334,17 +334,17 @@ var IP = {
|
|||
ip = null,
|
||||
network = null,
|
||||
networkStr = "";
|
||||
|
||||
|
||||
if (cidr < 0 || cidr > 127) {
|
||||
return "CIDR must be less than 32 for IPv4 or 128 for IPv6";
|
||||
}
|
||||
|
||||
|
||||
// Parse all IPs and add to network dictionary
|
||||
for (var i = 0; i < ips.length; i++) {
|
||||
if ((match = IP.IPV4_REGEX.exec(ips[i]))) {
|
||||
ip = IP._strToIpv4(match[1]) >>> 0;
|
||||
network = ip & ipv4Mask;
|
||||
|
||||
|
||||
if (ipv4Networks.hasOwnProperty(network)) {
|
||||
ipv4Networks[network].push(ip);
|
||||
} else {
|
||||
|
@ -354,13 +354,13 @@ var IP = {
|
|||
ip = IP._strToIpv6(match[1]);
|
||||
network = [];
|
||||
networkStr = "";
|
||||
|
||||
|
||||
for (var j = 0; j < 8; j++) {
|
||||
network.push(ip[j] & ipv6Mask[j]);
|
||||
}
|
||||
|
||||
|
||||
networkStr = IP._ipv6ToStr(network, true);
|
||||
|
||||
|
||||
if (ipv6Networks.hasOwnProperty(networkStr)) {
|
||||
ipv6Networks[networkStr].push(ip);
|
||||
} else {
|
||||
|
@ -368,13 +368,13 @@ var IP = {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Sort IPv4 network dictionaries and print
|
||||
for (network in ipv4Networks) {
|
||||
ipv4Networks[network] = ipv4Networks[network].sort();
|
||||
|
||||
|
||||
output += IP._ipv4ToStr(network) + "/" + cidr + "\n";
|
||||
|
||||
|
||||
if (!onlySubnets) {
|
||||
for (i = 0; i < ipv4Networks[network].length; i++) {
|
||||
output += " " + IP._ipv4ToStr(ipv4Networks[network][i]) + "\n";
|
||||
|
@ -382,13 +382,13 @@ var IP = {
|
|||
output += "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Sort IPv6 network dictionaries and print
|
||||
for (networkStr in ipv6Networks) {
|
||||
//ipv6Networks[networkStr] = ipv6Networks[networkStr].sort(); TODO
|
||||
|
||||
|
||||
output += networkStr + "/" + cidr + "\n";
|
||||
|
||||
|
||||
if (!onlySubnets) {
|
||||
for (i = 0; i < ipv6Networks[networkStr].length; i++) {
|
||||
output += " " + IP._ipv6ToStr(ipv6Networks[networkStr][i], true) + "\n";
|
||||
|
@ -399,15 +399,15 @@ var IP = {
|
|||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
* @private
|
||||
*/
|
||||
_LARGE_RANGE_ERROR: "The specified range contains more than 65,536 addresses. Running this query could crash your browser. If you want to run it, select the \"Allow large queries\" option. You are advised to turn off \"Auto Bake\" whilst editing large ranges.",
|
||||
|
||||
|
||||
/**
|
||||
* Parses an IPv4 CIDR range (e.g. 192.168.0.0/24) and displays information about it.
|
||||
*
|
||||
|
@ -422,15 +422,15 @@ var IP = {
|
|||
var output = "",
|
||||
network = IP._strToIpv4(cidr[1]),
|
||||
cidrRange = parseInt(cidr[2], 10);
|
||||
|
||||
|
||||
if (cidrRange < 0 || cidrRange > 31) {
|
||||
return "IPv4 CIDR must be less than 32";
|
||||
}
|
||||
|
||||
|
||||
var mask = ~(0xFFFFFFFF >>> cidrRange),
|
||||
ip1 = network & mask,
|
||||
ip2 = ip1 | ~mask;
|
||||
|
||||
|
||||
if (includeNetworkInfo) {
|
||||
output += "Network: " + IP._ipv4ToStr(network) + "\n";
|
||||
output += "CIDR: " + cidrRange + "\n";
|
||||
|
@ -438,7 +438,7 @@ var IP = {
|
|||
output += "Range: " + IP._ipv4ToStr(ip1) + " - " + IP._ipv4ToStr(ip2) + "\n";
|
||||
output += "Total addresses in range: " + (((ip2 - ip1) >>> 0) + 1) + "\n\n";
|
||||
}
|
||||
|
||||
|
||||
if (enumerateAddresses) {
|
||||
if (cidrRange >= 16 || allowLargeList) {
|
||||
output += IP._generateIpv4Range(ip1, ip2).join("\n");
|
||||
|
@ -448,8 +448,8 @@ var IP = {
|
|||
}
|
||||
return output;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parses an IPv6 CIDR range (e.g. ff00::/48) and displays information about it.
|
||||
*
|
||||
|
@ -462,22 +462,22 @@ var IP = {
|
|||
var output = "",
|
||||
network = IP._strToIpv6(cidr[1]),
|
||||
cidrRange = parseInt(cidr[cidr.length-1], 10);
|
||||
|
||||
|
||||
if (cidrRange < 0 || cidrRange > 127) {
|
||||
return "IPv6 CIDR must be less than 128";
|
||||
}
|
||||
|
||||
|
||||
var mask = IP._genIpv6Mask(cidrRange),
|
||||
ip1 = new Array(8),
|
||||
ip2 = new Array(8),
|
||||
totalDiff = "",
|
||||
total = new Array(128);
|
||||
|
||||
|
||||
for (var i = 0; i < 8; i++) {
|
||||
ip1[i] = network[i] & mask[i];
|
||||
ip2[i] = ip1[i] | (~mask[i] & 0x0000FFFF);
|
||||
totalDiff = (ip2[i] - ip1[i]).toString(2);
|
||||
|
||||
|
||||
if (totalDiff !== "0") {
|
||||
for (var n = 0; n < totalDiff.length; n++) {
|
||||
total[i*16 + 16-(totalDiff.length-n)] = totalDiff[n];
|
||||
|
@ -493,11 +493,11 @@ var IP = {
|
|||
output += "Range: " + IP._ipv6ToStr(ip1) + " - " + IP._ipv6ToStr(ip2) + "\n";
|
||||
output += "Total addresses in range: " + (parseInt(total.join(""), 2) + 1) + "\n\n";
|
||||
}
|
||||
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generates an IPv6 subnet mask given a CIDR value.
|
||||
*
|
||||
|
@ -508,7 +508,7 @@ var IP = {
|
|||
_genIpv6Mask: function(cidr) {
|
||||
var mask = new Array(8),
|
||||
shift;
|
||||
|
||||
|
||||
for (var i = 0; i < 8; i++) {
|
||||
if (cidr > ((i+1)*16)) {
|
||||
mask[i] = 0x0000FFFF;
|
||||
|
@ -518,11 +518,11 @@ var IP = {
|
|||
mask[i] = ~((0x0000FFFF >>> shift) | 0xFFFF0000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return mask;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parses an IPv4 hyphenated range (e.g. 192.168.0.0 - 192.168.0.255) and displays information
|
||||
* about it.
|
||||
|
@ -538,23 +538,23 @@ var IP = {
|
|||
var output = "",
|
||||
ip1 = IP._strToIpv4(range[1]),
|
||||
ip2 = IP._strToIpv4(range[2]);
|
||||
|
||||
|
||||
// Calculate mask
|
||||
var diff = ip1 ^ ip2,
|
||||
cidr = 32,
|
||||
mask = 0;
|
||||
|
||||
|
||||
while (diff !== 0) {
|
||||
diff >>= 1;
|
||||
cidr--;
|
||||
mask = (mask << 1) | 1;
|
||||
}
|
||||
|
||||
|
||||
mask = ~mask >>> 0;
|
||||
var network = ip1 & mask,
|
||||
subIp1 = network & mask,
|
||||
subIp2 = subIp1 | ~mask;
|
||||
|
||||
|
||||
if (includeNetworkInfo) {
|
||||
output += "Minimum subnet required to hold this range:\n";
|
||||
output += "\tNetwork: " + IP._ipv4ToStr(network) + "\n";
|
||||
|
@ -565,7 +565,7 @@ var IP = {
|
|||
output += "Range: " + IP._ipv4ToStr(ip1) + " - " + IP._ipv4ToStr(ip2) + "\n";
|
||||
output += "Total addresses in range: " + (((ip2 - ip1) >>> 0) + 1) + "\n\n";
|
||||
}
|
||||
|
||||
|
||||
if (enumerateAddresses) {
|
||||
if (((ip2 - ip1) >>> 0) <= 65536 || allowLargeList) {
|
||||
output += IP._generateIpv4Range(ip1, ip2).join("\n");
|
||||
|
@ -575,8 +575,8 @@ var IP = {
|
|||
}
|
||||
return output;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parses an IPv6 hyphenated range (e.g. ff00:: - ffff::) and displays information about it.
|
||||
*
|
||||
|
@ -589,14 +589,14 @@ var IP = {
|
|||
var output = "",
|
||||
ip1 = IP._strToIpv6(range[1]),
|
||||
ip2 = IP._strToIpv6(range[14]);
|
||||
|
||||
|
||||
var t = "",
|
||||
total = new Array(128);
|
||||
|
||||
|
||||
// Initialise total array to "0"
|
||||
for (var i = 0; i < 128; i++)
|
||||
total[i] = "0";
|
||||
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
t = (ip2[i] - ip1[i]).toString(2);
|
||||
if (t !== "0") {
|
||||
|
@ -605,17 +605,17 @@ var IP = {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (includeNetworkInfo) {
|
||||
output += "Range: " + IP._ipv6ToStr(ip1) + " - " + IP._ipv6ToStr(ip2) + "\n";
|
||||
output += "Shorthand range: " + IP._ipv6ToStr(ip1, true) + " - " + IP._ipv6ToStr(ip2, true) + "\n";
|
||||
output += "Total addresses in range: " + (parseInt(total.join(""), 2) + 1) + "\n\n";
|
||||
}
|
||||
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Converts an IPv4 address from string format to numerical format.
|
||||
*
|
||||
|
@ -631,21 +631,21 @@ var IP = {
|
|||
var blocks = ipStr.split("."),
|
||||
numBlocks = parseBlocks(blocks),
|
||||
result = 0;
|
||||
|
||||
|
||||
result += numBlocks[0] << 24;
|
||||
result += numBlocks[1] << 16;
|
||||
result += numBlocks[2] << 8;
|
||||
result += numBlocks[3];
|
||||
|
||||
|
||||
return result;
|
||||
|
||||
|
||||
/**
|
||||
* Converts a list of 4 numeric strings in the range 0-255 to a list of numbers.
|
||||
*/
|
||||
function parseBlocks(blocks) {
|
||||
if (blocks.length !== 4)
|
||||
throw "More than 4 blocks.";
|
||||
|
||||
|
||||
var numBlocks = [];
|
||||
for (var i = 0; i < 4; i++) {
|
||||
numBlocks[i] = parseInt(blocks[i], 10);
|
||||
|
@ -655,8 +655,8 @@ var IP = {
|
|||
return numBlocks;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Converts an IPv4 address from numerical format to string format.
|
||||
*
|
||||
|
@ -673,11 +673,11 @@ var IP = {
|
|||
blockB = (ipInt >> 16) & 255,
|
||||
blockC = (ipInt >> 8) & 255,
|
||||
blockD = ipInt & 255;
|
||||
|
||||
|
||||
return blockA + "." + blockB + "." + blockC + "." + blockD;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Converts an IPv6 address from string format to numerical array format.
|
||||
*
|
||||
|
@ -694,7 +694,7 @@ var IP = {
|
|||
numBlocks = parseBlocks(blocks),
|
||||
j = 0,
|
||||
ipv6 = new Array(8);
|
||||
|
||||
|
||||
for (var i = 0; i < 8; i++) {
|
||||
if (isNaN(numBlocks[j])) {
|
||||
ipv6[i] = 0;
|
||||
|
@ -705,7 +705,7 @@ var IP = {
|
|||
}
|
||||
}
|
||||
return ipv6;
|
||||
|
||||
|
||||
/**
|
||||
* Converts a list of 3-8 numeric hex strings in the range 0-65535 to a list of numbers.
|
||||
*/
|
||||
|
@ -721,8 +721,8 @@ var IP = {
|
|||
return numBlocks;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Converts an IPv6 address from numerical array format to string format.
|
||||
*
|
||||
|
@ -741,13 +741,13 @@ var IP = {
|
|||
_ipv6ToStr: function(ipv6, compact) {
|
||||
var output = "",
|
||||
i = 0;
|
||||
|
||||
|
||||
if (compact) {
|
||||
var start = -1,
|
||||
end = -1,
|
||||
s = 0,
|
||||
e = -1;
|
||||
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (ipv6[i] === 0 && e === (i-1)) {
|
||||
e = i;
|
||||
|
@ -759,7 +759,7 @@ var IP = {
|
|||
end = e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (i !== start) {
|
||||
output += Utils.hex(ipv6[i], 1) + ":";
|
||||
|
@ -778,8 +778,8 @@ var IP = {
|
|||
}
|
||||
return output.slice(0, output.length-1);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generates a list of IPv4 addresses in string format between two given numerical values.
|
||||
*
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* @namespace
|
||||
*/
|
||||
var JS = {
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -36,7 +36,7 @@ var JS = {
|
|||
* @default
|
||||
*/
|
||||
PARSE_TOLERANT: false,
|
||||
|
||||
|
||||
/**
|
||||
* JavaScript Parser operation.
|
||||
*
|
||||
|
@ -58,12 +58,12 @@ var JS = {
|
|||
comment: parseComment,
|
||||
tolerant: parseTolerant
|
||||
};
|
||||
|
||||
|
||||
result = esprima.parse(input, options);
|
||||
return JSON.stringify(result, null, 2);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -84,7 +84,7 @@ var JS = {
|
|||
* @default
|
||||
*/
|
||||
BEAUTIFY_COMMENT: true,
|
||||
|
||||
|
||||
/**
|
||||
* JavaScript Beautify operation.
|
||||
*
|
||||
|
@ -99,14 +99,14 @@ var JS = {
|
|||
beautifyComment = args[3],
|
||||
result = "",
|
||||
AST;
|
||||
|
||||
|
||||
try {
|
||||
AST = esprima.parse(input, {
|
||||
range: true,
|
||||
tokens: true,
|
||||
comment: true
|
||||
});
|
||||
|
||||
|
||||
var options = {
|
||||
format: {
|
||||
indent: {
|
||||
|
@ -117,19 +117,19 @@ var JS = {
|
|||
},
|
||||
comment: beautifyComment
|
||||
};
|
||||
|
||||
|
||||
if (options.comment)
|
||||
AST = escodegen.attachComments(AST, AST.comments, AST.tokens);
|
||||
|
||||
|
||||
result = escodegen.generate(AST, options);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
// Leave original error so the user can see the detail
|
||||
throw "Unable to parse JavaScript.<br>" + e.message;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* JavaScript Minify operation.
|
||||
*
|
||||
|
@ -142,7 +142,7 @@ var JS = {
|
|||
AST = esprima.parse(input),
|
||||
optimisedAST = esmangle.optimize(AST, null),
|
||||
mangledAST = esmangle.mangle(optimisedAST);
|
||||
|
||||
|
||||
result = escodegen.generate(mangledAST, {
|
||||
format: {
|
||||
renumber: true,
|
||||
|
|
|
@ -44,7 +44,7 @@ var MAC = {
|
|||
*/
|
||||
runFormat: function(input, args) {
|
||||
if (!input) return "";
|
||||
|
||||
|
||||
var outputCase = args[0],
|
||||
noDelim = args[1],
|
||||
dashDelim = args[2],
|
||||
|
@ -58,7 +58,7 @@ var MAC = {
|
|||
macHyphen = cleanMac.replace(/(.{2}(?=.))/g, "$1-"),
|
||||
macColon = cleanMac.replace(/(.{2}(?=.))/g, "$1:"),
|
||||
macCisco = cleanMac.replace(/(.{4}(?=.))/g, "$1.");
|
||||
|
||||
|
||||
if (outputCase === "Lower only") {
|
||||
if (noDelim) outputList.push(cleanMac);
|
||||
if (dashDelim) outputList.push(macHyphen);
|
||||
|
@ -75,7 +75,7 @@ var MAC = {
|
|||
if (colonDelim) outputList.push(macColon, macColon.toUpperCase());
|
||||
if (ciscoStyle) outputList.push(macCisco, macCisco.toUpperCase());
|
||||
}
|
||||
|
||||
|
||||
outputList.push(
|
||||
"" // Empty line to delimit groups
|
||||
);
|
||||
|
|
|
@ -89,7 +89,7 @@ var MorseCode = {
|
|||
words = Array.prototype.map.call(words, function(word) {
|
||||
var letters = Array.prototype.map.call(word, function(character) {
|
||||
var letter = character.toUpperCase();
|
||||
if(typeof MorseCode.MORSE_TABLE[letter] == "undefined") {
|
||||
if (typeof MorseCode.MORSE_TABLE[letter] == "undefined") {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ var MorseCode = {
|
|||
input = input.replace(
|
||||
/<dash>|<dot>|<ld>|<wd>/g,
|
||||
function(match) {
|
||||
switch(match) {
|
||||
switch (match) {
|
||||
case "<dash>": return dash;
|
||||
case "<dot>": return dot;
|
||||
case "<ld>": return letterDelim;
|
||||
|
@ -131,14 +131,14 @@ var MorseCode = {
|
|||
var reverseTable = function() {
|
||||
reversedTable = {};
|
||||
|
||||
for(var letter in MorseCode.MORSE_TABLE) {
|
||||
for (var letter in MorseCode.MORSE_TABLE) {
|
||||
var signal = MorseCode.MORSE_TABLE[letter];
|
||||
reversedTable[signal] = letter;
|
||||
}
|
||||
};
|
||||
|
||||
return function(input, args) {
|
||||
if(reversedTable === null) {
|
||||
if (reversedTable === null) {
|
||||
reverseTable();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,5 +23,5 @@ var Numberwang = {
|
|||
return "Sorry, that's not Numberwang. Let's rotate the board!";
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -10,13 +10,13 @@
|
|||
* @namespace
|
||||
*/
|
||||
var PublicKey = {
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
X509_INPUT_FORMAT: ["PEM", "DER Hex", "Base64", "Raw"],
|
||||
|
||||
|
||||
/**
|
||||
* Parse X.509 certificate operation.
|
||||
*
|
||||
|
@ -27,11 +27,11 @@ var PublicKey = {
|
|||
runParseX509: function (input, args) {
|
||||
var cert = new X509(),
|
||||
inputFormat = args[0];
|
||||
|
||||
|
||||
if (!input.length) {
|
||||
return "No input";
|
||||
}
|
||||
|
||||
|
||||
switch (inputFormat) {
|
||||
case "DER Hex":
|
||||
input = input.replace(/\s/g, "");
|
||||
|
@ -53,7 +53,7 @@ var PublicKey = {
|
|||
default:
|
||||
throw "Undefined input format";
|
||||
}
|
||||
|
||||
|
||||
var version = ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [0, 0, 0]),
|
||||
sn = cert.getSerialNumberHex(),
|
||||
algorithm = KJUR.asn1.x509.OID.oid2name(KJUR.asn1.ASN1Util.oidHexToInt(ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [0, 2, 0]))),
|
||||
|
@ -69,7 +69,7 @@ var PublicKey = {
|
|||
certSig = ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [2]).substr(2),
|
||||
sigStr = "",
|
||||
extensions = ASN1HEX.dump(ASN1HEX.getDecendantHexVByNthList(cert.hex, 0, [0, 7]));
|
||||
|
||||
|
||||
// Public Key fields
|
||||
if (pk.type === "EC") { // ECDSA
|
||||
pkFields.push({
|
||||
|
@ -120,7 +120,7 @@ var PublicKey = {
|
|||
value: "Unknown Public Key type"
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Signature fields
|
||||
if (ASN1HEX.dump(certSig).indexOf("SEQUENCE") === 0) { // DSA or ECDSA
|
||||
sigStr = " r: " + PublicKey._formatByteStr(ASN1HEX.getDecendantHexVByNthList(certSig, 0, [0]), 16, 18) + "\n" +
|
||||
|
@ -128,7 +128,7 @@ var PublicKey = {
|
|||
} else { // RSA
|
||||
sigStr = " Signature: " + PublicKey._formatByteStr(certSig, 16, 18) + "\n";
|
||||
}
|
||||
|
||||
|
||||
// Format Public Key fields
|
||||
for (var i = 0; i < pkFields.length; i++) {
|
||||
pkStr += " " + pkFields[i].key + ":" +
|
||||
|
@ -138,12 +138,12 @@ var PublicKey = {
|
|||
" "
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
var issuerStr = PublicKey._formatDnStr(issuer, 2),
|
||||
nbDate = PublicKey._formatDate(notBefore),
|
||||
naDate = PublicKey._formatDate(notAfter),
|
||||
subjectStr = PublicKey._formatDnStr(subject, 2);
|
||||
|
||||
|
||||
var output = "Version: " + (parseInt(version, 16) + 1) + " (0x" + version + ")\n" +
|
||||
"Serial number: " + new BigInteger(sn, 16).toString() + " (0x" + sn + ")\n" +
|
||||
"Algorithm ID: " + algorithm + "\n" +
|
||||
|
@ -162,11 +162,11 @@ var PublicKey = {
|
|||
sigStr +
|
||||
"\nExtensions (parsed ASN.1)\n" +
|
||||
extensions;
|
||||
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* PEM to Hex operation.
|
||||
*
|
||||
|
@ -185,14 +185,14 @@ var PublicKey = {
|
|||
}
|
||||
return KEYUTIL.getHexFromPEM(input);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
PEM_HEADER_STRING: "CERTIFICATE",
|
||||
|
||||
|
||||
/**
|
||||
* Hex to PEM operation.
|
||||
*
|
||||
|
@ -203,8 +203,8 @@ var PublicKey = {
|
|||
runHexToPem: function(input, args) {
|
||||
return KJUR.asn1.ASN1Util.getPEMStringFromHex(input.replace(/\s/g, ""), args[0]);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Hex to Object Identifier operation.
|
||||
*
|
||||
|
@ -215,8 +215,8 @@ var PublicKey = {
|
|||
runHexToObjectIdentifier: function(input, args) {
|
||||
return KJUR.asn1.ASN1Util.oidHexToInt(input.replace(/\s/g, ""));
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Object Identifier to Hex operation.
|
||||
*
|
||||
|
@ -227,14 +227,14 @@ var PublicKey = {
|
|||
runObjectIdentifierToHex: function(input, args) {
|
||||
return KJUR.asn1.ASN1Util.oidIntToHex(input);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
ASN1_TRUNCATE_LENGTH: 32,
|
||||
|
||||
|
||||
/**
|
||||
* Parse ASN.1 hex string operation.
|
||||
*
|
||||
|
@ -249,8 +249,8 @@ var PublicKey = {
|
|||
"ommitLongOctet": truncateLen
|
||||
}, index);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Formats Distinguished Name (DN) strings.
|
||||
*
|
||||
|
@ -266,29 +266,29 @@ var PublicKey = {
|
|||
key,
|
||||
value,
|
||||
str;
|
||||
|
||||
|
||||
for (var i = 0; i < fields.length; i++) {
|
||||
if (!fields[i].length) continue;
|
||||
|
||||
|
||||
key = fields[i].split("=")[0];
|
||||
|
||||
|
||||
maxKeyLen = key.length > maxKeyLen ? key.length : maxKeyLen;
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < fields.length; i++) {
|
||||
if (!fields[i].length) continue;
|
||||
|
||||
|
||||
key = fields[i].split("=")[0];
|
||||
value = fields[i].split("=")[1];
|
||||
str = Utils.padRight(key, maxKeyLen) + " = " + value + "\n";
|
||||
|
||||
|
||||
output += Utils.padLeft(str, indent + str.length, " ");
|
||||
}
|
||||
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Formats byte strings by adding line breaks and delimiters.
|
||||
*
|
||||
|
@ -302,7 +302,7 @@ var PublicKey = {
|
|||
byteStr = Utils.toHex(Utils.fromHex(byteStr), ":");
|
||||
length = length * 3;
|
||||
var output = "";
|
||||
|
||||
|
||||
for (var i = 0; i < byteStr.length; i += length) {
|
||||
var str = byteStr.slice(i, i + length) + "\n";
|
||||
if (i === 0) {
|
||||
|
@ -311,11 +311,11 @@ var PublicKey = {
|
|||
output += Utils.padLeft(str, indent + str.length, " ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return output.slice(0, output.length-1);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Formats dates.
|
||||
*
|
||||
|
@ -331,7 +331,7 @@ var PublicKey = {
|
|||
dateStr[8] + dateStr[9] + ":" +
|
||||
dateStr[10] + dateStr[11];
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ var Punycode = {
|
|||
* @default
|
||||
*/
|
||||
IDN: false,
|
||||
|
||||
|
||||
/**
|
||||
* To Punycode operation.
|
||||
*
|
||||
|
@ -26,15 +26,15 @@ var Punycode = {
|
|||
*/
|
||||
runToAscii: function(input, args) {
|
||||
var idn = args[0];
|
||||
|
||||
|
||||
if (idn) {
|
||||
return punycode.ToASCII(input);
|
||||
} else {
|
||||
return punycode.encode(input);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* From Punycode operation.
|
||||
*
|
||||
|
@ -44,12 +44,12 @@ var Punycode = {
|
|||
*/
|
||||
runToUnicode: function(input, args) {
|
||||
var idn = args[0];
|
||||
|
||||
|
||||
if (idn) {
|
||||
return punycode.ToUnicode(input);
|
||||
} else {
|
||||
return punycode.decode(input);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
========================================================================
|
||||
mimelib: http://github.com/andris9/mimelib
|
||||
Copyright (c) 2011-2012 Andris Reinman
|
||||
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
@ -31,7 +31,7 @@
|
|||
* @namespace
|
||||
*/
|
||||
var QuotedPrintable = {
|
||||
|
||||
|
||||
/**
|
||||
* To Quoted Printable operation.
|
||||
*
|
||||
|
@ -41,7 +41,7 @@ var QuotedPrintable = {
|
|||
*/
|
||||
runTo: function (input, args) {
|
||||
var mimeEncodedStr = QuotedPrintable.mimeEncode(input);
|
||||
|
||||
|
||||
// fix line breaks
|
||||
mimeEncodedStr = mimeEncodedStr.replace(/\r?\n|\r/g, function() {
|
||||
return "\r\n";
|
||||
|
@ -51,8 +51,8 @@ var QuotedPrintable = {
|
|||
|
||||
return QuotedPrintable._addSoftLinebreaks(mimeEncodedStr, "qp");
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* From Quoted Printable operation.
|
||||
*
|
||||
|
@ -64,8 +64,8 @@ var QuotedPrintable = {
|
|||
var str = input.replace(/\=(?:\r?\n|$)/g, "");
|
||||
return QuotedPrintable.mimeDecode(str);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Decodes mime-encoded data.
|
||||
*
|
||||
|
@ -91,8 +91,8 @@ var QuotedPrintable = {
|
|||
|
||||
return buffer;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Encodes mime data.
|
||||
*
|
||||
|
@ -123,8 +123,8 @@ var QuotedPrintable = {
|
|||
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Checks if a given number falls within a given set of ranges.
|
||||
*
|
||||
|
@ -145,7 +145,7 @@ var QuotedPrintable = {
|
|||
return false;
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds soft line breaks to a string.
|
||||
* Lines can't be longer that 76 + <CR><LF> = 78 bytes
|
||||
|
@ -168,7 +168,7 @@ var QuotedPrintable = {
|
|||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds soft line breaks to a base64 string.
|
||||
*
|
||||
|
@ -182,7 +182,7 @@ var QuotedPrintable = {
|
|||
return base64EncodedStr.replace(new RegExp(".{" + lineLengthMax + "}", "g"), "$&\r\n").trim();
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds soft line breaks to a quoted printable string.
|
||||
*
|
||||
|
@ -266,5 +266,5 @@ var QuotedPrintable = {
|
|||
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -21,7 +21,7 @@ var Rotate = {
|
|||
* @default
|
||||
*/
|
||||
ROTATE_WHOLE: false,
|
||||
|
||||
|
||||
/**
|
||||
* Runs rotation operations across the input data.
|
||||
*
|
||||
|
@ -42,8 +42,8 @@ var Rotate = {
|
|||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Rotate right operation.
|
||||
*
|
||||
|
@ -58,8 +58,8 @@ var Rotate = {
|
|||
return Rotate._rot(input, args[0], Rotate._rotr);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Rotate left operation.
|
||||
*
|
||||
|
@ -74,8 +74,8 @@ var Rotate = {
|
|||
return Rotate._rot(input, args[0], Rotate._rotl);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -105,12 +105,12 @@ var Rotate = {
|
|||
chr,
|
||||
rot13Lowercase = args[0],
|
||||
rot13Upperacse = args[1];
|
||||
|
||||
|
||||
if (amount) {
|
||||
if (amount < 0) {
|
||||
amount = 26 - (Math.abs(amount) % 26);
|
||||
}
|
||||
|
||||
|
||||
for (var i = 0; i < input.length; i++) {
|
||||
chr = input[i];
|
||||
if (rot13Upperacse && chr >= 65 && chr <= 90) { // Upper case
|
||||
|
@ -173,8 +173,8 @@ var Rotate = {
|
|||
var bit = (b & 1) << 7;
|
||||
return (b >> 1) | bit;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Rotate left bitwise op.
|
||||
*
|
||||
|
@ -186,8 +186,8 @@ var Rotate = {
|
|||
var bit = (b >> 7) & 1;
|
||||
return ((b << 1) | bit) & 0xFF;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Rotates a byte array to the right by a specific amount as a whole, so that bits are wrapped
|
||||
* from the end of the array to the beginning.
|
||||
|
@ -201,7 +201,7 @@ var Rotate = {
|
|||
var carryBits = 0,
|
||||
newByte,
|
||||
result = [];
|
||||
|
||||
|
||||
amount = amount % 8;
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var oldByte = data[i] >>> 0;
|
||||
|
@ -212,8 +212,8 @@ var Rotate = {
|
|||
result[0] |= carryBits;
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Rotates a byte array to the left by a specific amount as a whole, so that bits are wrapped
|
||||
* from the beginning of the array to the end.
|
||||
|
@ -227,7 +227,7 @@ var Rotate = {
|
|||
var carryBits = 0,
|
||||
newByte,
|
||||
result = [];
|
||||
|
||||
|
||||
amount = amount % 8;
|
||||
for (var i = data.length-1; i >= 0; i--) {
|
||||
var oldByte = data[i];
|
||||
|
|
|
@ -24,7 +24,7 @@ var SeqUtils = {
|
|||
* @default
|
||||
*/
|
||||
SORT_ORDER: ["Alphabetical (case sensitive)", "Alphabetical (case insensitive)", "IP address"],
|
||||
|
||||
|
||||
/**
|
||||
* Sort operation.
|
||||
*
|
||||
|
@ -37,7 +37,7 @@ var SeqUtils = {
|
|||
sortReverse = args[1],
|
||||
order = args[2],
|
||||
sorted = input.split(delim);
|
||||
|
||||
|
||||
if (order === "Alphabetical (case sensitive)") {
|
||||
sorted = sorted.sort();
|
||||
} else if (order === "Alphabetical (case insensitive)") {
|
||||
|
@ -45,12 +45,12 @@ var SeqUtils = {
|
|||
} else if (order === "IP address") {
|
||||
sorted = sorted.sort(SeqUtils._ipSort);
|
||||
}
|
||||
|
||||
|
||||
if (sortReverse) sorted.reverse();
|
||||
return sorted.join(delim);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Unique operation.
|
||||
*
|
||||
|
@ -62,14 +62,14 @@ var SeqUtils = {
|
|||
var delim = Utils.charRep[args[0]];
|
||||
return input.split(delim).unique().join(delim);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
SEARCH_TYPE: ["Regex", "Extended (\\n, \\t, \\x...)", "Simple string"],
|
||||
|
||||
|
||||
/**
|
||||
* Count occurrences operation.
|
||||
*
|
||||
|
@ -80,13 +80,13 @@ var SeqUtils = {
|
|||
runCount: function(input, args) {
|
||||
var search = args[0].string,
|
||||
type = args[0].option;
|
||||
|
||||
|
||||
if (type === "Regex" && search) {
|
||||
try {
|
||||
var regex = new RegExp(search, "gi"),
|
||||
matches = input.match(regex);
|
||||
return matches.length;
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
return 0;
|
||||
}
|
||||
} else if (search) {
|
||||
|
@ -98,14 +98,14 @@ var SeqUtils = {
|
|||
return 0;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
REVERSE_BY: ["Character", "Line"],
|
||||
|
||||
|
||||
/**
|
||||
* Reverse operation.
|
||||
*
|
||||
|
@ -137,8 +137,8 @@ var SeqUtils = {
|
|||
return input.reverse();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add line numbers operation.
|
||||
*
|
||||
|
@ -150,14 +150,14 @@ var SeqUtils = {
|
|||
var lines = input.split("\n"),
|
||||
output = "",
|
||||
width = lines.length.toString().length;
|
||||
|
||||
|
||||
for (var n = 0; n < lines.length; n++) {
|
||||
output += Utils.pad((n+1).toString(), width, " ") + " " + lines[n] + "\n";
|
||||
}
|
||||
return output.slice(0, output.length-1);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Remove line numbers operation.
|
||||
*
|
||||
|
@ -168,8 +168,8 @@ var SeqUtils = {
|
|||
runRemoveLineNumbers: function(input, args) {
|
||||
return input.replace(/^[ \t]{0,5}\d+[\s:|\-,.)\]]/gm, "");
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Expand alphabet range operation.
|
||||
*
|
||||
|
@ -180,8 +180,8 @@ var SeqUtils = {
|
|||
runExpandAlphRange: function(input, args) {
|
||||
return Utils.expandAlphRange(input).join(args[0]);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Comparison operation for sorting of strings ignoring case.
|
||||
*
|
||||
|
@ -193,8 +193,8 @@ var SeqUtils = {
|
|||
_caseInsensitiveSort: function(a, b) {
|
||||
return a.toLowerCase().localeCompare(b.toLowerCase());
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Comparison operation for sorting of IPv4 addresses.
|
||||
*
|
||||
|
@ -206,15 +206,15 @@ var SeqUtils = {
|
|||
_ipSort: function(a, b) {
|
||||
var a_ = a.split("."),
|
||||
b_ = b.split(".");
|
||||
|
||||
|
||||
a_ = a_[0] * 0x1000000 + a_[1] * 0x10000 + a_[2] * 0x100 + a_[3] * 1;
|
||||
b_ = b_[0] * 0x1000000 + b_[1] * 0x10000 + b_[2] * 0x100 + b_[3] * 1;
|
||||
|
||||
|
||||
if (isNaN(a_) && !isNaN(b_)) return 1;
|
||||
if (!isNaN(a_) && isNaN(b_)) return -1;
|
||||
if (isNaN(a_) && isNaN(b_)) return a.localeCompare(b);
|
||||
|
||||
|
||||
return a_ - b_;
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -89,7 +89,7 @@ var StrUtils = {
|
|||
* @default
|
||||
*/
|
||||
DISPLAY_TOTAL: false,
|
||||
|
||||
|
||||
/**
|
||||
* Regular expression operation.
|
||||
*
|
||||
|
@ -104,14 +104,14 @@ var StrUtils = {
|
|||
displayTotal = args[4],
|
||||
outputFormat = args[5],
|
||||
modifiers = "g";
|
||||
|
||||
|
||||
if (i) modifiers += "i";
|
||||
if (m) modifiers += "m";
|
||||
|
||||
|
||||
if (userRegex && userRegex !== "^" && userRegex !== "$") {
|
||||
try {
|
||||
var regex = new RegExp(userRegex, modifiers);
|
||||
|
||||
|
||||
switch (outputFormat) {
|
||||
case "Highlight matches":
|
||||
return StrUtils._regexHighlight(input, regex, displayTotal);
|
||||
|
@ -132,13 +132,13 @@ var StrUtils = {
|
|||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
CASE_SCOPE: ["All", "Word", "Sentence", "Paragraph"],
|
||||
|
||||
|
||||
/**
|
||||
* To Upper case operation.
|
||||
*
|
||||
|
@ -148,7 +148,7 @@ var StrUtils = {
|
|||
*/
|
||||
runUpper: function (input, args) {
|
||||
var scope = args[0];
|
||||
|
||||
|
||||
switch (scope) {
|
||||
case "Word":
|
||||
return input.replace(/(\b\w)/gi, function(m) {
|
||||
|
@ -168,8 +168,8 @@ var StrUtils = {
|
|||
return input.toUpperCase();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* To Upper case operation.
|
||||
*
|
||||
|
@ -180,8 +180,8 @@ var StrUtils = {
|
|||
runLower: function (input, args) {
|
||||
return input.toLowerCase();
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -202,7 +202,7 @@ var StrUtils = {
|
|||
* @default
|
||||
*/
|
||||
FIND_REPLACE_MULTILINE : true,
|
||||
|
||||
|
||||
/**
|
||||
* Find / Replace operation.
|
||||
*
|
||||
|
@ -218,24 +218,24 @@ var StrUtils = {
|
|||
i = args[3],
|
||||
m = args[4],
|
||||
modifiers = "";
|
||||
|
||||
|
||||
if (g) modifiers += "g";
|
||||
if (i) modifiers += "i";
|
||||
if (m) modifiers += "m";
|
||||
|
||||
|
||||
if (type === "Regex") {
|
||||
find = new RegExp(find, modifiers);
|
||||
} else if (type.indexOf("Extended") === 0) {
|
||||
find = Utils.parseEscapedChars(find);
|
||||
}
|
||||
|
||||
|
||||
return input.replace(find, replace, modifiers);
|
||||
// Non-standard addition of flags in the third argument. This will work in Firefox but
|
||||
// probably nowhere else. The purpose is to allow global matching when the `find` parameter
|
||||
// is just a string.
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -246,7 +246,7 @@ var StrUtils = {
|
|||
* @default
|
||||
*/
|
||||
DELIMITER_OPTIONS: ["Line feed", "CRLF", "Space", "Comma", "Semi-colon", "Colon", "Nothing (separate chars)"],
|
||||
|
||||
|
||||
/**
|
||||
* Split operation.
|
||||
*
|
||||
|
@ -258,7 +258,7 @@ var StrUtils = {
|
|||
var splitDelim = args[0] || StrUtils.SPLIT_DELIM,
|
||||
joinDelim = Utils.charRep[args[1]],
|
||||
sections = input.split(splitDelim);
|
||||
|
||||
|
||||
return sections.join(joinDelim);
|
||||
},
|
||||
|
||||
|
@ -287,8 +287,8 @@ var StrUtils = {
|
|||
|
||||
return input.split(delim).filter(regexFilter).join(delim);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -299,7 +299,7 @@ var StrUtils = {
|
|||
* @default
|
||||
*/
|
||||
DIFF_BY: ["Character", "Word", "Line", "Sentence", "CSS", "JSON"],
|
||||
|
||||
|
||||
/**
|
||||
* Diff operation.
|
||||
*
|
||||
|
@ -316,11 +316,11 @@ var StrUtils = {
|
|||
samples = input.split(sampleDelim),
|
||||
output = "",
|
||||
diff;
|
||||
|
||||
|
||||
if (!samples || samples.length !== 2) {
|
||||
return "Incorrect number of samples, perhaps you need to modify the sample delimiter or add more samples?";
|
||||
}
|
||||
|
||||
|
||||
switch (diffBy) {
|
||||
case "Character":
|
||||
diff = JsDiff.diffChars(samples[0], samples[1]);
|
||||
|
@ -351,7 +351,7 @@ var StrUtils = {
|
|||
default:
|
||||
return "Invalid 'Diff by' option.";
|
||||
}
|
||||
|
||||
|
||||
for (var i = 0; i < diff.length; i++) {
|
||||
if (diff[i].added) {
|
||||
if (showAdded) output += "<span class='hlgreen'>" + Utils.escapeHtml(diff[i].value) + "</span>";
|
||||
|
@ -361,17 +361,17 @@ var StrUtils = {
|
|||
output += Utils.escapeHtml(diff[i].value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
OFF_CHK_SAMPLE_DELIMITER: "\\n\\n",
|
||||
|
||||
|
||||
/**
|
||||
* Offset checker operation.
|
||||
*
|
||||
|
@ -388,21 +388,21 @@ var StrUtils = {
|
|||
match = false,
|
||||
inMatch = false,
|
||||
chr;
|
||||
|
||||
|
||||
if (!samples || samples.length < 2) {
|
||||
return "Not enough samples, perhaps you need to modify the sample delimiter or add more data?";
|
||||
}
|
||||
|
||||
|
||||
// Initialise output strings
|
||||
for (s = 0; s < samples.length; s++) {
|
||||
outputs[s] = "";
|
||||
}
|
||||
|
||||
|
||||
// Loop through each character in the first sample
|
||||
for (i = 0; i < samples[0].length; i++) {
|
||||
chr = samples[0][i];
|
||||
match = false;
|
||||
|
||||
|
||||
// Loop through each sample to see if the chars are the same
|
||||
for (s = 1; s < samples.length; s++) {
|
||||
if (samples[s][i] !== chr) {
|
||||
|
@ -411,7 +411,7 @@ var StrUtils = {
|
|||
}
|
||||
match = true;
|
||||
}
|
||||
|
||||
|
||||
// Write output for each sample
|
||||
for (s = 0; s < samples.length; s++) {
|
||||
if (samples[s].length <= i) {
|
||||
|
@ -419,7 +419,7 @@ var StrUtils = {
|
|||
if (s === samples.length - 1) inMatch = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (match && !inMatch) {
|
||||
outputs[s] += "<span class='hlgreen'>" + Utils.escapeHtml(samples[s][i]);
|
||||
if (samples[s].length === i + 1) outputs[s] += "</span>";
|
||||
|
@ -434,18 +434,18 @@ var StrUtils = {
|
|||
if (samples[s].length - 1 !== i) inMatch = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (samples[0].length - 1 === i) {
|
||||
if (inMatch) outputs[s] += "</span>";
|
||||
outputs[s] += Utils.escapeHtml(samples[s].substring(i + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return outputs.join(sampleDelim);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parse escaped string operation.
|
||||
*
|
||||
|
@ -456,8 +456,8 @@ var StrUtils = {
|
|||
runParseEscapedString: function(input, args) {
|
||||
return Utils.parseEscapedChars(input);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds HTML highlights to matches within a string.
|
||||
*
|
||||
|
@ -473,31 +473,31 @@ var StrUtils = {
|
|||
hl = 1,
|
||||
i = 0,
|
||||
total = 0;
|
||||
|
||||
|
||||
while ((m = regex.exec(input))) {
|
||||
// Add up to match
|
||||
output += Utils.escapeHtml(input.slice(i, m.index));
|
||||
|
||||
|
||||
// Add match with highlighting
|
||||
output += "<span class='hl"+hl+"'>" + Utils.escapeHtml(m[0]) + "</span>";
|
||||
|
||||
|
||||
// Switch highlight
|
||||
hl = hl === 1 ? 2 : 1;
|
||||
|
||||
|
||||
i = regex.lastIndex;
|
||||
total++;
|
||||
}
|
||||
|
||||
|
||||
// Add all after final match
|
||||
output += Utils.escapeHtml(input.slice(i, input.length));
|
||||
|
||||
|
||||
if (displayTotal)
|
||||
output = "Total found: " + total + "\n\n" + output;
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates a string listing the matches within a string.
|
||||
*
|
||||
|
@ -513,7 +513,7 @@ var StrUtils = {
|
|||
var output = "",
|
||||
total = 0,
|
||||
match;
|
||||
|
||||
|
||||
while ((match = regex.exec(input))) {
|
||||
total++;
|
||||
if (matches) {
|
||||
|
@ -528,11 +528,11 @@ var StrUtils = {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (displayTotal)
|
||||
output = "Total found: " + total + "\n\n" + output;
|
||||
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -39,7 +39,7 @@ var Tidy = {
|
|||
* @default
|
||||
*/
|
||||
REMOVE_FULL_STOPS : false,
|
||||
|
||||
|
||||
/**
|
||||
* Remove whitespace operation.
|
||||
*
|
||||
|
@ -55,7 +55,7 @@ var Tidy = {
|
|||
removeFormFeeds = args[4],
|
||||
removeFullStops = args[5],
|
||||
data = input;
|
||||
|
||||
|
||||
if (removeSpaces) data = data.replace(/ /g, "");
|
||||
if (removeCariageReturns) data = data.replace(/\r/g, "");
|
||||
if (removeLineFeeds) data = data.replace(/\n/g, "");
|
||||
|
@ -64,8 +64,8 @@ var Tidy = {
|
|||
if (removeFullStops) data = data.replace(/\./g, "");
|
||||
return data;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Remove null bytes operation.
|
||||
*
|
||||
|
@ -80,8 +80,8 @@ var Tidy = {
|
|||
}
|
||||
return output;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -97,7 +97,7 @@ var Tidy = {
|
|||
* @default
|
||||
*/
|
||||
DROP_LENGTH : 5,
|
||||
|
||||
|
||||
/**
|
||||
* Drop bytes operation.
|
||||
*
|
||||
|
@ -109,17 +109,17 @@ var Tidy = {
|
|||
var start = args[0],
|
||||
length = args[1],
|
||||
applyToEachLine = args[2];
|
||||
|
||||
|
||||
if (start < 0 || length < 0)
|
||||
throw "Error: Invalid value";
|
||||
|
||||
|
||||
if (!applyToEachLine)
|
||||
return input.slice(0, start).concat(input.slice(start+length, input.length));
|
||||
|
||||
|
||||
// Split input into lines
|
||||
var lines = [],
|
||||
line = [];
|
||||
|
||||
|
||||
for (var i = 0; i < input.length; i++) {
|
||||
if (input[i] === 0x0a) {
|
||||
lines.push(line);
|
||||
|
@ -129,7 +129,7 @@ var Tidy = {
|
|||
}
|
||||
}
|
||||
lines.push(line);
|
||||
|
||||
|
||||
var output = [];
|
||||
for (i = 0; i < lines.length; i++) {
|
||||
output = output.concat(lines[i].slice(0, start).concat(lines[i].slice(start+length, lines[i].length)));
|
||||
|
@ -137,8 +137,8 @@ var Tidy = {
|
|||
}
|
||||
return output.slice(0, output.length-1);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -149,7 +149,7 @@ var Tidy = {
|
|||
* @default
|
||||
*/
|
||||
TAKE_LENGTH: 5,
|
||||
|
||||
|
||||
/**
|
||||
* Take bytes operation.
|
||||
*
|
||||
|
@ -161,17 +161,17 @@ var Tidy = {
|
|||
var start = args[0],
|
||||
length = args[1],
|
||||
applyToEachLine = args[2];
|
||||
|
||||
|
||||
if (start < 0 || length < 0)
|
||||
throw "Error: Invalid value";
|
||||
|
||||
|
||||
if (!applyToEachLine)
|
||||
return input.slice(start, start+length);
|
||||
|
||||
|
||||
// Split input into lines
|
||||
var lines = [],
|
||||
line = [];
|
||||
|
||||
|
||||
for (var i = 0; i < input.length; i++) {
|
||||
if (input[i] === 0x0a) {
|
||||
lines.push(line);
|
||||
|
@ -181,7 +181,7 @@ var Tidy = {
|
|||
}
|
||||
}
|
||||
lines.push(line);
|
||||
|
||||
|
||||
var output = [];
|
||||
for (i = 0; i < lines.length; i++) {
|
||||
output = output.concat(lines[i].slice(start, start+length));
|
||||
|
@ -189,8 +189,8 @@ var Tidy = {
|
|||
}
|
||||
return output.slice(0, output.length-1);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
|
@ -206,7 +206,7 @@ var Tidy = {
|
|||
* @default
|
||||
*/
|
||||
PAD_CHAR : " ",
|
||||
|
||||
|
||||
/**
|
||||
* Pad lines operation.
|
||||
*
|
||||
|
@ -221,7 +221,7 @@ var Tidy = {
|
|||
lines = input.split("\n"),
|
||||
output = "",
|
||||
i = 0;
|
||||
|
||||
|
||||
if (position === "Start") {
|
||||
for (i = 0; i < lines.length; i++) {
|
||||
output += Utils.padLeft(lines[i], lines[i].length+len, chr) + "\n";
|
||||
|
@ -231,8 +231,8 @@ var Tidy = {
|
|||
output += Utils.padRight(lines[i], lines[i].length+len, chr) + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return output.slice(0, output.length-1);
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -17,7 +17,7 @@ var URL_ = {
|
|||
* @default
|
||||
*/
|
||||
ENCODE_ALL: false,
|
||||
|
||||
|
||||
/**
|
||||
* URL Encode operation.
|
||||
*
|
||||
|
@ -29,8 +29,8 @@ var URL_ = {
|
|||
var encodeAll = args[0];
|
||||
return encodeAll ? URL_._encodeAllChars(input) : encodeURI(input);
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* URL Decode operation.
|
||||
*
|
||||
|
@ -42,12 +42,12 @@ var URL_ = {
|
|||
var data = input.replace(/\+/g, "%20");
|
||||
try {
|
||||
return decodeURIComponent(data);
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
return unescape(data);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parse URI operation.
|
||||
*
|
||||
|
@ -57,11 +57,11 @@ var URL_ = {
|
|||
*/
|
||||
runParse: function(input, args) {
|
||||
var a = document.createElement("a");
|
||||
|
||||
|
||||
// Overwrite base href which will be the current CyberChef URL to reduce confusion.
|
||||
a.href = "http://example.com/";
|
||||
a.href = input;
|
||||
|
||||
|
||||
if (a.protocol) {
|
||||
var output = "";
|
||||
if (a.hostname !== window.location.hostname) {
|
||||
|
@ -69,7 +69,7 @@ var URL_ = {
|
|||
if (a.hostname) output += "Hostname:\t" + a.hostname + "\n";
|
||||
if (a.port) output += "Port:\t\t" + a.port + "\n";
|
||||
}
|
||||
|
||||
|
||||
if (a.pathname && a.pathname !== window.location.pathname) {
|
||||
var pathname = a.pathname;
|
||||
if (pathname.indexOf(window.location.pathname) === 0)
|
||||
|
@ -77,11 +77,11 @@ var URL_ = {
|
|||
if (pathname)
|
||||
output += "Path name:\t" + pathname + "\n";
|
||||
}
|
||||
|
||||
|
||||
if (a.hash && a.hash !== window.location.hash) {
|
||||
output += "Hash:\t\t" + a.hash + "\n";
|
||||
}
|
||||
|
||||
|
||||
if (a.search && a.search !== window.location.search) {
|
||||
output += "Arguments:\n";
|
||||
var args_ = (a.search.slice(1, a.search.length)).split("&");
|
||||
|
@ -97,14 +97,14 @@ var URL_ = {
|
|||
else output += "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
return "Invalid URI";
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* URL encodes additional special characters beyond the standard set.
|
||||
*
|
||||
|
@ -126,5 +126,5 @@ var URL_ = {
|
|||
.replace(/_/g, "%5F")
|
||||
.replace(/~/g, "%7E");
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -28,25 +28,25 @@ var Unicode = {
|
|||
output = "",
|
||||
m,
|
||||
i = 0;
|
||||
|
||||
|
||||
while ((m = regex.exec(input))) {
|
||||
// Add up to match
|
||||
output += input.slice(i, m.index);
|
||||
i = m.index;
|
||||
|
||||
|
||||
// Add match
|
||||
output += Utils.chr(parseInt(m[1], 16));
|
||||
|
||||
|
||||
i = regex.lastIndex;
|
||||
}
|
||||
|
||||
|
||||
// Add all after final match
|
||||
output += input.slice(i, input.length);
|
||||
|
||||
|
||||
return output;
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Lookup table to add prefixes to unicode delimiters so that they can be used in a regex.
|
||||
*
|
||||
|
|
|
@ -30,13 +30,13 @@ ControlsWaiter.prototype.adjustWidth = function() {
|
|||
stepImg = document.querySelector("#step img"),
|
||||
clrRecipImg = document.querySelector("#clr-recipe img"),
|
||||
clrBreaksImg = document.querySelector("#clr-breaks img");
|
||||
|
||||
|
||||
if (controls.clientWidth < 470) {
|
||||
step.childNodes[1].nodeValue = " Step";
|
||||
} else {
|
||||
step.childNodes[1].nodeValue = " Step through";
|
||||
}
|
||||
|
||||
|
||||
if (controls.clientWidth < 400) {
|
||||
saveImg.style.display = "none";
|
||||
loadImg.style.display = "none";
|
||||
|
@ -50,7 +50,7 @@ ControlsWaiter.prototype.adjustWidth = function() {
|
|||
clrRecipImg.style.display = "inline";
|
||||
clrBreaksImg.style.display = "inline";
|
||||
}
|
||||
|
||||
|
||||
if (controls.clientWidth < 330) {
|
||||
clrBreaks.childNodes[1].nodeValue = " Clear breaks";
|
||||
} else {
|
||||
|
@ -66,7 +66,7 @@ ControlsWaiter.prototype.adjustWidth = function() {
|
|||
*/
|
||||
ControlsWaiter.prototype.setAutoBake = function(value) {
|
||||
var autoBakeCheckbox = document.getElementById("auto-bake");
|
||||
|
||||
|
||||
if (autoBakeCheckbox.checked !== value) {
|
||||
autoBakeCheckbox.click();
|
||||
}
|
||||
|
@ -97,9 +97,9 @@ ControlsWaiter.prototype.stepClick = function() {
|
|||
ControlsWaiter.prototype.autoBakeChange = function() {
|
||||
var autoBakeLabel = document.getElementById("auto-bake-label"),
|
||||
autoBakeCheckbox = document.getElementById("auto-bake");
|
||||
|
||||
|
||||
this.app.autoBake_ = autoBakeCheckbox.checked;
|
||||
|
||||
|
||||
if (autoBakeCheckbox.checked) {
|
||||
autoBakeLabel.classList.remove("btn-default");
|
||||
autoBakeLabel.classList.add("btn-success");
|
||||
|
@ -124,7 +124,7 @@ ControlsWaiter.prototype.clearRecipeClick = function() {
|
|||
*/
|
||||
ControlsWaiter.prototype.clearBreaksClick = function() {
|
||||
var bps = document.querySelectorAll("#rec-list li.operation .breakpoint");
|
||||
|
||||
|
||||
for (var i = 0; i < bps.length; i++) {
|
||||
bps[i].setAttribute("break", "false");
|
||||
bps[i].classList.remove("breakpoint-selected");
|
||||
|
@ -139,12 +139,12 @@ ControlsWaiter.prototype.clearBreaksClick = function() {
|
|||
*/
|
||||
ControlsWaiter.prototype.initialiseSaveLink = function(recipeConfig) {
|
||||
recipeConfig = recipeConfig || this.app.getRecipeConfig();
|
||||
|
||||
|
||||
var includeRecipe = document.getElementById("save-link-recipe-checkbox").checked,
|
||||
includeInput = document.getElementById("save-link-input-checkbox").checked,
|
||||
saveLinkEl = document.getElementById("save-link"),
|
||||
saveLink = this.generateStateUrl(includeRecipe, includeInput, recipeConfig);
|
||||
|
||||
|
||||
saveLinkEl.innerHTML = Utils.truncate(saveLink, 120);
|
||||
saveLinkEl.setAttribute("href", saveLink);
|
||||
};
|
||||
|
@ -161,26 +161,26 @@ ControlsWaiter.prototype.initialiseSaveLink = function(recipeConfig) {
|
|||
*/
|
||||
ControlsWaiter.prototype.generateStateUrl = function(includeRecipe, includeInput, recipeConfig, baseURL) {
|
||||
recipeConfig = recipeConfig || this.app.getRecipeConfig();
|
||||
|
||||
|
||||
var link = baseURL || window.location.protocol + "//" +
|
||||
window.location.host +
|
||||
window.location.pathname,
|
||||
recipeStr = JSON.stringify(recipeConfig),
|
||||
inputStr = Utils.toBase64(this.app.getInput(), "A-Za-z0-9+/"); // B64 alphabet with no padding
|
||||
|
||||
|
||||
includeRecipe = includeRecipe && (recipeConfig.length > 0);
|
||||
includeInput = includeInput && (inputStr.length > 0) && (inputStr.length < 8000);
|
||||
|
||||
if (includeRecipe) {
|
||||
link += "?recipe=" + encodeURIComponent(recipeStr);
|
||||
}
|
||||
|
||||
|
||||
if (includeRecipe && includeInput) {
|
||||
link += "&input=" + encodeURIComponent(inputStr);
|
||||
} else if (includeInput) {
|
||||
link += "?input=" + encodeURIComponent(inputStr);
|
||||
}
|
||||
|
||||
|
||||
return link;
|
||||
};
|
||||
|
||||
|
@ -192,7 +192,7 @@ ControlsWaiter.prototype.saveTextChange = function() {
|
|||
try {
|
||||
var recipeConfig = JSON.parse(document.getElementById("save-text").value);
|
||||
this.initialiseSaveLink(recipeConfig);
|
||||
} catch(err) {}
|
||||
} catch (err) {}
|
||||
};
|
||||
|
||||
|
||||
|
@ -202,9 +202,9 @@ ControlsWaiter.prototype.saveTextChange = function() {
|
|||
ControlsWaiter.prototype.saveClick = function() {
|
||||
var recipeConfig = this.app.getRecipeConfig(),
|
||||
recipeStr = JSON.stringify(recipeConfig).replace(/},{/g, "},\n{");
|
||||
|
||||
|
||||
document.getElementById("save-text").value = recipeStr;
|
||||
|
||||
|
||||
this.initialiseSaveLink(recipeConfig);
|
||||
$("#save-modal").modal();
|
||||
};
|
||||
|
@ -241,25 +241,25 @@ ControlsWaiter.prototype.loadClick = function() {
|
|||
ControlsWaiter.prototype.saveButtonClick = function() {
|
||||
var recipeName = document.getElementById("save-name").value,
|
||||
recipeStr = document.getElementById("save-text").value;
|
||||
|
||||
|
||||
if (!recipeName) {
|
||||
this.app.alert("Please enter a recipe name", "danger", 2000);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var savedRecipes = localStorage.savedRecipes ?
|
||||
JSON.parse(localStorage.savedRecipes) : [],
|
||||
recipeId = localStorage.recipeId || 0;
|
||||
|
||||
|
||||
savedRecipes.push({
|
||||
id: ++recipeId,
|
||||
name: recipeName,
|
||||
recipe: recipeStr
|
||||
});
|
||||
|
||||
|
||||
localStorage.savedRecipes = JSON.stringify(savedRecipes);
|
||||
localStorage.recipeId = recipeId;
|
||||
|
||||
|
||||
this.app.alert("Recipe saved as \"" + recipeName + "\".", "success", 2000);
|
||||
};
|
||||
|
||||
|
@ -269,7 +269,7 @@ ControlsWaiter.prototype.saveButtonClick = function() {
|
|||
*/
|
||||
ControlsWaiter.prototype.populateLoadRecipesList = function() {
|
||||
var loadNameEl = document.getElementById("load-name");
|
||||
|
||||
|
||||
// Remove current recipes from select
|
||||
var i = loadNameEl.options.length;
|
||||
while (i--) {
|
||||
|
@ -279,15 +279,15 @@ ControlsWaiter.prototype.populateLoadRecipesList = function() {
|
|||
// Add recipes to select
|
||||
var savedRecipes = localStorage.savedRecipes ?
|
||||
JSON.parse(localStorage.savedRecipes) : [];
|
||||
|
||||
|
||||
for (i = 0; i < savedRecipes.length; i++) {
|
||||
var opt = document.createElement("option");
|
||||
opt.value = savedRecipes[i].id;
|
||||
opt.innerHTML = savedRecipes[i].name;
|
||||
|
||||
|
||||
loadNameEl.appendChild(opt);
|
||||
}
|
||||
|
||||
|
||||
// Populate textarea with first recipe
|
||||
document.getElementById("load-text").value = savedRecipes.length ? savedRecipes[0].recipe : "";
|
||||
};
|
||||
|
@ -300,11 +300,11 @@ ControlsWaiter.prototype.loadDeleteClick = function() {
|
|||
var id = parseInt(document.getElementById("load-name").value, 10),
|
||||
savedRecipes = localStorage.savedRecipes ?
|
||||
JSON.parse(localStorage.savedRecipes) : [];
|
||||
|
||||
|
||||
savedRecipes = savedRecipes.filter(function(r) {
|
||||
return r.id !== id;
|
||||
});
|
||||
|
||||
|
||||
localStorage.savedRecipes = JSON.stringify(savedRecipes);
|
||||
this.populateLoadRecipesList();
|
||||
};
|
||||
|
@ -318,11 +318,11 @@ ControlsWaiter.prototype.loadNameChange = function(e) {
|
|||
savedRecipes = localStorage.savedRecipes ?
|
||||
JSON.parse(localStorage.savedRecipes) : [],
|
||||
id = parseInt(el.value, 10);
|
||||
|
||||
|
||||
var recipe = savedRecipes.filter(function(r) {
|
||||
return r.id === id;
|
||||
})[0];
|
||||
|
||||
|
||||
document.getElementById("load-text").value = recipe.recipe;
|
||||
};
|
||||
|
||||
|
@ -336,7 +336,7 @@ ControlsWaiter.prototype.loadButtonClick = function() {
|
|||
this.app.setRecipeConfig(recipeConfig);
|
||||
|
||||
$("#rec-list [data-toggle=popover]").popover();
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
this.app.alert("Invalid recipe", "danger", 2000);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -362,13 +362,13 @@ HTMLApp.prototype.loadURIParams = function() {
|
|||
try {
|
||||
var recipeConfig = JSON.parse(this.queryString.recipe);
|
||||
this.setRecipeConfig(recipeConfig);
|
||||
} catch(err) {}
|
||||
} catch (err) {}
|
||||
} else if (this.queryString.op) {
|
||||
// If there's no recipe, look for single operations
|
||||
this.manager.recipe.clearRecipe();
|
||||
try {
|
||||
this.manager.recipe.addOperation(this.queryString.op);
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
// If no exact match, search for nearest match and add that
|
||||
var matchedOps = this.manager.ops.filterOperations(this.queryString.op, false);
|
||||
if (matchedOps.length) {
|
||||
|
@ -388,7 +388,7 @@ HTMLApp.prototype.loadURIParams = function() {
|
|||
try {
|
||||
var inputData = Utils.fromBase64(this.queryString.input);
|
||||
this.setInput(inputData);
|
||||
} catch(err) {}
|
||||
} catch (err) {}
|
||||
}
|
||||
|
||||
// Restore auto-bake state
|
||||
|
|
|
@ -40,11 +40,11 @@ HTMLCategory.prototype.toHtml = function() {
|
|||
</a>\
|
||||
<div id='" + catName + "' class='panel-collapse collapse\
|
||||
" + (this.selected ? " in" : "") + "'><ul class='op-list'>";
|
||||
|
||||
|
||||
for (var i = 0; i < this.opList.length; i++) {
|
||||
html += this.opList[i].toStubHtml();
|
||||
}
|
||||
|
||||
|
||||
html += "</ul></div></div>";
|
||||
return html;
|
||||
};
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
var HTMLIngredient = function(config, app, manager) {
|
||||
this.app = app;
|
||||
this.manager = manager;
|
||||
|
||||
|
||||
this.name = config.name;
|
||||
this.type = config.type;
|
||||
this.value = config.value;
|
||||
|
@ -39,11 +39,11 @@ HTMLIngredient.prototype.toHtml = function() {
|
|||
this.type === "binaryShortString"),
|
||||
html = inline ? "" : "<div class='clearfix'> </div>",
|
||||
i, m;
|
||||
|
||||
|
||||
html += "<div class='arg-group" + (inline ? " inline-args" : "") +
|
||||
(this.type === "text" ? " arg-group-text" : "") + "'><label class='arg-label' for='" +
|
||||
this.id + "'>" + this.name + "</label>";
|
||||
|
||||
|
||||
switch (this.type) {
|
||||
case "string":
|
||||
case "binaryString":
|
||||
|
@ -83,7 +83,7 @@ HTMLIngredient.prototype.toHtml = function() {
|
|||
html += "<input type='checkbox' id='" + this.id + "'class='arg' arg-name='" +
|
||||
this.name + "'" + (this.value ? " checked='checked' " : "") +
|
||||
(this.disabled ? " disabled='disabled'" : "") + ">";
|
||||
|
||||
|
||||
if (this.disableArgs) {
|
||||
this.manager.addDynamicListener("#" + this.id, "click", this.toggleDisableArgs, this);
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ HTMLIngredient.prototype.toHtml = function() {
|
|||
}
|
||||
}
|
||||
html += "</select>";
|
||||
|
||||
|
||||
this.manager.addDynamicListener("#" + this.id, "change", this.populateOptionChange, this);
|
||||
break;
|
||||
case "editableOption":
|
||||
|
@ -132,8 +132,8 @@ HTMLIngredient.prototype.toHtml = function() {
|
|||
(this.disabled ? " disabled='disabled'" : "") +
|
||||
(this.placeholder ? " placeholder='" + this.placeholder + "'" : "") + ">";
|
||||
html += "</div>";
|
||||
|
||||
|
||||
|
||||
|
||||
this.manager.addDynamicListener("#sel-" + this.id, "change", this.editableOptionChange, this);
|
||||
break;
|
||||
case "text":
|
||||
|
@ -146,7 +146,7 @@ HTMLIngredient.prototype.toHtml = function() {
|
|||
break;
|
||||
}
|
||||
html += "</div>";
|
||||
|
||||
|
||||
return html;
|
||||
};
|
||||
|
||||
|
@ -162,10 +162,10 @@ HTMLIngredient.prototype.toggleDisableArgs = function(e) {
|
|||
op = el.parentNode.parentNode,
|
||||
args = op.querySelectorAll(".arg-group"),
|
||||
els;
|
||||
|
||||
|
||||
for (var i = 0; i < this.disableArgs.length; i++) {
|
||||
els = args[this.disableArgs[i]].querySelectorAll("input, select, button");
|
||||
|
||||
|
||||
for (var j = 0; j < els.length; j++) {
|
||||
if (els[j].getAttribute("disabled")) {
|
||||
els[j].removeAttribute("disabled");
|
||||
|
@ -174,7 +174,7 @@ HTMLIngredient.prototype.toggleDisableArgs = function(e) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.manager.recipe.ingChange();
|
||||
};
|
||||
|
||||
|
@ -191,7 +191,7 @@ HTMLIngredient.prototype.populateOptionChange = function(e) {
|
|||
target = op.querySelectorAll(".arg-group")[this.target].querySelector("input, select, textarea");
|
||||
|
||||
target.value = el.childNodes[el.selectedIndex].getAttribute("populate-value");
|
||||
|
||||
|
||||
this.manager.recipe.ingChange();
|
||||
};
|
||||
|
||||
|
@ -207,6 +207,6 @@ HTMLIngredient.prototype.editableOptionChange = function(e) {
|
|||
input = select.nextSibling;
|
||||
|
||||
input.value = select.childNodes[select.selectedIndex].value;
|
||||
|
||||
|
||||
this.manager.recipe.ingChange();
|
||||
};
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
var HTMLOperation = function(name, config, app, manager) {
|
||||
this.app = app;
|
||||
this.manager = manager;
|
||||
|
||||
|
||||
this.name = name;
|
||||
this.description = config.description;
|
||||
this.manualBake = config.manualBake || false;
|
||||
this.config = config;
|
||||
this.ingList = [];
|
||||
|
||||
|
||||
for (var i = 0; i < config.args.length; i++) {
|
||||
var ing = new HTMLIngredient(config.args[i], this.app, this.manager);
|
||||
this.ingList.push(ing);
|
||||
|
@ -45,25 +45,25 @@ HTMLOperation.REMOVE_ICON = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABwkl
|
|||
*/
|
||||
HTMLOperation.prototype.toStubHtml = function(removeIcon) {
|
||||
var html = "<li class='operation'";
|
||||
|
||||
|
||||
if (this.description) {
|
||||
html += " data-container='body' data-toggle='popover' data-placement='auto right'\
|
||||
data-content=\"" + this.description + "\" data-html='true' data-trigger='hover'";
|
||||
}
|
||||
|
||||
|
||||
html += ">" + this.name;
|
||||
|
||||
|
||||
if (removeIcon) {
|
||||
html += "<img src='data:image/png;base64," + HTMLOperation.REMOVE_ICON +
|
||||
"' class='op-icon remove-icon'>";
|
||||
}
|
||||
|
||||
|
||||
if (this.description) {
|
||||
html += "<img src='data:image/png;base64," + HTMLOperation.INFO_ICON + "' class='op-icon'>";
|
||||
}
|
||||
|
||||
|
||||
html += "</li>";
|
||||
|
||||
|
||||
return html;
|
||||
};
|
||||
|
||||
|
@ -79,15 +79,15 @@ HTMLOperation.prototype.toFullHtml = function() {
|
|||
for (var i = 0; i < this.ingList.length; i++) {
|
||||
html += this.ingList[i].toHtml();
|
||||
}
|
||||
|
||||
|
||||
html += "<div class='recip-icons'>\
|
||||
<div class='breakpoint' title='Set breakpoint' break='false'></div>\
|
||||
<div class='disable-icon recip-icon' title='Disable operation'\
|
||||
disabled='false'></div>";
|
||||
|
||||
|
||||
html += "</div>\
|
||||
<div class='clearfix'> </div>";
|
||||
|
||||
|
||||
return html;
|
||||
};
|
||||
|
||||
|
@ -105,7 +105,7 @@ HTMLOperation.prototype.highlightSearchString = function(searchStr, namePos, des
|
|||
this.name.slice(namePos, namePos + searchStr.length) + "</u></b>" +
|
||||
this.name.slice(namePos + searchStr.length);
|
||||
}
|
||||
|
||||
|
||||
if (this.description && descPos >= 0) {
|
||||
this.description = this.description.slice(0, descPos) + "<b><u>" +
|
||||
this.description.slice(descPos, descPos + searchStr.length) + "</u></b>" +
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
var InputWaiter = function(app, manager) {
|
||||
this.app = app;
|
||||
this.manager = manager;
|
||||
|
||||
|
||||
// Define keys that don't change the input so we don't have to autobake when they are pressed
|
||||
this.badKeys = [
|
||||
16, //Shift
|
||||
|
@ -65,10 +65,10 @@ InputWaiter.prototype.set = function(input) {
|
|||
InputWaiter.prototype.setInputInfo = function(length, lines) {
|
||||
var width = length.toString().length;
|
||||
width = width < 2 ? 2 : width;
|
||||
|
||||
|
||||
var lengthStr = Utils.pad(length.toString(), width, " ").replace(/ /g, " ");
|
||||
var linesStr = Utils.pad(lines.toString(), width, " ").replace(/ /g, " ");
|
||||
|
||||
|
||||
document.getElementById("input-info").innerHTML = "length: " + lengthStr + "<br>lines: " + linesStr;
|
||||
};
|
||||
|
||||
|
@ -84,17 +84,17 @@ InputWaiter.prototype.setInputInfo = function(length, lines) {
|
|||
InputWaiter.prototype.inputChange = function(e) {
|
||||
// Remove highlighting from input and output panes as the offsets might be different now
|
||||
this.manager.highlighter.removeHighlights();
|
||||
|
||||
|
||||
// Reset recipe progress as any previous processing will be redundant now
|
||||
this.app.progress = 0;
|
||||
|
||||
|
||||
// Update the input metadata info
|
||||
var inputText = this.get(),
|
||||
lines = inputText.count("\n") + 1;
|
||||
|
||||
|
||||
this.setInputInfo(inputText.length, lines);
|
||||
|
||||
|
||||
|
||||
|
||||
if (this.badKeys.indexOf(e.keyCode) < 0) {
|
||||
// Fire the statechange event as the input has been modified
|
||||
window.dispatchEvent(this.manager.statechange);
|
||||
|
@ -112,7 +112,7 @@ InputWaiter.prototype.inputDragover = function(e) {
|
|||
// This will be set if we're dragging an operation
|
||||
if (e.dataTransfer.effectAllowed === "move")
|
||||
return false;
|
||||
|
||||
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
e.target.classList.add("dropping-file");
|
||||
|
@ -142,10 +142,10 @@ InputWaiter.prototype.inputDrop = function(e) {
|
|||
// This will be set if we're dragging an operation
|
||||
if (e.dataTransfer.effectAllowed === "move")
|
||||
return false;
|
||||
|
||||
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
|
||||
var el = e.target,
|
||||
file = e.dataTransfer.files[0],
|
||||
text = e.dataTransfer.getData("Text"),
|
||||
|
@ -153,23 +153,23 @@ InputWaiter.prototype.inputDrop = function(e) {
|
|||
inputCharcode = "",
|
||||
offset = 0,
|
||||
CHUNK_SIZE = 20480; // 20KB
|
||||
|
||||
|
||||
var setInput = function() {
|
||||
if (inputCharcode.length > 100000 && this.app.autoBake_) {
|
||||
this.manager.controls.setAutoBake(false);
|
||||
this.app.alert("Turned off Auto Bake as the input is large", "warning", 5000);
|
||||
}
|
||||
|
||||
|
||||
this.set(inputCharcode);
|
||||
var recipeConfig = this.app.getRecipeConfig();
|
||||
if (!recipeConfig[0] || recipeConfig[0].op !== "From Hex") {
|
||||
recipeConfig.unshift({op:"From Hex", args:["Space"]});
|
||||
this.app.setRecipeConfig(recipeConfig);
|
||||
}
|
||||
|
||||
|
||||
el.classList.remove("loadingFile");
|
||||
}.bind(this);
|
||||
|
||||
|
||||
var seek = function() {
|
||||
if (offset >= file.size) {
|
||||
setInput();
|
||||
|
@ -179,17 +179,17 @@ InputWaiter.prototype.inputDrop = function(e) {
|
|||
var slice = file.slice(offset, offset + CHUNK_SIZE);
|
||||
reader.readAsArrayBuffer(slice);
|
||||
};
|
||||
|
||||
|
||||
reader.onload = function(e) {
|
||||
var data = new Uint8Array(reader.result);
|
||||
inputCharcode += Utils.toHexFast(data);
|
||||
offset += CHUNK_SIZE;
|
||||
seek();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
el.classList.remove("dropping-file");
|
||||
|
||||
|
||||
if (file) {
|
||||
el.classList.add("loadingFile");
|
||||
seek();
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*/
|
||||
var Manager = function(app) {
|
||||
this.app = app;
|
||||
|
||||
|
||||
// Define custom events
|
||||
/**
|
||||
* @event Manager#appstart
|
||||
|
@ -32,7 +32,7 @@ var Manager = function(app) {
|
|||
* @event Manager#statechange
|
||||
*/
|
||||
this.statechange = new CustomEvent("statechange", {bubbles: true});
|
||||
|
||||
|
||||
// Define Waiter objects to handle various areas
|
||||
this.window = new WindowWaiter(this.app);
|
||||
this.controls = new ControlsWaiter(this.app, this);
|
||||
|
@ -43,10 +43,10 @@ var Manager = function(app) {
|
|||
this.options = new OptionsWaiter(this.app);
|
||||
this.highlighter = new HighlighterWaiter(this.app);
|
||||
this.seasonal = new SeasonalWaiter(this.app, this);
|
||||
|
||||
|
||||
// Object to store dynamic handlers to fire on elements that may not exist yet
|
||||
this.dynamicHandlers = {};
|
||||
|
||||
|
||||
this.initialiseEventListeners();
|
||||
};
|
||||
|
||||
|
@ -71,7 +71,7 @@ Manager.prototype.initialiseEventListeners = function() {
|
|||
window.addEventListener("focus", this.window.windowFocus.bind(this.window));
|
||||
window.addEventListener("statechange", this.app.stateChange.bind(this.app));
|
||||
window.addEventListener("popstate", this.app.popState.bind(this.app));
|
||||
|
||||
|
||||
// Controls
|
||||
document.getElementById("bake").addEventListener("click", this.controls.bakeClick.bind(this.controls));
|
||||
document.getElementById("auto-bake").addEventListener("change", this.controls.autoBakeChange.bind(this.controls));
|
||||
|
@ -88,7 +88,7 @@ Manager.prototype.initialiseEventListeners = function() {
|
|||
document.getElementById("load-button").addEventListener("click", this.controls.loadButtonClick.bind(this.controls));
|
||||
document.getElementById("support").addEventListener("click", this.controls.supportButtonClick.bind(this.controls));
|
||||
this.addMultiEventListener("#save-text", "keyup paste", this.controls.saveTextChange, this.controls);
|
||||
|
||||
|
||||
// Operations
|
||||
this.addMultiEventListener("#search", "keyup paste search", this.ops.searchOperations, this.ops);
|
||||
this.addDynamicListener(".op-list li.operation", "dblclick", this.ops.operationDblclick, this.ops);
|
||||
|
@ -99,7 +99,7 @@ Manager.prototype.initialiseEventListeners = function() {
|
|||
this.addDynamicListener(".op-list .op-icon", "mouseleave", this.ops.opIconMouseleave, this.ops);
|
||||
this.addDynamicListener(".op-list", "oplistcreate", this.ops.opListCreate, this.ops);
|
||||
this.addDynamicListener("li.operation", "operationadd", this.recipe.opAdd.bind(this.recipe));
|
||||
|
||||
|
||||
// Recipe
|
||||
this.addDynamicListener(".arg", "keyup", this.recipe.ingChange, this.recipe);
|
||||
this.addDynamicListener(".arg", "change", this.recipe.ingChange, this.recipe);
|
||||
|
@ -109,7 +109,7 @@ Manager.prototype.initialiseEventListeners = function() {
|
|||
this.addDynamicListener("#rec-list li.operation > div", "dblclick", this.recipe.operationChildDblclick, this.recipe);
|
||||
this.addDynamicListener("#rec-list .input-group .dropdown-menu a", "click", this.recipe.dropdownToggleClick, this.recipe);
|
||||
this.addDynamicListener("#rec-list", "operationremove", this.recipe.opRemove.bind(this.recipe));
|
||||
|
||||
|
||||
// Input
|
||||
this.addMultiEventListener("#input-text", "keyup paste", this.input.inputChange, this.input);
|
||||
document.getElementById("reset-layout").addEventListener("click", this.app.resetLayout.bind(this.app));
|
||||
|
@ -121,7 +121,7 @@ Manager.prototype.initialiseEventListeners = function() {
|
|||
document.getElementById("input-text").addEventListener("mouseup", this.highlighter.inputMouseup.bind(this.highlighter));
|
||||
document.getElementById("input-text").addEventListener("mousemove", this.highlighter.inputMousemove.bind(this.highlighter));
|
||||
this.addMultiEventListener("#input-text", "mousedown dblclick select", this.highlighter.inputMousedown, this.highlighter);
|
||||
|
||||
|
||||
// Output
|
||||
document.getElementById("save-to-file").addEventListener("click", this.output.saveClick.bind(this.output));
|
||||
document.getElementById("switch").addEventListener("click", this.output.switchClick.bind(this.output));
|
||||
|
@ -134,7 +134,7 @@ Manager.prototype.initialiseEventListeners = function() {
|
|||
document.getElementById("output-html").addEventListener("mousemove", this.highlighter.outputHtmlMousemove.bind(this.highlighter));
|
||||
this.addMultiEventListener("#output-text", "mousedown dblclick select", this.highlighter.outputMousedown, this.highlighter);
|
||||
this.addMultiEventListener("#output-html", "mousedown dblclick select", this.highlighter.outputHtmlMousedown, this.highlighter);
|
||||
|
||||
|
||||
// Options
|
||||
document.getElementById("options").addEventListener("click", this.options.optionsClick.bind(this.options));
|
||||
document.getElementById("reset-options").addEventListener("click", this.options.resetOptionsClick.bind(this.options));
|
||||
|
@ -143,7 +143,7 @@ Manager.prototype.initialiseEventListeners = function() {
|
|||
this.addDynamicListener(".option-item input[type=number]", "keyup", this.options.numberChange, this.options);
|
||||
this.addDynamicListener(".option-item input[type=number]", "change", this.options.numberChange, this.options);
|
||||
this.addDynamicListener(".option-item select", "change", this.options.selectChange, this.options);
|
||||
|
||||
|
||||
// Misc
|
||||
document.getElementById("alert-close").addEventListener("click", this.app.alertCloseClick.bind(this.app));
|
||||
};
|
||||
|
@ -231,7 +231,7 @@ Manager.prototype.addDynamicListener = function(selector, eventType, callback, s
|
|||
selector: selector,
|
||||
callback: callback.bind(scope || this)
|
||||
};
|
||||
|
||||
|
||||
if (this.dynamicHandlers.hasOwnProperty(eventType)) {
|
||||
// Listener already exists, add new handler to the appropriate list
|
||||
this.dynamicHandlers[eventType].push(eventConfig);
|
||||
|
@ -256,7 +256,7 @@ Manager.prototype.dynamicListenerHandler = function(e) {
|
|||
e.target.mozMatchesSelector ||
|
||||
e.target.msMatchesSelector ||
|
||||
e.target.oMatchesSelector;
|
||||
|
||||
|
||||
for (var i = 0; i < handlers.length; i++) {
|
||||
if (matches && e.target[matches.name](handlers[i].selector)) {
|
||||
handlers[i].callback(e);
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
var OperationsWaiter = function(app, manager) {
|
||||
this.app = app;
|
||||
this.manager = manager;
|
||||
|
||||
|
||||
this.options = {};
|
||||
this.removeIntent = false;
|
||||
};
|
||||
|
@ -28,7 +28,7 @@ var OperationsWaiter = function(app, manager) {
|
|||
*/
|
||||
OperationsWaiter.prototype.searchOperations = function(e) {
|
||||
var ops, selected;
|
||||
|
||||
|
||||
if (e.type === "search") { // Search
|
||||
e.preventDefault();
|
||||
ops = document.querySelectorAll("#search-results li");
|
||||
|
@ -40,7 +40,7 @@ OperationsWaiter.prototype.searchOperations = function(e) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (e.keyCode === 13) { // Return
|
||||
e.preventDefault();
|
||||
} else if (e.keyCode === 40) { // Down
|
||||
|
@ -69,21 +69,21 @@ OperationsWaiter.prototype.searchOperations = function(e) {
|
|||
var searchResultsEl = document.getElementById("search-results"),
|
||||
el = e.target,
|
||||
str = el.value;
|
||||
|
||||
|
||||
while (searchResultsEl.firstChild) {
|
||||
$(searchResultsEl.firstChild).popover("destroy");
|
||||
searchResultsEl.removeChild(searchResultsEl.firstChild);
|
||||
}
|
||||
|
||||
|
||||
$("#categories .in").collapse("hide");
|
||||
if (str) {
|
||||
var matchedOps = this.filterOperations(str, true),
|
||||
matchedOpsHtml = "";
|
||||
|
||||
|
||||
for (var i = 0; i < matchedOps.length; i++) {
|
||||
matchedOpsHtml += matchedOps[i].toStubHtml();
|
||||
}
|
||||
|
||||
|
||||
searchResultsEl.innerHTML = matchedOpsHtml;
|
||||
searchResultsEl.dispatchEvent(this.manager.oplistcreate);
|
||||
}
|
||||
|
@ -102,20 +102,20 @@ OperationsWaiter.prototype.searchOperations = function(e) {
|
|||
OperationsWaiter.prototype.filterOperations = function(searchStr, highlight) {
|
||||
var matchedOps = [],
|
||||
matchedDescs = [];
|
||||
|
||||
|
||||
searchStr = searchStr.toLowerCase();
|
||||
|
||||
|
||||
for (var opName in this.app.operations) {
|
||||
var op = this.app.operations[opName],
|
||||
namePos = opName.toLowerCase().indexOf(searchStr),
|
||||
descPos = op.description.toLowerCase().indexOf(searchStr);
|
||||
|
||||
|
||||
if (namePos >= 0 || descPos >= 0) {
|
||||
var operation = new HTMLOperation(opName, this.app.operations[opName], this.app, this.manager);
|
||||
if (highlight) {
|
||||
operation.highlightSearchString(searchStr, namePos, descPos);
|
||||
}
|
||||
|
||||
|
||||
if (namePos < 0) {
|
||||
matchedOps.push(operation);
|
||||
} else {
|
||||
|
@ -123,7 +123,7 @@ OperationsWaiter.prototype.filterOperations = function(searchStr, highlight) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return matchedDescs.concat(matchedOps);
|
||||
};
|
||||
|
||||
|
@ -165,7 +165,7 @@ OperationsWaiter.prototype.opListCreate = function(e) {
|
|||
*/
|
||||
OperationsWaiter.prototype.operationDblclick = function(e) {
|
||||
var li = e.target;
|
||||
|
||||
|
||||
this.manager.recipe.addOperation(li.textContent);
|
||||
this.app.autoBake();
|
||||
};
|
||||
|
@ -180,23 +180,23 @@ OperationsWaiter.prototype.operationDblclick = function(e) {
|
|||
OperationsWaiter.prototype.editFavouritesClick = function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
|
||||
// Add favourites to modal
|
||||
var favCat = this.app.categories.filter(function(c) {
|
||||
return c.name === "Favourites";
|
||||
})[0];
|
||||
|
||||
|
||||
var html = "";
|
||||
for (var i = 0; i < favCat.ops.length; i++) {
|
||||
var opName = favCat.ops[i];
|
||||
var operation = new HTMLOperation(opName, this.app.operations[opName], this.app, this.manager);
|
||||
html += operation.toStubHtml(true);
|
||||
}
|
||||
|
||||
|
||||
var editFavouritesList = document.getElementById("edit-favourites-list");
|
||||
editFavouritesList.innerHTML = html;
|
||||
this.removeIntent = false;
|
||||
|
||||
|
||||
var editableList = Sortable.create(editFavouritesList, {
|
||||
filter: ".remove-icon",
|
||||
onFilter: function (evt) {
|
||||
|
@ -210,15 +210,15 @@ OperationsWaiter.prototype.editFavouritesClick = function(e) {
|
|||
if (this.removeIntent) evt.item.remove();
|
||||
}.bind(this),
|
||||
});
|
||||
|
||||
|
||||
Sortable.utils.on(editFavouritesList, "dragleave", function() {
|
||||
this.removeIntent = true;
|
||||
}.bind(this));
|
||||
|
||||
|
||||
Sortable.utils.on(editFavouritesList, "dragover", function() {
|
||||
this.removeIntent = false;
|
||||
}.bind(this));
|
||||
|
||||
|
||||
$("#edit-favourites-list [data-toggle=popover]").popover();
|
||||
$("#favourites-modal").modal();
|
||||
};
|
||||
|
@ -231,7 +231,7 @@ OperationsWaiter.prototype.editFavouritesClick = function(e) {
|
|||
OperationsWaiter.prototype.saveFavouritesClick = function() {
|
||||
var favouritesList = [],
|
||||
favs = document.querySelectorAll("#edit-favourites-list li");
|
||||
|
||||
|
||||
for (var i = 0; i < favs.length; i++) {
|
||||
favouritesList.push(favs[i].textContent);
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ OperationsWaiter.prototype.opIconMouseover = function(e) {
|
|||
OperationsWaiter.prototype.opIconMouseleave = function(e) {
|
||||
var opEl = e.target.parentNode,
|
||||
toEl = e.toElement || e.relatedElement;
|
||||
|
||||
|
||||
if (e.target.getAttribute("data-toggle") === "popover" && toEl === opEl) {
|
||||
$(opEl).popover("show");
|
||||
}
|
||||
|
|
|
@ -23,11 +23,11 @@ OptionsWaiter.prototype.load = function(options) {
|
|||
size: "small",
|
||||
animate: false,
|
||||
});
|
||||
|
||||
|
||||
for (var option in options) {
|
||||
this.app.options[option] = options[option];
|
||||
}
|
||||
|
||||
|
||||
// Set options to match object
|
||||
var cboxes = document.querySelectorAll("#options-body input[type=checkbox]");
|
||||
for (var i = 0; i < cboxes.length; i++) {
|
||||
|
@ -39,7 +39,7 @@ OptionsWaiter.prototype.load = function(options) {
|
|||
nboxes[i].value = this.app.options[nboxes[i].getAttribute("option")];
|
||||
nboxes[i].dispatchEvent(new CustomEvent("change", {bubbles: true}));
|
||||
}
|
||||
|
||||
|
||||
var selects = document.querySelectorAll("#options-body select");
|
||||
for (i = 0; i < selects.length; i++) {
|
||||
selects[i].value = this.app.options[selects[i].getAttribute("option")];
|
||||
|
@ -76,7 +76,7 @@ OptionsWaiter.prototype.resetOptionsClick = function() {
|
|||
OptionsWaiter.prototype.switchChange = function(e, state) {
|
||||
var el = e.target,
|
||||
option = el.getAttribute("option");
|
||||
|
||||
|
||||
this.app.options[option] = state;
|
||||
localStorage.setItem("options", JSON.stringify(this.app.options));
|
||||
};
|
||||
|
@ -91,7 +91,7 @@ OptionsWaiter.prototype.switchChange = function(e, state) {
|
|||
OptionsWaiter.prototype.numberChange = function(e) {
|
||||
var el = e.target,
|
||||
option = el.getAttribute("option");
|
||||
|
||||
|
||||
this.app.options[option] = parseInt(el.value, 10);
|
||||
localStorage.setItem("options", JSON.stringify(this.app.options));
|
||||
};
|
||||
|
@ -106,7 +106,7 @@ OptionsWaiter.prototype.numberChange = function(e) {
|
|||
OptionsWaiter.prototype.selectChange = function(e) {
|
||||
var el = e.target,
|
||||
option = el.getAttribute("option");
|
||||
|
||||
|
||||
this.app.options[option] = el.value;
|
||||
localStorage.setItem("options", JSON.stringify(this.app.options));
|
||||
};
|
||||
|
@ -121,7 +121,7 @@ OptionsWaiter.prototype.setWordWrap = function() {
|
|||
document.getElementById("output-html").classList.remove("word-wrap");
|
||||
document.getElementById("input-highlighter").classList.remove("word-wrap");
|
||||
document.getElementById("output-highlighter").classList.remove("word-wrap");
|
||||
|
||||
|
||||
if (!this.app.options.wordWrap) {
|
||||
document.getElementById("input-text").classList.add("word-wrap");
|
||||
document.getElementById("output-text").classList.add("word-wrap");
|
||||
|
|
|
@ -43,10 +43,10 @@ OutputWaiter.prototype.set = function(dataStr, type, duration) {
|
|||
outputHtml.style.display = "block";
|
||||
outputHighlighter.display = "none";
|
||||
inputHighlighter.display = "none";
|
||||
|
||||
|
||||
outputText.value = "";
|
||||
outputHtml.innerHTML = dataStr;
|
||||
|
||||
|
||||
// Execute script sections
|
||||
var scriptElements = outputHtml.querySelectorAll("script");
|
||||
for (var i = 0; i < scriptElements.length; i++) {
|
||||
|
@ -61,11 +61,11 @@ OutputWaiter.prototype.set = function(dataStr, type, duration) {
|
|||
outputHtml.style.display = "none";
|
||||
outputHighlighter.display = "block";
|
||||
inputHighlighter.display = "block";
|
||||
|
||||
|
||||
outputText.value = Utils.printable(dataStr, true);
|
||||
outputHtml.innerHTML = "";
|
||||
}
|
||||
|
||||
|
||||
this.manager.highlighter.removeHighlights();
|
||||
var lines = dataStr.count("\n") + 1;
|
||||
this.setOutputInfo(dataStr.length, lines, duration);
|
||||
|
@ -82,11 +82,11 @@ OutputWaiter.prototype.set = function(dataStr, type, duration) {
|
|||
OutputWaiter.prototype.setOutputInfo = function(length, lines, duration) {
|
||||
var width = length.toString().length;
|
||||
width = width < 4 ? 4 : width;
|
||||
|
||||
|
||||
var lengthStr = Utils.pad(length.toString(), width, " ").replace(/ /g, " ");
|
||||
var linesStr = Utils.pad(lines.toString(), width, " ").replace(/ /g, " ");
|
||||
var timeStr = Utils.pad(duration.toString() + "ms", width, " ").replace(/ /g, " ");
|
||||
|
||||
|
||||
document.getElementById("output-info").innerHTML = "time: " + timeStr +
|
||||
"<br>length: " + lengthStr +
|
||||
"<br>lines: " + linesStr;
|
||||
|
@ -105,7 +105,7 @@ OutputWaiter.prototype.adjustWidth = function() {
|
|||
switchIO = document.getElementById("switch"),
|
||||
undoSwitch = document.getElementById("undo-switch"),
|
||||
maximiseOutput = document.getElementById("maximise-output");
|
||||
|
||||
|
||||
if (output.clientWidth < 680) {
|
||||
saveToFile.childNodes[1].nodeValue = "";
|
||||
switchIO.childNodes[1].nodeValue = "";
|
||||
|
@ -128,16 +128,16 @@ OutputWaiter.prototype.adjustWidth = function() {
|
|||
OutputWaiter.prototype.saveClick = function() {
|
||||
var data = Utils.toBase64(this.app.dishStr),
|
||||
filename = window.prompt("Please enter a filename:", "download.dat");
|
||||
|
||||
|
||||
if (filename) {
|
||||
var el = document.createElement("a");
|
||||
el.setAttribute("href", "data:application/octet-stream;base64;charset=utf-8," + data);
|
||||
el.setAttribute("download", filename);
|
||||
|
||||
|
||||
// Firefox requires that the element be added to the DOM before it can be clicked
|
||||
el.style.display = "none";
|
||||
document.body.appendChild(el);
|
||||
|
||||
|
||||
el.click();
|
||||
el.remove();
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ var RecipeWaiter = function(app, manager) {
|
|||
*/
|
||||
RecipeWaiter.prototype.initialiseOperationDragNDrop = function() {
|
||||
var recList = document.getElementById("rec-list");
|
||||
|
||||
|
||||
|
||||
|
||||
// Recipe list
|
||||
Sortable.create(recList, {
|
||||
group: "recipe",
|
||||
|
@ -42,11 +42,11 @@ RecipeWaiter.prototype.initialiseOperationDragNDrop = function() {
|
|||
}
|
||||
}.bind(this)
|
||||
});
|
||||
|
||||
|
||||
Sortable.utils.on(recList, "dragover", function() {
|
||||
this.removeIntent = false;
|
||||
}.bind(this));
|
||||
|
||||
|
||||
Sortable.utils.on(recList, "dragleave", function() {
|
||||
this.removeIntent = true;
|
||||
this.app.progress = 0;
|
||||
|
@ -58,7 +58,7 @@ RecipeWaiter.prototype.initialiseOperationDragNDrop = function() {
|
|||
|
||||
this.removeIntent = !recList.contains(target);
|
||||
}.bind(this));
|
||||
|
||||
|
||||
// Favourites category
|
||||
document.querySelector("#categories a").addEventListener("dragover", this.favDragover.bind(this));
|
||||
document.querySelector("#categories a").addEventListener("dragleave", this.favDragleave.bind(this));
|
||||
|
@ -106,16 +106,16 @@ RecipeWaiter.prototype.opSortEnd = function(evt) {
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Reinitialise the popover on the original element in the ops list because for some reason it
|
||||
// gets destroyed and recreated.
|
||||
$(evt.clone).popover();
|
||||
$(evt.clone).children("[data-toggle=popover]").popover();
|
||||
|
||||
|
||||
if (evt.item.parentNode.id !== "rec-list") {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
this.buildRecipeOperation(evt.item);
|
||||
evt.item.dispatchEvent(this.manager.operationadd);
|
||||
};
|
||||
|
@ -131,7 +131,7 @@ RecipeWaiter.prototype.opSortEnd = function(evt) {
|
|||
RecipeWaiter.prototype.favDragover = function(e) {
|
||||
if (e.dataTransfer.effectAllowed !== "move")
|
||||
return false;
|
||||
|
||||
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
if (e.target.className && e.target.className.indexOf("category-title") > -1) {
|
||||
|
@ -170,7 +170,7 @@ RecipeWaiter.prototype.favDrop = function(e) {
|
|||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
e.target.classList.remove("favourites-hover");
|
||||
|
||||
|
||||
var opName = e.dataTransfer.getData("Text");
|
||||
this.app.addFavourite(opName);
|
||||
};
|
||||
|
@ -195,7 +195,7 @@ RecipeWaiter.prototype.ingChange = function() {
|
|||
*/
|
||||
RecipeWaiter.prototype.disableClick = function(e) {
|
||||
var icon = e.target;
|
||||
|
||||
|
||||
if (icon.getAttribute("disabled") === "false") {
|
||||
icon.setAttribute("disabled", "true");
|
||||
icon.classList.add("disable-icon-selected");
|
||||
|
@ -205,7 +205,7 @@ RecipeWaiter.prototype.disableClick = function(e) {
|
|||
icon.classList.remove("disable-icon-selected");
|
||||
icon.parentNode.parentNode.classList.remove("disabled");
|
||||
}
|
||||
|
||||
|
||||
this.app.progress = 0;
|
||||
window.dispatchEvent(this.manager.statechange);
|
||||
};
|
||||
|
@ -228,7 +228,7 @@ RecipeWaiter.prototype.breakpointClick = function(e) {
|
|||
bp.setAttribute("break", "false");
|
||||
bp.classList.remove("breakpoint-selected");
|
||||
}
|
||||
|
||||
|
||||
window.dispatchEvent(this.manager.statechange);
|
||||
};
|
||||
|
||||
|
@ -267,13 +267,13 @@ RecipeWaiter.prototype.operationChildDblclick = function(e) {
|
|||
RecipeWaiter.prototype.getConfig = function() {
|
||||
var config = [], ingredients, ingList, disabled, bp, item,
|
||||
operations = document.querySelectorAll("#rec-list li.operation");
|
||||
|
||||
|
||||
for (var i = 0; i < operations.length; i++) {
|
||||
ingredients = [];
|
||||
disabled = operations[i].querySelector(".disable-icon");
|
||||
bp = operations[i].querySelector(".breakpoint");
|
||||
ingList = operations[i].querySelectorAll(".arg");
|
||||
|
||||
|
||||
for (var j = 0; j < ingList.length; j++) {
|
||||
if (ingList[j].getAttribute("type") === "checkbox") {
|
||||
// checkbox
|
||||
|
@ -289,23 +289,23 @@ RecipeWaiter.prototype.getConfig = function() {
|
|||
ingredients[j] = ingList[j].value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
item = {
|
||||
op: operations[i].querySelector(".arg-title").textContent,
|
||||
args: ingredients
|
||||
};
|
||||
|
||||
|
||||
if (disabled && disabled.getAttribute("disabled") === "true") {
|
||||
item.disabled = true;
|
||||
}
|
||||
|
||||
|
||||
if (bp && bp.getAttribute("break") === "true") {
|
||||
item.breakpoint = true;
|
||||
}
|
||||
|
||||
|
||||
config.push(item);
|
||||
}
|
||||
|
||||
|
||||
return config;
|
||||
};
|
||||
|
||||
|
@ -337,11 +337,11 @@ RecipeWaiter.prototype.buildRecipeOperation = function(el) {
|
|||
var opName = el.textContent;
|
||||
var op = new HTMLOperation(opName, this.app.operations[opName], this.app, this.manager);
|
||||
el.innerHTML = op.toFullHtml();
|
||||
|
||||
|
||||
if (this.app.operations[opName].flowControl) {
|
||||
el.classList.add("flow-control-op");
|
||||
}
|
||||
|
||||
|
||||
// Disable auto-bake if this is a manual op - this should be moved to the 'operationadd'
|
||||
// handler after event restructuring
|
||||
if (op.manualBake && this.app.autoBake_) {
|
||||
|
@ -359,12 +359,12 @@ RecipeWaiter.prototype.buildRecipeOperation = function(el) {
|
|||
*/
|
||||
RecipeWaiter.prototype.addOperation = function(name) {
|
||||
var item = document.createElement("li");
|
||||
|
||||
|
||||
item.classList.add("operation");
|
||||
item.innerHTML = name;
|
||||
this.buildRecipeOperation(item);
|
||||
document.getElementById("rec-list").appendChild(item);
|
||||
|
||||
|
||||
item.dispatchEvent(this.manager.operationadd);
|
||||
return item;
|
||||
};
|
||||
|
@ -393,7 +393,7 @@ RecipeWaiter.prototype.clearRecipe = function() {
|
|||
RecipeWaiter.prototype.dropdownToggleClick = function(e) {
|
||||
var el = e.target,
|
||||
button = el.parentNode.parentNode.previousSibling;
|
||||
|
||||
|
||||
button.innerHTML = el.textContent + " <span class='caret'></span>";
|
||||
this.ingChange();
|
||||
};
|
||||
|
|
|
@ -227,7 +227,7 @@ SeasonalWaiter.treeWalk = (function() {
|
|||
while (node && node !== parent) {
|
||||
if (allNodes || node.nodeType === 1) {
|
||||
if (fn(node) === false) {
|
||||
return(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// If it's an element &&
|
||||
|
|
|
@ -22,7 +22,7 @@ var main = function() {
|
|||
"Entropy",
|
||||
"Fork"
|
||||
];
|
||||
|
||||
|
||||
var defaultOptions = {
|
||||
updateUrl : true,
|
||||
showHighlighter : true,
|
||||
|
|
Loading…
Reference in a new issue