SkillAgentSearch skills...

ViewSwitcher

JavaScript View Switcher for single-page Websites.

Install / Use

/learn @KevinGimbel/ViewSwitcher
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

viewSwitcher

A very basic View Switcher for single-page Websites.

See the Full Page Example or the quick 'n dirty documentation for more information. There's also a CV example to show how to create a two language CV using viewSwitcher.

Basic Usage

  1. Load the Scripts
<script src="path/to/viewswitcher.min.js"></script>
  1. Set up views by adding a data-view attribute to the wrapping element.
<section data-view="hello">
  <h1>Hello!</h1>
</section>


<section data-view="world">
  <h1>World!</h1>
</section>
  1. Initiate default views and generate a menu (if you wish).
// Set options, currently only changeTitle is supported which prevents
// the page Title from being changed.
View.setOptions({
  changeTitle: false
})
// if no #hash is set, active the data-view="hello" View
View.initActive('hello'); 

// get a nav container
var nav = document.querySelector('nav');
// add the generated HTML to the nav container, the
// argument passed to getHtmlMenu is a string representing
// the class name assigned to all <li> elements.
nav.innerHTML = View.getHtmlMenu('list__item');
View on GitHub
GitHub Stars5
CategoryDevelopment
Updated1y ago
Forks1

Languages

HTML

Security Score

55/100

Audited on Mar 6, 2025

No findings