Allow to display binary content using hex-editor like interface
<!DOCTYPE html>
<html>
<body>
</body>
</html>
const content = await (await fetch(dataApiUrl)).blob();
const viewer = new HexaViewer('my-viewer', { content });
document.body.append(viewer.table);
<!DOCTYPE html>
<html>
<body>
<input type="file" id=myFile>
<hr>
</body>
</html>
var viewer;
myFile.addEventListener('change', function (event) {
if (!viewer) {
viewer = new HexaViewer('my-viewer');
document.body.append(viewer.table);
}
const [file] = event.target.files;
if (!file) return;
viewer.reset();
viewer.load(file);
});
Kind: global class
-
- new HexaViewer(id, [options])
- instance
- .load([content], [base64], [mime]) ⇒
Promise
- .reset()
- .load([content], [base64], [mime]) ⇒
- static
- .TABLE_STYLE :
object
- .bytesToHexa(byte) ⇒
string
- .bytesToAscii(byte) ⇒
string
- .TABLE_STYLE :
Param | Type | Description |
---|---|---|
id | string |
Viewer DOM id, to ease CSS styling |
[options] | object |
Optional properties |
[options.style] | object |
Default to {fontFamily: 'Source Code Pro,Menlo,Consolas,PT Mono,Liberation Mono,monospace', fontSize: 14, lineHeight: 20, whiteSpace: 'pre'} |
[options.content] | File | Blob | string |
binary content to display, may be a base64 encoded string |
[options.base64] | boolean |
flag to declare the content as base64 encoded |
[options.mime] | string |
Binary content media type. default to application/octet-stream |
Load the binary content and build the Viewer table
Kind: instance method of HexaViewer
Param | Type | Description |
---|---|---|
[content] | Blob | string |
binary content to display, may be a base64 encoded string |
[base64] | boolean |
flag to declare the content as base64 encoded |
[mime] | string |
Binary content media type. default to application/octet-stream |
Clear the viewer table
Kind: instance method of HexaViewer
Table style used by default by the constructor
Default to {fontFamily: 'Source Code Pro,Menlo,Consolas,PT Mono,Liberation Mono,monospace', fontSize: 14, lineHeight: 20, whiteSpace: 'pre'}
Kind: static method of HexaViewer
Param | Type |
---|---|
byte | number |
Kind: static method of HexaViewer
Param | Type |
---|---|
byte | number |
MIT