aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/webui/static/js
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2016-11-01 16:00:14 +0800
committerAaron LI <aaronly.me@outlook.com>2016-11-01 16:00:14 +0800
commit91447bbd6f66a1a334b30ea7840e3407bfc7fd33 (patch)
treedf0409c82916efad80e6b5b9b5a00c0c248cad24 /fg21sim/webui/static/js
parent06cd1295fd4035fc01dde2212fe403de7545857b (diff)
downloadfg21sim-91447bbd6f66a1a334b30ea7840e3407bfc7fd33.tar.bz2
webui: Add the main CSS and JavaScript
The js code still misses many necessary functions.
Diffstat (limited to 'fg21sim/webui/static/js')
-rw-r--r--fg21sim/webui/static/js/main.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/fg21sim/webui/static/js/main.js b/fg21sim/webui/static/js/main.js
new file mode 100644
index 0000000..2878721
--- /dev/null
+++ b/fg21sim/webui/static/js/main.js
@@ -0,0 +1,28 @@
+/**
+ * Copyright (c) 2016 Weitian LI <liweitianux@live.com>
+ * MIT license
+ *
+ * JavaScript codes for the Web UI of "fg21sim"
+ */
+
+
+$(document).ready(function () {
+ /**
+ * Offset the page to adjust for the fixed navigation banner
+ */
+ var nav_height = $("nav.navigation").outerHeight();
+
+ var scroll_target = function () {
+ if ($(":target").length) {
+ var offset = $(":target").offset();
+ var scroll_to = offset.top - nav_height * 1.2;
+ $("html, body").animate({scrollTop: scroll_to}, 0);
+ }
+ };
+
+ $(window).on("hashchange", scroll_target);
+ /* FIXME: This seems not work ... */
+ if (window.location.hash) {
+ scroll_target();
+ }
+});