summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAilin Nemui2016-04-18 14:21:46 +0200
committerAilin Nemui2016-04-18 14:21:59 +0200
commit33b0332ceefc5deb239fa53a0b2db1edbfa3560c (patch)
treeb9bf13e24417ad6d7d0442da4ecd037c3290452d
parent726b046a3c616a0d50a220aad72e3459bef334f1 (diff)
downloadscripts.irssi.org-33b0332ceefc5deb239fa53a0b2db1edbfa3560c.tar.bz2
support filling the javascript filter from url hash
[skip ci]
-rw-r--r--_includes/footer.html1
-rw-r--r--assets/js/hashfill.js32
-rw-r--r--index.html2
3 files changed, 34 insertions, 1 deletions
diff --git a/_includes/footer.html b/_includes/footer.html
index 45a1f46..1438833 100644
--- a/_includes/footer.html
+++ b/_includes/footer.html
@@ -3,6 +3,7 @@
<script src="assets/js/sorttable.js"></script>
<script src="assets/js/filtertable.js"></script>
<script src="assets/js/jquery.timeago.js"></script>
+ <script src="assets/js/hashfill.js"></script>
<script>
$(function() {
jQuery.timeago.settings.cutoff = 365*24*60*60*1000;
diff --git a/assets/js/hashfill.js b/assets/js/hashfill.js
new file mode 100644
index 0000000..a831703
--- /dev/null
+++ b/assets/js/hashfill.js
@@ -0,0 +1,32 @@
+(function(document, $) {
+ 'use strict';
+
+ function readhash() {
+ var kv = window.location.hash.substr(1).split('&');
+ for(var i = 0; i < kv.length; i++) {
+ var p = kv[i].split('=');
+ var e = $(':input').filter(function(i, e) {
+ return (e.dataset||{}).name === p[0];
+ });
+ if (e && e[0]) {
+ e[0].value = decodeURIComponent(p[1].replace(/[+]/g, '%20'));
+ if ('createEvent' in document) {
+ var ev = document.createEvent('HTMLEvents');
+ ev.initEvent('input', true, false);
+ e[0].dispatchEvent(ev);
+ }
+ }
+ }
+ }
+
+ if ('onhashchange' in window) {
+ $(window).bind('hashchange', readhash);
+ }
+
+ document.addEventListener('readystatechange', function() {
+ if (document.readyState === 'complete') {
+ readhash();
+ }
+ });
+
+})(document, $);
diff --git a/index.html b/index.html
index 696e6c6..cbfc91c 100644
--- a/index.html
+++ b/index.html
@@ -40,7 +40,7 @@ layout: default
<hr>
- <input type="search" class="light-table-filter form-control" data-table="sortable" placeholder="Filter" style="width: 100%">
+ <input type="search" class="light-table-filter form-control" data-table="sortable" data-name="q" placeholder="Filter" style="width: 100%">
<table class="table table-striped table-condensed sortable">
<thead>
<tr>