j1-template 2024.3.13 → 2024.3.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/_includes/themes/j1/layouts/content_generator_news_panel_posts.html +1 -1
- data/_includes/themes/j1/layouts/layout_resource_generator.html +1 -4
- data/_includes/themes/j1/procedures/blocks/footer/boxes/social_media_icons.proc +24 -23
- data/_includes/themes/j1/procedures/layouts/content_writer.proc +4 -3
- data/_includes/themes/j1/procedures/layouts/default_writer.proc +37 -6
- data/_includes/themes/j1/procedures/layouts/module_writer.proc +31 -95
- data/_includes/themes/j1/procedures/layouts/resource_writer.proc +51 -29
- data/assets/data/amplitude.28.html +887 -0
- data/assets/data/amplitude.29.html +923 -0
- data/assets/data/amplitude.html +311 -46
- data/assets/data/banner.html +9 -7
- data/assets/data/masterslider.html +128 -7
- data/assets/data/panel.html +16 -65
- data/assets/theme/j1/adapter/js/amplitude.23.js +1165 -0
- data/assets/theme/j1/adapter/js/amplitude.24.js +1164 -0
- data/assets/theme/j1/adapter/js/amplitude.25.js +1268 -0
- data/assets/theme/j1/adapter/js/amplitude.js +294 -117
- data/assets/theme/j1/adapter/js/attic.js +14 -11
- data/assets/theme/j1/adapter/js/docsearch.js +2 -2
- data/assets/theme/j1/adapter/js/fab.js +2 -2
- data/assets/theme/j1/adapter/js/j1.js +8 -8
- data/assets/theme/j1/adapter/js/lazyLoader.js +60 -10
- data/assets/theme/j1/adapter/js/masonry.js +1 -1
- data/assets/theme/j1/adapter/js/masterslider.js +2 -2
- data/assets/theme/j1/adapter/js/particles.js +2 -2
- data/assets/theme/j1/adapter/js/scroller.js +2 -2
- data/assets/theme/j1/adapter/js/slick.js +2 -2
- data/assets/theme/j1/adapter/js/themes.js +1 -1
- data/assets/theme/j1/adapter/js/translator.js +2 -2
- data/assets/theme/j1/adapter/js/waves.js +1 -1
- data/assets/theme/j1/core/css/animate.css +1634 -1070
- data/assets/theme/j1/core/css/animate.css.map +1 -0
- data/assets/theme/j1/core/css/animate.min.css +2 -1
- data/assets/theme/j1/core/css/animate.min.css.map +1 -0
- data/assets/theme/j1/core/css/icon-fonts/fontawesome.css +3060 -1538
- data/assets/theme/j1/core/css/icon-fonts/fontawesome.css.map +1 -0
- data/assets/theme/j1/core/css/icon-fonts/fontawesome.min.css +2 -1
- data/assets/theme/j1/core/css/icon-fonts/fontawesome.min.css.map +1 -0
- data/assets/theme/j1/core/css/icon-fonts/iconify.css +2308 -1153
- data/assets/theme/j1/core/css/icon-fonts/iconify.css.map +1 -0
- data/assets/theme/j1/core/css/icon-fonts/iconify.min.css +2 -1
- data/assets/theme/j1/core/css/icon-fonts/iconify.min.css.map +1 -0
- data/assets/theme/j1/core/css/icon-fonts/mdi.css +16716 -8423
- data/assets/theme/j1/core/css/icon-fonts/mdi.css.map +1 -0
- data/assets/theme/j1/core/css/icon-fonts/mdi.min.css +2 -1
- data/assets/theme/j1/core/css/icon-fonts/mdi.min.css.map +1 -0
- data/assets/theme/j1/core/css/icon-fonts/mdib.css +5554 -2766
- data/assets/theme/j1/core/css/icon-fonts/mdib.css.map +1 -0
- data/assets/theme/j1/core/css/icon-fonts/mdib.min.css +2 -1
- data/assets/theme/j1/core/css/icon-fonts/mdib.min.css.map +1 -0
- data/assets/theme/j1/core/css/icon-fonts/mdil.css +742 -441
- data/assets/theme/j1/core/css/icon-fonts/mdil.css.map +1 -0
- data/assets/theme/j1/core/css/icon-fonts/mdil.min.css +2 -1
- data/assets/theme/j1/core/css/icon-fonts/mdil.min.css.map +1 -0
- data/assets/theme/j1/core/css/themes/bootstrap/bootstrap.css +6552 -3980
- data/assets/theme/j1/core/css/themes/bootstrap/bootstrap.css.map +1 -0
- data/assets/theme/j1/core/css/themes/bootstrap/bootstrap.min.css +2 -5
- data/assets/theme/j1/core/css/themes/bootstrap/bootstrap.min.css.map +1 -0
- data/assets/theme/j1/core/css/themes/unodark/bootstrap.css +6818 -4131
- data/assets/theme/j1/core/css/themes/unodark/bootstrap.css.map +1 -0
- data/assets/theme/j1/core/css/themes/unodark/bootstrap.min.css +2 -5
- data/assets/theme/j1/core/css/themes/unodark/bootstrap.min.css.map +1 -0
- data/assets/theme/j1/core/css/themes/unolight/bootstrap.css +18568 -11577
- data/assets/theme/j1/core/css/themes/unolight/bootstrap.css.map +1 -0
- data/assets/theme/j1/core/css/themes/unolight/bootstrap.min.css +2 -35
- data/assets/theme/j1/core/css/themes/unolight/bootstrap.min.css.map +1 -0
- data/assets/theme/j1/core/css/vendor.css +1771 -1043
- data/assets/theme/j1/core/css/vendor.css.map +1 -0
- data/assets/theme/j1/core/css/vendor.min.css +2 -1
- data/assets/theme/j1/core/css/vendor.min.css.map +1 -0
- data/assets/theme/j1/core/js/template.js +399 -447
- data/assets/theme/j1/core/js/template.min.js +7 -7
- data/assets/theme/j1/core/js/template.min.js.map +1 -1
- data/assets/theme/j1/modules/amplitudejs/css/theme/uno/dark/amplitude.css +4 -2
- data/assets/theme/j1/modules/amplitudejs/css/theme/uno/dark/player/compact.css +39 -4
- data/assets/theme/j1/modules/amplitudejs/css/theme/uno/dark/player/compact.min.css +1 -1
- data/assets/theme/j1/modules/amplitudejs/css/theme/uno/dark/player/large.css +57 -17
- data/assets/theme/j1/modules/amplitudejs/css/theme/uno/dark/player/large.min.css +1 -1
- data/assets/theme/j1/modules/amplitudejs/icons/player/blue/pause.png +0 -0
- data/assets/theme/j1/modules/amplitudejs/icons/player/blue/play.png +0 -0
- data/assets/theme/j1/modules/amplitudejs/icons/player/blue/play.svg +87 -0
- data/assets/theme/j1/modules/amplitudejs/icons/player/dark/skip-backward.svg +60 -0
- data/assets/theme/j1/modules/amplitudejs/icons/player/dark/skip-forward.svg +59 -0
- data/assets/theme/j1/modules/amplitudejs/js/amplitude.js +65 -21
- data/assets/theme/j1/modules/amplitudejs/js/amplitude.min.js +1 -1
- data/assets/theme/j1/modules/amplitudejs/js/tech/ytp.js +113 -0
- data/assets/theme/j1/modules/iconPicker/js/universal-icon-picker.js +471 -471
- data/assets/theme/j1/modules/j1LazyLoader/LICENSE +21 -0
- data/assets/theme/j1/modules/j1LazyLoader/js/j1Lazy.js +870 -0
- data/assets/theme/j1/modules/js-cookies/js/js.cookie.js +3 -3
- data/assets/theme/j1/modules/lazyCssLoader/js/main.0.js +166 -0
- data/assets/theme/j1/modules/lazyCssLoader/js/main.1.js +65 -0
- data/assets/theme/j1/modules/lazyCssLoader/js/main.js +66 -0
- data/assets/theme/j1/modules/lazyCssLoader/js/plugins/examplePlugin.js +13 -0
- data/assets/theme/j1/modules/lazyCssLoader/js/plugins/my-plugin.js +25 -0
- data/assets/theme/j1/modules/lazyCssLoader/js/plugins/plugin-interface.js +9 -0
- data/assets/theme/j1/modules/lazyCssLoader/js/plugins/pluginA.js +46 -0
- data/assets/theme/j1/modules/lazyLoader/js/plugins/README.md +324 -0
- data/assets/theme/j1/modules/lazyLoader/js/plugins/jquery.lazy.picture.js +188 -0
- data/assets/theme/j1/modules/lightGallery/js/lightgallery.js +1 -1
- data/assets/theme/j1/modules/lightGallery/js/plugins/lg-video.0.js +794 -0
- data/assets/theme/j1/modules/lightGallery/js/plugins/lg-video.js +151 -67
- data/assets/theme/j1/modules/slimSelect/js/select.js +1 -1
- data/assets/theme/j1/modules/slimSelect/js/select.min.js +3 -3
- data/assets/theme/j1/modules/themeSwitcher/js/switcher.js +2 -1
- data/assets/theme/j1/modules/videojs/js/plugins/players/dm/dailymotion.min.js +1 -1
- data/assets/theme/j1/modules/videojs/js/plugins/players/dm/icon/scalable/dailymotion.svg +62 -0
- data/assets/theme/j1/modules/videojs/js/plugins/players/yt/v3.0.0/youtube.js +832 -0
- data/assets/theme/j1/modules/videojs/js/plugins/players/yt/v3.0.0/youtube.min.js +17 -0
- data/assets/theme/j1/modules/videojs/js/plugins/players/yt/youtube.min.js +1 -1
- data/assets/theme/j1/modules/videojs/js/video.js +2 -2
- data/lib/j1/version.rb +1 -1
- data/lib/starter_web/README.md +577 -560
- data/lib/starter_web/_config.yml +2 -2
- data/lib/starter_web/_data/blocks/footer.yml +10 -5
- data/lib/starter_web/_data/blocks/panel.yml +2 -2
- data/lib/starter_web/_data/layouts/default.yml +14 -3
- data/lib/starter_web/_data/modules/amplitude.yml +145 -0
- data/lib/starter_web/_data/modules/defaults/amplitude.yml +29 -7
- data/lib/starter_web/_data/modules/defaults/lazyLoader.yml +2 -2
- data/lib/starter_web/_data/modules/gallery.yml +136 -0
- data/lib/starter_web/_data/modules/lazyLoader.0.yml +118 -0
- data/lib/starter_web/_data/modules/lazyLoader.yml +68 -31
- data/lib/starter_web/_data/modules/masonry.yml +4 -4
- data/lib/starter_web/_data/modules/masterslider.yml +118 -12
- data/lib/starter_web/_data/modules/navigator_menu.yml +831 -803
- data/lib/starter_web/_data/resources.yml +154 -190
- data/lib/starter_web/_data/templates/feed.xml +1 -1
- data/lib/starter_web/_includes/attributes.asciidoc +1 -0
- data/lib/starter_web/_plugins/asciidoctor/amplitude-block.rb +1 -1
- data/lib/starter_web/_plugins/asciidoctor/dailymotion-block.rb +1 -1
- data/lib/starter_web/_plugins/asciidoctor/gallery-block.rb +4 -2
- data/lib/starter_web/_plugins/asciidoctor/masonry-block.rb +1 -1
- data/lib/starter_web/_plugins/asciidoctor/videojs-block.rb +58 -46
- data/lib/starter_web/_plugins/asciidoctor/vimeo-block.rb +26 -19
- data/lib/starter_web/_plugins/asciidoctor/youtube-block.rb +30 -40
- data/lib/starter_web/_plugins/index/lunr.rb +1 -1
- data/lib/starter_web/assets/image/icons/lanus/favicon.ico +0 -0
- data/lib/starter_web/assets/image/icons/lanus/lanus-512x512.png +0 -0
- data/lib/starter_web/assets/image/icons/lanus/lanus.ico +0 -0
- data/lib/starter_web/assets/image/icons/lanus/lanus.png +0 -0
- data/lib/starter_web/assets/image/icons/lanus/scalable/lanus.svg +76 -0
- data/lib/starter_web/assets/image/icons/lanus/scalable/lanus_sw.svg +62 -0
- data/lib/starter_web/assets/image/modules/icons/social/scalable/icon-twitter-x-28 - social.svg +86 -0
- data/lib/starter_web/assets/image/modules/icons/social/scalable/icon-twitter-x-28.svg +64 -0
- data/lib/starter_web/assets/image/modules/icons/social/scalable/icon-twitter-x.svg +1 -0
- data/lib/starter_web/assets/image/modules/icons/social/twitter_x.png +0 -0
- data/lib/starter_web/package.json +7 -18
- data/lib/starter_web/pages/public/amplitude_yt_tester.adoc +218 -0
- data/lib/starter_web/pages/public/features/template.adoc +18 -8
- data/lib/starter_web/pages/public/features/template.asciidoc +758 -0
- data/lib/starter_web/pages/public/lazy_loader_tester.adoc +402 -0
- data/lib/starter_web/pages/public/manuals/ytdl/man.adoc +3020 -0
- data/lib/starter_web/pages/public/manuals/ytdl/man.md +2378 -0
- data/lib/starter_web/pages/public/tools/previewer/_includes/attributes.asciidoc +0 -16
- data/lib/starter_web/pages/public/tools/previewer/_includes/documents/amplitudejs.large.css.asciidoc +505 -0
- data/lib/starter_web/pages/public/tools/previewer/_includes/documents/frame.hover.html +69 -0
- data/lib/starter_web/pages/public/tools/previewer/_includes/documents/frame.nested.html +75 -0
- data/lib/starter_web/pages/public/tools/previewer/_includes/documents/frame.textarea.html +57 -0
- data/lib/starter_web/pages/public/tools/previewer/_includes/documents/my.content.html +112 -0
- data/lib/starter_web/pages/public/tools/previewer/preview_amplitudejs.adoc +172 -0
- data/lib/starter_web/pages/public/tour/_includes/attributes.asciidoc +2 -2
- data/lib/starter_web/pages/public/tour/_includes/documents/419_advanced_modals_demo.asciidoc +16 -16
- data/lib/starter_web/pages/public/tour/asciidoc_extensions.adoc +13 -3
- data/lib/starter_web/pages/public/tour/bootstrap_themes.adoc +12 -3
- data/lib/starter_web/pages/public/tour/highlghter_rouge.adoc +13 -3
- data/lib/starter_web/pages/public/tour/icon_fonts.adoc +12 -3
- data/lib/starter_web/pages/public/tour/modal_extentions.adoc +12 -6
- data/lib/starter_web/pages/public/tour/{playback_audio.adoc → play_audio.adoc} +207 -188
- data/lib/starter_web/pages/public/tour/{playback_video.adoc → play_video.adoc} +49 -51
- data/lib/starter_web/pages/public/tour/present_images.adoc +27 -5
- data/lib/starter_web/pages/public/tour/quicksearch.adoc +13 -3
- data/lib/starter_web/pages/public/tour/responsive_tables.adoc +13 -4
- data/lib/starter_web/pages/public/tour/typography.adoc +12 -3
- metadata +90 -22
- /data/assets/theme/j1/modules/{lazyLoader → j1LazyLoader/js}/plugins/README.md +0 -0
- /data/assets/theme/j1/modules/{lazyLoader/plugins/jquery.lazy.picture.js → j1LazyLoader/js/plugins/picture.js} +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.ajax.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.ajax.min.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.av.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.av.min.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.iframe.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.iframe.min.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.noop.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.noop.min.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.picture.min.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.script.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.script.min.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.vimeo.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.vimeo.min.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.youtube.js +0 -0
- /data/assets/theme/j1/modules/lazyLoader/{plugins → js/plugins}/jquery.lazy.youtube.min.js +0 -0
@@ -0,0 +1,1164 @@
|
|
1
|
+
---
|
2
|
+
regenerate: true
|
3
|
+
---
|
4
|
+
|
5
|
+
{%- capture cache -%}
|
6
|
+
|
7
|
+
{% comment %}
|
8
|
+
# -----------------------------------------------------------------------------
|
9
|
+
# ~/assets/theme/j1/adapter/js/amplitude.js
|
10
|
+
# Liquid template to adapt the AmplitudeJS v4 module
|
11
|
+
#
|
12
|
+
# Product/Info:
|
13
|
+
# https://jekyll.one
|
14
|
+
# Copyright (C) 2023, 2024 Juergen Adams
|
15
|
+
#
|
16
|
+
# J1 Template is licensed under the MIT License.
|
17
|
+
# For details, see: https://github.com/jekyll-one-org/j1-template/blob/main/LICENSE
|
18
|
+
# -----------------------------------------------------------------------------
|
19
|
+
# Test data:
|
20
|
+
# {{ liquid_var | debug }}
|
21
|
+
# amplitude_options: {{ amplitude_options | 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 asset_path = "/assets/theme/j1" %}
|
32
|
+
|
33
|
+
{% comment %} Process YML config data
|
34
|
+
================================================================================ {% endcomment %}
|
35
|
+
|
36
|
+
{% comment %} Set config files
|
37
|
+
-------------------------------------------------------------------------------- {% endcomment %}
|
38
|
+
{% assign template_config = site.data.j1_config %}
|
39
|
+
{% assign blocks = site.data.blocks %}
|
40
|
+
{% assign modules = site.data.modules %}
|
41
|
+
|
42
|
+
{% comment %} Set config data (settings only)
|
43
|
+
-------------------------------------------------------------------------------- {% endcomment %}
|
44
|
+
{% assign amplitude_defaults = modules.defaults.amplitude.defaults %}
|
45
|
+
{% assign amplitude_settings = modules.amplitude.settings %}
|
46
|
+
|
47
|
+
{% comment %} Set config options (settings only)
|
48
|
+
-------------------------------------------------------------------------------- {% endcomment %}
|
49
|
+
{% assign amplitude_options = amplitude_defaults | merge: amplitude_settings %}
|
50
|
+
|
51
|
+
{% comment %} Variables
|
52
|
+
-------------------------------------------------------------------------------- {% endcomment %}
|
53
|
+
{% assign comments = amplitude_options.enabled %}
|
54
|
+
|
55
|
+
{% comment %} Detect prod mode
|
56
|
+
-------------------------------------------------------------------------------- {% endcomment %}
|
57
|
+
{% assign production = false %}
|
58
|
+
{% if environment == 'prod' or environment == 'production' %}
|
59
|
+
{% assign production = true %}
|
60
|
+
{% endif %}
|
61
|
+
|
62
|
+
/*
|
63
|
+
# -----------------------------------------------------------------------------
|
64
|
+
# ~/assets/theme/j1/adapter/js/amplitude.js
|
65
|
+
# J1 Adapter for the amplitude module
|
66
|
+
#
|
67
|
+
# Product/Info:
|
68
|
+
# https://jekyll.one
|
69
|
+
#
|
70
|
+
# Copyright (C) 2023, 2024 Juergen Adams
|
71
|
+
#
|
72
|
+
# J1 Template is licensed under the MIT License.
|
73
|
+
# For details, see: https://github.com/jekyll-one-org/j1-template/blob/main/LICENSE
|
74
|
+
# -----------------------------------------------------------------------------
|
75
|
+
# Adapter generated: {{site.time}}
|
76
|
+
# -----------------------------------------------------------------------------
|
77
|
+
*/
|
78
|
+
|
79
|
+
// -----------------------------------------------------------------------------
|
80
|
+
// ESLint shimming
|
81
|
+
// -----------------------------------------------------------------------------
|
82
|
+
/* eslint indent: "off" */
|
83
|
+
// -----------------------------------------------------------------------------
|
84
|
+
|
85
|
+
"use strict";
|
86
|
+
j1.adapter.amplitude = ((j1, window) => {
|
87
|
+
|
88
|
+
// göobal settings
|
89
|
+
// ---------------------------------------------------------------------------
|
90
|
+
var environment = '{{environment}}';
|
91
|
+
var cookie_names = j1.getCookieNames();
|
92
|
+
var user_state = j1.readCookie(cookie_names.user_state);
|
93
|
+
var state = 'not_started';
|
94
|
+
|
95
|
+
// module settings
|
96
|
+
// ---------------------------------------------------------------------------
|
97
|
+
|
98
|
+
// control|logging
|
99
|
+
// ---------------
|
100
|
+
var _this;
|
101
|
+
var logger;
|
102
|
+
var logText;
|
103
|
+
var toJSON;
|
104
|
+
var toText;
|
105
|
+
|
106
|
+
// date|time monitoring
|
107
|
+
//---------------------
|
108
|
+
var startTime;
|
109
|
+
var endTime;
|
110
|
+
var startTimeModule;
|
111
|
+
var endTimeModule;
|
112
|
+
var timeSeconds;
|
113
|
+
|
114
|
+
// amplitude api settings
|
115
|
+
// ----------------------
|
116
|
+
var ytpSongIndex = "0";
|
117
|
+
var ytpAutoPlay = false;
|
118
|
+
var ytpLoop = true;
|
119
|
+
var playLists = {};
|
120
|
+
var playersUILoaded = { state: false };
|
121
|
+
var apiInitialized = { state: false };
|
122
|
+
var playList;
|
123
|
+
var playerID;
|
124
|
+
var playerType;
|
125
|
+
var playListTitle;
|
126
|
+
var playListName;
|
127
|
+
var amplitudePlayerState;
|
128
|
+
var amplitudeDefaults;
|
129
|
+
var amplitudeSettings;
|
130
|
+
var amplitudeOptions;
|
131
|
+
var ytPlayer;
|
132
|
+
|
133
|
+
// amplitude player (instance) settings
|
134
|
+
// NOTE: slider VALUE is set by Adapter|Amplitude API
|
135
|
+
// ------------------------------------
|
136
|
+
var xhrLoadState;
|
137
|
+
var dependency;
|
138
|
+
var playerCounter = 0;
|
139
|
+
var load_dependencies = {};
|
140
|
+
var playersProcessed = [];
|
141
|
+
var playersHtmlLoaded = false;
|
142
|
+
var processingPlayersFinished = false;
|
143
|
+
var playerAudioInfo = ('{{amplitude_defaults.playlist.audio_info}}' === 'true') ? true : false;
|
144
|
+
var playerDefaultType = '{{amplitude_defaults.player.type}}';
|
145
|
+
var playerVolumeValue = '{{amplitude_defaults.player.volume_slider.preset_value}}';
|
146
|
+
var playerVolumeSliderStep = '{{amplitude_defaults.player.volume_slider.slider_step}}';
|
147
|
+
var playerRepeat = ('{{amplitude_defaults.player.repeat}}' === 'true') ? true : false;
|
148
|
+
var playerShuffle = ('{{amplitude_defaults.player.shuffle}}' === 'true') ? true : false;
|
149
|
+
var playerPlayNextTitle = ('{{amplitude_defaults.player.play_next_title}}' === 'true') ? true : false;
|
150
|
+
var playerPauseNextTitle = ('{{amplitude_defaults.player.pause_next_title}}' === 'true') ? true : false;
|
151
|
+
var playerDelayNextTitle = '{{amplitude_defaults.player.delay_next_title}}';
|
152
|
+
var playerForwardBackwardSkipSeconds = '{{amplitude_defaults.player.forward_backward_skip_seconds}}';
|
153
|
+
|
154
|
+
// unused settings
|
155
|
+
// ---------------------------------------------------------------------------
|
156
|
+
// var playerWaveformSampleRate = '{{amplitude_defaults.player.waveform_sample_rate}}';
|
157
|
+
|
158
|
+
// ---------------------------------------------------------------------------
|
159
|
+
// main
|
160
|
+
// ---------------------------------------------------------------------------
|
161
|
+
return {
|
162
|
+
|
163
|
+
// -------------------------------------------------------------------------
|
164
|
+
// adapter initializer
|
165
|
+
// -------------------------------------------------------------------------
|
166
|
+
init: (options) => {
|
167
|
+
|
168
|
+
// -----------------------------------------------------------------------
|
169
|
+
// default module settings
|
170
|
+
// -----------------------------------------------------------------------
|
171
|
+
var settings = $.extend({
|
172
|
+
module_name: 'j1.adapter.amplitude',
|
173
|
+
generated: '{{site.time}}'
|
174
|
+
}, options);
|
175
|
+
|
176
|
+
// -----------------------------------------------------------------------
|
177
|
+
// global variable settings
|
178
|
+
// -----------------------------------------------------------------------
|
179
|
+
amplitudeDefaults = $.extend({}, {{amplitude_defaults | replace: 'nil', 'null' | replace: '=>', ':' }});
|
180
|
+
amplitudeSettings = $.extend({}, {{amplitude_settings | replace: 'nil', 'null' | replace: '=>', ':' }});
|
181
|
+
amplitudeOptions = $.extend(true, {}, amplitudeDefaults, amplitudeSettings);
|
182
|
+
|
183
|
+
// -----------------------------------------------------------------------
|
184
|
+
// control|logging settings
|
185
|
+
// -----------------------------------------------------------------------
|
186
|
+
_this = j1.adapter.amplitude;
|
187
|
+
logger = log4javascript.getLogger('j1.adapter.amplitude');
|
188
|
+
|
189
|
+
|
190
|
+
// -----------------------------------------------------------------------
|
191
|
+
// module initializer
|
192
|
+
// -----------------------------------------------------------------------
|
193
|
+
var dependencies_met_page_ready = setInterval (() => {
|
194
|
+
var pageState = $('#content').css("display");
|
195
|
+
var pageVisible = (pageState === 'block') ? true : false;
|
196
|
+
var j1CoreFinished = (j1.getState() === 'finished') ? true : false;
|
197
|
+
// var atticFinished = (j1.adapter.attic.getState() == 'finished') ? true : false;
|
198
|
+
|
199
|
+
if (j1CoreFinished && pageVisible) {
|
200
|
+
startTimeModule = Date.now();
|
201
|
+
|
202
|
+
_this.setState('started');
|
203
|
+
logger.debug('\n' + 'module state: ' + _this.getState());
|
204
|
+
logger.info('\n' + 'module is being initialized');
|
205
|
+
|
206
|
+
// jQuery('.scrollbar-rail').scrollbar();
|
207
|
+
|
208
|
+
// -------------------------------------------------------------------
|
209
|
+
// create global playlist (songs)
|
210
|
+
// -------------------------------------------------------------------
|
211
|
+
var songs = [];
|
212
|
+
_this.songLoader(songs);
|
213
|
+
|
214
|
+
// -------------------------------------------------------------------
|
215
|
+
// load all players (HTML|UI)
|
216
|
+
// -------------------------------------------------------------------
|
217
|
+
_this.playerHtmlLoader(playersUILoaded);
|
218
|
+
// _this.ytpAudioInit("bla");
|
219
|
+
|
220
|
+
// -------------------------------------------------------------------
|
221
|
+
// inititialize amplitude api
|
222
|
+
// -------------------------------------------------------------------
|
223
|
+
var dependencies_met_players_loaded = setInterval (() => {
|
224
|
+
if (playersUILoaded.state) {
|
225
|
+
_this.initApi(songs);
|
226
|
+
_this.ytpAudioInit({
|
227
|
+
ytpVideoID: "qEhzpBJpUq0",
|
228
|
+
ytpAutoPlay: ytpAutoPlay,
|
229
|
+
ytpLoop: ytpLoop
|
230
|
+
});
|
231
|
+
|
232
|
+
clearInterval(dependencies_met_players_loaded);
|
233
|
+
} // END if playersUILoaded
|
234
|
+
}, 10); // END dependencies_met_players_loaded
|
235
|
+
|
236
|
+
// -------------------------------------------------------------------
|
237
|
+
// initialize player specific UI events
|
238
|
+
// -------------------------------------------------------------------
|
239
|
+
var dependencies_met_api_initialized = setInterval (() => {
|
240
|
+
if (apiInitialized.state) {
|
241
|
+
_this.initPlayerUiEvents();
|
242
|
+
|
243
|
+
clearInterval(dependencies_met_api_initialized);
|
244
|
+
} // END if apiInitialized
|
245
|
+
}, 10); // END dependencies_met_api_initialized
|
246
|
+
|
247
|
+
clearInterval(dependencies_met_page_ready);
|
248
|
+
} // END pageVisible
|
249
|
+
}, 10); // END dependencies_met_page_ready
|
250
|
+
}, // END init
|
251
|
+
|
252
|
+
// -------------------------------------------------------------------------
|
253
|
+
// Create global playlist|songs (API)
|
254
|
+
// -------------------------------------------------------------------------
|
255
|
+
songLoader: (songs) => {
|
256
|
+
|
257
|
+
logger.info('\n' + 'creating global playlist (API): started');
|
258
|
+
|
259
|
+
// -----------------------------------------------------------------------
|
260
|
+
// initialize amplitude songs
|
261
|
+
// -----------------------------------------------------------------------
|
262
|
+
{% for playlist in amplitude_settings.playlists %} {% if playlist.enabled %}
|
263
|
+
var song_items = $.extend({}, {{playlist.items | replace: 'nil', 'null' | replace: '=>', ':' }});
|
264
|
+
|
265
|
+
for (var i = 0; i < Object.keys(song_items).length; i++) {
|
266
|
+
if (song_items[i].enabled) {
|
267
|
+
var item = song_items[i];
|
268
|
+
var song = {};
|
269
|
+
|
270
|
+
// map config settings|amplitude song items
|
271
|
+
// -----------------------------------------------------------------
|
272
|
+
for (const key in item) {
|
273
|
+
// skip properties NOT needed for a song
|
274
|
+
if (key === 'item' || key === 'audio_base' || key === 'enabled') {
|
275
|
+
continue;
|
276
|
+
} else if (key === 'audio') {
|
277
|
+
song.url = item.audio_base + '/' + item[key];
|
278
|
+
continue;
|
279
|
+
} else if (key === 'title') {
|
280
|
+
song.name = item[key];
|
281
|
+
continue;
|
282
|
+
} else if (key === 'name') {
|
283
|
+
song.album = item[key];
|
284
|
+
continue;
|
285
|
+
} else if (key === 'cover_image') {
|
286
|
+
song.cover_art_url = item[key];
|
287
|
+
continue;
|
288
|
+
} else if (key === 'audio_info') {
|
289
|
+
if (playerAudioInfo) {
|
290
|
+
song.audio_info = item[key];
|
291
|
+
} else {
|
292
|
+
song.audio_info = '';
|
293
|
+
} // END if playerAudioInfo
|
294
|
+
continue;
|
295
|
+
} else {
|
296
|
+
song[key] = item[key];
|
297
|
+
} // END if key
|
298
|
+
} // END for item
|
299
|
+
} // END id enabled
|
300
|
+
|
301
|
+
songs.push(song);
|
302
|
+
} // END for song_items
|
303
|
+
|
304
|
+
{% endif %} {% endfor %}
|
305
|
+
|
306
|
+
logger.info('\n' + 'creating global playlist (API): finished');
|
307
|
+
}, // END songLoader
|
308
|
+
|
309
|
+
// -------------------------------------------------------------------------
|
310
|
+
// load players HTML portion (UI)
|
311
|
+
// -------------------------------------------------------------------------
|
312
|
+
playerHtmlLoader: (playersLoaded) => {
|
313
|
+
var playerExistsInPage;
|
314
|
+
|
315
|
+
// -----------------------------------------------------------------------
|
316
|
+
// initialize HTML portion (UI) for all players configured|enabled
|
317
|
+
// -----------------------------------------------------------------------
|
318
|
+
logger.info('\n' + 'loading player HTML components (UI): started');
|
319
|
+
|
320
|
+
{% for player in amplitude_options.players %} {% if player.enabled %}
|
321
|
+
{% assign xhr_data_path = amplitude_options.xhr_data_path %}
|
322
|
+
{% capture xhr_container_id %}{{player.id}}_parent{% endcapture %}
|
323
|
+
|
324
|
+
// load players only that are configured in current page
|
325
|
+
//
|
326
|
+
playerExistsInPage = ($('#' + '{{xhr_container_id}}')[0] !== undefined) ? true : false;
|
327
|
+
if (playerExistsInPage) {
|
328
|
+
playerCounter++;
|
329
|
+
logger.debug('\n' + 'load player UI on ID #{{player.id}}: started');
|
330
|
+
|
331
|
+
j1.loadHTML({
|
332
|
+
xhr_container_id: '{{xhr_container_id}}',
|
333
|
+
xhr_data_path: '{{xhr_data_path}}',
|
334
|
+
xhr_data_element: '{{player.id}}'
|
335
|
+
},
|
336
|
+
'j1.adapter.amplitude',
|
337
|
+
'data_loaded'
|
338
|
+
);
|
339
|
+
|
340
|
+
// dynamic loader variable to setup the player on ID {{player.id}}
|
341
|
+
dependency = 'dependencies_met_html_loaded_{{player.id}}';
|
342
|
+
load_dependencies[dependency] = '';
|
343
|
+
|
344
|
+
// ---------------------------------------------------------------------
|
345
|
+
// initialize amplitude instance (when player UI loaded)
|
346
|
+
// ---------------------------------------------------------------------
|
347
|
+
load_dependencies['dependencies_met_html_loaded_{{player.id}}'] = setInterval (() => {
|
348
|
+
// check if HTML portion of the player is loaded successfully
|
349
|
+
xhrLoadState = j1.xhrDOMState['#' + '{{xhr_container_id}}'];
|
350
|
+
|
351
|
+
if (xhrLoadState === 'success') {
|
352
|
+
playersProcessed.push('{{xhr_container_id}}');
|
353
|
+
logger.debug('\n' + 'load player UI on ID #{{player.id}}: finished');
|
354
|
+
|
355
|
+
clearInterval(load_dependencies['dependencies_met_html_loaded_{{player.id}}']);
|
356
|
+
}
|
357
|
+
}, 10); // END dependencies_met_html_loaded
|
358
|
+
} // END if playerExistsInPage
|
359
|
+
|
360
|
+
{% endif %} {% endfor %}
|
361
|
+
|
362
|
+
load_dependencies['dependencies_met_players_loaded'] = setInterval (() => {
|
363
|
+
|
364
|
+
if (playersProcessed.length === playerCounter) {
|
365
|
+
processingPlayersFinished = true;
|
366
|
+
}
|
367
|
+
|
368
|
+
if (processingPlayersFinished) {
|
369
|
+
logger.info('\n' + 'loading player HTML components (UI): finished');
|
370
|
+
|
371
|
+
clearInterval(load_dependencies['dependencies_met_players_loaded']);
|
372
|
+
playersLoaded.state = true;
|
373
|
+
}
|
374
|
+
}, 10); // END dependencies_met_players_loaded
|
375
|
+
|
376
|
+
}, // END playerHtmlLoader
|
377
|
+
|
378
|
+
// -------------------------------------------------------------------------
|
379
|
+
// initApi
|
380
|
+
// -------------------------------------------------------------------------
|
381
|
+
initApi: (songlist) => {
|
382
|
+
|
383
|
+
logger.info('\n' + 'initialze API: started');
|
384
|
+
|
385
|
+
{% comment %} collect playlists
|
386
|
+
-------------------------------------------------------------------------- {% endcomment %}
|
387
|
+
{% assign playlists_enabled = 0 %}
|
388
|
+
{% for list in amplitude_settings.playlists %} {% if list.enabled %}
|
389
|
+
{% assign playlists_enabled = playlists_enabled | plus: 1 %}
|
390
|
+
{% endif %} {% endfor %}
|
391
|
+
|
392
|
+
{% assign playlists_processed = 0 %}
|
393
|
+
{% for list in amplitude_settings.playlists %} {% if list.enabled %}
|
394
|
+
{% assign playlist_items = list.items %}
|
395
|
+
{% assign playlist_name = list.name %}
|
396
|
+
{% assign playlist_title = list.title %}
|
397
|
+
|
398
|
+
{% comment %} collect song items
|
399
|
+
------------------------------------------------------------------------ {% endcomment %}
|
400
|
+
{% for item in playlist_items %} {% if item.enabled %}
|
401
|
+
{% capture song_item %}
|
402
|
+
{
|
403
|
+
"name": "{{item.title}}",
|
404
|
+
"artist": "{{item.artist}}",
|
405
|
+
"album": "{{item.name}}",
|
406
|
+
"url": "{{item.audio_base}}/{{item.audio}}",
|
407
|
+
"cover_art_url": "{{item.cover_image}}"
|
408
|
+
}{% if forloop.last %}{% else %},{% endif %}
|
409
|
+
{% endcapture %}
|
410
|
+
{% capture song_items %}{{song_items}} {{song_item}}{% endcapture %}
|
411
|
+
|
412
|
+
{% comment %} create playlist
|
413
|
+
---------------------------------------------------------------------- {% endcomment %}
|
414
|
+
{% if forloop.last %}
|
415
|
+
{% capture playlist %}
|
416
|
+
"{{playlist_name}}": {
|
417
|
+
"title": "{{playlist_title}}",
|
418
|
+
"songs": [
|
419
|
+
{{song_items}}
|
420
|
+
]
|
421
|
+
}
|
422
|
+
{% endcapture %}
|
423
|
+
{% assign playlists_processed = playlists_processed | plus: 1 %}
|
424
|
+
|
425
|
+
{% comment %} reset song_items
|
426
|
+
-------------------------------------------------------------------- {% endcomment %}
|
427
|
+
{% capture song_items %}{% endcapture %}
|
428
|
+
{% endif %}
|
429
|
+
{% endif %} {% endfor %}
|
430
|
+
|
431
|
+
{% comment %} collect playlists players enabled
|
432
|
+
------------------------------------------------------------------------ {% endcomment %}
|
433
|
+
{% capture playlists %}
|
434
|
+
{{playlists}} {{playlist}} {% if playlists_processed == playlists_enabled %}{% else %},{% endif %}
|
435
|
+
{% endcapture %}
|
436
|
+
|
437
|
+
{% endif %} {% endfor %}
|
438
|
+
|
439
|
+
// See: https://521dimensions.com/open-source/amplitudejs/docs
|
440
|
+
// NOTE: slider VALUE (volume) is set by DEFAULT settings (player)
|
441
|
+
Amplitude.init({
|
442
|
+
bindings: {
|
443
|
+
33: 'play_pause',
|
444
|
+
37: 'prev',
|
445
|
+
39: 'next'
|
446
|
+
},
|
447
|
+
songs: songlist,
|
448
|
+
playlists: {
|
449
|
+
{{playlists}}
|
450
|
+
},
|
451
|
+
callbacks: {
|
452
|
+
initialized: function() {
|
453
|
+
var amplitudeConfig = Amplitude.getConfig();
|
454
|
+
logger.info('\n' + 'initialze API: finished');
|
455
|
+
// indicate api successfully initialized
|
456
|
+
apiInitialized.state = true;
|
457
|
+
},
|
458
|
+
onInitError: function() {
|
459
|
+
// indicate api failed on initialization
|
460
|
+
apiInitialized.state = false;
|
461
|
+
console.error('\n' + 'Amplitude API failed on initialization');
|
462
|
+
},
|
463
|
+
play: function() {
|
464
|
+
var songMetaData = Amplitude.getActiveSongMetadata();
|
465
|
+
logger.debug('\n' + 'playing title: ' + songMetaData.name);
|
466
|
+
document.getElementById('album-art').style.visibility = 'hidden';
|
467
|
+
document.getElementById('large-visualization').style.visibility = 'visible';
|
468
|
+
},
|
469
|
+
pause: function() {
|
470
|
+
var songMetaData = Amplitude.getActiveSongMetadata();
|
471
|
+
logger.debug('\n' + 'pause title: ' + songMetaData.name);
|
472
|
+
document.getElementById('album-art').style.visibility = 'visible';
|
473
|
+
document.getElementById('large-visualization').style.visibility = 'hidden';
|
474
|
+
},
|
475
|
+
song_change: function() {
|
476
|
+
var songMetaData = Amplitude.getActiveSongMetadata();
|
477
|
+
logger.debug('\n' + 'changed to title: ' + songMetaData.name + ' with titleIndex ' + songMetaData.index);
|
478
|
+
},
|
479
|
+
next: function() {
|
480
|
+
var songMetaData = Amplitude.getActiveSongMetadata();
|
481
|
+
|
482
|
+
if (playerDelayNextTitle) {
|
483
|
+
logger.debug('\n' + 'delay on next title: ' + songMetaData.name + ' with titleIndex ' + songMetaData.index);
|
484
|
+
}
|
485
|
+
|
486
|
+
if (playerPauseNextTitle) {
|
487
|
+
amplitudePlayerState = Amplitude.getPlayerState();
|
488
|
+
if (amplitudePlayerState === 'playing' || amplitudePlayerState === 'stopped' ) {
|
489
|
+
setTimeout(() => {
|
490
|
+
// pause playback of next title
|
491
|
+
logger.debug('\n' + 'paused on next title: ' + songMetaData.name);
|
492
|
+
Amplitude.pause();
|
493
|
+
}, 150);
|
494
|
+
} // END if playing
|
495
|
+
} // END if pause on next title
|
496
|
+
},
|
497
|
+
prev: function() {
|
498
|
+
var songMetaData = Amplitude.getActiveSongMetadata();
|
499
|
+
|
500
|
+
if (playerDelayNextTitle) {
|
501
|
+
logger.debug('\n' + 'delay on previous title: ' + songMetaData.name + ' with titleIndex ' + songMetaData.index);
|
502
|
+
}
|
503
|
+
|
504
|
+
if (playerPauseNextTitle) {
|
505
|
+
amplitudePlayerState = Amplitude.getPlayerState();
|
506
|
+
if (amplitudePlayerState === 'playing' || amplitudePlayerState === 'stopped' ) {
|
507
|
+
setTimeout(() => {
|
508
|
+
// pause playback of next title
|
509
|
+
logger.debug('\n' + 'paused on next title: ' + songMetaData.name);
|
510
|
+
Amplitude.pause();
|
511
|
+
}, 150);
|
512
|
+
} // END if playing
|
513
|
+
} // END if pause on next title
|
514
|
+
}
|
515
|
+
}, // END callbacks
|
516
|
+
// waveforms: {
|
517
|
+
// sample_rate: playerWaveformSampleRate
|
518
|
+
// },
|
519
|
+
continue_next: playerPlayNextTitle,
|
520
|
+
volume: playerVolumeValue,
|
521
|
+
volume_decrement: playerVolumeSliderStep,
|
522
|
+
volume_increment: playerVolumeSliderStep
|
523
|
+
}); // END Amplitude init
|
524
|
+
|
525
|
+
}, // END initApi
|
526
|
+
|
527
|
+
// -------------------------------------------------------------------------
|
528
|
+
// initPlayerUiEvents
|
529
|
+
// -------------------------------------------------------------------------
|
530
|
+
initPlayerUiEvents: () => {
|
531
|
+
|
532
|
+
var dependencies_met_player_instances_initialized = setInterval (() => {
|
533
|
+
if (apiInitialized.state) {
|
534
|
+
logger.info('\n' + 'initialize player specific UI events: started');
|
535
|
+
|
536
|
+
{% for player in amplitude_options.players %} {% if player.enabled %}
|
537
|
+
{% assign xhr_data_path = amplitude_options.xhr_data_path %}
|
538
|
+
{% capture xhr_container_id %}{{player.id}}_parent{% endcapture %}
|
539
|
+
|
540
|
+
playerID = '{{player.id}}';
|
541
|
+
playerType = '{{player.type}}';
|
542
|
+
playList = '{{player.playlist}}';
|
543
|
+
playListName = '{{player.playlist.name}}'
|
544
|
+
playListTitle = '{{player.playlist.title}}';
|
545
|
+
|
546
|
+
logger.debug('\n' + 'set playlist {{player.playlist}} on id #{{player.id}} with title: ' + playListTitle);
|
547
|
+
|
548
|
+
// dynamic loader variable to setup the player on ID {{player.id}}
|
549
|
+
dependency = 'dependencies_met_player_loaded_{{player.id}}';
|
550
|
+
load_dependencies[dependency] = '';
|
551
|
+
|
552
|
+
// -----------------------------------------------------------------
|
553
|
+
// initialize player instance (when player UI is loaded)
|
554
|
+
// -----------------------------------------------------------------
|
555
|
+
load_dependencies['dependencies_met_player_loaded_{{player.id}}'] = setInterval (() => {
|
556
|
+
// check if HTML portion of the player is loaded successfully
|
557
|
+
var xhrLoadState = j1.xhrDOMState['#' + '{{xhr_container_id}}'];
|
558
|
+
|
559
|
+
if (xhrLoadState === 'success') {
|
560
|
+
|
561
|
+
// set song (title) specific audio info links
|
562
|
+
// -------------------------------------------------------------
|
563
|
+
if (playerAudioInfo) {
|
564
|
+
var infoLinks = document.getElementsByClassName('audio-info-link');
|
565
|
+
_this.setAudioInfo(infoLinks);
|
566
|
+
}
|
567
|
+
|
568
|
+
// jadams, 2024-10-19: (song) events DISABLED
|
569
|
+
// set song (title) specific UI events
|
570
|
+
// -------------------------------------------------------------
|
571
|
+
// var songElements = document.getElementsByClassName('song');
|
572
|
+
// _this.songEvents(songElements);
|
573
|
+
|
574
|
+
// player specific UI events
|
575
|
+
// -------------------------------------------------------------
|
576
|
+
logger.debug('\n' + 'setup player specific UI events on ID #{{player.id}}: started');
|
577
|
+
|
578
|
+
var dependencies_met_api_initialized = setInterval (() => {
|
579
|
+
if (apiInitialized.state) {
|
580
|
+
amplitudePlayerState = Amplitude.getPlayerState();
|
581
|
+
|
582
|
+
{% if player.id contains 'mini' %}
|
583
|
+
// ---------------------------------------------------------
|
584
|
+
// START mini player UI events
|
585
|
+
//
|
586
|
+
if (document.getElementById('{{player.id}}') !== null) {
|
587
|
+
|
588
|
+
// click on progress bar
|
589
|
+
// -------------------------------------------------------
|
590
|
+
|
591
|
+
// getElementsByClassName returns an Array-like object
|
592
|
+
var progressBars = document.getElementsByClassName("mini-player-progress");
|
593
|
+
|
594
|
+
// add listeners to all progress bars found
|
595
|
+
for (var i=0; i<progressBars.length; i++) {
|
596
|
+
progressBars[i].addEventListener('click', function(event) {
|
597
|
+
var offset = this.getBoundingClientRect();
|
598
|
+
var xpos = event.pageX - offset.left;
|
599
|
+
|
600
|
+
Amplitude.setSongPlayedPercentage(
|
601
|
+
(parseFloat(xpos)/parseFloat(this.offsetWidth))*100);
|
602
|
+
});
|
603
|
+
}
|
604
|
+
|
605
|
+
} // END mini player UI events
|
606
|
+
{% endif %}
|
607
|
+
|
608
|
+
{% if player.id contains 'compact' %}
|
609
|
+
// ---------------------------------------------------------
|
610
|
+
// START compact player UI events
|
611
|
+
//
|
612
|
+
if (document.getElementById('{{player.id}}') !== null) {
|
613
|
+
|
614
|
+
// show|hide scrollbar in playlist
|
615
|
+
// -------------------------------------------------------
|
616
|
+
const songsInPlaylist = Amplitude.getSongsInPlaylist(playListName);
|
617
|
+
if (songsInPlaylist.length <= 8) {
|
618
|
+
const titleListCompactPlayer = document.getElementById('compact_player_title_list_' + playListName);
|
619
|
+
if (titleListCompactPlayer !== null) {
|
620
|
+
titleListCompactPlayer.classList.add('hide-scrollbar');
|
621
|
+
}
|
622
|
+
}
|
623
|
+
|
624
|
+
// show|hide playlist
|
625
|
+
// -------------------------------------------------------
|
626
|
+
|
627
|
+
// show playlist
|
628
|
+
var showPlaylist = document.getElementById("show_playlist_{{player.id}}");
|
629
|
+
if (showPlaylist !== null) {
|
630
|
+
showPlaylist.addEventListener('click', function(event) {
|
631
|
+
var scrollOffset = (window.innerWidth >= 720) ? -130 : -110;
|
632
|
+
|
633
|
+
// scroll player to top position
|
634
|
+
const targetDiv = document.getElementById("show_playlist_{{player.id}}");
|
635
|
+
const targetDivPosition = targetDiv.offsetParent.offsetTop;
|
636
|
+
window.scrollTo(0, targetDivPosition + scrollOffset);
|
637
|
+
|
638
|
+
// open playlist
|
639
|
+
var playlistScreen = document.getElementById("playlist_screen_{{player.id}}");
|
640
|
+
|
641
|
+
playlistScreen.classList.remove('slide-out-top');
|
642
|
+
playlistScreen.classList.add('slide-in-top');
|
643
|
+
playlistScreen.style.display = "block";
|
644
|
+
playlistScreen.style.zIndex = "999";
|
645
|
+
|
646
|
+
// disable scrolling (if window viewport >= BS Medium and above)
|
647
|
+
if (window.innerWidth >= 720) {
|
648
|
+
if ($('body').hasClass('stop-scrolling')) {
|
649
|
+
return false;
|
650
|
+
} else {
|
651
|
+
$('body').addClass('stop-scrolling');
|
652
|
+
}
|
653
|
+
}
|
654
|
+
}); // END EventListener 'click' (compact player|show playlist)
|
655
|
+
}
|
656
|
+
|
657
|
+
// hide playlist
|
658
|
+
var hidePlaylist = document.getElementById("hide_playlist_{{player.id}}");
|
659
|
+
if (hidePlaylist !== null) {
|
660
|
+
hidePlaylist.addEventListener('click', function(event) {
|
661
|
+
var playlistScreen = document.getElementById("playlist_screen_{{player.id}}");
|
662
|
+
|
663
|
+
playlistScreen.classList.remove('slide-in-top');
|
664
|
+
playlistScreen.classList.add('slislide-out-top');
|
665
|
+
playlistScreen.style.display = "none";
|
666
|
+
playlistScreen.style.zIndex = "1";
|
667
|
+
|
668
|
+
// enable scrolling
|
669
|
+
if ($('body').hasClass('stop-scrolling')) {
|
670
|
+
$('body').removeClass('stop-scrolling');
|
671
|
+
}
|
672
|
+
}); // END EventListener 'click' (compact player|show playlist)
|
673
|
+
}
|
674
|
+
|
675
|
+
// click on progress bar
|
676
|
+
// -------------------------------------------------------
|
677
|
+
|
678
|
+
// getElementsByClassName returns an Array-like object
|
679
|
+
var progressBars = document.getElementsByClassName("compact-player-progress");
|
680
|
+
|
681
|
+
// add listeners to all progress bars found
|
682
|
+
for (var i=0; i<progressBars.length; i++) {
|
683
|
+
progressBars[i].addEventListener('click', function(event) {
|
684
|
+
var offset = this.getBoundingClientRect();
|
685
|
+
var xpos = event.pageX - offset.left;
|
686
|
+
|
687
|
+
Amplitude.setSongPlayedPercentage(
|
688
|
+
(parseFloat(xpos)/parseFloat(this.offsetWidth))*100);
|
689
|
+
}); // END EventListener 'click'
|
690
|
+
}
|
691
|
+
|
692
|
+
// click on skip forward|backward (compact player)
|
693
|
+
// See: https://github.com/serversideup/amplitudejs/issues/384
|
694
|
+
// -------------------------------------------------------
|
695
|
+
|
696
|
+
// add listeners to all SkipForwardButtons found
|
697
|
+
var compactPlayerSkipForwardButtons = document.getElementsByClassName("compact-player-skip-forward");
|
698
|
+
for (var i=0; i<compactPlayerSkipForwardButtons.length; i++) {
|
699
|
+
if (compactPlayerSkipForwardButtons[i].id === 'skip-forward_{{player.id}}') {
|
700
|
+
compactPlayerSkipForwardButtons[i].addEventListener('click', function(event) {
|
701
|
+
const skipOffset = parseFloat(playerForwardBackwardSkipSeconds);
|
702
|
+
const duration = Amplitude.getSongDuration();
|
703
|
+
const currentTime = parseFloat(Amplitude.getSongPlayedSeconds());
|
704
|
+
const targetTime = parseFloat(currentTime + skipOffset);
|
705
|
+
|
706
|
+
if (currentTime > 0) {
|
707
|
+
Amplitude.setSongPlayedPercentage((targetTime / duration) * 100);
|
708
|
+
} // END EventListener 'click'
|
709
|
+
});
|
710
|
+
} // END if ID
|
711
|
+
} // END for SkipForwardButtons
|
712
|
+
|
713
|
+
// add listeners to all SkipBackwardButtons found
|
714
|
+
var compactPlayerSkipBackwardButtons = document.getElementsByClassName("compact-player-skip-backward");
|
715
|
+
for (var i=0; i<compactPlayerSkipBackwardButtons.length; i++) {
|
716
|
+
if (compactPlayerSkipBackwardButtons[i].id === 'skip-backward_{{player.id}}') {
|
717
|
+
compactPlayerSkipBackwardButtons[i].addEventListener('click', function(event) {
|
718
|
+
const skipOffset = parseFloat(playerForwardBackwardSkipSeconds);
|
719
|
+
const duration = Amplitude.getSongDuration();
|
720
|
+
const currentTime = parseFloat(Amplitude.getSongPlayedSeconds());
|
721
|
+
const targetTime = parseFloat(currentTime - skipOffset);
|
722
|
+
|
723
|
+
if (currentTime > 0) {
|
724
|
+
Amplitude.setSongPlayedPercentage((targetTime / duration) * 100);
|
725
|
+
} // END EventListener 'click'
|
726
|
+
});
|
727
|
+
} // END if ID
|
728
|
+
} // END for SkipBackwardButtons
|
729
|
+
|
730
|
+
// click on shuffle button
|
731
|
+
var compactPlayerShuffleButton = document.getElementById('compact_player_shuffle');
|
732
|
+
if (compactPlayerShuffleButton) {
|
733
|
+
compactPlayerShuffleButton.addEventListener('click', function(event) {
|
734
|
+
var shuffleState = (document.getElementById('compact_player_shuffle').className.includes('amplitude-shuffle-on')) ? true : false;
|
735
|
+
Amplitude.setShuffle(shuffleState)
|
736
|
+
}); // END EventListener 'click'
|
737
|
+
} // END compactPlayerShuffleButton
|
738
|
+
|
739
|
+
// click on repeat button
|
740
|
+
var compactPlayerRepeatButton = document.getElementById('compact_player_repeat');
|
741
|
+
if (compactPlayerRepeatButton) {
|
742
|
+
compactPlayerRepeatButton.addEventListener('click', function(event) {
|
743
|
+
var repeatState = (document.getElementById('compact_player_repeat').className.includes('amplitude-repeat-on')) ? true : false;
|
744
|
+
Amplitude.setRepeat(repeatState)
|
745
|
+
}); // END EventListener 'click'
|
746
|
+
} // END compactPlayerRepeatButton
|
747
|
+
|
748
|
+
} // END compact player UI events
|
749
|
+
{% endif %}
|
750
|
+
|
751
|
+
{% if player.id contains 'large' %}
|
752
|
+
// START large player UI events
|
753
|
+
//
|
754
|
+
if (document.getElementById('{{player.id}}') !== null) {
|
755
|
+
|
756
|
+
// listener overloads for Youtube video (large player)
|
757
|
+
// -------------------------------------------------------
|
758
|
+
|
759
|
+
// click on prev button
|
760
|
+
var largePlayerPreviousButton = document.getElementById('large_player_previous');
|
761
|
+
if (largePlayerPreviousButton && largePlayerPreviousButton.getAttribute("data-amplitude-source") === 'youtube') {
|
762
|
+
largePlayerPreviousButton.addEventListener('click', function(event) {
|
763
|
+
var playlist = this.getAttribute("data-amplitude-playlist");
|
764
|
+
var songIndex = ytpSongIndex; // Amplitude.getActiveIndex();
|
765
|
+
|
766
|
+
}); // END EventListener 'click'
|
767
|
+
}
|
768
|
+
|
769
|
+
// click on play_pause button
|
770
|
+
var largePlayerPlayButton = document.getElementById('large_player_play_pause');
|
771
|
+
if (largePlayerPlayButton && largePlayerPlayButton.getAttribute("data-amplitude-source") === 'youtube') {
|
772
|
+
largePlayerPlayButton.addEventListener('click', function(event) {
|
773
|
+
var playlist = this.getAttribute("data-amplitude-playlist");
|
774
|
+
var songMetaData = Amplitude.getSongAtIndex(ytpSongIndex);
|
775
|
+
var songURL = songMetaData.url;
|
776
|
+
// Amplitude.getActiveIndex();
|
777
|
+
var songIndex = ytpSongIndex;
|
778
|
+
}); // END EventListener 'click'
|
779
|
+
}
|
780
|
+
|
781
|
+
// click on next button
|
782
|
+
var largePlayerNextButton = document.getElementById('large_player_next');
|
783
|
+
if (largePlayerNextButton && largePlayerPlayButton.getAttribute("data-amplitude-source") === 'youtube') {
|
784
|
+
largePlayerNextButton.addEventListener('click', function(event) {
|
785
|
+
var playlist = this.getAttribute("data-amplitude-playlist");
|
786
|
+
var songIndex = ytpSongIndex; // Amplitude.getActiveIndex();
|
787
|
+
}); // END EventListener 'click'
|
788
|
+
}
|
789
|
+
|
790
|
+
// click on song container
|
791
|
+
var largetPlayerSongContainer = document.getElementsByClassName("song amplitude-song-container");
|
792
|
+
for (var i=0; i<largetPlayerSongContainer.length; i++) {
|
793
|
+
if (largetPlayerSongContainer[i].dataset.amplitudeSource === 'youtube') {
|
794
|
+
largetPlayerSongContainer[i].addEventListener('click', function(event) {
|
795
|
+
var playlist = this.getAttribute("data-amplitude-playlist");
|
796
|
+
var playlistLength = largetPlayerSongContainer.length;
|
797
|
+
ytpSongIndex = this.getAttribute("data-amplitude-song-index");
|
798
|
+
});
|
799
|
+
} // END if Attribute
|
800
|
+
} // END for
|
801
|
+
|
802
|
+
// add listeners to all progress bars found
|
803
|
+
// -------------------------------------------------------
|
804
|
+
var progressBars = document.getElementsByClassName("large-player-progress");
|
805
|
+
for (var i=0; i<progressBars.length; i++) {
|
806
|
+
progressBars[i].addEventListener('click', function(event) {
|
807
|
+
var offset = this.getBoundingClientRect();
|
808
|
+
var xpos = event.pageX - offset.left;
|
809
|
+
|
810
|
+
Amplitude.setSongPlayedPercentage(
|
811
|
+
(parseFloat(xpos)/parseFloat(this.offsetWidth))*100);
|
812
|
+
}); // END EventListener 'click'
|
813
|
+
}
|
814
|
+
|
815
|
+
// click on skip forward|backward (large player)
|
816
|
+
// See: https://github.com/serversideup/amplitudejs/issues/384
|
817
|
+
// -------------------------------------------------------
|
818
|
+
|
819
|
+
// add listeners to all SkipForwardButtons found
|
820
|
+
var largePlayerSkipForwardButtons = document.getElementsByClassName("large-player-skip-forward");
|
821
|
+
for (var i=0; i<largePlayerSkipForwardButtons.length; i++) {
|
822
|
+
if (largePlayerSkipForwardButtons[i].id === 'skip-forward_{{player.id}}') {
|
823
|
+
if (largePlayerSkipForwardButtons[i].dataset.amplitudeSource === 'youtube') {
|
824
|
+
largePlayerSkipForwardButtons[i].addEventListener('click', function(event) {
|
825
|
+
const skipOffset = parseFloat(playerForwardBackwardSkipSeconds);
|
826
|
+
//const duration = Amplitude.getSongDuration();
|
827
|
+
//const currentTime = parseFloat(Amplitude.getSongPlayedSeconds());
|
828
|
+
//const targetTime = parseFloat(currentTime + skipOffset);
|
829
|
+
|
830
|
+
// if (currentTime > 0) {
|
831
|
+
// Amplitude.setSongPlayedPercentage((targetTime / duration) * 100);
|
832
|
+
// }
|
833
|
+
}); // END EventListener 'click
|
834
|
+
} else {
|
835
|
+
largePlayerSkipForwardButtons[i].addEventListener('click', function(event) {
|
836
|
+
const skipOffset = parseFloat(playerForwardBackwardSkipSeconds);
|
837
|
+
const duration = Amplitude.getSongDuration();
|
838
|
+
const currentTime = parseFloat(Amplitude.getSongPlayedSeconds());
|
839
|
+
const targetTime = parseFloat(currentTime + skipOffset);
|
840
|
+
|
841
|
+
if (currentTime > 0) {
|
842
|
+
Amplitude.setSongPlayedPercentage((targetTime / duration) * 100);
|
843
|
+
}
|
844
|
+
}); // END EventListener 'click
|
845
|
+
}
|
846
|
+
|
847
|
+
} // END if ID
|
848
|
+
} // END for SkipForwardButtons
|
849
|
+
|
850
|
+
// add listeners to all SkipBackwardButtons found
|
851
|
+
var largePlayerSkipBackwardButtons = document.getElementsByClassName("large-player-skip-backward");
|
852
|
+
for (var i=0; i<largePlayerSkipBackwardButtons.length; i++) {
|
853
|
+
if (largePlayerSkipBackwardButtons[i].id === 'skip-backward_{{player.id}}') {
|
854
|
+
if (largePlayerSkipBackwardButtons[i].dataset.amplitudeSource === 'youtube') {
|
855
|
+
largePlayerSkipBackwardButtons[i].addEventListener('click', function(event) {
|
856
|
+
const skipOffset = parseFloat(playerForwardBackwardSkipSeconds);
|
857
|
+
}); // END EventListener 'click'
|
858
|
+
} else {
|
859
|
+
largePlayerSkipBackwardButtons[i].addEventListener('click', function(event) {
|
860
|
+
const skipOffset = parseFloat(playerForwardBackwardSkipSeconds);
|
861
|
+
const duration = Amplitude.getSongDuration();
|
862
|
+
const currentTime = parseFloat(Amplitude.getSongPlayedSeconds());
|
863
|
+
const targetTime = parseFloat(currentTime - skipOffset);
|
864
|
+
|
865
|
+
if (currentTime > 0) {
|
866
|
+
Amplitude.setSongPlayedPercentage((targetTime / duration) * 100);
|
867
|
+
}
|
868
|
+
}); // END EventListener 'click'
|
869
|
+
}
|
870
|
+
|
871
|
+
} // END if ID
|
872
|
+
} // END for SkipBackwardButtons
|
873
|
+
|
874
|
+
// click on shuffle button
|
875
|
+
var largePlayerShuffleButton = document.getElementById('large_player_shuffle');
|
876
|
+
if (largePlayerShuffleButton) {
|
877
|
+
largePlayerShuffleButton.addEventListener('click', function(event) {
|
878
|
+
var shuffleState = (document.getElementById('large_player_shuffle').className.includes('amplitude-shuffle-on')) ? true : false;
|
879
|
+
Amplitude.setShuffle(shuffleState)
|
880
|
+
}); // END EventListener 'click'
|
881
|
+
} // END largePlayerShuffleButton
|
882
|
+
|
883
|
+
// click on repeat button
|
884
|
+
var largePlayerRepeatButton = document.getElementById('large_player_repeat');
|
885
|
+
if (largePlayerShuffleButton) {
|
886
|
+
largePlayerRepeatButton.addEventListener('click', function(event) {
|
887
|
+
var repeatState = (document.getElementById('large_player_repeat').className.includes('amplitude-repeat-on')) ? true : false;
|
888
|
+
Amplitude.setRepeat(repeatState)
|
889
|
+
}); // END EventListener 'click'
|
890
|
+
} // END largePlayerRepeatButton
|
891
|
+
|
892
|
+
// enable|disable scrolling on playlist
|
893
|
+
// -------------------------------------------------------
|
894
|
+
if (document.getElementById('large_player_right') !== null) {
|
895
|
+
|
896
|
+
// show|hide scrollbar in playlist
|
897
|
+
// -------------------------------------------------------
|
898
|
+
const songsInPlaylist = Amplitude.getSongsInPlaylist(playListName);
|
899
|
+
|
900
|
+
if (songsInPlaylist.length <= 8) {
|
901
|
+
const titleListLargePlayer = document.getElementById('large_player_title_list_' + playListName);
|
902
|
+
if (titleListLargePlayer !== null) {
|
903
|
+
titleListLargePlayer.classList.add('hide-scrollbar');
|
904
|
+
}
|
905
|
+
}
|
906
|
+
|
907
|
+
// scroll to player top position
|
908
|
+
// -------------------------------------------------------
|
909
|
+
var playlistHeader = document.getElementById("playlist_header_{{player.id}}");
|
910
|
+
|
911
|
+
playlistHeader.addEventListener('click', function(event) {
|
912
|
+
var scrollOffset = (window.innerWidth >= 720) ? -130 : -110;
|
913
|
+
|
914
|
+
// scroll player to top position
|
915
|
+
const targetDiv = document.getElementById("playlist_header_{{player.id}}");
|
916
|
+
const targetDivPosition = targetDiv.offsetTop;
|
917
|
+
window.scrollTo(0, targetDivPosition + scrollOffset);
|
918
|
+
}); // END EventListener 'click'
|
919
|
+
|
920
|
+
// disable scrolling (if window viewport >= BS Medium and above)
|
921
|
+
document.getElementById('large_player_right').addEventListener('mouseenter', function() {
|
922
|
+
if (window.innerWidth >= 720) {
|
923
|
+
if ($('body').hasClass('stop-scrolling')) {
|
924
|
+
return false;
|
925
|
+
} else {
|
926
|
+
$('body').addClass('stop-scrolling');
|
927
|
+
}
|
928
|
+
}
|
929
|
+
}); // END EventListener 'mouseenter'
|
930
|
+
|
931
|
+
// enable scrolling
|
932
|
+
document.getElementById('large_player_right').addEventListener('mouseleave', function() {
|
933
|
+
if ($('body').hasClass('stop-scrolling')) {
|
934
|
+
$('body').removeClass('stop-scrolling');
|
935
|
+
}
|
936
|
+
}); // END EventListener 'mouseleave'
|
937
|
+
|
938
|
+
} // END enable|disable scrolling on playlist
|
939
|
+
|
940
|
+
} // END large player UI events
|
941
|
+
{% endif %}
|
942
|
+
|
943
|
+
// ---------------------------------------------------------
|
944
|
+
// START configured player features
|
945
|
+
|
946
|
+
logger.debug('\n' + 'set play next title: ' + playerPlayNextTitle);
|
947
|
+
logger.debug('\n' + 'set delay between titles: ' + playerDelayNextTitle + 'ms');
|
948
|
+
logger.debug('\n' + 'set repeat (album): ' + playerRepeat);
|
949
|
+
logger.debug('\n' + 'set shuffle (album): ' + playerShuffle);
|
950
|
+
|
951
|
+
// set delay between titles (songs)
|
952
|
+
Amplitude.setDelay(playerDelayNextTitle);
|
953
|
+
// set repeat (album)
|
954
|
+
Amplitude.setRepeat(playerRepeat);
|
955
|
+
// set shuffle (album)
|
956
|
+
Amplitude.setShuffle(playerShuffle);
|
957
|
+
|
958
|
+
// ---------------------------------------------------------
|
959
|
+
// END configured player features
|
960
|
+
|
961
|
+
// finished messages
|
962
|
+
// ---------------------------------------------------------
|
963
|
+
logger.debug('\n' + 'current player state: ' + amplitudePlayerState);
|
964
|
+
logger.debug('\n' + 'setup player specific UI events on ID #{{player.id}}: finished');
|
965
|
+
|
966
|
+
clearInterval(dependencies_met_api_initialized);
|
967
|
+
} // END if apiInitialized
|
968
|
+
}, 10); // END dependencies_met_api_initialized
|
969
|
+
|
970
|
+
clearInterval(load_dependencies['dependencies_met_player_loaded_{{player.id}}']);
|
971
|
+
} // END if xhrLoadState success
|
972
|
+
}, 10); // END dependencies_met_html_loaded
|
973
|
+
|
974
|
+
{% endif %} {% endfor %}
|
975
|
+
|
976
|
+
logger.info('\n' + 'initialize player specific UI events: finished');
|
977
|
+
|
978
|
+
_this.setState('finished');
|
979
|
+
logger.debug('\n' + 'module state: ' + _this.getState());
|
980
|
+
logger.info('\n' + 'module initialized successfully');
|
981
|
+
|
982
|
+
endTimeModule = Date.now();
|
983
|
+
logger.info('\n' + 'module initializing time: ' + (endTimeModule-startTimeModule) + 'ms');
|
984
|
+
|
985
|
+
clearInterval(dependencies_met_player_instances_initialized);
|
986
|
+
} // END if apiInitialized
|
987
|
+
}, 10); // END initialize player specific UI events
|
988
|
+
}, // END initPlayerUiEvents
|
989
|
+
|
990
|
+
// -------------------------------------------------------------------------
|
991
|
+
// START setAudioInfo
|
992
|
+
setAudioInfo: (audioInfo) => {
|
993
|
+
// jadams: ??? new config setting 'pause_on_audio_info' ???
|
994
|
+
// when the audioInfo link is clicked, stop all propagation so
|
995
|
+
// AmplitudeJS doesn't play the song.
|
996
|
+
for (var i=0; i<audioInfo.length; i++) {
|
997
|
+
audioInfo[i].addEventListener('click', function (event) {
|
998
|
+
event.stopPropagation();
|
999
|
+
});
|
1000
|
+
}
|
1001
|
+
}, // END setAudioInfo
|
1002
|
+
|
1003
|
+
// -------------------------------------------------------------------------
|
1004
|
+
// songEvents
|
1005
|
+
// -------------------------------------------------------------------------
|
1006
|
+
songEvents: (songs) => {
|
1007
|
+
logger.debug('\n' + 'initializing title events for player on ID ' + '#' + playerID + ': started');
|
1008
|
+
|
1009
|
+
for (var i = 0; i < songs.length; i++) {
|
1010
|
+
// ensure that on mouseover, CSS styles don't get messed up for active songs
|
1011
|
+
songs[i].addEventListener('mouseover', function() {
|
1012
|
+
// active song indicator (mini play button) in playlist
|
1013
|
+
if (!this.classList.contains('amplitude-active-song-container')) {
|
1014
|
+
if (this.querySelectorAll('.play-button-container')[0] !== undefined) {
|
1015
|
+
this.querySelectorAll('.play-button-container')[0].style.display = 'block';
|
1016
|
+
}
|
1017
|
+
} // END mini play button in playlist
|
1018
|
+
}); // END EventListener 'mouseover' (songlist)
|
1019
|
+
|
1020
|
+
// ensure that on mouseout, CSS styles don't get messed up for active songs
|
1021
|
+
songs[i].addEventListener('mouseout', function() {
|
1022
|
+
if (this.querySelectorAll('.play-button-container')[0] !== undefined) {
|
1023
|
+
this.querySelectorAll('.play-button-container')[0].style.display = 'none';
|
1024
|
+
}
|
1025
|
+
}); // END EventListener 'mouseout' (songlist)
|
1026
|
+
|
1027
|
+
// show|hide the (mini) play button when the song is clicked
|
1028
|
+
songs[i].addEventListener('click', function () {
|
1029
|
+
if (this.querySelectorAll('.play-button-container')[0] !== undefined) {
|
1030
|
+
this.querySelectorAll('.play-button-container')[0].style.display = 'none';
|
1031
|
+
}
|
1032
|
+
}); // END EventListener 'click' (songlist)
|
1033
|
+
}
|
1034
|
+
|
1035
|
+
logger.debug('\n' + 'initializing title events for player on ID ' + '#' + playerID + ': finished');
|
1036
|
+
}, // END songEvents
|
1037
|
+
|
1038
|
+
// -------------------------------------------------------------------------
|
1039
|
+
// YT Player
|
1040
|
+
// -------------------------------------------------------------------------
|
1041
|
+
ytpAudioInit: (options) => {
|
1042
|
+
var ytpSettings = options;
|
1043
|
+
var firstScriptTag;
|
1044
|
+
|
1045
|
+
// load the IFrame Player API code asynchronously
|
1046
|
+
//
|
1047
|
+
var tag = document.createElement('script');
|
1048
|
+
tag.id = 'iframe_api';
|
1049
|
+
tag.src = '//youtube.com/iframe_api';
|
1050
|
+
firstScriptTag = document.getElementsByTagName('script')[0];
|
1051
|
+
|
1052
|
+
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
1053
|
+
|
1054
|
+
function onPlayerReady(event) {
|
1055
|
+
ytPlayer.setPlaybackQuality("small");
|
1056
|
+
// document.getElementById("youtube-audio").style.display = "block";
|
1057
|
+
// togglePlayButton1(ytPlayer.getPlayerState() !== 5);
|
1058
|
+
} // END event onPlayerReady
|
1059
|
+
|
1060
|
+
function onPlayerStateChange(event) {
|
1061
|
+
if (event.data === 0) {
|
1062
|
+
var bla = 'blupp'
|
1063
|
+
// togglePlayButton1(false);
|
1064
|
+
}
|
1065
|
+
} // END event onPlayerStateChange
|
1066
|
+
|
1067
|
+
// Create a new div element
|
1068
|
+
const ytpContainer = document.createElement('div');
|
1069
|
+
|
1070
|
+
// Set attributes for the div container
|
1071
|
+
ytpContainer.id = 'youtube_player_container';
|
1072
|
+
// ytpContainer.className = 'container';
|
1073
|
+
// ytpContainer.setAttribute("data-video", "WxcWO9O4DSM");
|
1074
|
+
// ytpContainer.setAttribute("data-autoplay", "0");
|
1075
|
+
// ytpContainer.setAttribute("data-loop", "1");
|
1076
|
+
// ytpContainer.innerHTML = 'data-video="WxcWO9O4DSM" data-autoplay="0" data-loop="1"';
|
1077
|
+
|
1078
|
+
// Append the div container to the end of the body
|
1079
|
+
document.body.appendChild(ytpContainer);
|
1080
|
+
|
1081
|
+
}, // END ytpAudioInit
|
1082
|
+
|
1083
|
+
// Create an <iframe> (and the YouTube player) after the YT API code
|
1084
|
+
// has been downloaded
|
1085
|
+
onYouTubeIframeAPIReady: () => {
|
1086
|
+
var ytCtrl = document.getElementById("youtube_player_container");
|
1087
|
+
ytCtrl.innerHTML = '<img id="youtube-icon1 src=""/> <div id="ytPlayer"></div>';
|
1088
|
+
ytCtrl.style.cssText = 'width:150px;margin:2em auto;cursor:pointer;cursor:hand;display:none';
|
1089
|
+
// ytCtrl.onclick = toggleAudio1;
|
1090
|
+
|
1091
|
+
ytPlayer = new YT.Player('ytPlayer', {
|
1092
|
+
height: 0,
|
1093
|
+
width: 0,
|
1094
|
+
videoId: ytpSettings.ytpVideoID,
|
1095
|
+
playerVars: {
|
1096
|
+
autoplay: ytpSettings.ytpAutoPlay,
|
1097
|
+
loop: ytpSettings.ytpLoop
|
1098
|
+
},
|
1099
|
+
events: {
|
1100
|
+
onReady: onPlayerReady,
|
1101
|
+
onStateChange: onPlayerStateChange
|
1102
|
+
}
|
1103
|
+
});
|
1104
|
+
|
1105
|
+
logger.info('\n' + 'YouTube IframeAPI: ready');
|
1106
|
+
}, // END onYouTubeIframeAPIReady
|
1107
|
+
|
1108
|
+
// -------------------------------------------------------------------------
|
1109
|
+
// messageHandler()
|
1110
|
+
// manage messages send from other J1 modules
|
1111
|
+
// -------------------------------------------------------------------------
|
1112
|
+
messageHandler: (sender, message) => {
|
1113
|
+
var json_message = JSON.stringify(message, undefined, 2);
|
1114
|
+
|
1115
|
+
logText = '\n' + 'received message from ' + sender + ': ' + json_message;
|
1116
|
+
logger.debug(logText);
|
1117
|
+
|
1118
|
+
// -----------------------------------------------------------------------
|
1119
|
+
// process commands|actions
|
1120
|
+
// -----------------------------------------------------------------------
|
1121
|
+
if (message.type === 'command' && message.action === 'module_initialized') {
|
1122
|
+
|
1123
|
+
//
|
1124
|
+
// place handling of command|action here
|
1125
|
+
//
|
1126
|
+
|
1127
|
+
logger.info('\n' + message.text);
|
1128
|
+
}
|
1129
|
+
|
1130
|
+
//
|
1131
|
+
// place handling of other command|action here
|
1132
|
+
//
|
1133
|
+
|
1134
|
+
return true;
|
1135
|
+
}, // END messageHandler
|
1136
|
+
|
1137
|
+
// -------------------------------------------------------------------------
|
1138
|
+
// setState()
|
1139
|
+
// sets the current (processing) state of the module
|
1140
|
+
// -------------------------------------------------------------------------
|
1141
|
+
setState: (stat) => {
|
1142
|
+
_this.state = stat;
|
1143
|
+
}, // END setState
|
1144
|
+
|
1145
|
+
// -------------------------------------------------------------------------
|
1146
|
+
// getState()
|
1147
|
+
// Returns the current (processing) state of the module
|
1148
|
+
// -------------------------------------------------------------------------
|
1149
|
+
getState: () => {
|
1150
|
+
return _this.state;
|
1151
|
+
} // END getState
|
1152
|
+
|
1153
|
+
}; // END main (return)
|
1154
|
+
})(j1, window);
|
1155
|
+
|
1156
|
+
{%- endcapture -%}
|
1157
|
+
|
1158
|
+
{%- if production -%}
|
1159
|
+
{{ cache|minifyJS }}
|
1160
|
+
{%- else -%}
|
1161
|
+
{{ cache|strip_empty_lines }}
|
1162
|
+
{%- endif -%}
|
1163
|
+
|
1164
|
+
{%- assign cache = false -%}
|