added autocomplete= to login, tag length enforcement

This commit is contained in:
or-else
2018-03-09 11:49:19 -08:00
parent b7a4efa6b6
commit 6d8b49c36c
+13 -3
View File
@@ -39,13 +39,14 @@
// Minimum time between two keypress notifications, milliseconds. // Minimum time between two keypress notifications, milliseconds.
var KEYPRESS_DELAY = 3*1000; var KEYPRESS_DELAY = 3*1000;
// Delay before sending a {note} for reciving a message, milliseconds. // Delay before sending a {note} for reciving a message, milliseconds.
var RECEIVED_DELAY = 500; var RECEIVED_DELAY = 500;
// Delay before sending a read notification, milliseconds. // Delay before sending a read notification, milliseconds.
var READ_DELAY = 1000; var READ_DELAY = 1000;
// The shortest allowed tag length. Matches one on the server.
var MIN_TAG_LENGTH = 4;
// Mediaquery breakpoint between desktop and mobile, in px. Should match the value // Mediaquery breakpoint between desktop and mobile, in px. Should match the value
// in @meadia (max-size: 640px) in base.css // in @meadia (max-size: 640px) in base.css
var MEDIA_BREAKPOINT = 640; var MEDIA_BREAKPOINT = 640;
@@ -1014,11 +1015,13 @@
<form id="login-form" onSubmit={this.handleSubmit}> <form id="login-form" onSubmit={this.handleSubmit}>
<input type="text" id="inputLogin" <input type="text" id="inputLogin"
placeholder="Login (alice, bob, carol, dave, frank)" placeholder="Login (alice, bob, carol, dave, frank)"
autocomplete="username"
value={this.state.login} value={this.state.login}
onChange={this.handleLoginChange} onChange={this.handleLoginChange}
required autoFocus /> required autoFocus />
<input type="password" id="inputPassword" <input type="password" id="inputPassword"
placeholder="Password (alice123, bob123, ...)" placeholder="Password (alice123, bob123, ...)"
autocomplete="current-password"
value={this.state.password} value={this.state.password}
onChange={this.handlePasswordChange} onChange={this.handlePasswordChange}
required /> required />
@@ -1545,7 +1548,10 @@
if (text.length > 0) { if (text.length > 0) {
var last = text[text.length-1]; var last = text[text.length-1];
if (last == ',' || last == ' ' || last == ';') { if (last == ',' || last == ' ' || last == ';') {
this.handleAddTag(text.substr(0, text.length-1)); var tag = text.substr(0, text.length-1).trim();
if (tag.length >= MIN_TAG_LENGTH) {
this.handleAddTag(tag);
}
} }
} }
}, },
@@ -3462,6 +3468,7 @@
window.addEventListener('resize', this.handleResize); window.addEventListener('resize', this.handleResize);
window.addEventListener('online', function(e) { instance.handleOnline(true); }); window.addEventListener('online', function(e) { instance.handleOnline(true); });
window.addEventListener('offline', function(e) { instance.handleOnline(false); }); window.addEventListener('offline', function(e) { instance.handleOnline(false); });
window.addEventListener('hashchange', this.handleHashRoute);
this.setState({viewportWidth: document.documentElement.clientWidth}); this.setState({viewportWidth: document.documentElement.clientWidth});
@@ -3481,6 +3488,9 @@
this.setState({displayMobile: mobile}); this.setState({displayMobile: mobile});
} }
}, },
handleHashRoute: function(e) {
console.log("hashchange", location.hash, e.oldURL, e.newURL);
},
handleOnline: function(online) { handleOnline: function(online) {
var newState = {liveConnection: online}; var newState = {liveConnection: online};
if (online) { if (online) {