Skip to content

Commit 2a0b46c

Browse files
authored
Merge pull request #1090 from autolab/highlight-lines-over-80
lines with over 80 chars are now highlighted
2 parents e7a8f30 + e3adef4 commit 2a0b46c

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

app/assets/javascripts/annotations.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,17 +292,17 @@ function make_editable($editable) {
292292

293293
/* Highlights lines longer than 80 characters autolab red color */
294294
var highlightLines = function(highlight) {
295-
var highlightColor = "rgba(200, 200, 0, 0.9)"
296-
$("#code-list > li > code").each(function() {
295+
var highlightColor = "rgba(255, 255, 0, 0.3)"
296+
$("#code-box > .code-table > .code-line > .code").each(function() {
297297
var text = $(this).text();
298298
// To account for lines that have 80 characters and a line break
299299
var diff = text[text.length - 1] === "\n" ? 1 : 0;
300300
if (text.length - diff > 80 && highlight) {
301-
$(this).css("background-color", highlightColor);
302-
$(this).prev().css("background-color", highlightColor);
301+
$(this).css("background", highlightColor);
302+
$(this).prev().css("background", highlightColor);
303303
} else {
304-
$(this).css("background-color", "white");
305-
$(this).prev().css("background-color", "white");
304+
$(this).css("background", "inherit");
305+
$(this).prev().css("background", "inherit");
306306
}
307307
});
308308
};
@@ -323,6 +323,8 @@ function displayAnnotations() {
323323
}
324324

325325
function attachEvents() {
326+
var status = $('#highlightLongLines')[0].checked;
327+
highlightLines(status);
326328

327329
$(".add-button").on("click", function(e) {
328330

app/assets/stylesheets/annotations.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@
513513
box-shadow: none;
514514
border: none;
515515
margin: 10px 0;
516+
max-height: 350px;
516517
}
517518

518519
.annotationSummary .collapsible-header{

app/views/submissions/_annotation_pane.html.erb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<div id="annotationPane">
2-
<%# TODO: Bring back highlight lines longer than 80 characters %>
3-
42
<div class="annotationSummary">
53
<h1>Annotations</h1>
64
<ul class="collapsible expandable">

app/views/submissions/view.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@
131131
</div>
132132
</div>
133133
<div class="col s8">
134+
<input type="checkbox" id="highlightLongLines" checked>
135+
<label for="highlightLongLines">Highlight lines longer than 80 characters</label>
134136
<%= render "code_viewer" %>
135137
</div>
136138
<div class="col s2">

0 commit comments

Comments
 (0)