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

Better input behavior #27

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
<x-card id="setup">
<h1>Firesea IRC</h1>
<div class="connect">
<input type="text" placeholder="host" id="host"/>
<input type="text" placeholder="username" id="username"/>
<input type="text" placeholder="channels" id="channels"/>
<input type="text" autocorrect="off" autocapitalize="off" placeholder="host" id="host"/>
<input type="text" autocorrect="off" autocapitalize="off" placeholder="username" id="username"/>
<input type="text" autocorrect="off" autocapitalize="off" placeholder="channels" id="channels"/>
</div>
<button id="connect" class="moz-button">Connect</button>
<img src="setting.png" id="advanced-link" class="moz-button"/>
<div id="advanced">
<label><input type="checkbox" id="secure"/>Secure</label>
<input type="text" placeholder="port" id="port" />
<input type="number" placeholder="port (6667)" id="port" />
</div>
<div id="hostlist"></div>
<div id="loading"><img src="ajax-loader.gif" /></div>
Expand Down
9 changes: 9 additions & 0 deletions my.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ document.addEventListener("DOMContentLoaded", function () {
$advanced.style.display = "block";
}
}
$("secure").onchange = function () {
var port = $("port");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A notation we've been using is to prefix variable identifiers that are elements with a dollar sign. Please rename to var $port = ...

if (port.value) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a true branch with an early return, can you just use if (!port.value) and put everything in that?

return;
}
var secure = this.checked;
var hint = port.placeholder.replace(/\d+/, secure ? '6697' : '6667');
port.placeholder = hint;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could all be one line: $port.placeholder = this.checked ? '6697' : '6667'

}

if (localStorage.nick) {
$("username").value = localStorage.nick;
Expand Down