Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide "live shell" hint after console has been used #490

Merged
merged 2 commits into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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