JSFiddle - React, Tailwind, and code Playground

by tmoeller

HTML

<div id="accordion">
  <div class="group">
    <h3>Section 1</h3>
    <div>
      <table id="sel-table" class='stats'>
        <thead>
          <tr>
            <th>ID</th>
            <th>Customer</th>
            <th>Servername</th>
            <th>IP</th>
            <th>Port</th>
            <th>Port2</th>
            <th>GID</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>1</td>
            <td>Cust1</td>
            <td>testmachine</td>
            <td>127.0.0.1</td>
            <td>11970</td>
            <td>30035</td>
            <td>2</td>
          </tr>
          <tr>
            <td>2</td>
            <td>Cust2</td>
            <td>testmachine</td>
            <td>127.0.0.1</td>
            <td>11970</td>
            <td>30035</td>
            <td>2</td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
  <div class="group">
    <h3>Section 2</h3>
    <div>
      <table id="sel-table" class='stats'>
        <thead>
          <tr>
            <th>ID</th>
            <th>Customer</th>
            <th>Servername</th>
            <th>IP</th>
            <th>Port</th>
            <th>Port2</th>
            <th>GID</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>1</td>
            <td>Cust1</td>
            <td>testmachine</td>
            <td>127.0.0.1</td>
            <td>11970</td>
            <td>30035</td>
            <td>2</td>
          </tr>
          <tr>
            <td>2</td>
            <td>Cust2</td>
            <td>testmachine</td>
            <td>127.0.0.1</td>
            <td>11970</td>
            <td>30035</td>
            <td>2</td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</div>

CSS

table.stats {
   text-align: center;
   font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
   font-weight: normal;
   font-size: 11px;
   color: #fff;
   width: 580px;
   background-color: #666;
   border: 0px;
   border-collapse: collapse;
   border-spacing: 0px;
 }
 
 table.stats td {
   background-color: #CCC;
   color: #000;
   padding: 4px;
   text-align: left;
   border: 1px #fff solid;
 }
 
 table.stats td.hed {
   background-color: #666;
   color: #fff;
   padding: 4px;
   text-align: left;
   border-bottom: 2px #fff solid;
   font-size: 12px;
   font-weight: bold;
 }
 
 #sel-table .ui-selecting td {
   background-color: #FECA40;
 }
 
 #sel-table .ui-selected td {
   background-color: #F39814;
   color: white;
 }

JavaScript

$("#accordion").accordion({
          header: "> div > h3"
        })
        .sortable({
          axis: "y",
          handle: "h3",
          stop: function(event, ui) {
            // IE doesn't register the blur when sorting
            // so trigger focusout handlers to remove .ui-state-focus
            ui.item.children("h3").triggerHandler("focusout");

            // Refresh accordion to handle new order
            $(this).accordion("refresh");
          }
        });

      $("#sel-table tbody").bind("mousedown", function(e) {
        e.metaKey = true;
      }).selectable({

        selected: function(e, ui) {

          //alert('Selected');
          var agents = $("#sel-table .ui-selected").text();
          alert(agents);
        }
      }, {
        unselected: function(e, ui) {

          //alert('Unselected');
          var agents = $("#sel-table .ui-selected").text();
          alert(agents);
        }
      });