summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Magorsch <arzano@gentoo.org>2020-07-11 01:21:02 +0000
committerMax Magorsch <arzano@gentoo.org>2020-07-11 01:21:02 +0000
commit49c0de347f84d5701e8e06321bd25b66eb1a6ed5 (patch)
tree2df3b1b378a2ea1e02751894f27aaeaa9b885671 /views/message.erb
parentFix the lin-number layout for all browsers (diff)
downloadfrontend-49c0de347f84d5701e8e06321bd25b66eb1a6ed5.tar.gz
frontend-49c0de347f84d5701e8e06321bd25b66eb1a6ed5.tar.bz2
frontend-49c0de347f84d5701e8e06321bd25b66eb1a6ed5.zip
Highlight a selected line via #Lnn
Signed-off-by: Max Magorsch <arzano@gentoo.org>
Diffstat (limited to 'views/message.erb')
-rw-r--r--views/message.erb12
1 files changed, 11 insertions, 1 deletions
diff --git a/views/message.erb b/views/message.erb
index 5e2537d..fa58a63 100644
--- a/views/message.erb
+++ b/views/message.erb
@@ -37,7 +37,7 @@
</table>
</div>
-<pre class="ag-message-content"><div class="d-flex flex-row"><div class="text-right pr-3"><% strip_email(message['_source']['content']).split("\n").each_with_index do |line, index| %><a id="L<%= index + 1 %>" class="ag-line-number" href="#L<%= index + 1 %>"><%= index + 1 %></a><br/><% end %></div><div><%= linkize(strip_email(message['_source']['content'])) %></div></div></pre>
+<pre class="ag-message-content"><div class="d-flex flex-row"><div class="text-right pr-3"><% strip_email(message['_source']['content']).split("\n").each_with_index do |line, index| %><a id="L<%= index + 1 %>" class="ag-line-number" href="#L<%= index + 1 %>"><%= index + 1 %></a><br/><% end %></div><div id="ag-message-body" class="w-100"><%= linkize(strip_email(message['_source']['content'])) %></div></div></pre>
<% if message['_source']['attachments'] and not message['_source']['attachments'].empty? %>
<h3>Attachments</h3>
@@ -84,3 +84,13 @@
<a href="<%= msgid_to_googlegroup(message['_source']['raw_message_id']) %>" class="btn btn-outline-secondary"><span class="fa fa-fw fa-share-square"></span>Find on Google Groups</a>
</div>
</div>
+
+<script>
+ var lineNumber = window.location.hash.substr(1).replace("L", "");
+
+ if(!isNaN(parseFloat(lineNumber)) && isFinite(lineNumber)){
+ var lines = document.getElementById("ag-message-body").innerHTML.split("\n");
+ lines[parseFloat(lineNumber) - 1] = '<div style="display: inline-block;background-color:#FFF3CD;">' + lines[parseFloat(lineNumber) - 1] + '</div>'
+ document.getElementById("ag-message-body").innerHTML = lines.join("\n");
+ }
+</script> \ No newline at end of file