1 | #!/usr/bin/env bash
|
2 | #
|
3 | # Usage:
|
4 | # source web/table/html.sh
|
5 |
|
6 | set -o nounset
|
7 | set -o pipefail
|
8 | set -o errexit
|
9 |
|
10 | table-sort-begin() {
|
11 | local body_css_class=${1:-}
|
12 |
|
13 | cat <<EOF
|
14 |
|
15 | <body class="$body_css_class"
|
16 | onload="initPage(gUrlHash, gTableStates, kStatusElem);"
|
17 | onhashchange="onHashChange(gUrlHash, gTableStates, kStatusElem);">
|
18 | <p id="status"></p>
|
19 |
|
20 | EOF
|
21 | }
|
22 |
|
23 | table-sort-end() {
|
24 | local name=$1
|
25 |
|
26 | cat <<EOF
|
27 |
|
28 | <!-- page globals -->
|
29 | <script type="text/javascript">
|
30 | var gUrlHash = new UrlHash(location.hash);
|
31 | var gTableStates = {};
|
32 | var kStatusElem = document.getElementById('status');
|
33 |
|
34 | function initPage(urlHash, tableStates, statusElem) {
|
35 | var elem = document.getElementById('$name');
|
36 | makeTablesSortable(urlHash, [elem], tableStates);
|
37 | updateTables(urlHash, tableStates, statusElem);
|
38 | }
|
39 |
|
40 | function onHashChange(urlHash, tableStates, statusElem) {
|
41 | updateTables(urlHash, tableStates, statusElem);
|
42 | }
|
43 | </script>
|
44 |
|
45 | </body>
|
46 | </html>
|
47 | EOF
|
48 | }
|