--- regenerate: true --- {%- capture cache -%} {% comment %} # ----------------------------------------------------------------------------- # ~/assets/theme/j1/adapter/js/amplitude.js # Liquid template to adapt the AmplitudeJS v4 module # # Product/Info: # https://jekyll.one # Copyright (C) 2023, 2024 Juergen Adams # # J1 Template is licensed under the MIT License. # For details, see: https://github.com/jekyll-one-org/j1-template/blob/main/LICENSE # ----------------------------------------------------------------------------- # Test data: # {{ liquid_var | debug }} # amplitude_options: {{ amplitude_options | debug }} # ----------------------------------------------------------------------------- {% endcomment %} {% comment %} Liquid procedures -------------------------------------------------------------------------------- {% endcomment %} {% comment %} Set global settings -------------------------------------------------------------------------------- {% endcomment %} {% assign environment = site.environment %} {% assign asset_path = "/assets/theme/j1" %} {% comment %} Process YML config data ================================================================================ {% endcomment %} {% comment %} Set config files -------------------------------------------------------------------------------- {% endcomment %} {% assign template_config = site.data.j1_config %} {% assign blocks = site.data.blocks %} {% assign modules = site.data.modules %} {% comment %} Set config data (settings only) -------------------------------------------------------------------------------- {% endcomment %} {% assign amplitude_defaults = modules.defaults.amplitude.defaults %} {% assign amplitude_settings = modules.amplitude.settings %} {% comment %} Set config options (settings only) -------------------------------------------------------------------------------- {% endcomment %} {% assign amplitude_options = amplitude_defaults | merge: amplitude_settings %} {% comment %} Variables -------------------------------------------------------------------------------- {% endcomment %} {% assign comments = amplitude_options.enabled %} {% comment %} Detect prod mode -------------------------------------------------------------------------------- {% endcomment %} {% assign production = false %} {% if environment == 'prod' or environment == 'production' %} {% assign production = true %} {% endif %} /* # ----------------------------------------------------------------------------- # ~/assets/theme/j1/adapter/js/amplitude.js # J1 Adapter for the amplitude module # # Product/Info: # https://jekyll.one # # Copyright (C) 2023, 2024 Juergen Adams # # J1 Template is licensed under the MIT License. # For details, see: https://github.com/jekyll-one-org/j1-template/blob/main/LICENSE # ----------------------------------------------------------------------------- # Adapter generated: {{site.time}} # ----------------------------------------------------------------------------- */ // ----------------------------------------------------------------------------- // ESLint shimming // ----------------------------------------------------------------------------- /* eslint indent: "off" */ // ----------------------------------------------------------------------------- "use strict"; j1.adapter.amplitude = ((j1, window) => { // göobal settings // --------------------------------------------------------------------------- var environment = '{{environment}}'; var cookie_names = j1.getCookieNames(); var user_state = j1.readCookie(cookie_names.user_state); var state = 'not_started'; // module settings // --------------------------------------------------------------------------- // control|logging // --------------- var _this; var logger; var logText; var toJSON; var toText; // date|time monitoring //--------------------- var startTime; var endTime; var startTimeModule; var endTimeModule; var timeSeconds; // amplitude api settings // ---------------------- var ytpSongIndex = "0"; var ytpAutoPlay = false; var ytpLoop = true; var playLists = {}; var playersUILoaded = { state: false }; var apiInitialized = { state: false }; var playList; var playerID; var playerType; var playListTitle; var playListName; var amplitudePlayerState; var amplitudeDefaults; var amplitudeSettings; var amplitudeOptions; var ytPlayer; var ytpSettings; // amplitude player (instance) settings // NOTE: slider VALUE is set by Adapter|Amplitude API // ------------------------------------ var xhrLoadState; var dependency; var playerCounter = 0; var load_dependencies = {}; var playersProcessed = []; var playersHtmlLoaded = false; var processingPlayersFinished = false; var playerAudioInfo = ('{{amplitude_defaults.playlist.audio_info}}' === 'true') ? true : false; var playerDefaultType = '{{amplitude_defaults.player.type}}'; var playerVolumeValue = '{{amplitude_defaults.player.volume_slider.preset_value}}'; var playerVolumeSliderStep = '{{amplitude_defaults.player.volume_slider.slider_step}}'; var playerRepeat = ('{{amplitude_defaults.player.repeat}}' === 'true') ? true : false; var playerShuffle = ('{{amplitude_defaults.player.shuffle}}' === 'true') ? true : false; var playerPlayNextTitle = ('{{amplitude_defaults.player.play_next_title}}' === 'true') ? true : false; var playerPauseNextTitle = ('{{amplitude_defaults.player.pause_next_title}}' === 'true') ? true : false; var playerDelayNextTitle = '{{amplitude_defaults.player.delay_next_title}}'; var playerForwardBackwardSkipSeconds = '{{amplitude_defaults.player.forward_backward_skip_seconds}}'; // unused settings // --------------------------------------------------------------------------- // var playerWaveformSampleRate = '{{amplitude_defaults.player.waveform_sample_rate}}'; // --------------------------------------------------------------------------- // helper functions // --------------------------------------------------------------------------- $(function() { // Load the IFrame Player API code asynchronously var techScript; var tech = document.createElement('script'); tech.id = 'yt_player_init'; tech.src = "/assets/theme/j1/modules/amplitudejs/js/tech/ytPlayerInit.js"; techScript = document.getElementsByTagName('script')[0]; techScript.parentNode.insertBefore(tech, techScript); }); // --------------------------------------------------------------------------- // YouTube Player (loaded early) // --------------------------------------------------------------------------- // function ytpAudioInit (options) { // ytpSettings = options; // // // load the IFrame Player API code asynchronously // // // var firstScriptTag; // var tag = document.createElement('script'); // tag.id = 'iframe_api'; // tag.src = '//youtube.com/iframe_api'; // firstScriptTag = document.getElementsByTagName('script')[0]; // // firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); // // // Create an