j1-template 2021.1.4 → 2021.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/_includes/themes/j1/modules/connectors/ad/google-adsense.html +7 -15
  3. data/_includes/themes/j1/modules/connectors/analytic/google-analytics.html +9 -5
  4. data/_includes/themes/j1/modules/navigator/generator.html +2 -2
  5. data/_layouts/default.html +4 -7
  6. data/assets/data/cookieconsent.html +249 -0
  7. data/assets/data/quicklinks.html +18 -16
  8. data/assets/themes/j1/adapter/js/{cookiebar.js → cookieConsent.js} +102 -54
  9. data/assets/themes/j1/adapter/js/j1.js +40 -15
  10. data/assets/themes/j1/core/css/themes/uno-light/bootstrap.css +2 -2
  11. data/assets/themes/j1/core/css/themes/uno-light/bootstrap.min.css +1 -1
  12. data/assets/themes/j1/core/js/template.js +3 -9
  13. data/assets/themes/j1/core/js/template.js.map +1 -1
  14. data/assets/themes/j1/core/js/template.min.js +3 -9
  15. data/assets/themes/j1/core/js/template.min.js.map +1 -1
  16. data/assets/themes/j1/modules/cookieConsent/LICENSE +21 -0
  17. data/assets/themes/j1/modules/cookieConsent/js/cookieConsent.js +286 -0
  18. data/assets/themes/j1/modules/cookieConsent/js/cookieConsent.min.js +28 -0
  19. data/assets/themes/j1/modules/iframeResizer/examples/frame.absolute.html +4 -2
  20. data/assets/themes/j1/modules/iframeResizer/examples/frame.content.html +4 -3
  21. data/assets/themes/j1/modules/iframeResizer/examples/frame.hover.html +4 -2
  22. data/assets/themes/j1/modules/iframeResizer/examples/frame.nested.html +4 -2
  23. data/assets/themes/j1/modules/iframeResizer/examples/frame.textarea.html +4 -2
  24. data/assets/themes/j1/modules/iframeResizer/examples/frame.tolerance.html +4 -2
  25. data/assets/themes/j1/modules/iframeResizer/examples/index.html +2 -0
  26. data/assets/themes/j1/modules/iframeResizer/examples/two.html +4 -2
  27. data/assets/themes/j1/modules/util/js/domready.js +146 -0
  28. data/assets/themes/j1/modules/util/js/gtag-opt-in.js +1 -0
  29. data/lib/j1/version.rb +3 -3
  30. data/lib/starter_web/Gemfile +1 -1
  31. data/lib/starter_web/_config.yml +2 -1
  32. data/lib/starter_web/_data/_defaults/resources.yml +11 -8
  33. data/lib/starter_web/_data/modules/{cookiebar.yml → cookieconsent.yml} +4 -4
  34. data/lib/starter_web/_data/modules/defaults/cookieconsent.yml +135 -0
  35. data/lib/starter_web/_data/pages/builder.yml +7 -7
  36. data/lib/starter_web/_data/private.yml +6 -6
  37. data/lib/starter_web/_data/resources.yml +9 -7
  38. data/lib/starter_web/_includes/attributes.asciidoc +10 -1
  39. data/lib/starter_web/_plugins/lunr_index.rb +1 -1
  40. data/lib/starter_web/assets/images/modules/attics/{cookies-1920x1200-bw.jpg → cookies-1920x1200.jpg} +0 -0
  41. data/lib/starter_web/assets/images/modules/attics/lianhao-1920x1280.jpg +0 -0
  42. data/lib/starter_web/collections/posts/public/featured/_posts/2020-01-01-about-cookies.adoc +2 -2
  43. data/lib/starter_web/package.json +1 -1
  44. data/lib/starter_web/pages/public/cookieConsent.adoc +93 -0
  45. data/lib/starter_web/pages/public/learn/roundtrip/400_asciidoc_extensions.adoc +2 -1
  46. data/lib/starter_web/pages/public/legal/en/300_privacy.adoc +104 -209
  47. data/lib/starter_web/utilsrv/_defaults/package.json +1 -1
  48. data/lib/starter_web/utilsrv/package.json +1 -1
  49. metadata +14 -13
  50. data/_includes/themes/j1/modules/navigator/generator.org.html +0 -232
  51. data/assets/data/cookiebar.html +0 -288
  52. data/assets/data/footer.new.1.html +0 -256
  53. data/assets/data/footer.new.2.html +0 -256
  54. data/assets/data/footer.org.html +0 -249
  55. data/assets/themes/j1/adapter/js/j1.new.js +0 -1878
  56. data/assets/themes/j1/adapter/js/j1.org.js +0 -1874
  57. data/lib/starter_web/_data/modules/defaults/cookiebar.yml +0 -133
@@ -1,249 +0,0 @@
1
- ---
2
- regenerate: true
3
- ---
4
- {% capture cache %}
5
-
6
- {% comment %}
7
- # -----------------------------------------------------------------------------
8
- # ~/assets/data/footer.html
9
- # Liquid procedure to generate HTML (data) portion of the page footer for
10
- # (fragmented) AJAX load
11
- #
12
- # Product/Info:
13
- # https://jekyll.one
14
- #
15
- # Copyright (C) 2021 Juergen Adams
16
- #
17
- # J1 Template is licensed under the MIT License.
18
- # See: https://github.com/jekyll-one-org/J1 Template/blob/master/LICENSE
19
- # -----------------------------------------------------------------------------
20
- # Test data:
21
- # {{ variable | debug }}
22
- # -----------------------------------------------------------------------------
23
- {% endcomment %}
24
-
25
- <!-- [INFO ] [j1.assets.data.footer ] [Footer generated: {{site.time}}] -->
26
-
27
- {% comment %} Liquid procedures
28
- -------------------------------------------------------------------------------- {% endcomment %}
29
- {% capture select_color %}themes/{{site.template.name}}/procedures/global/select_color.proc{% endcapture %}
30
- {% capture select_icon_size %}themes/{{site.template.name}}/procedures/global/select_icon_size.proc{% endcapture %}
31
- {% capture about_box %}themes/{{site.template.name}}/blocks/footer/boxes/about_box.proc{% endcapture %}
32
- {% capture news_box %}themes/{{site.template.name}}/blocks/footer/boxes/news_box.proc{% endcapture %}
33
- {% capture links_box %}themes/{{site.template.name}}/blocks/footer/boxes/links_box.proc{% endcapture %}
34
- {% capture contacts_box %}themes/{{site.template.name}}/blocks/footer/boxes/contacts_box.proc{% endcapture %}
35
- {% capture legal_statements %}themes/{{site.template.name}}/blocks/footer/boxes/legal_statements.proc{% endcapture %}
36
- {% capture issue %}themes/{{site.template.name}}/blocks/footer/boxes/issue.proc{% endcapture %}
37
- {% capture social_media_icons %}themes/{{site.template.name}}/blocks/footer/boxes/social_media_icons.proc{% endcapture %}
38
-
39
- {% comment %} Process YML config data
40
- ================================================================================ {% endcomment %}
41
-
42
- {% comment %} Set config files
43
- -------------------------------------------------------------------------------- {% endcomment %}
44
- {% assign footer_config_defaults = site.data.blocks.defaults.footer %}
45
- {% assign footer_config_settings = site.data.blocks.footer %}
46
-
47
- {% comment %} Set config data
48
- -------------------------------------------------------------------------------- {% endcomment %}
49
- {% assign environment = site.environment %}
50
-
51
- {% assign footer_config_defaults = footer_config_defaults.defaults %}
52
- {% assign footer_config_settings = footer_config_settings.settings %}
53
-
54
- {% comment %} Variables
55
- -------------------------------------------------------------------------------- {% endcomment %}
56
-
57
- {% assign production = false %}
58
- {% if environment == 'prod' or environment == 'production' %}
59
- {% assign production = true %}
60
- {% endif %}
61
-
62
- {% comment %} Set HELPER variables
63
- -------------------------------------------------------------------------------- {% endcomment %}
64
- {% capture footer_config_file_name %}~/_data/modules/footer.yml{% endcapture %}
65
-
66
- <!-- [INFO ] [j1.assets.data.footer.html ] [ set meta data (robots) to exclude HTML datafiles from index ] -->
67
- <!-- head>
68
- <meta name="robots" content="noindex, nofollow" />
69
- </head -->
70
-
71
- {% comment %} Main
72
- ================================================================================ {% endcomment %}
73
- {% for items in footer_config_settings %}
74
- {% assign key = items[0] %}
75
- {% assign value = items[1] %}
76
- {% assign footer_config = value %}
77
-
78
- {% for items in footer_config %}
79
- {% for footers in items %}
80
-
81
- {% if debug %} footers: {{ footers }} {% endif %}
82
-
83
- {% comment %} parse settings for MAIN keys
84
- -------------------------------------------------------------------------- {% endcomment %}
85
- {% for footer in footers %}
86
- {% assign data_type = footer | is_type %}
87
- {% if data_type == 'hash' %}
88
- {% assign footer_settings = footer %}
89
- {% endif %}
90
- {% endfor %}
91
-
92
- {% if debug %} <!-- footer_settings.boxes: {{ footer_settings.boxes }} --> {% endif %}
93
-
94
-
95
- {% comment %} process current footer
96
- -------------------------------------------------------------------------- {% endcomment %}
97
- {% if footer_settings.enabled %}
98
-
99
- {% assign enabled_boxes = 0 %}
100
- {% assign footer_options = footer_config_defaults.footer | merge: footer_settings %}
101
- {% if debug %} <!-- footer_options: {{ footer_options }} --> {% endif %}
102
-
103
- {% comment %} Calculate number of enabled footer boxes
104
- ------------------------------------------------------------------------ {% endcomment %}
105
- {% for property in footer_options.boxes %}
106
- {% if debug %} <!-- property: {{property}} --> {% endif %}
107
- {% if property.enabled %} {% assign enabled_boxes = enabled_boxes | plus:1 %} {% endif %}
108
- {% endfor %}
109
- {% assign footer_box_width_md = 12 | divided_by:enabled_boxes %}
110
- <!-- [INFO ] [j1.assets.data.footer ] [Set footer box column width to: {{ footer_box_width_md }}] -->
111
-
112
- <!-- div id="{{footer_config_defaults.container-id}}" class="{{footer_options.theme}}" -->
113
- <div id="{{footer_config_defaults.container-id}}">
114
- <div class="footer">
115
-
116
- <div class="container">
117
- <div class="row">
118
-
119
- {% comment %} Collect footer config data
120
- ------------------------------------------------------------------ {% endcomment %}
121
- {% for box in footer_options.boxes %}
122
-
123
- {% comment %} COLLECT|PLACE footer boxes
124
- ---------------------------------------------------------------- {% endcomment %}
125
- {% case box.type %}
126
-
127
- {% comment %} PLACE AboutBox
128
- ---------------------------------------------------------------- {% endcomment %}
129
- {% when 'about' %}
130
- {% if box.enabled %}
131
- {% include {{about_box}} title=box.title tagline=box.tagline text=box.text justify=box.justify %}
132
- {% endif %}
133
-
134
- {% comment %} Reset element variable
135
- -------------------------------------------------------------- {% endcomment %}
136
- {% assign footer_options.boxes = nil %}
137
-
138
- {% comment %} PLACE NewsBox
139
- ---------------------------------------------------------------- {% endcomment %}
140
- {% when 'news' %}
141
- {% if box.enabled %}
142
- {% include {{news_box}} title=box.title tagline=box.tagline category=box.category max_posts=box.max_posts posts=site.posts %}
143
- {% endif %}
144
-
145
- {% comment %} Reset element variable
146
- -------------------------------------------------------------- {% endcomment %}
147
- {% assign footer_options.boxes = nil %}
148
-
149
- {% comment %} PLACE LinksBox
150
- --------------------------------------------------------------- {% endcomment %}
151
- {% when 'references' %}
152
- {% if box.enabled %}
153
- {% include {{links_box}} title=box.title tagline=box.tagline links=box.links %}
154
- {% endif %}
155
-
156
- {% comment %} Reset element variable
157
- -------------------------------------------------------------- {% endcomment %}
158
- {% assign footer_options.boxes = nil %}
159
-
160
- {% comment %} PLACE ContactsBox
161
- --------------------------------------------------------------- {% endcomment %}
162
- {% when 'contact' %}
163
- {% if box.enabled %}
164
- {% include {{contacts_box}} %}
165
- {% endif %}
166
-
167
- {% comment %} Reset element variable
168
- -------------------------------------------------------------- {% endcomment %}
169
- {% assign footer_options.boxes = nil %}
170
-
171
- {% else %}
172
- {% comment %} Collect EXCEPTION
173
- -------------------------------------------------------------- {% endcomment %}
174
- {% unless box.type == 'exception_container' %}
175
- <div id="exception_container">
176
- <div id="{{panel_settings.id}}" class="container-fluid no-padding">
177
- <div class="col-md-12 col-sm-12 col-xs-12 no-padding">
178
- <div class="box">
179
- <div class="content content-danger">
180
- <h2 class="notoc">
181
- <i class="mdi mdi-alarm-light mdi-3x mdi-md-red mr-1"></i>
182
- panel of type <big>{{panel_settings.type}}</big> not found
183
- </h2>
184
- <h4 class="notoc box-title">Check your configuration at {{panel_config_file_name}}</h4>
185
- <div class="box-description">
186
- Don't worry about this. Maybe you've a typo in the panel configuration.
187
- Check the panel config file for the unknown type. <br />
188
- Check for something wrong like:
189
- <div class="mt-2 mb-2">
190
- <b>id: {{panel_settings.id}}</b> <br />
191
- <b>type: {{panel_settings.type}}</b> <br />
192
- <b>comment: {{panel_settings.comment}}</b>
193
- </div>
194
- </div>
195
- </div>
196
- </div>
197
- </div>
198
- </div> <!-- End panel {{panel_settings.id}} -->
199
- </div> <!-- End exception_container -->
200
- {% endunless %}
201
-
202
- {% endcase %}
203
-
204
- {% comment %} END footer boxes
205
- ---------------------------------------------------------------- {% endcomment %}
206
-
207
- {% endfor %}
208
- </div>
209
- </div>
210
- </div>
211
-
212
- {% comment %} COLLECT|PLACE copyright|issue date information
213
- ---------------------------------------------------------------------- {% endcomment %}
214
- <div class="copyright">
215
- <div class="container">
216
- <div class="row">
217
- <!-- [INFO ] [j1.assets.data.footer ] [Enable horizontal list using id #inline] -->
218
- <div class="col-md-10" id="inline">
219
- {% include {{legal_statements}} legals=footer_options.legals %}
220
- </div>
221
- <div class="col-md-10" id="inline">
222
- {% include {{issue}} %}
223
- </div>
224
- <div class="col-md-2">
225
- {% include {{social_media_icons}} icons=footer_options.icons %}
226
- </div>
227
- </div>
228
- </div>
229
- </div>
230
-
231
- </div>
232
-
233
- {% comment %} Reset element variables (already processed)
234
- ------------------------------------------------------------------------ {% endcomment %}
235
- {% assign footer_settings = nil %}
236
-
237
- {% endif %}
238
-
239
- {% endfor %}
240
- {% endfor %}
241
- {% endfor %}
242
-
243
- {% endcapture %}
244
- {% if production %}
245
- {% capture _LINE_FEED %}{% endcapture %}{% if site.compress_html.ignore.envs contains jekyll.environment %}{{ cache | strip_html_comments }}{% else %}{% capture _content %}{{ cache | strip_html_comments }}{% endcapture %}{% assign _profile = site.compress_html.profile %}{% if site.compress_html.endings == "all" %}{% assign _endings = "html head body li dt dd p rt rp optgroup option colgroup caption thead tbody tfoot tr td th" | split: " " %}{% else %}{% assign _endings = site.compress_html.endings %}{% endif %}{% for _element in _endings %}{% capture _end %}</{{ _element }}>{% endcapture %}{% assign _content = _content | remove: _end %}{% endfor %}{% if _profile and _endings %}{% assign _profile_endings = _content | size | plus: 1 %}{% endif %}{% for _element in site.compress_html.startings %}{% capture _start %}<{{ _element }}>{% endcapture %}{% assign _content = _content | remove: _start %}{% endfor %}{% if _profile and site.compress_html.startings %}{% assign _profile_startings = _content | size | plus: 1 %}{% endif %}{% if site.compress_html.comments == "all" %}{% assign _comments = "<!-- -->" | split: " " %}{% else %}{% assign _comments = site.compress_html.comments %}{% endif %}{% if _comments.size == 2 %}{% capture _comment_befores %}.{{ _content }}{% endcapture %}{% assign _comment_befores = _comment_befores | split: _comments.first %}{% for _comment_before in _comment_befores %}{% if forloop.first %}{% continue %}{% endif %}{% capture _comment_outside %}{% if _carry %}{{ _comments.first }}{% endif %}{{ _comment_before }}{% endcapture %}{% capture _comment %}{% unless _carry %}{{ _comments.first }}{% endunless %}{{ _comment_outside | split: _comments.last | first }}{% if _comment_outside contains _comments.last %}{{ _comments.last }}{% assign _carry = false %}{% else %}{% assign _carry = true %}{% endif %}{% endcapture %}{% assign _content = _content | remove_first: _comment %}{% endfor %}{% if _profile %}{% assign _profile_comments = _content | size | plus: 1 %}{% endif %}{% endif %}{% assign _pre_befores = _content | split: "<pre" %}{% assign _content = "" %}{% for _pre_before in _pre_befores %}{% assign _pres = _pre_before | split: "</pre>" %}{% assign _pres_after = "" %}{% if _pres.size != 0 %}{% if site.compress_html.blanklines %}{% assign _lines = _pres.last | split: _LINE_FEED %}{% capture _pres_after %}{% for _line in _lines %}{% assign _trimmed = _line | split: " " | join: " " %}{% if _trimmed != empty or forloop.last %}{% unless forloop.first %}{{ _LINE_FEED }}{% endunless %}{{ _line }}{% endif %}{% endfor %}{% endcapture %}{% else %}{% assign _pres_after = _pres.last | split: " " | join: " " %}{% endif %}{% endif %}{% capture _content %}{{ _content }}{% if _pre_before contains "</pre>" %}<pre{{ _pres.first }}</pre>{% endif %}{% unless _pre_before contains "</pre>" and _pres.size == 1 %}{{ _pres_after }}{% endunless %}{% endcapture %}{% endfor %}{% if _profile %}{% assign _profile_collapse = _content | size | plus: 1 %}{% endif %}{% if site.compress_html.clippings == "all" %}{% assign _clippings = "html head title base link meta style body article section nav aside h1 h2 h3 h4 h5 h6 hgroup header footer address p hr blockquote ol ul li dl dt dd figure figcaption main div table caption colgroup col tbody thead tfoot tr td th" | split: " " %}{% else %}{% assign _clippings = site.compress_html.clippings %}{% endif %}{% for _element in _clippings %}{% assign _edges = " <e;<e; </e>;</e>;</e> ;</e>" | replace: "e", _element | split: ";" %}{% assign _content = _content | replace: _edges[0], _edges[1] | replace: _edges[2], _edges[3] | replace: _edges[4], _edges[5] %}{% endfor %}{% if _profile and _clippings %}{% assign _profile_clippings = _content | size | plus: 1 %}{% endif %}{{ _content }}{% if _profile %} <table id="compress_html_profile_{{ site.time | date: "%Y%m%d" }}" class="compress_html_profile"> <thead> <tr> <td>Step <td>Bytes <tbody> <tr> <td>raw <td>{{ cache | strip_html_comments | size }}{% if _profile_endings %} <tr> <td>endings <td>{{ _profile_endings }}{% endif %}{% if _profile_startings %} <tr> <td>startings <td>{{ _profile_startings }}{% endif %}{% if _profile_comments %} <tr> <td>comments <td>{{ _profile_comments }}{% endif %}{% if _profile_collapse %} <tr> <td>collapse <td>{{ _profile_collapse }}{% endif %}{% if _profile_clippings %} <tr> <td>clippings <td>{{ _profile_clippings }}{% endif %} </table>{% endif %}{% endif %}
246
- {% else %}
247
- {{ cache | pretty_print | remove:'<html><body>' | remove:'</body></html>' | strip_empty_lines }}
248
- {% endif %}
249
- {% assign cache = nil %}
@@ -1,1878 +0,0 @@
1
- ---
2
- regenerate: true
3
- ---
4
-
5
- {% capture cache %}
6
-
7
- {% comment %}
8
- # -----------------------------------------------------------------------------
9
- # ~/assets/themes/j1/core/js/j1.js
10
- # Liquid template to initialize J1 Template Core functions
11
- #
12
- # Product/Info:
13
- # https://jekyll.one
14
- #
15
- # Copyright (C) 2021 Juergen Adams
16
- #
17
- # J1 Template is licensed under the MIT License.
18
- # For details, see https://jekyll.one
19
- # -----------------------------------------------------------------------------
20
- # Test data:
21
- # {{ liquid_var | debug }}
22
- # -----------------------------------------------------------------------------
23
- {% endcomment %}
24
-
25
- {% comment %} Liquid procedures
26
- -------------------------------------------------------------------------------- {% endcomment %}
27
-
28
- {% comment %} Set global settings
29
- -------------------------------------------------------------------------------- {% endcomment %}
30
- {% assign environment = site.environment %}
31
- {% assign template_version = site.version %}
32
-
33
- {% if site.permalink == 'none' %}
34
- {% capture page_url %}{{ site.url }}.html{% endcapture %}
35
- {% else %}
36
- {% capture page_url %}{{ site.url }}{% endcapture %}
37
- {% endif %}
38
-
39
- {% comment %} Process YML config data
40
- ================================================================================ {% endcomment %}
41
-
42
- {% comment %} Set config files
43
- -------------------------------------------------------------------------------- {% endcomment %}
44
- {% assign template_config = site.data.j1_config %}
45
- {% assign blocks = site.data.blocks %}
46
- {% assign modules = site.data.modules %}
47
-
48
- {% comment %} Set config data
49
- -------------------------------------------------------------------------------- {% endcomment %}
50
- {% assign banner_config_defaults = blocks.defaults.banner.defaults %}
51
- {% assign banner_config_settings = blocks.banner.settings %}
52
- {% assign panel_config_defaults = blocks.defaults.panel.defaults %}
53
- {% assign panel_config_settings = blocks.panel.settings %}
54
- {% assign footer_config_defaults = blocks.defaults.footer.defaults %}
55
- {% assign toccer_defaults = modules.defaults.toccer.defaults %}
56
- {% assign toccer_settings = modules.toccer.settings %}
57
- {% assign themer_defaults = modules.defaults.themer.defaults %}
58
- {% assign themer_settings = modules.themer.settings %}
59
-
60
- {% assign authentication_defaults = modules.defaults.authentication.defaults %}
61
- {% assign authentication_settings = modules.authentication.settings %}
62
-
63
- {% comment %} Set config options
64
- -------------------------------------------------------------------------------- {% endcomment %}
65
- {% assign toccer_options = toccer_defaults | merge: toccer_settings %}
66
- {% assign themer_options = themer_defaults | merge: themer_settings %}
67
-
68
- {% assign authentication_options = authentication_defaults | merge: authentication_settings %}
69
-
70
- {% assign footer_id = footer_config_defaults.container-id %}
71
- {% assign footer_data_path = footer_config_defaults.data_path %}
72
- {% assign banner_data_path = banner_config_defaults.data_path %}
73
- {% assign panel_data_path = panel_config_defaults.data_path %}
74
-
75
- {% assign hideOnReload = modules.themer_options.hideOnReload %}
76
-
77
- {% assign production = false %}
78
- {% if environment == 'prod' or environment == 'production' %}
79
- {% assign production = true %}
80
- {% endif %}
81
-
82
- /*
83
- # -----------------------------------------------------------------------------
84
- # ~/assets/themes/j1/adapter/js/j1_template.js
85
- # JS Adapter for J1 Template
86
- #
87
- # Product/Info:
88
- # https://jekyll.one
89
- #
90
- # Copyright (C) 2021 Juergen Adams
91
- #
92
- # J1 Template is licensed under the MIT License.
93
- # For details, see https://jekyll.one
94
- # -----------------------------------------------------------------------------
95
- # TODO:
96
- # MANAGE themeExtensionCss is to be checked
97
- #
98
- # -----------------------------------------------------------------------------
99
- # Adapter generated: {{site.time}}
100
- # -----------------------------------------------------------------------------
101
- */
102
-
103
- // -----------------------------------------------------------------------------
104
- // ESLint shimming
105
- // -----------------------------------------------------------------------------
106
- /* eslint indent: "off" */
107
- /* eslint quotes: "off" */
108
- /* eslint semi: "off" */
109
- // -----------------------------------------------------------------------------
110
- 'use strict';
111
-
112
- var j1 = (function () {
113
-
114
- // ---------------------------------------------------------------------------
115
- // globals
116
- // ---------------------------------------------------------------------------
117
- var rePager = new RegExp('navigator|dateview|tagview|archive');
118
- var environment = '{{environment}}';
119
- var moduleOptions = {};
120
- var j1_runtime_data = {};
121
-
122
- // Status information
123
- var state = 'not_started';
124
- var mode = 'not_detected';
125
-
126
- var current_user_data;
127
- var current_page;
128
- var previous_page;
129
- var last_pager;
130
- var last_pager_url;
131
- var app_detected;
132
- var user_session_detected;
133
-
134
- // Connector settings
135
- var translation_enabled = {{template_config.translation.enabled}};
136
-
137
- // Theme information
138
- var themeName;
139
- var themeCss;
140
- var themeExtensionCss = environment === 'production' ? '/assets/themes/j1/core/css/themes/theme-extensions.min.css' : '/assets/themes/j1/core/css/themes/theme-extensions.css';
141
-
142
- // Pathes of J1 data files
143
- var colors_data_path = '{{template_config.colors_data_path}}';
144
- var font_size_data_path = '{{template_config.font_size_data_path}}';
145
- var runtime_data_path = '{{template_config.runtime_data_path}}';
146
- var message_catalog_data_path = '{{template_config.message_catalog_data_path}}';
147
-
148
- // Logger
149
- var logger;
150
- var logText;
151
-
152
- var _this;
153
- var settings;
154
- var json_data;
155
- var ep;
156
- var baseUrl;
157
- var referrer;
158
-
159
- // var default_theme_css = environment === 'production' ? '/assets/themes/j1/core/css/themes/uno-light/bootstrap.min.css' : '/assets/themes/j1/core/css/themes/uno-light/bootstrap.css';
160
- // // TODO: check what property is used default_theme|default_theme_name ?
161
- // var default_theme_display_name = 'Uno (light)';
162
- // var default_theme_name = 'uno-light';
163
- // var default_theme_author = 'J1 Team';
164
- // var default_theme_link = 'https://jekyll.one/';
165
- var default_white_listed_pages = [];
166
-
167
- var cookie_names = {
168
- 'app_session': '{{template_config.cookies.app_session}}',
169
- 'user_session': '{{template_config.cookies.user_session}}',
170
- 'user_state': '{{template_config.cookies.user_state}}'
171
- };
172
-
173
- // user SESSION cookie (initial values)
174
- var user_session = {
175
- 'mode': 'web',
176
- 'writer': 'web',
177
- 'locale': navigator.language || navigator.userLanguage,
178
- 'user_name': '{{template_config.user.user_name}}',
179
- 'provider': '{{template_config.user.provider}}',
180
- 'provider_membership': '{{template_config.user.provider_membership}}',
181
- 'provider_permissions': 'public,{{template_config.user.provider_permissions}}',
182
- 'provider_site_url': '{{template_config.user.provider_site_url}}',
183
- 'provider_home_url': '{{template_config.user.provider_home_url}}',
184
- 'provider_blog_url': '{{template_config.user.provider_blog_url}}',
185
- 'provider_member_url': '{{template_config.user.provider_member_url}}',
186
- 'provider_privacy_url': '{{template_config.user.provider_privacy_url}}',
187
- 'requested_page': 'na',
188
- 'previous_page': 'na',
189
- 'last_pager': '/pages/public/blog/navigator/'
190
- };
191
-
192
- // user STATE cookie (initial values)
193
- var user_state = {
194
- 'theme_css': "",
195
- 'theme_name': "",
196
- 'theme_author': "",
197
- 'theme_version': '{{site.version}}',
198
- 'cookies_accepted': 'pending',
199
- 'whitelistedPages': default_white_listed_pages,
200
- 'deleteOnDecline': false,
201
- 'showConsentOnPending': false,
202
- 'stopScrolling': true,
203
- 'session_active': false,
204
- 'last_session_ts': '',
205
- 'cc_authenticated': false
206
- };
207
-
208
- // ---------------------------------------------------------------------------
209
- // helper functions
210
- // ---------------------------------------------------------------------------
211
-
212
- function executeFunctionByName(functionName, context /*, args */) {
213
- // See: https://stackoverflow.com/questions/359788/how-to-execute-a-javascript-function-when-i-have-its-name-as-a-string
214
- //
215
- var args = Array.prototype.slice.call(arguments, 2);
216
- var namespaces = functionName.split('.');
217
- var func = namespaces.pop();
218
- for(var i = 0; i < namespaces.length; i++) {
219
- context = context[namespaces[i]];
220
- }
221
- return context[func].apply(context, args);
222
- }
223
-
224
- // ---------------------------------------------------------------------------
225
- // main object
226
- // ---------------------------------------------------------------------------
227
- return {
228
-
229
- // -------------------------------------------------------------------------
230
- // init()
231
- // initializer
232
- // -------------------------------------------------------------------------
233
- init: function (options) {
234
-
235
- // -----------------------------------------------------------------------
236
- // global var (function)
237
- // -----------------------------------------------------------------------
238
- var logger = log4javascript.getLogger('j1.init');
239
- var url = new liteURL(window.location.href);
240
- var baseUrl = url.origin;
241
- // moment not used anymore
242
- // var epoch = Math.floor(Date.now()/1000);
243
- // var timestamp_now = moment.unix(epoch).format('YYYY-MM-DD HH:mm:ss');
244
- var date = new Date();
245
- var timestamp_now = date.toISOString();
246
- var curr_state = 'started';
247
- // var date = new Date();
248
- // var my_timestamp = date.toISOString();
249
-
250
-
251
- // -----------------------------------------------------------------------
252
- // options loader
253
- // -----------------------------------------------------------------------
254
- var settings = $.extend(
255
- {
256
- foo: 'foo_option',
257
- bar: 'bar_option'
258
- },
259
- options
260
- );
261
-
262
- // -----------------------------------------------------------------------
263
- // status settings
264
- // save status into the adapter object for (later) global access
265
- // -----------------------------------------------------------------------
266
- j1['xhrDataState'] = {};
267
- j1['xhrDOMState'] = {};
268
-
269
- // -----------------------------------------------------------------------
270
- // session ON_CLOSE event
271
- // wrapup if ALL browser windows get closed. Update user STATE
272
- // cookie on window CLOSE.
273
- // see: https://stackoverflow.com/questions/3888902/detect-browser-or-tab-closing
274
- // -----------------------------------------------------------------------
275
- window.addEventListener('beforeunload', function (event) {
276
- var cookie_names = j1.getCookieNames();
277
- var cookie_user_state_name = cookie_names.user_state;
278
- var cookie_user_session_name = cookie_names.user_session;
279
- // moment not used anymore
280
- // var epoch = Math.floor(Date.now()/1000);
281
- // var timestamp_now = moment.unix(epoch).format('YYYY-MM-DD HH:mm:ss');
282
- var date = new Date();
283
- var timestamp_now = date.toISOString();
284
- var user_state = j1.readCookie(cookie_user_state_name);
285
- var ep_status;
286
- var url;
287
- var baseUrl;
288
-
289
- // update cookie only, if (already) exists
290
- //
291
- if (user_state) {
292
- user_state.session_active = false;
293
- user_state.last_session_ts = timestamp_now;
294
-
295
- j1.writeCookie({
296
- name: cookie_user_state_name,
297
- data: user_state,
298
- expires: 365
299
- });
300
- }
301
-
302
- });
303
-
304
- // -----------------------------------------------------------------------
305
- // initialize|load (existing) user cookies
306
- // -----------------------------------------------------------------------
307
- user_session.created = timestamp_now;
308
- user_session.timestamp = timestamp_now;
309
-
310
- user_session = j1.existsCookie(cookie_names.user_session)
311
- ? j1.readCookie(cookie_names.user_session)
312
- : j1.writeCookie({
313
- name: cookie_names.user_session,
314
- data: user_session,
315
- });
316
-
317
- user_state = j1.existsCookie(cookie_names.user_state)
318
- ? j1.readCookie(cookie_names.user_state)
319
- : j1.writeCookie({
320
- name: cookie_names.user_state,
321
- data: user_state,
322
- expires: 365
323
- });
324
-
325
- user_state.session_active = true;
326
- j1.writeCookie({
327
- name: cookie_names.user_state,
328
- data: user_state,
329
- expires: 365
330
- });
331
-
332
- // detect middleware (mode 'app') and update user session cookie
333
- // -----------------------------------------------------------------------
334
- // if (user_session.mode === 'na' || user_session.mode === 'app') {
335
- if (user_session.mode === 'app') {
336
- var url = new liteURL(window.location.href);
337
- var ep_status = baseUrl + '/status' + '?page=' + window.location.pathname;
338
- var detectTimeout = 50;
339
-
340
- baseUrl = url.origin;
341
-
342
- // see: https://stackoverflow.com/questions/3709597/wait-until-all-jquery-ajax-requests-are-done
343
- $.when (
344
- $.ajax(ep_status)
345
- )
346
- .then(function(data) {
347
- var logger = log4javascript.getLogger('j1.init');
348
- user_session = j1.readCookie(cookie_names.user_session);
349
- user_session.mode = 'app';
350
- user_session.requested_page = window.location.pathname;
351
- user_session.timestamp = timestamp_now;
352
- user_session = j1.mergeData(user_session, data);
353
- logText = 'mode detected: ' + user_session.mode;
354
-
355
- logger.info(logText);
356
- logger.info('update user session cookie');
357
- j1.writeCookie({
358
- name: cookie_names.user_session,
359
- data: user_session
360
- });
361
- j1.setState(curr_state);
362
- logger.info('state: ' + j1.getState());
363
-
364
-
365
-
366
-
367
- var dependencies_met_page_displayed = setInterval (function () {
368
- if (j1.getState() == 'finished') {
369
- if (j1.authEnabled()) {
370
- if (user_session.authenticated === 'true') {
371
- // set signout
372
- logger.info('show signout icon');
373
- $('#navLinkSignInOut').attr('data-target','#modalOmniSignOut');
374
- $('#iconSignInOut').removeClass('mdi-login').addClass('mdi-logout');
375
- } else {
376
- // set signin
377
- logger.info('show signin icon');
378
- $('#navLinkSignInOut').attr('data-target','#modalOmniSignIn');
379
- $('#iconSignInOut').removeClass('mdi-logout').addClass('mdi-login');
380
- }
381
- logger.info('authentication detected as: ' + user_session.authenticated);
382
- $('#quickLinksSignInOutButton').css('display', 'block');
383
- logger.info('met dependencies for: j1');
384
- clearInterval(dependencies_met_page_displayed);
385
- }
386
- }
387
- }, 25); // END dependencies_met_page_displayed
388
- })
389
- .catch(function(error) {
390
- // jadams, 2018-08-31: Why a hell a setTimeout is needed ???
391
- setTimeout (function() {
392
- var logger = log4javascript.getLogger('j1.init');
393
- user_session = j1.readCookie(cookie_names.user_session);
394
- user_session.mode = 'web';
395
- user_session.requested_page = window.location.pathname;
396
- user_session.timestamp = timestamp_now;
397
- logText = 'mode detected: ' + user_session.mode;
398
-
399
- logger.info(logText);
400
- j1.writeCookie({
401
- name: cookie_names.user_session,
402
- data: user_session
403
- });
404
- j1.setState(curr_state);
405
- logger.info('state: ' + j1.getState());
406
- }, detectTimeout);
407
- });
408
- } else { // app mode
409
- state = 'started';
410
- logger.info('state: ' + state);
411
- logger.info('page is being initialized');
412
- }
413
-
414
- // jadams: for testing only
415
- // display page
416
- // $('#no_flicker').css('display', 'block');
417
-
418
- state = 'started';
419
- logger.info('state: ' + state);
420
- logger.info('page is being initialized');
421
-
422
- if ( settings.scrollbar === 'false' ) {
423
- $('body').addClass('hide-scrollbar');
424
- $('html').addClass('hide-scrollbar-moz');
425
- }
426
-
427
- logger.info('read user state from cookie');
428
- user_session = j1.readCookie(cookie_names.user_session);
429
-
430
- // process|update user state cookie
431
- themeName = user_session.theme_name;
432
- themeCss = user_session.theme_css;
433
- themeExtensionCss = user_session.theme_extension_css;
434
-
435
- // save last page access
436
- // see: https://stackoverflow.com/questions/3528324/how-to-get-the-previous-url-in-javascript
437
- // see: https://developer.mozilla.org/de/docs/Web/API/Window/history
438
- //
439
- user_session.timestamp = timestamp_now;
440
- referrer = new liteURL(document.referrer);
441
- current_page = window.location.pathname;
442
- user_session.requested_page = current_page;
443
- user_session.previous_page = referrer.search === '' ?
444
- (referrer.pathname === '' ? current_page : referrer.pathname) :
445
- (user_session.previous_page === '' || user_session.previous_page === 'na'
446
- ? '/'
447
- : user_session.previous_page
448
- );
449
-
450
- // calculate last 'pager' if any
451
- if (rePager.test(user_session.previous_page)) {
452
- last_pager = user_session.previous_page;
453
- user_session.last_pager = last_pager;
454
- } else {
455
- last_pager = user_session.last_pager;
456
- }
457
-
458
- // jadams: for testing only
459
- // display page
460
- //$('#no_flicker').css('display', 'block');
461
-
462
- logger.info('update user session cookie');
463
- j1.writeCookie({
464
- name: cookie_names.user_session,
465
- data: user_session
466
- });
467
-
468
- // initialize page resources for blocks
469
- // (asynchronous, should be rewitten to xhrData)
470
- j1.initBanner(settings);
471
- j1.initPanel(settings);
472
- j1.initFooter(settings);
473
-
474
- state = 'running';
475
- logger.info('state: ' + state);
476
- logger.info(logText);
477
-
478
- user_session.timestamp = timestamp_now;
479
- j1.writeCookie({
480
- name: cookie_names.user_session,
481
- data: user_session
482
- });
483
-
484
- // -----------------------------------------------------------------------
485
- // additional BS helpers from j1.core
486
- // -----------------------------------------------------------------------
487
- j1.core.bsFormClearButton();
488
-
489
- // finalize and display page
490
- j1.displayPage();
491
-
492
- }, // END init
493
-
494
- // -------------------------------------------------------------------------
495
- // initBanner()
496
- // AJAX fetcher to load and place all banner used for a page
497
- // -------------------------------------------------------------------------
498
- initBanner: function (options) {
499
- var logger = log4javascript.getLogger('j1.initBanner');
500
- var banner = [];
501
- var bannerOptions = [];
502
- var mod = 'j1';
503
- var logText;
504
-
505
- {% comment %}
506
- Closure to pass additional data (e.g. #banner_id) to AJAX load callback
507
- See: http://stackoverflow.com/questions/939032/jquery-pass-more-parameters-into-callback
508
- -------------------------------------------------------------------------- {% endcomment %}
509
- var cb_load_closure = function(banner_id) {
510
- return function ( responseTxt, statusTxt, xhr ) {
511
- if ( statusTxt == 'success' ) {
512
- var logger = log4javascript.getLogger('j1.adapter.xhrData');
513
- logText = 'loading banner completed on id: ' +banner_id;
514
- logger.info(logText);
515
- j1.setXhrDataState(banner_id, statusTxt);
516
- j1.setXhrDomState(banner_id, statusTxt);
517
- logger.info('XHR data loaded in the DOM: ' + banner_id);
518
- }
519
- if ( statusTxt == 'error' ) {
520
- logText = 'loading banner failed on id: ' +banner_id+ ', error: ' + xhr.status + ': ' + xhr.statusText;
521
- logger.error(logText);
522
- j1.setXhrDataState(banner_id, statusTxt);
523
- j1.setXhrDomState(banner_id, statusTxt);
524
- // Set|Log status
525
- state = 'failed';
526
- logger.error('state: ' + state);
527
- }
528
- };
529
- };
530
-
531
- {% comment %} Collect all banner id|s configured
532
- -------------------------------------------------------------------------- {% endcomment %}
533
- {% for items in banner_config_settings %}
534
- {% assign key = items[0] %}
535
- {% assign value = items[1] %}
536
-
537
- {% if key == 'divider' %} {% assign banner_config = value %} {% endif %}
538
- {% if key == 'teaser' %} {% assign banner_config = value %} {% endif %}
539
- {% if key == 'image' %} {% assign banner_config = value %} {% endif %}
540
- {% if key == 'parallax' %} {% assign banner_config = value %} {% endif %}
541
- {% if key == 'exception' %} {% assign banner_config = value %} {% endif %}
542
-
543
- {% for items in banner_config %}
544
- {% for banners in items %}
545
-
546
- {% for banner in banners %}
547
- {% for item in banner %}
548
- {% assign key = item[0] %}
549
- {% assign value = item[1] %}
550
-
551
- {% if key and debug %} item:value {{key}}:{{value}} {% endif %}
552
-
553
- {% if key == 'id' %} {% assign id = value %} {% endif %}
554
- {% if key == 'enabled' %} {% assign enabled = value %} {% endif %}
555
- {% endfor %}
556
- {% endfor %}
557
-
558
- {% if id and enabled %}
559
-
560
- {% comment %} Register current banner
561
- -------------------------------------------------------------------- {% endcomment %}
562
- banner.push('{{id}}');
563
- {% endif %}
564
-
565
- {% endfor %} {% comment %} END banners {% endcomment %}
566
-
567
- {% comment %} Reset (Liquid) element variables
568
- ---------------------------------------------------------------------- {% endcomment %}
569
- {% assign id = nil %}
570
- {% assign enabled = nil %}
571
- {% assign banner_config = nil %}
572
-
573
- {% endfor %} {% comment %} END banner_config {% endcomment %}
574
- {% endfor %} {% comment %} END banner_config_settings {% endcomment %}
575
-
576
- {% comment %} REGISTER exceptions container
577
- -------------------------------------------------------------------------- {% endcomment %}
578
- banner.push('exception_container');
579
-
580
- {% comment %} LOAD all banner registered
581
- -------------------------------------------------------------------------- {% endcomment %}
582
- if ( banner.length ) {
583
- for (var i in banner) {
584
- var id = '#' + banner[i];
585
- var selector = $(id);
586
- if (selector.length) {
587
- logText = 'loading banner on id: ' +banner[i];
588
- logger.info(logText);
589
- // var banner_data_path = '{{banner_data_path}} ' + id + ' > *';
590
- var banner_data_path = '{{banner_data_path}} ' + id;
591
- selector.load(banner_data_path, cb_load_closure(id));
592
- }
593
- } // END for
594
- } else {
595
- logText = 'no banner found in site';
596
- logger.info(logText);
597
- return false;
598
- }
599
- return true;
600
- }, // END initBanner
601
-
602
- // -------------------------------------------------------------------------
603
- // initPanel()
604
- // AJAX fetcher to load and place all panel used for a page
605
- // -------------------------------------------------------------------------
606
- // ToDo:
607
- initPanel: function ( options ) {
608
- var logger = log4javascript.getLogger('j1.initPanel');
609
- var panel = [];
610
- var mod = 'j1';
611
- var logText;
612
-
613
- {% comment %} Closure to pass additional data (e.g. panel_id) to AJAX load callback
614
- See: http://stackoverflow.com/questions/939032/jquery-pass-more-parameters-into-callback
615
- -------------------------------------------------------------------------- {% endcomment %}
616
-
617
- {% comment %} NOTE
618
- strategy for MutationObserver callbacks to monitor DOM changes
619
- needs to be checked if multiple containers are chenaged in a row
620
- -------------------------------------------------------------------------- {% endcomment %}
621
- var cb_load_closure = function(panel_id) {
622
- return function ( responseTxt, statusTxt, xhr ) {
623
- var logger = log4javascript.getLogger('j1.adapter.xhrData');
624
- if ( statusTxt == 'success' ) {
625
- logText = 'loading panel completed on id: ' +panel_id;
626
- logger.info(logText);
627
- j1.setXhrDataState(panel_id, statusTxt);
628
- j1.setXhrDomState(panel_id, statusTxt);
629
- logger.info('XHR data loaded in the DOM: ' + panel_id);
630
- }
631
- if ( statusTxt == 'error' ) {
632
- logText = 'loading panel failed on id: ' +panel_id+ ', error ' + xhr.status + ': ' + xhr.statusText;
633
- logger.error(logText);
634
- j1.setXhrDataState(panel_id, statusTxt);
635
- j1.setXhrDomState(panel_id, statusTxt);
636
- // Set|Log status
637
- state = 'Error';
638
- logger.error('state: ' + state);
639
- }
640
- };
641
- };
642
-
643
- {% comment %} Collect all panel id|s configured
644
- -------------------------------------------------------------------------- {% endcomment %}
645
- {% for items in panel_config_settings %}
646
- {% assign key = items[0] %}
647
- {% assign value = items[1] %}
648
-
649
- {% if key == 'intro' %} {% assign panel_config = value %} {% endif %}
650
- {% if key == 'service' %} {% assign panel_config = value %} {% endif %}
651
- {% if key == 'step' %} {% assign panel_config = value %} {% endif %}
652
- {% if key == 'news' %} {% assign panel_config = value %} {% endif %}
653
- {% if key == 'exception' %} {% assign panel_config = value %} {% endif %}
654
-
655
- {% for items in panel_config %}
656
- {% for panels in items %}
657
-
658
- {% for panel in panels %}
659
- {% for item in panel %}
660
- {% assign key = item[0] %}
661
- {% assign value = item[1] %}
662
-
663
- {% if key and debug %} item:value {{key}}:{{value}} {% endif %}
664
-
665
- {% if key == 'id' %} {% assign id = value %} {% endif %}
666
- {% if key == 'enabled' %} {% assign enabled = value %} {% endif %}
667
- {% endfor %}
668
- {% endfor %}
669
-
670
- {% comment %} Register current panel
671
- -------------------------------------------------------------------------- {% endcomment %}
672
- {% if id and enabled %}
673
- panel.push('{{id}}');
674
- {% endif %}
675
-
676
- {% comment %} Reset (Liquid) element variables
677
- -------------------------------------------------------------------------- {% endcomment %}
678
- {% assign id = nil %}
679
- {% assign enabled = nil %}
680
- {% assign panel_config = nil %}
681
-
682
- {% endfor %} {% comment %} END panels {% endcomment %}
683
- {% endfor %} {% comment %} END panel_config {% endcomment %}
684
- {% endfor %} {% comment %} END panel_config_settings {% endcomment %}
685
-
686
- if (panel.length) {
687
- for (var i in panel) {
688
- var id = '#' + panel[i];
689
- var selector = $(id);
690
- if ( selector.length ) {
691
- logText = 'loading panel on id: ' +panel[i];
692
- logger.info(logText);
693
- // var panel_data_path = '{{panel_data_path}} ' + id + ' > *';
694
- var panel_data_path = '{{panel_data_path}} ' + id;
695
- selector.load(panel_data_path, cb_load_closure(id));
696
- }
697
- } // END for
698
- } else {
699
- logText = 'no panel found in site';
700
- logger.info(logText);
701
- return false;
702
- }
703
- return true;
704
- }, // END initPanel
705
-
706
- // -------------------------------------------------------------------------
707
- // initFooter()
708
- // AJAX fetcher to load and place the footer used for a page
709
- // -------------------------------------------------------------------------
710
- initFooter: function ( options ) {
711
- var logger = log4javascript.getLogger('j1.initFooter');
712
- var mod = 'j1';
713
- var logText;
714
-
715
- logText = 'loading footer started';
716
- logger.info(logText);
717
-
718
- var cb_load_closure = function(footer_id) {
719
- return function ( responseTxt, statusTxt, xhr ) {
720
- var logger = log4javascript.getLogger('j1.adapter.xhrData');
721
- if ( statusTxt == 'success' ) {
722
- logText = 'footer loaded successfully on id: ' + footer_id;
723
- logger.info(logText);
724
- j1.setXhrDataState(footer_id, statusTxt);
725
- j1.setXhrDomState(footer_id, statusTxt);
726
- logger.info('XHR data loaded in the DOM: ' + footer_id);
727
-
728
- // jadams, 2020-07-21: intermediate state DISABLED
729
- // state = 'footer_loaded';
730
- // logger.info('set state for module ' + mod + ': ' + state);
731
- // executeFunctionByName(mod + '.setState', window, state);
732
-
733
- logText = 'initialization finished';
734
- logger.info(logText);
735
- }
736
- if ( statusTxt == 'error' ) {
737
- logText = 'loading footer failed on id: ' +footer_id+ ', error ' + xhr.status + ': ' + xhr.statusText;
738
- logger.error(logText);
739
- j1.setXhrDataState(footer_id, statusTxt);
740
- j1.setXhrDomState(footer_id, statusTxt);
741
-
742
- // Set|Log status
743
- state = 'failed';
744
- logger.error('state: ' + state);
745
- logText = 'initialization finished';
746
- logger.info(logText);
747
- }
748
- };
749
- };
750
-
751
- var id = '#' + '{{footer_id}}';
752
- var selector = $(id);
753
- if ( selector.length ) {
754
- // var footer_data_path = '{{footer_data_path}} ' + id + ' > *';
755
- var footer_data_path = '{{footer_data_path}} ' + id;
756
- selector.load(footer_data_path, cb_load_closure(id));
757
- } else {
758
- logText = 'data not loaded';
759
- logger.warn(logText);
760
- j1.setXhrDataState(id, 'not loaded');
761
- j1.setXhrDomState(id, 'pending');
762
- return false;
763
- }
764
- return true;
765
- }, // END initFooter
766
-
767
- // -------------------------------------------------------------------------
768
- // displayPage
769
- // show the page after timeout of {{flickerTimeout}} ms
770
- // -------------------------------------------------------------------------
771
- // NOTE:
772
- // jadams, 2019-08-21: for unknown reason, the user state data
773
- // (read from cookie) seems not correct (or loaded too late).
774
- // To make correct data sure for APP mode, a status request is done
775
- // to load the current state from the middleware (skipped in WEB mode)
776
- // -------------------------------------------------------------------------
777
- displayPage: function (options) {
778
- var logger = log4javascript.getLogger('j1.adapter.displayPage');
779
- var flickerTimeout = {{template_config.flicker_timeout}};
780
- var url = new liteURL(window.location.href);
781
- var baseUrl = url.origin;
782
- var ep_status = baseUrl + '/status' + '?page=' + window.location.pathname;
783
- var user_session = j1.readCookie(cookie_names.user_session);
784
- var user_state = j1.readCookie(cookie_names.user_state);
785
- var current_url = new liteURL(window.location.href);
786
- var providerPermissions = {};
787
- var provider;
788
- var previous_page;
789
- var appDetected;
790
- var categoryAllowed;
791
-
792
- logger.info('finalize page');
793
- j1.setCss();
794
-
795
- logText= 'loading page partials: started';
796
- logger.info(logText);
797
-
798
- if (j1.appDetected()) { // app mode
799
- logger.info('mode detected: app');
800
-
801
- $.when ($.ajax(ep_status))
802
- .then(function(data) {
803
- var logger = log4javascript.getLogger('j1.displayPage');
804
-
805
- user_session = j1.mergeData(user_session, data);
806
-
807
- user_session.current_page = current_url.pathname;
808
- j1.writeCookie({
809
- name: cookie_names.user_session,
810
- data: user_session
811
- });
812
-
813
- providerPermissions = user_session.provider_permissions;
814
- categoryAllowed = providerPermissions.includes(user_session.page_permission);
815
-
816
- // check protected pages (applies for APP only)
817
- // make sure that protected pages are ALWAYS checked for permissions
818
- // -------------------------------------------------------------------
819
- if (
820
- j1.authEnabled() &&
821
- user_session.page_permission !== 'public' &&
822
- categoryAllowed === false
823
- ){
824
- // redirect to middleware|page_authentication
825
- if (data.authenticated === 'true') {
826
- var ep_post_authentication = baseUrl + '/post_authentication';
827
- window.location.href = ep_post_authentication;
828
- } else if (j1.authEnabled()) {
829
- var ep_page_validation = baseUrl + '/page_validation?page=' + window.location.pathname;
830
- window.location.href = ep_page_validation;
831
- return false;
832
- }
833
- } // END check protected pages
834
-
835
- // show the page delayed
836
- setTimeout (function() {
837
- // display page
838
- $('#no_flicker').css('display', 'block');
839
-
840
- // show|hide cookie icon (should MOVED to Cookiebar ???)
841
- if (user_state.cookies_accepted === 'accepted') {
842
- // Display cookie icon
843
- logText = 'show cookie icon';
844
- logger.info(logText);
845
- $('#quickLinksCookieButton').css('display', 'block');
846
- } else {
847
- logText = 'hide cookie icon';
848
- logger.info(logText);
849
- // Display cookie icon
850
- $('#quickLinksCookieButton').css('display', 'none');
851
- }
852
-
853
- // show|hide translator icon
854
- if (translation_enabled) {
855
- logger.info('translator detected: google');
856
- logger.info('initialize language selector');
857
- $('.goog-te-combo').addClass('form-control');
858
- }
859
-
860
- // show cc icon
861
- // $('#quickLinksControlCenterButton').css('display', 'block');
862
-
863
- if (j1.authEnabled()) {
864
- if (user_session.authenticated === 'true') {
865
- // set signout
866
- logger.info('show signout icon');
867
- $('#navLinkSignInOut').attr('data-target','#modalOmniSignOut');
868
- $('#iconSignInOut').removeClass('mdi-login').addClass('mdi-logout');
869
- } else {
870
- // set signin
871
- logger.info('show signin icon');
872
- $('#navLinkSignInOut').attr('data-target','#modalOmniSignIn');
873
- $('#iconSignInOut').removeClass('mdi-logout').addClass('mdi-login');
874
- }
875
- logger.info('authentication detected as: ' + user_session.authenticated);
876
- $('#quickLinksSignInOutButton').css('display', 'block');
877
- }
878
-
879
- // if the page requested contains an anchor element,
880
- // do a smooth scroll to
881
- j1.scrollTo();
882
-
883
- if (user_session.previous_page !== user_session.current_page) {
884
- logText = 'page change detected';
885
- logger.info(logText);
886
- logText = 'previous page: ' + user_session.previous_page;
887
- logger.info(logText);
888
- logText = 'current page: ' + user_session.current_page;
889
- logger.info(logText);
890
- }
891
-
892
- // update sidebar for changed theme data
893
- logger.info('update sidebar');
894
- user_state = j1.readCookie(cookie_names.user_state);
895
- current_user_data = j1.mergeData(user_session, user_state);
896
- j1.core.navigator.updateSidebar(current_user_data);
897
-
898
- // Set|Log status
899
- state = 'finished';
900
- logText = 'state: ' + state;
901
- logger.info(logText);
902
- logText = 'page finalized successfully';
903
- logger.info(logText);
904
-
905
- }, flickerTimeout);
906
- }); // END APP mode
907
- } else { // web mode
908
- // show the page delayed
909
- setTimeout (function() {
910
- j1.setState('finished');
911
- logger.info('state: finished');
912
- logger.info('page initialization: finished');
913
-
914
- // display page
915
- $('#no_flicker').css('display', 'block');
916
-
917
- logger.info('mode detected: web');
918
- logger.info('hide signin icon');
919
- $('#quickLinksSignInOutButton').css('display', 'none');
920
-
921
- user_session.current_page = current_url.pathname;
922
- j1.writeCookie({
923
- name: cookie_names.user_session,
924
- data: user_session
925
- });
926
-
927
- // show|hide translator icon
928
- if (translation_enabled) {
929
- logger.info('translator detected: google');
930
- logger.info('initialize language selector');
931
- $('.goog-te-combo').addClass('form-control');
932
- }
933
-
934
- // show|hide cookie icon (should MOVED to Cookiebar ???)
935
- if (user_state.cookies_accepted === 'accepted') {
936
- // Display cookie icon
937
- logText = 'show cookie icon';
938
- logger.info(logText);
939
- $('#quickLinksCookieButton').css('display', 'block');
940
- } else {
941
- logText = 'hide cookie icon';
942
- logger.info(logText);
943
- // Display cookie icon
944
- $('#quickLinksCookieButton').css('display', 'none');
945
- }
946
-
947
- // If the page requested contains an anchor element,
948
- // do a smooth scroll to
949
- j1.scrollTo();
950
-
951
- if (user_session.previous_page !== user_session.current_page) {
952
- logText = 'page change detected';
953
- logger.info(logText);
954
- logText = 'previous page: ' + user_session.previous_page;
955
- logger.info(logText);
956
- logText = 'current page: ' + user_session.current_page;
957
- logger.info(logText);
958
- }
959
-
960
- // update sidebar for changed theme data
961
- logger.info('update sidebar');
962
- user_state = j1.readCookie(cookie_names.user_state);
963
- current_user_data = j1.mergeData(user_session, user_state);
964
- j1.core.navigator.updateSidebar(current_user_data);
965
-
966
- // set|log status
967
- state = 'finished';
968
- logText = 'state: ' + state;
969
- logger.info(logText);
970
- logText = 'page finalized successfully';
971
- logger.info(logText);
972
-
973
- }, flickerTimeout);
974
- } // END WEB mode
975
- }, // END displayPage
976
-
977
- // -------------------------------------------------------------------------
978
- // Helper functions
979
- // -------------------------------------------------------------------------
980
-
981
- // -------------------------------------------------------------------------
982
- // mergeData()
983
- // merge two objects (properties) and returns the resulting object
984
- // see: https://stackoverflow.com/questions/43109229/merge-default-options-containing-object-with-json-object
985
- // TODO: Improve comment, give synopsis and example
986
- // -------------------------------------------------------------------------
987
- mergeData: function () {
988
- var a = [].slice.call(arguments), o = a.shift();
989
-
990
- for(var i=0,l=a.length; i<l; i++){
991
- for(var p in a[i]){
992
- o[p] = a[i][p];
993
- }
994
- }
995
- return o;
996
- }, // END mergeData
997
-
998
- // -------------------------------------------------------------------------
999
- // getPrevPage()
1000
- // Returns the last vistited page
1001
- // -------------------------------------------------------------------------
1002
- getPrevPage: function () {
1003
- return previous_page;
1004
- }, // END getPrevPage
1005
-
1006
- // -------------------------------------------------------------------------
1007
- // getLanguage()
1008
- // Returns the preferred language taken form window.navigator
1009
- // See:
1010
- // https://stackoverflow.com/questions/1043339/javascript-for-detecting-browser-language-preference
1011
- // -------------------------------------------------------------------------
1012
- getLanguage: function () {
1013
- var language = navigator.languages ? navigator.languages[0] : (navigator.language || navigator.userLanguage);
1014
- }, // END getLanguage
1015
-
1016
- // -------------------------------------------------------------------------
1017
- // getTemplateVersion()
1018
- // Returns the template version taken from site config (_config.yml)
1019
- // -------------------------------------------------------------------------
1020
- getTemplateVersion: function () {
1021
- return '{{template_version}}';
1022
- }, // END getTemplateVersion
1023
-
1024
- // -------------------------------------------------------------------------
1025
- // scrollTo()
1026
- // Scrolls smooth to any anchor referenced by an page URL on
1027
- // e.g. a page reload. Values for delay|offset are taken from
1028
- // TOCCER module
1029
- // -------------------------------------------------------------------------
1030
- scrollTo: function () {
1031
- var anchor = window.location.href.split('#')[1];
1032
- var anchor_id = '#' + anchor;
1033
- var selector;
1034
-
1035
- var logger = log4javascript.getLogger('j1.scrollTo');
1036
-
1037
- var toccerScrollDuration = {{toccer_options.scrollSmoothDuration}};
1038
- var toccerScrollOffset = {{toccer_options.scrollSmoothOffset}};
1039
-
1040
- // calculate offset for correct (smooth) scroll position
1041
- //
1042
- var $pagehead = $('.attic');
1043
- var $navbar = $('nav.navbar');
1044
- var $adblock = $('#adblock');
1045
-
1046
- var navbarType = $navbar.hasClass('navbar-fixed') ? 'fixed' : 'scrolled';
1047
- var fontSize = $('body').css('font-size').replace('px','');
1048
- var start = window.pageYOffset;
1049
-
1050
- var l = parseInt(fontSize);
1051
-
1052
- var h = $pagehead.length ? $pagehead.height() : 0;
1053
- var n = $navbar.length ? $navbar.height() : 0;
1054
- var a = $adblock.length ? $adblock.height() : 0;
1055
-
1056
- var scrollOffset = navbarType == 'fixed' ? -1*(n + a + l) : -1*(h + n + a + l);
1057
-
1058
- // static offset, to be checked why this is needed
1059
- //
1060
- scrollOffset = scrollOffset + toccerScrollOffset;
1061
-
1062
- if (anchor_id && anchor_id !== '#') {
1063
- // scroll only, if an anchor is given with URL
1064
- selector = $(anchor_id);
1065
- if (selector.length) {
1066
- j1.core.scrollSmooth.scroll( anchor_id, {
1067
- duration: toccerScrollDuration,
1068
- offset: scrollOffset,
1069
- callback: null
1070
- });
1071
- } else {
1072
- // scroll the page one pixel back and forth (trigger)
1073
- // to get the right position for the Toccer and adjust the
1074
- // Navigator to display the (tranparent) navbar correctly
1075
- //
1076
- $(window).scrollTop($(window).scrollTop()+1);
1077
- $(window).scrollTop($(window).scrollTop()-1);
1078
- } // END if anchor_id
1079
- } else if (anchor_id === '#') {
1080
- logger.info('bound click event to "#", suppress default action');
1081
- $(window).scrollTop($(window).scrollTop()+1);
1082
- $(window).scrollTop($(window).scrollTop()-1);
1083
- return false;
1084
- }
1085
- }, // END scrollTo
1086
-
1087
- // -------------------------------------------------------------------------
1088
- // authEnabled()
1089
- // Returns the state of the authentication module
1090
- // -------------------------------------------------------------------------
1091
- authEnabled: function () {
1092
- var logger = log4javascript.getLogger('j1.authentication');
1093
- var authEnabled = {{authentication_options.j1_auth.enabled}};
1094
-
1095
- return authEnabled;
1096
- }, // END authEnabled
1097
-
1098
- // -------------------------------------------------------------------------
1099
- // appDetected()
1100
- // Returns true if a web session cookie exists
1101
- // -------------------------------------------------------------------------
1102
- appDetected: function () {
1103
- var user_session;
1104
- var cookieExists = j1.existsCookie(cookie_names.user_session);
1105
- var detected = false;
1106
-
1107
- if (cookieExists) {
1108
- user_session = j1.readCookie(cookie_names.user_session);
1109
- detected = user_session.mode === 'app' ? true : false;
1110
- } else {
1111
- // detected = 'unknown';
1112
- detected = false;
1113
- }
1114
- return detected;
1115
- }, // END appDetected
1116
-
1117
- // -------------------------------------------------------------------------
1118
- // xhrData()
1119
- // Load data asychronously using XHR|jQuery on an HTML element (e.g. <div>)
1120
- // specified by xhr_container_id, xhr_data_path (options)
1121
- // -------------------------------------------------------------------------
1122
- xhrData: function (options, mod, status) {
1123
- var logger = log4javascript.getLogger('j1.adapter.xhrData');
1124
- var selector = $('#' + options.xhr_container_id);
1125
- var state = status;
1126
- var observer_options = {
1127
- attributes: false,
1128
- childList: true,
1129
- characterData: false,
1130
- subtree: true
1131
- };
1132
- var observer;
1133
- var logText;
1134
-
1135
- var cb_load_closure = function(mod, id) {
1136
- return function (responseTxt, statusTxt, xhr) {
1137
- var logger = log4javascript.getLogger('j1.adapter.xhrData');
1138
- if ( statusTxt === 'success' ) {
1139
- // jadams, 2020-07-21: intermediate state should DISABLED
1140
- // if (state) {
1141
- // logger.info('set state for ' +mod+ ' to: ' + state);
1142
- // executeFunctionByName(mod + '.setState', window, state);
1143
- // }
1144
- j1.setXhrDataState(id, statusTxt);
1145
- j1.setXhrDomState(id, 'pending');
1146
-
1147
- logText = 'data loaded successfully on id: ' +id;
1148
- logger.info(logText);
1149
- state = true;
1150
- }
1151
- if ( statusTxt === 'error' ) {
1152
- // jadams, 2020-07-21: to be checked why id could be UNDEFINED
1153
- if (typeof(id) != "undefined") {
1154
- state = 'failed';
1155
- logger.info('set state for ' +mod+ ' to: ' + state);
1156
- // jadams, 2020-07-21: intermediate state should DISABLED
1157
- // executeFunctionByName(mod + '.setState', window, state);
1158
- j1.setXhrDataState(id, statusTxt);
1159
- j1.setXhrDomState(id, 'pending');
1160
- logText = 'loading data failed on id: ' +id+ ', error ' + xhr.status + ': ' + xhr.statusText;
1161
- logger.error(logText);
1162
- state = false;
1163
- }
1164
- }
1165
- };
1166
- };
1167
- // see: https://stackoverflow.com/questions/20420577/detect-added-element-to-dom-with-mutation-observer
1168
- var html_data_path;
1169
- var id = '#' + options.xhr_container_id;
1170
- var $selector = $(id);
1171
-
1172
- if ( $selector.length ) {
1173
- if (options.xhr_data_element) {
1174
- html_data_path = options.xhr_data_path + ' #' + options.xhr_data_element + ' > *';
1175
- // html_data_path = options.xhr_data_path + ' #' + options.xhr_data_element;
1176
- } else {
1177
- html_data_path = options.xhr_data_path + ' > *';
1178
- }
1179
- $selector.load( html_data_path, cb_load_closure( mod, id ) );
1180
-
1181
- var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
1182
- var xhrObserver = new MutationObserver (mutationHandler);
1183
- var obsConfig = {
1184
- childList: true,
1185
- characterData: false,
1186
- attributes: false,
1187
- subtree: false };
1188
-
1189
- selector.each(function(){
1190
- xhrObserver.observe(this, obsConfig);
1191
- } );
1192
-
1193
- function mutationHandler (mutationRecords) {
1194
- mutationRecords.forEach ( function (mutation) {
1195
- if (mutation.addedNodes.length) {
1196
- logger.info('XHR data loaded in the DOM: ' + id);
1197
- j1.setXhrDomState(id, 'success');
1198
- }
1199
- });
1200
- }
1201
- } else {
1202
- // jadams, 2020-07-21: To be clarified why a id is "undefined"
1203
- if (id != '#undefined') {
1204
- logText = 'data not loaded on id:' + id;
1205
- logger.warn(logText);
1206
- j1.setXhrDataState(id, 'not loaded');
1207
- j1.setXhrDomState(id, 'not loaded');
1208
- // Set processing state to 'finished' to complete module load
1209
- state = 'finished';
1210
- logger.info('state: ' + state);
1211
- // jadams, 2020-07-21: intermediate state should DISABLED
1212
- // executeFunctionByName(mod + '.setState', window, state);
1213
- state = false;
1214
- }
1215
- }
1216
- return state;
1217
- }, // END xhrData
1218
-
1219
- // -------------------------------------------------------------------------
1220
- // readCookie()
1221
- // -------------------------------------------------------------------------
1222
- readCookie: function (name) {
1223
- var data;
1224
- var data_json;
1225
- var cookieExists = j1.existsCookie(name);
1226
-
1227
- if (cookieExists) {
1228
- data_json = window.atob(Cookies.get(name));
1229
- data = JSON.parse(data_json);
1230
-
1231
- if (data) {
1232
- return data;
1233
- } else {
1234
- return false;
1235
- }
1236
- } else {
1237
- return false;
1238
- }
1239
- }, // END readCookie
1240
-
1241
- // -------------------------------------------------------------------------
1242
- // writeCookie()
1243
- // Write 'data' to a cookie 'name'. If not exists, the cookie gets
1244
- // created. Returns 'true' if cookie was written, otherwise 'false'.
1245
- // -------------------------------------------------------------------------
1246
- // NOTE:
1247
- // https://web.dev/samesite-cookies-explained/
1248
- // https://developer.mozilla.org/de/docs/Web/HTTP/Headers/Set-Cookie/SameSite
1249
- // https://www.smarketer.de/blog/chrome-update-80-cookies/
1250
- // -------------------------------------------------------------------------
1251
- // TODO:
1252
- // Change attribute "Secure" to true, if HTTPS is used.
1253
- // Checks and config changes are to be done.
1254
- // -------------------------------------------------------------------------
1255
- // TODO:
1256
- // Handling of attribute "SameSite".
1257
- // Config to use this attribute should be configurable
1258
- // (what config file?).
1259
- // Disabled use for now in general.
1260
- //
1261
- // The SameSite attribute of the Set-Cookie HTTP response header
1262
- // allows you to declare if your cookie should be restricted to a
1263
- // first-party or same-site context. Cookies with SameSite=None
1264
- // must now also specify the Secure attribute (they require a secure
1265
- // context/HTTPS).
1266
- // -------------------------------------------------------------------------
1267
- //
1268
- writeCookie: function (options /*name, data, [path, expires, SameSite, secure]*/) {
1269
- var defaults = {
1270
- data: {},
1271
- name: '',
1272
- expires: 0,
1273
- path: '/',
1274
- // SameSite: 'Strict',
1275
- // SameSite: 'Lax',
1276
- http_only: false,
1277
- secure: false
1278
- };
1279
- var settings = $.extend(defaults, options);
1280
- // moment not used anymore
1281
- // var epoch = Math.floor(Date.now()/1000);
1282
- // var timestamp_now = moment.unix(epoch).format('YYYY-MM-DD HH:mm:ss');
1283
- var date = new Date();
1284
- var timestamp_now = date.toISOString();
1285
- var cookie_data = {};
1286
- var data_json;
1287
- var data_encoded;
1288
-
1289
- if (j1.existsCookie(settings.name)) {
1290
- cookie_data = j1.readCookie(settings.name);
1291
- cookie_data.timestamp = timestamp_now;
1292
- cookie_data = j1.mergeData(cookie_data, settings.data);
1293
- data_json = JSON.stringify( cookie_data );
1294
- data_encoded = window.btoa(data_json);
1295
-
1296
- if (settings.expires > 0) {
1297
- Cookies.set(settings.name, data_encoded, {
1298
- expires: settings.expires,
1299
- SameSite: settings.SameSite
1300
- });
1301
- } else {
1302
- Cookies.set(settings.name, data_encoded, {
1303
- SameSite: settings.SameSite
1304
- });
1305
- }
1306
- } else {
1307
- cookie_data = settings.data;
1308
- data_json = JSON.stringify(settings.data);
1309
- data_encoded = window.btoa(data_json);
1310
- if (settings.expires > 0) {
1311
- Cookies.set(settings.name, data_encoded, {
1312
- expires: settings.expires,
1313
- SameSite: settings.SameSite
1314
- });
1315
- } else {
1316
- Cookies.set(settings.name, data_encoded, {
1317
- SameSite: settings.SameSite
1318
- });
1319
- }
1320
- }
1321
-
1322
- if (j1.existsCookie(settings.name)) {
1323
- return cookie_data;
1324
- } else {
1325
- return false;
1326
- }
1327
-
1328
- }, // END writeCookie
1329
-
1330
- // -------------------------------------------------------------------------
1331
- // Clears all given cookies by name (except cookies set to httpOnly).
1332
- // For all cookies the expire date is set in the past, those cookies
1333
- // are 'session' cookies. All session cookies are deleted (automatically)
1334
- // by the browser if the last session (browser window) is closed.
1335
- // See: https://stackoverflow.com/questions/179355/clearing-all-cookies-with-javascript
1336
- // -------------------------------------------------------------------------
1337
- removeCookie: function (options /*name [, path]*/) {
1338
- var cookieExists;
1339
- var defaults = {
1340
- name: '',
1341
- path: '/'
1342
- };
1343
- var settings = $.extend(defaults, options);
1344
-
1345
- Cookies.remove(settings.name, { path: settings.path });
1346
-
1347
- }, // END removeCookie
1348
-
1349
- // -------------------------------------------------------------------------
1350
- // Clears all given cookies by name (except cookies set to httpOnly).
1351
- // For all cookies the expire date is set in the past, those cookies
1352
- // are 'session' cookies. All session cookies are deleted (automatically)
1353
- // by the browser if the last session (browser window) is closed.
1354
- // See: https://stackoverflow.com/questions/179355/clearing-all-cookies-with-javascript
1355
- // -------------------------------------------------------------------------
1356
- deleteCookie: function (options) {
1357
- var name = options;
1358
- var all_cookies = document.cookie.split('; ');
1359
-
1360
- if ( name === 'all' ) {
1361
- for (var c = 0; c < all_cookies.length; c++) {
1362
- var d = window.location.hostname.split('.');
1363
- while (d.length > 0) {
1364
- var cookieBase = encodeURIComponent(all_cookies[c].split(';')[0].split('=')[0]) + '=; expires=Thu, 01-Jan-1970 00:00:01 GMT; domain=' + d.join('.') + ' ;path=';
1365
- var p = location.pathname.split('/');
1366
- document.cookie = cookieBase + '/';
1367
- while (p.length > 0) {
1368
- document.cookie = cookieBase + p.join('/');
1369
- p.pop();
1370
- };
1371
- d.shift();
1372
- }
1373
- }
1374
- } else {
1375
- document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT';
1376
- }
1377
-
1378
- return true;
1379
- }, // END deleteCookie
1380
-
1381
- // -------------------------------------------------------------------------
1382
- // returns true if a given cookie exists
1383
- // -------------------------------------------------------------------------
1384
- existsCookie: function (name) {
1385
- var dc = document.cookie;
1386
- var prefix = name + '=';
1387
- var begin = dc.indexOf('; ' + prefix);
1388
- var end = dc.length; // default to end of the string
1389
- var cookieExists = false;
1390
- var cookieContent = '';
1391
-
1392
- // found, and not in first position
1393
- if (begin !== -1) {
1394
- // exclude the "; "
1395
- begin += 2;
1396
- } else {
1397
- //see if cookie is in first position
1398
- begin = dc.indexOf(prefix);
1399
- // not found at all or found as a portion of another cookie name
1400
- if (begin === -1 || begin !== 0 ) return false;
1401
- }
1402
-
1403
- // if ";" is found somewhere after the prefix position then "end" is
1404
- // that position, otherwise it defaults to the end of the string
1405
- if (dc.indexOf(';', begin) !== -1) {
1406
- end = dc.indexOf(';', begin);
1407
- }
1408
-
1409
- cookieContent = decodeURI(dc.substring(begin + prefix.length, end) ).replace(/"/g, '');
1410
- cookieExists = cookieContent.length ? true : false;
1411
-
1412
- return cookieExists;
1413
- }, // END existsCookie
1414
-
1415
- // -------------------------------------------------------------------------
1416
- // Resolve MACROs
1417
- //
1418
- // See:
1419
- // https://stackoverflow.com/questions/5376431/wildcards-in-jquery-selectors
1420
- // https://stackoverflow.com/questions/16400072/jquery-each-only-affects-last-element
1421
- // https://dzone.com/articles/why-does-javascript-loop-only-use-last-value
1422
- // https://stackoverflow.com/questions/179713/how-to-change-the-href-for-a-hyperlink-using-jquery
1423
- // https://stackoverflow.com/questions/5223/length-of-a-javascript-object
1424
- // -------------------------------------------------------------------------
1425
- resolveMacros: function (user_data) {
1426
- var logger = log4javascript.getLogger('j1.resolveMacros');
1427
-
1428
- var sidebarLoaded = setInterval(function() {
1429
- if ($('#sidebar_mmenu').length) {
1430
- if (Object.keys(user_data).length) {
1431
- $('[id^=macro-]').each(function() {
1432
-
1433
- $('#macro-provider').each(function() {
1434
- var $this = $(this);
1435
- var $html = $this.html();
1436
- $this.html($html.replace('??provider', user_data.provider));
1437
- this.href = this.href.replace(/.*\/??provider-site-url/, user_data.provider_site_url);
1438
- });
1439
- $('#macro-user-name').each(function() {
1440
- var $this = $(this);
1441
- var $html = $this.html();
1442
- $this.html($html.replace('??user-name', user_data.user_name));
1443
- this.href = this.href.replace(/.*\/??provider_member_url/, user_data.provider_member_url);
1444
- });
1445
- $('#macro-provider-permissions').each(function() {
1446
- var $this = $(this);
1447
- var $html = $this.html();
1448
- $this.html($html.replace('??provider-permissions', user_data.provider_permissions));
1449
- this.href = this.href.replace(/.*\/??provider_member_url/, user_data.provider_member_url);
1450
- });
1451
- $('#macro-provider-membership').each(function() {
1452
- var $this = $(this);
1453
- var $html = $this.html();
1454
- $this.html($html.replace('??provider-membership', user_data.provider_membership));
1455
- this.href = this.href.replace(/.*\/??provider_member_url/, user_data.provider_member_url);
1456
- });
1457
- $('#macro-cookie-state').each(function() {
1458
- var $this = $(this);
1459
- var $html = $this.html();
1460
- $this.html($html.replace('??cookie-state', user_data.cookies_accepted));
1461
- this.href = this.href.replace(/.*\/??provider_privacy_url/, user_data.provider_privacy_url);
1462
- });
1463
- $('#macro-theme-name').each(function() {
1464
- var $this = $(this);
1465
- var $html = $this.html();
1466
- $this.html($html.replace('??theme-name', user_data.theme_name));
1467
- });
1468
- $('#macro-theme-author').each(function() {
1469
- var $this = $(this);
1470
- var $html = $this.html();
1471
- $this.html($html.replace('??theme-author', user_data.theme_author));
1472
- this.href = this.href.replace(/.*\/??theme-author-url/, user_data.theme_author_url);
1473
- });
1474
- $('#macro-theme-version').each(function() {
1475
- var $this = $(this);
1476
- var $html = $this.html();
1477
- $this.html($html.replace('??theme-version', user_data.theme_version));
1478
- });
1479
-
1480
- });
1481
- logger.info('met dependencies for: sidebarLoaded');
1482
- clearInterval(sidebarLoaded);
1483
- return true;
1484
- } else {
1485
- logger.error('no user data provided');
1486
- clearInterval(sidebarLoaded);
1487
- return false;
1488
- }
1489
- }
1490
- }, 25); // END 'sidebarLoaded'
1491
- }, // END resolveMacros
1492
-
1493
- // -------------------------------------------------------------------------
1494
- // Update MACROs
1495
- // Update the values, NOT the placeholders
1496
- // -------------------------------------------------------------------------
1497
- updateMacros: function (user_data) {
1498
- var logger = log4javascript.getLogger('j1.updateMacros');
1499
-
1500
- var sidebarLoaded = setInterval(function() {
1501
- if ($('#sidebar_mmenu').length) {
1502
-
1503
- if (Object.keys(user_data).length) {
1504
- $('[id^=macro-]').each(function() {
1505
-
1506
- $('#macro-provider').each(function() {
1507
- var $this = $(this);
1508
- var $html = $this.html();
1509
- $this.html($html.replace(/Provider:.*/, 'Provider: ' + user_data.provider));
1510
- $('#macro-provider').attr('href', user_data.provider_site_url);
1511
- });
1512
- $('#macro-user-name').each(function() {
1513
- var $this = $(this);
1514
- var $html = $this.html();
1515
- $this.html($html.replace(/User:.*/, 'User: ' + user_data.user_name));
1516
- $('#macro-user-name').attr('href', user_data.provider_member_url);
1517
- });
1518
- $('#macro-provider-permissions').each(function() {
1519
- var $this = $(this);
1520
- var $html = $this.html();
1521
- // $this.html($html.replace(/public|protected|private|blocked/, user_data.provider_permissions));
1522
- $this.html($html.replace(/public.*|protected.*|private.*|blocked.*/, user_data.provider_permissions));
1523
- $('#macro-provider-permissions').attr('href', user_data.provider_member_url);
1524
- });
1525
- $('#macro-provider-membership').each(function() {
1526
- var $this = $(this);
1527
- var $html = $this.html();
1528
- $this.html($html.replace(/guest|member/, user_data.provider_membership));
1529
- $('#macro-provider-membership').attr('href', user_data.provider_member_url);
1530
- });
1531
- $('#macro-cookie-state').each(function() {
1532
- var $this = $(this);
1533
- var $html = $this.html();
1534
- $this.html($html.replace(/accepted|declined|pending/, user_data.cookies_accepted));
1535
- $('#macro-cookie-state').attr('href', user_data.provider_privacy_url);
1536
- });
1537
-
1538
- });
1539
- logger.info('met dependencies for: sidebarLoaded');
1540
- clearInterval(sidebarLoaded);
1541
- return true;
1542
- } else {
1543
- logger.error('no user data provided');
1544
- clearInterval(sidebarLoaded);
1545
- return false;
1546
- }
1547
- }
1548
- }, 25); // END 'sidebarLoaded'
1549
- }, // END updateMacros
1550
-
1551
- // -------------------------------------------------------------------------
1552
- // getMessage
1553
- // Get a log message from the log message catalog object
1554
- // -------------------------------------------------------------------------
1555
- getMessage: function (level, message, property) {
1556
- var message = j1.messages[level][message]['message'][property];
1557
-
1558
- return message;
1559
- }, // END getMessage
1560
-
1561
- // -------------------------------------------------------------------------
1562
- // logger
1563
- // Log a message
1564
- // -------------------------------------------------------------------------
1565
- logger: function (logger, level, message) {
1566
- var logger = log4javascript.getLogger(logger);
1567
-
1568
- logger[level](message);
1569
-
1570
- return true;
1571
- }, // END logger
1572
-
1573
- // -------------------------------------------------------------------------
1574
- // Send message
1575
- // -------------------------------------------------------------------------
1576
- sendMessage: function ( sender, receiver, message ) {
1577
- var logger = log4javascript.getLogger('j1.sendMessage');
1578
- // var json_message = JSON.stringify(message, undefined, 2); // multiline
1579
- var json_message = JSON.stringify(message);
1580
-
1581
- if ( receiver === 'j1' ) {
1582
- logText = 'send message from ' + sender + ' to' + receiver + ': ' + json_message;
1583
- logger.debug(logText);
1584
- executeFunctionByName('j1' + '.messageHandler', window, sender, message);
1585
- } else {
1586
- logText = 'send message from ' + sender + ' to ' + receiver + ': ' + json_message;
1587
- logger.debug(logText);
1588
- //executeFunctionByName('j1.' + receiver + '.messageHandler', window, sender, message)
1589
- executeFunctionByName(receiver + '.messageHandler', window, sender, message);
1590
- }
1591
-
1592
- }, // END sendMessage
1593
-
1594
- // -------------------------------------------------------------------------
1595
- // messageHandler: MessageHandler for J1 CookieConsent module
1596
- // Manage messages send from other J1 modules
1597
- // -------------------------------------------------------------------------
1598
- messageHandler: function ( sender, message ) {
1599
- // var json_message = JSON.stringify(message, undefined, 2); // multiline
1600
- var json_message = JSON.stringify(message);
1601
-
1602
- logText = 'received message from ' + sender + ': ' + json_message;
1603
- logger.debug(logText);
1604
-
1605
- // -----------------------------------------------------------------------
1606
- // Process commands|actions
1607
- // -----------------------------------------------------------------------
1608
- if ( message.type === 'command' && message.action === 'module_initialized' ) {
1609
- _this.setState('finished');
1610
- logger.info(message.text);
1611
- }
1612
-
1613
- //
1614
- // Place handling of other command|action here
1615
- //
1616
-
1617
- return true;
1618
- }, // END messageHandler
1619
-
1620
- // -------------------------------------------------------------------------
1621
- // getStyleValue:
1622
- // Returns the value of a style from a css class definition
1623
- // example: j1.getStyleValue('uno-primary', 'background-color')
1624
- getStyleValue: function (className, style) {
1625
- var elementId = 'test-' + className,
1626
- testElement = document.getElementById(elementId),
1627
- val;
1628
-
1629
- if (testElement === null) {
1630
- testElement = document.createElement('div');
1631
- testElement.className = className;
1632
- testElement.style.display = 'none';
1633
- document.body.appendChild(testElement);
1634
- }
1635
- val = $(testElement).css(style);
1636
- document.body.removeChild(testElement);
1637
-
1638
- return val;
1639
- }, // END getStyleValue
1640
-
1641
- // -------------------------------------------------------------------------
1642
- // getStyleSheetLoaded:
1643
- // NOTE:
1644
- // EXAMPLE: getStyleSheetLoaded('bootstrap');
1645
- //
1646
- getStyleSheetLoaded: function (styleSheet) {
1647
- // var styleSheet = styleSheetName.toLowerCase() + '.css';
1648
- var sheets = document.styleSheets, stylesheet = sheets[(sheets.length - 1)];
1649
-
1650
- // find CSS file 'styleSheetName' in document
1651
- for(var i in document.styleSheets) {
1652
- if(sheets[i].href && sheets[i].href.indexOf(styleSheet) > -1) {
1653
- return true;;
1654
- }
1655
- }
1656
- },
1657
-
1658
- // -------------------------------------------------------------------------
1659
- // Returns the names of cookies used for J1 Template
1660
- // -------------------------------------------------------------------------
1661
- getCookieNames: function () {
1662
- return cookie_names;
1663
- }, // end getCookieNames
1664
-
1665
- // -------------------------------------------------------------------------
1666
- // Set dynamic styles
1667
- // -------------------------------------------------------------------------
1668
- setCss: function () {
1669
- var logger = log4javascript.getLogger('j1.setCss');
1670
- var bg_primary = j1.getStyleValue('bg-primary', 'background-color');
1671
- var bg_secondary = j1.getStyleValue('bg-secondary', 'background-color');
1672
-
1673
- logger.info('set color scheme for selected theme');
1674
-
1675
- // globals
1676
- // -----------------------------------------------------------------------
1677
- $('head').append('<style>.g-bg-primary { background-color: ' +bg_primary+ ' !important; }</style>');
1678
-
1679
- // Set color of timeline bullet
1680
- // -----------------------------------------------------------------------
1681
- // $('head').append('<style>.tmicon { background: ' +bg_primary+ ' !important; }</style>');
1682
- // $('head').append('<style>.timeline-panel:after { border-left-color: ' +bg_primary+ ' !important; }</style>');
1683
- // $('head').append('<style>.timeline-panel:after { border-right-color: ' +bg_primary+ ' !important; }</style>');
1684
-
1685
- // mdi icons
1686
- // -----------------------------------------------------------------------
1687
- $('head').append('<style>.iconify-md-bg-primary { color: ' +bg_primary+ ' !important; }</style>');
1688
- $('head').append('<style>.fa-md-bg-primary { color: ' +bg_primary+ ' !important; }</style>');
1689
- $('head').append('<style>.fas-md-bg-primary { color: ' +bg_primary+ ' !important; }</style>');
1690
- $('head').append('<style>.mdi-md-bg-primary { color: ' +bg_primary+ ' !important; }</style>');
1691
-
1692
- // asciidoc
1693
- // -----------------------------------------------------------------------
1694
- var admonitionblock_note_color = bg_primary;
1695
- var admonitionblock_tip_color = j1.getStyleValue('btn-success', 'background-color');
1696
- var admonitionblock_important_color = j1.getStyleValue('btn-info', 'background-color');
1697
- var admonitionblock_warning_color = j1.getStyleValue('icon-warning', 'color');
1698
- var admonitionblock_caution_color = j1.getStyleValue('btn-danger', 'background-color');
1699
-
1700
- $('head').append('<style>.icon-note { color: ' +admonitionblock_note_color+ ' !important; }</style>');
1701
- $('head').append('<style>.icon-tip { color: ' +admonitionblock_tip_color+ ' !important; }</style>');
1702
- $('head').append('<style>.icon-important { color: ' +admonitionblock_important_color+ ' !important; }</style>');
1703
- $('head').append('<style>.icon-warning { color: ' +admonitionblock_warning_color+ ' !important; }</style>');
1704
- $('head').append('<style>.icon-caution { color: ' +admonitionblock_caution_color+ ' !important; }</style>');
1705
-
1706
- // bs base styles (2020-09-20: diabled. Taken for BS CSS code)
1707
- // -----------------------------------------------------------------------
1708
- // $('head').append('<style>code { color: ' +bg_secondary+ ' !important; }</style>');
1709
-
1710
- // bs tool tips
1711
- // -----------------------------------------------------------------------
1712
- $('head').append('<style>.tooltip-inner { background-color: ' +bg_primary+ ' !important; }</style>');
1713
- // $('head').append('<style>.tooltip-arrow { background-color: ' +bg_primary+ ' !important; }</style>');
1714
- $('head').append('<style>.bs-tooltip-auto[x-placement^=bottom] .arrow::before, .bs-tooltip-bottom .arrow::before { border-bottom-color: ' +bg_primary+ ' !important; }</style>');
1715
-
1716
- // asciidoc results viewer
1717
- // -----------------------------------------------------------------------
1718
- $('head').append('<style>.btn-viewer:hover { background-color: ' +bg_primary+ ' !important; }</style>');
1719
-
1720
- // extended modals
1721
- // -----------------------------------------------------------------------
1722
- // var tabs_pills_link_color_active = j1.setColorData('md_blue'); // j1.getStyleValue('btn-info', 'background-color');
1723
- // var tabs_pills_link_color_hover = j1.setColorData('md_gray_300'); // j1.getStyleValue('btn-secondary', 'background-color');
1724
-
1725
- // var tabs_pills_link_color_active = 'mdi-blue';
1726
- // var tabs_pills_link_color_hover = 'mdi-gray-300';
1727
-
1728
- // nav module
1729
- // -----------------------------------------------------------------------
1730
- // $('head').append('<style>.nav-link:hover { background-color: ' +tabs_pills_link_color_hover+ ' !important; }</style>');
1731
- // $('head').append('<style>.nav-link.active { background-color: ' +tabs_pills_link_color_active+ ' !important; }</style>');
1732
-
1733
- return true;
1734
- }, // END setCss
1735
-
1736
- // -------------------------------------------------------------------------
1737
- // setState()
1738
- // Set the current (processing) state of the module
1739
- // -------------------------------------------------------------------------
1740
- setState: function (stat) {
1741
- state = stat;
1742
- }, // end setState
1743
-
1744
- // -------------------------------------------------------------------------
1745
- // getState()
1746
- // Returns the current (processing) state of the module
1747
- // -------------------------------------------------------------------------
1748
- getState: function () {
1749
- return state;
1750
- }, // end getState
1751
-
1752
- // -------------------------------------------------------------------------
1753
- // setXhrDataState()
1754
- // Set the final (loading) state of an element (partial) loaded via Xhr
1755
- // -------------------------------------------------------------------------
1756
- setXhrDataState: function (obj, stat) {
1757
- j1.xhrDataState[obj] = stat;
1758
- }, // END setXhrDataState
1759
-
1760
- // -------------------------------------------------------------------------
1761
- // getXhrDataState()
1762
- // Returns the final (loading) state of an element (partial) loaded via Xhr
1763
- // -------------------------------------------------------------------------
1764
- getXhrDataState: function (obj) {
1765
- return j1.xhrDataState[obj];
1766
- }, // END getXhrDataState
1767
-
1768
- // -------------------------------------------------------------------------
1769
- // setXhrDomState()
1770
- // Set the state of an element loaded via Xhr that is
1771
- // successfully added to the DOM
1772
- // -------------------------------------------------------------------------
1773
- setXhrDomState: function (obj, stat) {
1774
- j1.xhrDOMState[obj] = stat;
1775
- }, // END setXhrDomState
1776
-
1777
- // -------------------------------------------------------------------------
1778
- // getXhrDataState()
1779
- // Returns the state of an element loaded via Xhr that is
1780
- // successfully added to the DOM
1781
- // -------------------------------------------------------------------------
1782
- getXhrDOMState: function (obj) {
1783
- return j1.xhrDOMState[obj];
1784
- }, // END getXhrDOMState
1785
-
1786
- // -------------------------------------------------------------------------
1787
- // setMode()
1788
- // Set the current mode of the site (web|app)
1789
- // -------------------------------------------------------------------------
1790
- setMode: function (mod) {
1791
- mode = mod;
1792
- }, // END setMode
1793
-
1794
- // -------------------------------------------------------------------------
1795
- // getMode()
1796
- // Returns the current mode of the site (web|app)
1797
- // -------------------------------------------------------------------------
1798
- getMode: function () {
1799
- return mode;
1800
- }, // END getMode
1801
-
1802
- // -------------------------------------------------------------------------
1803
- // checkUserAgent()
1804
- // Returns the name (UA) of the web browser
1805
- // -------------------------------------------------------------------------
1806
- checkUserAgent: function () {
1807
- if (navigator.userAgent.search(ua_name) >= 0) {
1808
- return true;
1809
- } else {
1810
- return false;
1811
- }
1812
- }, // END checkUserAgent
1813
-
1814
- // -------------------------------------------------------------------------
1815
- // generateId()
1816
- // Generate a unique (thread) id used by the logger
1817
- // -------------------------------------------------------------------------
1818
- generateId: function (length) {
1819
- var result = '';
1820
- var characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
1821
- var charactersLength = characters.length;
1822
- for ( var i = 0; i < length; i++ ) {
1823
- result += characters.charAt(Math.floor(Math.random() * charactersLength));
1824
- }
1825
- return result;
1826
- }, // END generateId
1827
-
1828
- // -------------------------------------------------------------------------
1829
- // getTrue()
1830
- // Returns always true (for testing purposes)
1831
- // -------------------------------------------------------------------------
1832
- getTrue: function () {
1833
- return true;
1834
- }, // END isTrue
1835
-
1836
- // -------------------------------------------------------------------------
1837
- // getFalse()
1838
- // Returns always false (for testing purposes)
1839
- // -------------------------------------------------------------------------
1840
- getFalse: function () {
1841
- return false;
1842
- }, // END isTrue
1843
-
1844
- // -------------------------------------------------------------------------
1845
- // goHome()
1846
- // Redirect current page to the browser homepage
1847
- // -------------------------------------------------------------------------
1848
- goHome: function () {
1849
- // most browsers
1850
- if (typeof window.home == 'function') {
1851
- window.home();
1852
- } else if (document.all) {
1853
- // for IE
1854
- window.location.href = 'about:home';
1855
- } else {
1856
- window.location.href = 'about:blank';
1857
- }
1858
- }, // END gohome
1859
-
1860
- // -------------------------------------------------------------------------
1861
- // goBack()
1862
- // Redirect current page to last visited page (referrer)
1863
- // -------------------------------------------------------------------------
1864
- goBack: function () {
1865
- // where visitor has come from
1866
- window.location.href = document.referrer;
1867
- } // END goBack
1868
-
1869
- }; // END j1 (return)
1870
- }) (j1, window);
1871
-
1872
- {% endcapture %}
1873
- {% if production %}
1874
- {{ cache | minifyJS }}
1875
- {% else %}
1876
- {{ cache | strip_empty_lines }}
1877
- {% endif %}
1878
- {% assign cache = nil %}