specifications

Specification and standard documents
git clone git://git.finwo.net/misc/specifications
Log | Files | Refs | README | LICENSE

index.html.tail (1799B)


      1               </tbody>
      2           </table>
      3         </main>
      4 
      5         <script>
      6 
      7             // Query String handler
      8             const qs = {
      9                 parse(str) {
     10                     let output    = {};
     11                     str.split('&').forEach(param => {
     12                         let [key, value] = param.split('=');
     13                         output[decodeURIComponent(key)] = decodeURIComponent(value);
     14                     });
     15                     return output;
     16                 },
     17             };
     18 
     19             // Make the table nice and searchable
     20             const datatable = new simpleDatatables.DataTable('#specTable', {
     21                 searchable: true
     22             });
     23 
     24             // Make all elements act as anchors when [href] is present
     25             Array.from(document.querySelectorAll('[href]')).forEach(node => {
     26                 node.style.cursor = 'pointer';
     27                 node.addEventListener('click', ev => {
     28                     ev.preventDefault();
     29                     let elem = ev.target;
     30                     while(!elem.attributes.href)
     31                         elem = elem.parentNode;
     32                     document.location.href = elem.attributes.href.value;
     33                 });
     34             });
     35 
     36             // Hardwired data binding
     37             function onHashChange() {
     38                 let q = qs.parse(document.location.hash.substr(1));
     39                 if (q.q == datatable.input.value) return;
     40                 datatable.input.value = q.q || '';
     41                 datatable.search(q.q || '');
     42             };
     43             window.addEventListener('hashchange', onHashChange, false);
     44             datatable.on('datatable.search', query => {
     45                 document.location.hash = '#q=' + query;
     46             });
     47             onHashChange();
     48 
     49         </script>
     50     </body>
     51 </html>