HTML and CSS techniques to reduce your JavaScript
Just in case, in Sciter (https://sciter.com) you can declare   div {
     behavior:check;
   }
   div:checked {
     color:red; 
   }

and all divs will behave as checkboxes - will toggle :checked  flag on clicks.Same way:   div {
     behavior:radio;
   }
   div:checked {
     color:red; 
   }

Or even :   table > tbody { /* scrollable table body, behaves as */ 
     behavior:select;
     overflow-y: auto; 
   }

   table > tbody > tr:current { /*current "option" */
     color:red; 
   }

Also you can put this in your markup:   
      left
      right
   

to have split view.No script is required for all these.