--- regenerate: true --- {% capture cache %} {% comment %} # ----------------------------------------------------------------------------- # ~/assets/themes/j1/core/js/adapter/promise_test.js # Liquid template to create the Template Adapter for promise_test # # Product/Info: # https://jekyll.one # https://YOUR.SITE # # Copyright (C) 2019 Juergen Adams # Copyright (C) YEAR YOUR NAME # # J1 Template is licensed under the MIT License. # For details, see https://jekyll.one # YOUR_MODULE_NAME is licensed under YOUR LICENSE # For details, see https://YOUR.SITE # ----------------------------------------------------------------------------- # Test data: # {{ liquid_var | debug }} # ----------------------------------------------------------------------------- {% endcomment %} {% comment %} Set global settings -------------------------------------------------------------------------------- {% endcomment %} {% assign data = site.data %} {% assign environment = site.environment %} {% assign template_name = site.template.name %} {% assign apps = data.apps %} {% assign blocks = data.blocks %} {% assign builder = data.builder %} {% assign layouts = data.layouts %} {% assign modules = data.modules %} {% assign pages = data.pages %} {% assign tables = data.tables %} {% comment %} Liquid procedures -------------------------------------------------------------------------------- {% endcomment %} {% capture select_color %}themes/{{template_name}}/procedures/global/select_color.proc{% endcapture %} {% comment %} Process YML config data ================================================================================ {% endcomment %} {% comment %} Set config data {% assign your_defaults = modules.defaults.YOUR_DATA.defaults %} {% assign your_settings = modules.YOUR_DATA.settings %} -------------------------------------------------------------------------------- {% endcomment %} {% comment %} Set config options {% assign your_options = your_defaults | merge: your_settings %} -------------------------------------------------------------------------------- {% endcomment %} /* # ----------------------------------------------------------------------------- # ~/assets/themes/j1/core/js/adapter/YOUR_ADAPTER_NAME.js # J1 Adapter for YOUR_MODULE_NAME # # Product/Info: # https://jekyll.one # # Copyright (C) 2019 Juergen Adams # Copyright (C) YEAR YOUR NAME # # J1 Template is licensed under the MIT License. # For details, see https://jekyll.one # YOUR_MODULE_NAME is licensed under YOUR LICENSE # For details, see https://YOUR.SITE # ----------------------------------------------------------------------------- # Adapter generated: {{site.time}} # ----------------------------------------------------------------------------- */ 'use strict'; j1.promiseTest = (function (j1, window) { var environment = '{{environment}}'; var state = 'not_started'; var j1_colors = {}; var j1_font_sizes = {}; var logger; var logText; // --------------------------------------------------------------------------- // Helper functions // --------------------------------------------------------------------------- function executeFunctionByName(functionName, context /*, args */) { // See: https://stackoverflow.com/questions/359788/how-to-execute-a-javascript-function-when-i-have-its-name-as-a-string // var args = Array.prototype.slice.call(arguments, 2); var namespaces = functionName.split("."); var func = namespaces.pop(); for(var i = 0; i < namespaces.length; i++) { context = context[namespaces[i]]; } return context[func].apply(context, args); } return { // Initialize init: function () { j1promiseTest.init(); // Setup logger logger = log4javascript.getLogger("j1.promise_test"); state = 'started'; logger.info('state: ' + state); // Set|Log status return true; }, // END init // ------------------------------------------------------------------------- // Send message // ------------------------------------------------------------------------- sendMessage: function ( mod, message ) { var logger = log4javascript.getLogger('j1.sendMessage'); var json_message = JSON.stringify(message, undefined, 2); logText = 'Send message to ' + mod + ': ' + json_message; logger.info(logText); if ( mod === 'j1' ) { executeFunctionByName('j1' + '.messageHandler', window, message) } else { executeFunctionByName('j1.' + mod + '.messageHandler', window, message) } }, // END sendMessage // ------------------------------------------------------------------------- // messageHandler for J1 Adapter // Manage messages (paylods) send from other J1 modules // ------------------------------------------------------------------------- messageHandler: function ( message ) { var json_message = JSON.stringify(message, undefined, 2); logText = 'Received message: ' + json_message; logger.info(logText); return true; }, // END messageHandler // ------------------------------------------------------------------------- // Set the current (processing) state of the module // ------------------------------------------------------------------------- setState: function ( stat ) { state = stat; }, // end setState // ------------------------------------------------------------------------- // Returns the current (processing) state of the module // ------------------------------------------------------------------------- getState: function () { return state; } // end state }; // END return })(j1, window); {% endcapture %} {{ cache | strip_empty_lines }} {% assign cache = nil %}