{
"auto_complete":
{
"selected_items":
[
[
"file",
"file"
],
[
"read",
"readBlob"
],
[
"otp",
"outputLine"
],
[
"binary",
"binaryLength"
],
[
"generate",
"generateBinary"
]
]
},
"buffers":
[
{
"file": "partials/dump.html",
"settings":
{
"buffer_size": 592,
"line_ending": "Unix"
}
},
{
"file": "index.html",
"settings":
{
"buffer_size": 1526,
"line_ending": "Unix"
}
},
{
"contents": "'use strict';\n\nfunction MainController($scope, $routeParams) {\n $scope.allowedLengths = [4, 8, 16, 32, 64, 128, 256];\n $scope.binaryLength = 64;\n $scope.binary = generateBinary($scope.binaryLength);\n $scope.parts = [];\n $scope.hex = \"\";\n \n $scope.displayResults = function () {\n return $scope.hex.length > 0;\n };\n \n $scope.generate = function () {\n $scope.binary = generateBinary($scope.binaryLength);\n $scope.parts = [];\n $scope.hex = \"\";\n \n return false;\n };\n \n $scope.solve = function () {\n $scope.parts = [];\n $scope.hex = \"\";\n \n var original = $scope.binary;\n \n while (original.length > 0) {\n // Find the 16 bytes we need.\n var part = original.substr(-4);\n var character = binaryToHex(part);\n \n // Divvy this stuff up.\n $scope.parts.push({ \"binary\": part, \"hex\": character });\n $scope.hex = character + $scope.hex;\n \n // Remove the last four.\n original = original.substr(0, original.length - 4);\n }\n \n return false;\n };\n}\n\nfunction DumpController($scope, $routeParams) {\n $scope.columns = 16;\n $scope.fileApi = false;\n $scope.instructions = \"Drop a file here!\";\n $scope.uppercaseHex = false;\n $scope.file = null;\n $scope.lastLine = 0;\n \n $scope.isProcessing = function () {\n\n };\n\n function outputLine(bytes) {\n // Add a break line.\n $(\"#lineNumbers, #lineHex, #lineCharacters\").append(\"
\");\n \n // Get the line number.\n var lineNumber = padLeft($scope.lastLine.toString(16), 6);\n if ($scope.uppercaseHex) {\n lineNumber = lineNumber.toUpperCase();\n }\n $(\"#lineNumbers\").append(lineNumber + \":\");\n \n for (var i = 0; i < bytes.length; i++) {\n // Get the hex string.\n var hexString = padLeft(bytes[i].toString(16), 2);\n if ($scope.uppercaseHex) {\n hexString = hexString.toUpperCase();\n }\n \n // Output the remaining lines.\n $(\"#lineHex\").append(hexString + \" \");\n $(\"#lineCharacters\").append(String.fromCharCode(bytes[i]));\n }\n\n // Increment to next line.\n $scope.lastLine++;\n }\n\n function readBlob(start, stop) {\n if (start < $scope.file.size) {\n var reader = new FileReader();\n \n // Closure to capture the file information.\n reader.onload = function(evt) {\n var bytes = new Uint8Array(evt.target.result);\n outputLine(bytes);\n readBlob(stop, stop + $scope.columns);\n }\n\n var blob = $scope.file.webkitSlice(start, stop);\n reader.readAsArrayBuffer(blob);\n }\n }\n \n // Check for the various File API support.\n if (window.File && window.FileReader && window.FileList && window.Blob) {\n // Great success! All the File APIs are supported.\n $(\"#drop-zone\").bind(\"dragover\", function (e) {\n e.stopPropagation();\n e.preventDefault();\n e.originalEvent.dataTransfer.dropEffect = 'copy';\n });\n \n $(\"#drop-zone\").bind(\"drop\", function(e) {\n e.stopPropagation();\n e.preventDefault();\n \n // Remove previous output.\n $(\"#lineNumbers, #lineHex, #lineCharacters\").empty();\n $scope.lastLine = 0;\n $scope.file = null;\n\n //$(\"#drop-zone\").append($(\"