initial commit

This commit is contained in:
s2
2019-04-12 19:28:21 +02:00
commit 3179f5581e
669 changed files with 124297 additions and 0 deletions

93
js/index.js Normal file
View File

@@ -0,0 +1,93 @@
(function() {
// globals
MyApp.Utils = {};
// utility functions
MyApp.Utils.getUrlParameter = function(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};
// app functions
MyApp.renderShell = function() {
document.title = i18next.t('vanillaJS');
$('.js-main-content').html(ejs.rtfe('/templates/main.ejs'));
};
MyApp.renderHomePage = function() {
$('.js-page-container').html(ejs.rtfe('/templates/home.ejs'));
};
MyApp.renderTextPage = function() {
$('.js-page-container').html(ejs.rtfe('/templates/sometext.ejs', {
texts: [
{
id: 100,
description: 'Some text with id 100'
},
{
id: 200,
description: 'Some other text with id 200. Click it!'
}
]
}));
};
MyApp.renderAboutPage = function() {
$('.js-page-container').html(ejs.rtfe('/templates/about.ejs'));
};
// events
$(document).on('click', '.js-link', function(ev) {
var el = $(ev.currentTarget);
var linkId = el.attr('data-id');
PNotify.success('The text you clicked had id ' + linkId + '. Maybe next time I will do something with this id.');
});
// app startup
// set language
i18next.init({
lng: MyApp.config.lang,
resources: {
en: {
translation: {
'vanillaJS': 'vanillaJS seed project',
'awesome': 'This is an awesome app!'
}
},
it: {
translation: {
'vanillaJS': 'progetto di esempio vanillaJS',
'awesome': 'Questa app è fantastica!'
}
},
de: {
translation: {
'vanillaJS': 'vanillaJS Beispiel Projekt',
'awesome': 'Coole app.'
}
}
}
});
// when main content is rendered, set up routing so the app starts up
$(document).arrive('.js-page-container', {existing: true, onceOnly: true}, function() {
//setup routing
page('/', MyApp.renderHomePage);
page('/about', MyApp.renderAboutPage);
page('/text', MyApp.renderTextPage);
page({
hashbang: true
});
});
MyApp.renderShell();
})();