mirror of https://github.com/MISP/MISP
commit
5a7fe2a576
|
@ -64,9 +64,8 @@ switch ($object['type']) {
|
|||
break;
|
||||
|
||||
case 'hex':
|
||||
$sigDisplay = str_replace("\r", '', $sigDisplay);
|
||||
echo '<span class="hex-value" title="' . __('Hexadecimal representation') . '">' . nl2br(h($sigDisplay)) . '</span> ';
|
||||
echo '<span role="button" tabindex="0" aria-label="' . __('Switch to binary representation') . '" class="icon-repeat hex-value-convert useCursorPointer" title="' . __('Switch to binary representation') . '"></span>';
|
||||
echo '<span class="hex-value" title="' . __('Hexadecimal representation') . '">' . h($sigDisplay) . '</span> ';
|
||||
echo '<span role="button" tabindex="0" aria-label="' . __('Switch to binary representation') . '" class="fas fa-redo hex-value-convert useCursorPointer" title="' . __('Switch to binary representation') . '"></span>';
|
||||
break;
|
||||
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
|
|
|
@ -117,32 +117,6 @@
|
|||
screenshotPopup($(this).attr('src'), $(this).attr('title'));
|
||||
});
|
||||
});
|
||||
$('.hex-value-convert').click(function() {
|
||||
var val = $(this).parent().children(':first-child').text();
|
||||
if ($(this).parent().children(':first-child').attr('data-original-title') == 'Hexadecimal representation') {
|
||||
var bin = [];
|
||||
var temp;
|
||||
val.split('').forEach(function(entry) {
|
||||
temp = parseInt(entry, 16).toString(2);
|
||||
bin.push(Array(5 - (temp.length)).join('0') + temp);
|
||||
});
|
||||
bin = bin.join(' ');
|
||||
$(this).parent().children(':first-child').text(bin);
|
||||
$(this).parent().children(':first-child').attr('data-original-title', __('Binary representation'));
|
||||
$(this).parent().children(':nth-child(2)').attr('data-original-title', __('Switch to hexadecimal representation'));
|
||||
$(this).parent().children(':nth-child(2)').attr('aria-label', __('Switch to hexadecimal representation'));
|
||||
} else {
|
||||
val = val.split(' ');
|
||||
hex = '';
|
||||
val.forEach(function(entry) {
|
||||
hex += parseInt(entry , 2).toString(16).toUpperCase();
|
||||
});
|
||||
$(this).parent().children(':first-child').text(hex);
|
||||
$(this).parent().children(':first-child').attr('data-original-title', __('Hexadecimal representation'));
|
||||
$(this).parent().children(':nth-child(2)').attr('data-original-title', __('Switch to binary representation'));
|
||||
$(this).parent().children(':nth-child(2)').attr('aria-label', __('Switch to binary representation'));
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
echo $this->Js->writeBuffer();
|
||||
|
|
|
@ -117,32 +117,6 @@
|
|||
screenshotPopup($(this).attr('src'), $(this).attr('title'));
|
||||
});
|
||||
});
|
||||
$('.hex-value-convert').click(function() {
|
||||
var val = $(this).parent().children(':first-child').text();
|
||||
if ($(this).parent().children(':first-child').attr('data-original-title') == 'Hexadecimal representation') {
|
||||
var bin = [];
|
||||
var temp;
|
||||
val.split('').forEach(function(entry) {
|
||||
temp = parseInt(entry, 16).toString(2);
|
||||
bin.push(Array(5 - (temp.length)).join('0') + temp);
|
||||
});
|
||||
bin = bin.join(' ');
|
||||
$(this).parent().children(':first-child').text(bin);
|
||||
$(this).parent().children(':first-child').attr('data-original-title', __('Binary representation'));
|
||||
$(this).parent().children(':nth-child(2)').attr('data-original-title', __('Switch to hexadecimal representation'));
|
||||
$(this).parent().children(':nth-child(2)').attr('aria-label', __('Switch to hexadecimal representation'));
|
||||
} else {
|
||||
val = val.split(' ');
|
||||
hex = '';
|
||||
val.forEach(function(entry) {
|
||||
hex += parseInt(entry , 2).toString(16).toUpperCase();
|
||||
});
|
||||
$(this).parent().children(':first-child').text(hex);
|
||||
$(this).parent().children(':first-child').attr('data-original-title', __('Hexadecimal representation'));
|
||||
$(this).parent().children(':nth-child(2)').attr('data-original-title', __('Switch to binary representation'));
|
||||
$(this).parent().children(':nth-child(2)').attr('aria-label', __('Switch to binary representation'));
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
echo $this->Js->writeBuffer();
|
||||
|
|
|
@ -369,32 +369,6 @@ attributes or the appropriate distribution level. If you think there is a mistak
|
|||
filterAttributes('value', eventid);
|
||||
}
|
||||
});
|
||||
$('.hex-value-convert').click(function() {
|
||||
var val = $(this).parent().children(':first-child').text();
|
||||
if ($(this).parent().children(':first-child').attr('data-original-title') == 'Hexadecimal representation') {
|
||||
var bin = [];
|
||||
var temp;
|
||||
val.split('').forEach(function(entry) {
|
||||
temp = parseInt(entry, 16).toString(2);
|
||||
bin.push(Array(5 - (temp.length)).join('0') + temp);
|
||||
});
|
||||
bin = bin.join(' ');
|
||||
$(this).parent().children(':first-child').text(bin);
|
||||
$(this).parent().children(':first-child').attr('data-original-title', 'Binary representation');
|
||||
$(this).parent().children(':nth-child(2)').attr('data-original-title', 'Switch to hexadecimal representation');
|
||||
$(this).parent().children(':nth-child(2)').attr('aria-label', 'Switch to hexadecimal representation');
|
||||
} else {
|
||||
val = val.split(' ');
|
||||
hex = '';
|
||||
val.forEach(function(entry) {
|
||||
hex += parseInt(entry , 2).toString(16).toUpperCase();
|
||||
});
|
||||
$(this).parent().children(':first-child').text(hex);
|
||||
$(this).parent().children(':first-child').attr('data-original-title', 'Hexadecimal representation');
|
||||
$(this).parent().children(':nth-child(2)').attr('data-original-title', 'Switch to binary representation');
|
||||
$(this).parent().children(':nth-child(2)').attr('aria-label', 'Switch to binary representation');
|
||||
}
|
||||
});
|
||||
$('.searchFilterButton').click(function() {
|
||||
filterAttributes('value', '<?php echo h($event['Event']['id']); ?>');
|
||||
});
|
||||
|
|
|
@ -5087,3 +5087,41 @@ function changeLocationFromIndexDblclick(row_index) {
|
|||
var href = $('table tr[data-row-id=\"' + row_index + '\"] .dblclickActionElement').attr('href')
|
||||
window.location = href;
|
||||
}
|
||||
|
||||
$('body').on('click', '.hex-value-convert', function() {
|
||||
var $hexValueSpan = $(this).parent().children(':first-child');
|
||||
var val = $hexValueSpan.text().trim();
|
||||
if (!$hexValueSpan.hasClass('binary-representation')) {
|
||||
var bin = [];
|
||||
val.split('').forEach(function (entry) {
|
||||
var temp = parseInt(entry, 16).toString(2);
|
||||
bin.push(Array(5 - (temp.length)).join('0') + temp);
|
||||
});
|
||||
bin = bin.join(' ');
|
||||
$hexValueSpan
|
||||
.text(bin)
|
||||
.attr('data-original-title', 'Binary representation')
|
||||
.addClass('binary-representation');
|
||||
if ($hexValueSpan.attr('title')) {
|
||||
$hexValueSpan.attr('title', 'Binary representation');
|
||||
}
|
||||
$(this)
|
||||
.attr('data-original-title', 'Switch to hexadecimal representation')
|
||||
.attr('aria-label', 'Switch to hexadecimal representation');
|
||||
} else {
|
||||
var hex = '';
|
||||
val.split(' ').forEach(function (entry) {
|
||||
hex += parseInt(entry, 2).toString(16).toUpperCase();
|
||||
});
|
||||
$hexValueSpan
|
||||
.text(hex)
|
||||
.attr('data-original-title', 'Hexadecimal representation')
|
||||
.removeClass('binary-representation');
|
||||
if ($hexValueSpan.attr('title')) {
|
||||
$hexValueSpan.attr('title', 'Hexadecimal representation');
|
||||
}
|
||||
$(this)
|
||||
.attr('data-original-title', 'Switch to binary representation')
|
||||
.attr('aria-label', 'Switch to binary representation');
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue