github.com/jlowellwofford/u-root@v1.0.0/pkg/sos/html/upspin.html (about)

     1  <head>
     2    <title>Upspin</title>
     3    <link rel="stylesheet" href="css/stylesheet.css">
     4    <meta charset="utf-8">
     5    <script>
     6      function sendEdit() {
     7        fetch("http://localhost:{{.Port}}/edit", {
     8          method: 'Post'
     9        })
    10        .then(r => r.json())
    11        .then( s => {
    12          if (s !== null) {
    13            alert(s.Error);
    14            window.location.reload();
    15          }
    16          else {
    17            window.location.reload();
    18          }
    19        })
    20        .catch(err => alert(err))
    21      }
    22      function sendSubmit() {
    23        username = document.getElementById("user").value
    24        dirserver = document.getElementById("dir").value
    25        storeserver = document.getElementById("store").value
    26        secretseed = document.getElementById("seed").value
    27        fetch("http://localhost:{{.Port}}/submit", {
    28          method: 'Post',
    29          headers: {
    30            'Accept': 'application/json',
    31            'Content-Type': 'application/json'
    32          },
    33          body: JSON.stringify({
    34            User:  username,
    35            Dir:   dirserver,
    36            Store: storeserver,
    37            Seed:  secretseed
    38          })
    39        })
    40        .then(r => r.json())
    41        .then( s => {
    42          if (s !== null) {
    43            alert(s.Error);
    44            window.location.reload();
    45          }
    46          else {
    47            window.location.reload();
    48          }
    49        })
    50        .catch(err => alert(err))
    51      }
    52  
    53      function setFieldsOnLoad(config) {
    54        if (config) {
    55          disableFields();
    56        }
    57        else {
    58          enableFields();
    59        }
    60      }
    61  
    62      function enableFields() {
    63        fields = document.getElementsByClassName("form");
    64        for(let field of fields) {
    65          field.removeAttribute("disabled")
    66        }
    67        document.getElementById("button").setAttribute("value", "Submit");
    68        document.getElementById("button").setAttribute("onclick", "sendSubmit()");
    69      }
    70      function disableFields() {
    71        fields = document.getElementsByClassName("form");
    72        for(let field of fields) {
    73          field.setAttribute("disabled", "true")
    74        }
    75        document.getElementById("button").setAttribute("value", "Edit");
    76        document.getElementById("button").setAttribute("onclick", "sendEdit()");
    77      }
    78    </script>
    79  </head>
    80  <body onload="setFieldsOnLoad({{.Configured}})">
    81    <div class="banner">
    82        <h1><a href="http://localhost:8000" target="_blank" class="bannerbtn">Service of Services</a></h1>
    83    </div>
    84    <div class="content">
    85      <!-- Copy to local variables -->
    86      {{$user := .User}}
    87      {{$dir := .Dir}}
    88      {{$store := .Store}}
    89      {{$seed := .Seed}}
    90      <div class="center">
    91        <h2 class="centernarrow">Upspin Config Settings</h2>
    92        <div class="card">
    93          <h3 class="label">Username</h3>
    94          <input type="text" id="user"  class="form" value="{{$user}}">
    95          <h3 class="label">Dir Server</h3>
    96          <input type="text" id="dir"   class="form" value="{{$dir}}">
    97          <h3 class="label">Store Server</h3>
    98          <input type="text" id="store" class="form" value="{{$store}}">
    99          <h3 class="label">Secret Seed</h3>
   100          <input type="text" id="seed"  class="form" value="{{$seed}}">
   101        </div>
   102        <input type="submit" id="button" class="button submitbtn">
   103        <!--
   104          <table class="center">
   105            <tr>
   106              <th>Username</th>
   107              <th>Dir Server</th>
   108              <th>Store Server</th>
   109              <th>Secret Seed</th>
   110              <th></th>
   111            </tr>
   112            <tr>
   113              <td><input type="text" id="user"  class="text" value="{{$user}}"></td>
   114              <td><input type="text" id="dir"   class="text" value="{{$dir}}"></td>
   115              <td><input type="text" id="store" class="text" value="{{$store}}"></td>
   116              <td><input type="text" id="seed"  class="text" value="{{$seed}}"></td>
   117              <td><input type="submit" id="button" class="btn"></td>
   118            </tr>
   119          </table>
   120        -->
   121        </div>
   122      </div>
   123    </div>
   124  </body>