{% extends 'base/layout.html' %}
{% load static %}

{% block title %}CIDR to supernet{% endblock %}

{% block content %}
<div class="row">
  <div class="col-6">
    <div class="card">
      <div class="card-body">
        <div class="mb-3">
          <label for="cidr" class="form-label">CIDR separated by comma, space, tab or new line. </label>
          <textarea class="form-control" id="cidr" rows="7" style="resize: none;"></textarea>
          <div class="invalid-feedback">
            Please provide a CIDR.
          </div>
        </div>
        <button type="submit" class="btn btn-primary" id="btn_cidr_supernet">Calculate</button>
      </div>
    </div>
  </div>
  <div class="col-6">
    <div class="card d-none" id="card-result">
      <div class="card-header">
        <h5>Result</h5>
      </div>
      <div class="card-body">
        <table class="table table-striped">
          <tbody>
            <tr>
              <th>Supernet address</th>
              <td id="td-address"></td>
            </tr>
            <tr>
              <th>Netmask</th>
              <td id="td-mask"></td>
            </tr>
            <tr>
              <th>Wildcard Bits</th>
              <td id="td-wildcard"></td>
            </tr>
            <tr>
              <th>Network IP</th>
              <td id="td-network"></td>
            </tr>
            <tr>
              <th>Broadcast IP</th>
              <td id="td-broadcast"></td>
            </tr>
            <tr>
              <th>First usable IP</th>
              <td id="td-first"></td>
            </tr>
            <tr>
              <th>Last usable IP</th>
              <td id="td-last"></td>
            </tr>
            <tr>
              <th>Usable Host</th>
              <td id="td-hosts"></td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
  </div>
</div>
{% endblock content %}

{% block javascript %}
<script src="{% static 'netbox_ipv4_tools/js/netmask.js' %}" defer></script>
<script src="{% static 'netbox_ipv4_tools/js/supernet.js' %}" defer></script>
{% endblock javascript %}