Skip to content

Commit

Permalink
Merge pull request #490 from BetterErrors/feature/hide-live-shell-hin…
Browse files Browse the repository at this point in the history
…t-after-use

Hide "live shell" hint after console has been used
  • Loading branch information
RobinDaugherty authored Nov 4, 2020
2 parents bf34bbf + a5293df commit 54aa288
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
29 changes: 17 additions & 12 deletions lib/better_errors/templates/main.erb
Original file line number Diff line number Diff line change
Expand Up @@ -611,17 +611,6 @@
margin: 10px 0;
}

.sub:before {
content: '';
display: block;
width: 100%;
height: 4px;

border-radius: 2px;
background: rgba(0, 150, 200, 0.05);
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);
}

.sub h3 {
color: #39a;
font-size: 1.1em;
Expand Down Expand Up @@ -849,15 +838,31 @@
this.inputElement = this.container.querySelector("input");
this.outputElement = this.container.querySelector("pre");

this.hasUsedConsole = document.cookie.split('; ').find(function(cookie) {
return cookie.startsWith('BetterErrors-has-used-console=');
});
if (this.hasUsedConsole) {
this.hideConsoleHint();
}

var self = this;
this.inputElement.onkeydown = function(ev) {
self.onKeyDown(ev);
if (!self.hasUsedConsole) {
self.hideConsoleHint();
self.hasUsedConsole = true;
document.cookie = "BetterErrors-has-used-console=true;path=/;max-age=31536000;samesite"
}
};

this.setPrompt(">>");

REPL.all[this.index] = this;
}
};

REPL.prototype.hideConsoleHint = function() {
document.querySelector('#live-shell-hint').style["display"] = "none";
};

REPL.prototype.focus = function() {
this.inputElement.focus();
Expand Down
2 changes: 1 addition & 1 deletion lib/better_errors/templates/variable_info.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</header>

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

Expand Down

0 comments on commit 54aa288

Please sign in to comment.