From a8ca7e38d78abf58ebe432aa261a1e0d3cd6b7fc Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Thu, 17 Nov 2016 16:07:27 +0800 Subject: webui: login: Submit login form on "Enter" key --- fg21sim/webui/static/js/login.js | 23 +++++++++++++++++++++++ fg21sim/webui/templates/login.html | 6 +++++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 fg21sim/webui/static/js/login.js diff --git a/fg21sim/webui/static/js/login.js b/fg21sim/webui/static/js/login.js new file mode 100644 index 0000000..301de73 --- /dev/null +++ b/fg21sim/webui/static/js/login.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2016 Weitian LI + * MIT license + * + * JavaScript codes for the Web UI of "fg21sim" + */ + +"use strict"; + + +$(document).ready(function () { + /** + * Submit the login form on "Enter" key + * Credit: https://stackoverflow.com/a/12518467/4856091 + */ + $("form#login input").keypress(function (e) { + if (e.which === 13) { + // "Enter" key pressed + $(e.target).closest("form").submit(); + return false; + } + }); +}); diff --git a/fg21sim/webui/templates/login.html b/fg21sim/webui/templates/login.html index 51d4cd1..e0e98da 100644 --- a/fg21sim/webui/templates/login.html +++ b/fg21sim/webui/templates/login.html @@ -14,7 +14,7 @@

Login


-
+ {% module xsrf_form_html() %}