// All our different views
const views = (() => {
let navigation_ = []; // navigation between views
let current_page_; // where we are
// Button to go backward
const $backward_ = document.querySelector('#backward');
$backward_.addEventListener("click", function() {
navigation_.pop().load();
});
// Title
const $title_ = document.querySelector('#title');
// Buttons to go to different pages
['main', 'profile', 'help'].forEach(page => {
document.querySelector('#' + page)
.addEventListener('click', function() {
views[page].load(current_page_);
});
});
// This contains what will change within our layout
const $container_ = document.querySelector('#container');
document.querySelector('#right-button').addEventListener('click', function() {
$container_.innerHTML = 'This can do what ever you want to!';
});
// Main view
const main = (() => {
function load(previous) {
current_page_ = main;
// Reset navigation
navigation_ = [];
$backward_.classList.add('hide');
// Add specific content
$title_.textContent = 'Main';
$container_.innerHTML = 'Simplicity as Reliability';
}
return {
load: load
};
})();
// Profile view
const profile = (() => {
function load(previous) {
current_page_ = profile;
if (current_page_ != previous) {
// We need to keep track of where we came from
if (previous) navigation_.push(previous);
$backward_.classList.remove('hide');
}
// Add specific content
$title_.textContent = 'Profile';
$container_.innerHTML =
`<span class="mdl-chip mdl-chip--contact">
<span class="mdl-chip__contact mdl-color--teal mdl-color-text--white">A</span>
<span class="mdl-chip__text">Contact Chip</span>
</span>`;
}
return {
load: load
};
})();
// Help view
const help = (() => {
function load(previous) {
current_page_ =...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.