Skip to content

Commit

Permalink
Fix word wrap button not working on inspect submission page
Browse files Browse the repository at this point in the history
Fixes #1281
  • Loading branch information
ihalaij1 authored and markkuriekkinen committed Oct 23, 2023
1 parent 8e6d873 commit 851dc29
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions assets/js/aplus.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,18 +335,20 @@ $(function() {
// The for-loop can freeze the page if line numbers are added to extremely long feedback/code.
const pre = $(codeBlock);
const lines = pre.html().split(/\r\n|\r|\n/g);
const table = $('<table/>').addClass('src');
if (lines.length < 5000) {
const list = $("<table/>").addClass("src");
for (var i = 1; i <= lines.length; i++) {
list.append('<tr><td class="num unselectable">' + i + '</td><td class="src">' + lines[i - 1] + '</td></tr>');
table.append('<tr><td class="num unselectable">' + i + '</td><td class="src">' + lines[i - 1] + '</td></tr>');
}
pre.html(list);
} else {
table.append('<tr><td class="src">' + pre.html() + '</td></tr>');
}
pre.html(table);

if (!options || !options.noWrap) {
addButton(buttonContainer, {
action: function() {
list.toggleClass('no-wrap');
table.toggleClass('no-wrap');
},
icon: 'check',
text: _('Word wrap'),
Expand Down

0 comments on commit 851dc29

Please sign in to comment.