javascript router handy for latte use

Member | 41

i haven't ever seen this published, although i guess its out
there somewhere…pretty handy for working with the DOM. fyi.
easy to add many event types and many diff methods…

those elements not listed in the switch stmt are unaffected…
tested and works well in latte…

		window.onload = function () {

			body.addEventListener('click', () => { myalert(); });

		function myalert() {

			//basically this is a router

			switch ( {

				case 'add': alert("add button");break;
				case 'edit': alert("edit button");break;
				case 'delete': alert("delete button");break;
				case 'undo': alert("undo button");break;
				case 'store': alert("store button");break;
				case 'share': alert("share button");break;
				case 'done': alert("done button");break;




and the bootstrap html…

<div class="row">
  	<div class="col-lg-12" style="margin-bottom: 20px" align="center">
  		<span class="button btn-primary btn-lg" id="add">Add</span>
  		<span class="button btn-info btn-lg" id="edit">Edit</span>
  		<span class="button btn-danger btn-lg" id="delete">Delete</span>
  		<span class="button btn-success btn-lg" id="undo">Undo</span>
  		<span class="button btn-warning btn-lg" id="store">Store</span>
  		<span class="button btn-default btn-lg" id="share">Share</span>
  		<span class="button btn-primary btn-lg" id="done">Delegate</span>