OILS / web / table / html.sh View on Github | oilshell.org

48 lines, 11 significant
1#!/usr/bin/env bash
2#
3# Usage:
4# source web/table/html.sh
5
6set -o nounset
7set -o pipefail
8set -o errexit
9
10table-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
20EOF
21}
22
23table-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>
47EOF
48}