| <!-- |
| Copyright (C) 2019 Apple Inc. All rights reserved. |
| |
| Redistribution and use in source and binary forms, with or without |
| modification, are permitted provided that the following conditions |
| are met: |
| 1. Redistributions of source code must retain the above copyright |
| notice, this list of conditions and the following disclaimer. |
| 2. Redistributions in binary form must reproduce the above copyright |
| notice, this list of conditions and the following disclaimer in the |
| documentation and/or other materials provided with the distribution. |
| |
| THIS SOFTWARE IS PROVIDED BY APPLE INC. "AS IS" AND ANY |
| EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| --> |
| |
| <!DOCTYPE html> |
| <html> |
| <head> |
| <title>{{title}}</title> |
| <meta content="width=device-width, initial-scale=1, viewport-fit=cover" name="viewport"> |
| <meta charset="UTF-8"> |
| <link rel="stylesheet" type="text/css" href="/library/css/webkit.css"> |
| {% block head %}{% endblock %} |
| </head> |
| <body> |
| <div class="header fixed"> |
| <div class="title"> |
| <div class="text large block" style="width: calc(100% - 44px); overflow: hidden; white-space: nowrap; text-overflow: ellipsis;"> |
| {{site_title}} |
| </div> |
| <button style="width: 44px" class="button mobile-sidebar-control">☰</button> |
| </div> |
| <div class="actions"> |
| <div class="list" id="site-menu"></div> |
| </div> |
| </div> |
| {% block content %}{% endblock %} |
| <script type="module"> |
| import {queryToParams, paramsToQuery} from '/assets/js/common.js'; |
| import {DOM, REF} from '/library/js/Ref.js'; |
| import {disableBackGesture} from '/library/js/Utils.js'; |
| |
| disableBackGesture(); |
| |
| DOM.inject( |
| document.getElementById('site-menu'), |
| `{% for name, url_info in site_menu.items() %} |
| <div class="item"> |
| <a style="cursor: pointer" ref="${REF.createRef({ |
| onElementMount: element => { |
| element.onclick = () => { |
| const currentParams = queryToParams(document.URL.split('?')[1]); |
| let retainedParams = {}; |
| {{ url_info['parameters']|safe }}.forEach((parameter) => { |
| if (currentParams.hasOwnProperty(parameter)) |
| retainedParams[parameter] = currentParams[parameter]; |
| }); |
| let destination = "{{ url_info['url']() }}"; |
| if (Object.keys(retainedParams).length) |
| destination = `${destination}?${paramsToQuery(retainedParams)}`; |
| window.location.assign(destination); |
| }; |
| }, |
| })}"> |
| {{ name }} |
| </a> |
| </div> |
| {% endfor %}`, |
| ); |
| </script> |
| </body> |
| </html> |