Skip to content

Commit 54aa288

Browse files
Merge pull request #490 from BetterErrors/feature/hide-live-shell-hint-after-use
Hide "live shell" hint after console has been used
2 parents bf34bbf + a5293df commit 54aa288

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

lib/better_errors/templates/main.erb

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -611,17 +611,6 @@
611611
margin: 10px 0;
612612
}
613613

614-
.sub:before {
615-
content: '';
616-
display: block;
617-
width: 100%;
618-
height: 4px;
619-
620-
border-radius: 2px;
621-
background: rgba(0, 150, 200, 0.05);
622-
box-shadow: 1px 1px 0 rgba(255, 255, 255, 0.7), inset 0 0 0 1px rgba(0, 0, 0, 0.04), inset 2px 2px 2px rgba(0, 0, 0, 0.07);
623-
}
624-
625614
.sub h3 {
626615
color: #39a;
627616
font-size: 1.1em;
@@ -849,15 +838,31 @@
849838
this.inputElement = this.container.querySelector("input");
850839
this.outputElement = this.container.querySelector("pre");
851840

841+
this.hasUsedConsole = document.cookie.split('; ').find(function(cookie) {
842+
return cookie.startsWith('BetterErrors-has-used-console=');
843+
});
844+
if (this.hasUsedConsole) {
845+
this.hideConsoleHint();
846+
}
847+
852848
var self = this;
853849
this.inputElement.onkeydown = function(ev) {
854850
self.onKeyDown(ev);
851+
if (!self.hasUsedConsole) {
852+
self.hideConsoleHint();
853+
self.hasUsedConsole = true;
854+
document.cookie = "BetterErrors-has-used-console=true;path=/;max-age=31536000;samesite"
855+
}
855856
};
856857

857858
this.setPrompt(">>");
858859

859860
REPL.all[this.index] = this;
860-
}
861+
};
862+
863+
REPL.prototype.hideConsoleHint = function() {
864+
document.querySelector('#live-shell-hint').style["display"] = "none";
865+
};
861866

862867
REPL.prototype.focus = function() {
863868
this.inputElement.focus();

lib/better_errors/templates/variable_info.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</header>
2626

2727
<% if BetterErrors.binding_of_caller_available? && @frame.frame_binding %>
28-
<div class="hint">
28+
<div class="hint" id='live-shell-hint'>
2929
This is a live shell. Type in here.
3030
</div>
3131

0 commit comments

Comments
 (0)