server.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. var proxmoxVPS_td1;
  2. var proxmoxVPS_td2;
  3. var proxmoxVPS_accesshash;
  4. var proxmoxVPS_selectAdded = false;
  5. function proxmoxVPS_addSelect(){
  6. var accessTd = $( "#inputServerType").closest("tbody").find(" tr:eq(3)").find(" td:eq(0)");
  7. proxmoxVPS_td1 = accessTd.html();
  8. accessTd.html("Authentication");
  9. var accessInput = $( "#inputServerType").closest("tbody").find(" tr:eq(3)").find(" td:eq(1)");
  10. proxmoxVPS_td2 = accessInput.html();
  11. accessInput.html("<select name=\"accesshash\"><option value=\"pam\">Linux PAM standard authentication</option><option value=\"pve\">Proxmox VE authentication server</option><option value=\"PVEAPIToken\" hidden>API Tokens</option></select>");
  12. proxmoxVPS_accesshash ? $("select[name='accesshash']").val(proxmoxVPS_accesshash): $("select[name='accesshash']").val("pam")
  13. proxmoxVPS_selectAdded = true;
  14. }
  15. function proxmoxVPS_removeSelect(){
  16. $( "#inputServerType").closest("tbody").find(" tr:eq(3)").find(" td:eq(0)").html(proxmoxVPS_td1);
  17. $( "#inputServerType").closest("tbody").find(" tr:eq(3)").find(" td:eq(1)").html(proxmoxVPS_td2);
  18. proxmoxVPS_selectAdded = false
  19. }
  20. $(document).ready(function(){
  21. var pc_ServerType = $( "#inputServerType").val();
  22. proxmoxVPS_accesshash = $( "textarea[name='accesshash']").val();
  23. if(pc_ServerType=="proxmoxVPS" || pc_ServerType=="ProxmoxCloudVps"){
  24. proxmoxVPS_addSelect();
  25. }
  26. $( "#inputServerType").change(function(){
  27. pc_ServerType = $( this).val();
  28. if(proxmoxVPS_selectAdded==true && pc_ServerType!="proxmoxVPS" && pc_ServerType!="ProxmoxCloudVps" ){
  29. proxmoxVPS_removeSelect();
  30. }else if(!proxmoxVPS_selectAdded && pc_ServerType=="proxmoxVPS" || pc_ServerType=="ProxmoxCloudVps" ){
  31. proxmoxVPS_addSelect();
  32. }
  33. });
  34. });