Skip to content

Commit

Permalink
Remove Jekyll tags from JavaScript source and load configuration instead
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzschmid committed Feb 19, 2022
1 parent 8476dbe commit be00c90
Show file tree
Hide file tree
Showing 11 changed files with 550 additions and 434 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,11 @@ Example:
{% include js/conference.js %}
(function() {
let map = window.conference.map;
(() => {
const map = window.conference.map;
if (typeof map !== 'undefined') {
var main_station = L.marker([47.37785, 8.54035], {
let main_station = L.marker([47.37785, 8.54035], {
icon: L.divIcon({
className: '',
html: '<span class="fas fa-train"></span> Main Station',
Expand Down
21 changes: 15 additions & 6 deletions _includes/js/conference.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
// Global app variable
window.conference = {};

// Bootstrap (Style Framework)
// Libraries
// Bootstrap (Style Framework)
{% include js/lib/jquery-3.5.1.min.js %}
{% include js/lib/popper.min.js %}
{% include js/lib/bootstrap.js %}

// FontAwesome (Icons)
// Imported via CSS and webfonts
// FontAwesome (Icons)
// Imported via CSS and webfonts

// Conference
window.conference = {
config: {
baseurl: '{{ site.baseurl }}'
}
};


// Program
{% include js/lib/syncscroll.js %}
Expand All @@ -31,3 +37,6 @@ window.conference = {};
{% if site.conference.live %}
{% include js/live.js %}
{% endif %}

// Load configuration and start initialization
{% include js/init.js %}
37 changes: 37 additions & 0 deletions _includes/js/init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const init = () => {
// Load configuration
const request = new Request(window.conference.config.baseurl + '/assets/js/config.json');

fetch(request)
.then(response =>
response.json()
)
.then(config => {
// Add configuration to global scope
window.conference.config = Object.assign(window.conference.config, config);

// Execute initialization functions
for (const [name, module] of Object.entries(window.conference)) {
if (name == 'config') {
continue;
}

let c;
if (name in config) {
c = config[name];
}
let l;
if (name in config.lang) {
l = config.lang[name];
}

module.init(c, l)
}

})
.catch((error) => {
console.log(error);
});
};

init();
Loading

0 comments on commit be00c90

Please sign in to comment.