Skip to content

Commit

Permalink
chg: [tracker] collapse long rule
Browse files Browse the repository at this point in the history
  • Loading branch information
Terrtia committed Jan 24, 2025
1 parent 1cb4142 commit 440c84e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
8 changes: 8 additions & 0 deletions var/www/static/css/ail-project.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@
font-size: 16px;
pointer-events: none;
}

.text-collapse {
overflow: hidden;
display: block;
max-height: 3em;
line-height: 1.5em;
transition: max-height 0.3s ease-in-out;
}
27 changes: 26 additions & 1 deletion var/www/templates/hunter/tracker_show.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<link rel="icon" href="{{ url_for('static', filename='image/ail-icon.png') }}">

<!-- Core CSS -->
<link href="{{ url_for('static', filename='css/ail-project.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='css/bootstrap4.min.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='css/font-awesome.min.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='css/daterangepicker.min.css') }}" rel="stylesheet">
Expand Down Expand Up @@ -219,7 +220,7 @@ <h4><span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }}">
{% if rule_content %}
<h5 class="mb-0">Yara Rule:</h5>
<p class="my-0">
<pre class="border bg-light">{{ rule_content }}</pre>
<pre class="text-collapse border bg-light">{{ rule_content }}</pre>
</p>
{% endif %}

Expand Down Expand Up @@ -379,6 +380,7 @@ <h5>Filter Objects:</h5>
$('#div_edit_tags').hide();
$('#div_edit_description').hide();
$("#page-Tracker").addClass("active");
text_collapse();

$('#date-range-from').dateRangePicker({
separator: ' to ',
Expand Down Expand Up @@ -437,6 +439,29 @@ <h5>Filter Objects:</h5>
}
}

function text_collapse() {
const textElements = document.querySelectorAll(".text-collapse");

textElements.forEach((textElement) => {
console.log(textElements)
const lineHeight = parseFloat(window.getComputedStyle(textElement).lineHeight);
const maxLines = 30;
const maxHeight = lineHeight * maxLines;

// Apply initial truncation
textElement.style.maxHeight = maxHeight + 'px';

// Hover effect
textElement.addEventListener("mouseenter", () => {
textElement.style.maxHeight = 'none';
});

textElement.addEventListener("mouseleave", () => {
textElement.style.maxHeight = maxHeight + 'px';
});
});
}

function edit_tags() {
$('#div_edit_mails').hide();
$('#div_edit_description').hide();
Expand Down

0 comments on commit 440c84e

Please sign in to comment.