add_instance.htm 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <div class="cbi-section-create cbi-tblsection-create">
  2. <br />
  3. <table class="cbi-section-table">
  4. <tr class="cbi-section-table-row">
  5. <td class="cbi-section-table-cell" style="width:140px">
  6. <select class="cbi-input-select" id="_newinst.type" name="_newinst.type">
  7. <option value="_dummy">-- instance type --</option>
  8. <option value="ss_local">ss-local</option>
  9. <option value="ss_tunnel">ss-tunnel</option>
  10. <option value="ss_redir">ss-redir</option>
  11. <option value="ss_server">ss-server</option>
  12. </select>
  13. </td>
  14. <td class="cbi-section-table-cell" style="width:110px">
  15. <input type="text" class="cbi-input-text" id="_newinst.name" name="_newinst.name" placeholder="<%:Name%>"/>
  16. </td>
  17. <td class="cbi-section-table-cell left">
  18. <input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>" value="<%:Add%>" />
  19. </td>
  20. </tr>
  21. </table>
  22. </div>
  23. <script type="text/javascript">//<![CDATA[
  24. XHR.poll(5, '<%=url('admin/services/shadowsocks-libev/status')%>', null,
  25. function(x, st)
  26. {
  27. var names = [
  28. <%-
  29. for _, name in ipairs(self:cfgsections()) do
  30. write("%q," % name)
  31. end
  32. -%>
  33. ];
  34. var instances = st["instances"] || {};
  35. for (var i = 0, len = names.length; i < len; i++) {
  36. var name = names[i];
  37. var el = document.getElementById('cbi-table-' + name + '-running');
  38. if (el) {
  39. var running = instances.hasOwnProperty(name)? instances[name].running : false;
  40. el.innerText = running ? 'yes' : 'no';
  41. }
  42. }
  43. }
  44. );
  45. //]]></script>