Навел красоту в hexdump, почистил код

This commit is contained in:
saber-nyan 2019-05-06 19:48:21 +03:00
parent 567946ac2a
commit 76d524ca06
No known key found for this signature in database
GPG Key ID: 7B069E9C295E6B4A
4 changed files with 8 additions and 63 deletions

View File

@ -19,23 +19,7 @@ export default {
props: ['servicePort', 'streamId',],
data: function () {
return {
packets: [
// {
// id: 39,
// timestamp: 1556555231394,
// content: 'wuAAUEtPbKUAAAAAoAL///jUAAACBAW0BAIIChMcPpEAAAAAAQMDBw==',
// },
// {
// id: 40,
// timestamp: 1556555231392,
// content: 'AFDC4CVNkpxLT2ymoBJxIIKHAAACBAW0BAIICoTZHMUTHD6RAQMDBw==',
// },
// {
// id: 41,
// timestamp: 1556555231396,
// content: '0KLQtdGB0YLQvtCy0LDRjyDRgdGC0YDQvtC60LAuLi4=',
// },
],
packets: [],
}
},
watch: {

View File

@ -42,12 +42,7 @@ export default {
name: "Navbar",
data: function () {
return {
ctfServices: [
// {
// port: 1337,
// name: 'ShittyService',
// },
],
ctfServices: [],
}
},
methods: {

View File

@ -9,8 +9,6 @@
<script>
// import {Hexdump,} from '@/components/hexdump.js' // Why the fuck is this working, Babel?!?!
export default {
name: 'Packet',
props: ['id', 'content', 'timestamp',],
@ -21,16 +19,16 @@ export default {
const hex = "0123456789ABCDEF";
for (let b = 0; b < buffer.length; b += blockSize) {
let block = buffer.slice(b, Math.min(b + blockSize, buffer.length));
let addr = ("0000" + b.toString(10)).slice(-4);
let codes = block.split('').map(function (ch) {
let addr = ("0000000000" + b.toString(10)).slice(-10);
let codes = block.split('').map(ch => {
let code = ch.charCodeAt(0);
return " " + hex[(0xF0 & code) >> 4] + hex[0x0F & code];
}).join("");
codes += " ".repeat(blockSize - block.length);
codes += " ..".repeat(blockSize - block.length);
// eslint-disable-next-line no-control-regex
let chars = block.replace(/[\x00-\x1F\x20]/g, '.');
let chars = block.replace(/[\x00-\x1F]/g, '.');
chars += " ".repeat(blockSize - block.length);
lines.push(addr + " " + codes + " " + chars);
lines.push(addr + ":" + codes + " |" + chars + "|");
}
return lines.join("\n");
},
@ -42,33 +40,6 @@ export default {
return this.hexdump(dataString, this.$store.state.hexdumpBlockSize);
},
},
// mounted() {
//
// this.hex = new Hexdump(dataString, { // TODO: в настройки
// container: 'hexdump-' + this.$props.id,
// base: 'hex',
// width: 16,
// ascii: false,
// byteGrouping: 1,
// html: false,
// // endian: 'little',
// lineNumber: true,
// nonPrintable: '?',
// style: {
// lineNumberLeft: '',
// lineNumberRight: ':',
// stringLeft: '|',
// stringRight: '|',
// hexLeft: '',
// hexRight: '',
// hexNull: '.g',
// stringNull: ' ',
// },
// });
// },
// beforeDestroy() {
// delete this.hex;
// },
}
</script>
<style scoped>

View File

@ -24,12 +24,7 @@ export default {
props: ['servicePort', 'streamId',],
data: function () {
return {
streams: [
// {
// id: 111,
// time: 1556411080,
// },
],
streams: [],
}
},
watch: {