--- regenerate: false --- {% capture cache %} {% comment %} # ----------------------------------------------------------------------------- # ~/assets/themes/j1/adapter/js/rouge.js # Liquid template to adapt J1 Highlighter (Rouge) # # Product/Info: # https://jekyll.one # Copyright (C) 2022 Juergen Adams # # J1 Template is licensed under the MIT License. # For details, see: https://github.com/jekyll-one-org/j1-template/blob/main/LICENSE.md # ----------------------------------------------------------------------------- # Test data: # {{ liquid_var | debug }} # ----------------------------------------------------------------------------- {% endcomment %} {% comment %} Liquid procedures -------------------------------------------------------------------------------- {% endcomment %} {% comment %} Set global settings -------------------------------------------------------------------------------- {% endcomment %} {% assign environment = site.environment %} {% assign template_version = site.version %} {% assign asset_path = "/assets/themes/j1" %} {% comment %} Process YML config data ================================================================================ {% endcomment %} {% comment %} Set config files -------------------------------------------------------------------------------- {% endcomment %} {% assign template_config = site.data.j1_config %} {% comment %} Detect prod mode -------------------------------------------------------------------------------- {% endcomment %} {% assign production = false %} {% if environment == 'prod' or environment == 'production' %} {% assign production = true %} {% endif %} /* # ----------------------------------------------------------------------------- # ~/assets/themes/j1/adapter/js/rouge.js # J1 Adapter for rouge # # Product/Info: # https://jekyll.one # # Copyright (C) 2022 Juergen Adams # # J1 Template is licensed under the MIT License. # For details, see: https://github.com/jekyll-one-org/j1-template/blob/main/LICENSE.md # ----------------------------------------------------------------------------- # Note: # https://github.com/jirutka/asciidoctor-rouge/issues/9 # ----------------------------------------------------------------------------- # Adapter generated: {{site.time}} # ----------------------------------------------------------------------------- */ // ----------------------------------------------------------------------------- // ESLint shimming // ----------------------------------------------------------------------------- /* eslint indent: "off" */ /* eslint quotes: "off" */ // ----------------------------------------------------------------------------- 'use strict'; j1.adapter.rouge = (function (j1, window) { // --------------------------------------------------------------------------- // globals // --------------------------------------------------------------------------- var environment = '{{environment}}'; var moduleOptions = {}; var user_state = {}; var cookie_names = j1.getCookieNames(); var cookie_user_state_name = cookie_names.user_state; var user_state_detected; var themeCss; var _this; var logger; var logText; var darkTheme; var templateOptions = $.extend({}, {{template_config | replace: 'nil', 'null' | replace: '=>', ':' }}); // --------------------------------------------------------------------------- // Helper functions // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // Main object // --------------------------------------------------------------------------- return { // ------------------------------------------------------------------------- // helper functions // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Initializer // ------------------------------------------------------------------------- init: function (options) { // ----------------------------------------------------------------------- // Default module settings // ----------------------------------------------------------------------- var settings = $.extend({ module_name: 'j1.adapter.rouge', generated: '{{site.time}}' }, options); // ----------------------------------------------------------------------- // Global variable settings // ----------------------------------------------------------------------- _this = j1.adapter.rouge; logger = log4javascript.getLogger('j1.adapter.rouge'); // ----------------------------------------------------------------------- // rouge initializer // ----------------------------------------------------------------------- var dependencies_met_j1_finished = setInterval(function() { if (j1.getState() == 'finished') { // initialize state flag _this.setState('started'); logger.debug('\n' + 'state: ' + _this.getState()); logger.info('\n' + 'module is being initialized'); // Detect|Set J1 UserState user_state_detected = j1.existsCookie(cookie_user_state_name); if (user_state_detected) { user_state = j1.readCookie(cookie_user_state_name); themeCss = user_state.theme_css; darkTheme = themeCss.includes('dark') || themeCss.includes('cyborg') || themeCss.includes('darkly') || themeCss.includes('slate') || themeCss.includes('superhero'); } else { log_text = '\n' + 'user_state cookie not found'; logger.warn(log_text); } $('.dropdown-menu a').click(function(){ $('#selected-theme').html('Current selection: