");$("#sendTestModalSubmit").html(btnHtml)})}function save(idx){var profile={headers:[]};$.each($("#headersTable").DataTable().rows().data(),function(i,header){profile.headers.push({key:unescapeHtml(header[0]),value:unescapeHtml(header[1])})});profile.name=$("#name").val();profile.interface_type=$("#interface_type").val();profile.from_address=$("#from").val();profile.host=$("#host").val();profile.username=$("#username").val();profile.password=$("#password").val();profile.ignore_cert_errors=$("#ignore_cert_errors").prop("checked");if(idx!=-1){profile.id=profiles[idx].id;api.SMTPId.put(profile).success(function(data){successFlash("Profile edited successfully!");load();dismiss()}).error(function(data){modalError(data.responseJSON.message)})}else{api.SMTP.post(profile).success(function(data){successFlash("Profile added successfully!");load();dismiss()}).error(function(data){modalError(data.responseJSON.message)})}}function dismiss(){$("#modal\\.flashes").empty();$("#name").val("");$("#interface_type").val("SMTP");$("#from").val("");$("#host").val("");$("#username").val("");$("#password").val("");$("#ignore_cert_errors").prop("checked",true);$("#headersTable").dataTable().DataTable().clear().draw();$("#modal").modal("hide")}var dismissSendTestEmailModal=function(){$("#sendTestEmailModal\\.flashes").empty();$("#sendTestModalSubmit").html(" Send")};var deleteProfile=function(idx){Swal.fire({title:"Are you sure?",text:"This will delete the sending profile. This can't be undone!",type:"warning",animation:false,showCancelButton:true,confirmButtonText:"Delete "+escapeHtml(profiles[idx].name),confirmButtonColor:"#428bca",reverseButtons:true,allowOutsideClick:false,preConfirm:function(){return new Promise(function(resolve,reject){api.SMTPId.delete(profiles[idx].id).success(function(msg){resolve()}).error(function(data){reject(data.responseJSON.message)})})}}).then(function(result){if(result.value){Swal.fire("Sending Profile Deleted!","This sending profile has been deleted!","success")}$('button:contains("OK")').on("click",function(){location.reload()})})};function edit(idx){headers=$("#headersTable").dataTable({destroy:true,columnDefs:[{orderable:false,targets:"no-sort"}]});$("#modalSubmit").unbind("click").click(function(){save(idx)});var profile={};if(idx!=-1){$("#profileModalLabel").text("Edit Sending Profile");profile=profiles[idx];$("#name").val(profile.name);$("#interface_type").val(profile.interface_type);$("#from").val(profile.from_address);$("#host").val(profile.host);$("#username").val(profile.username);$("#password").val(profile.password);$("#ignore_cert_errors").prop("checked",profile.ignore_cert_errors);$.each(profile.headers,function(i,record){addCustomHeader(record.key,record.value)})}else{$("#profileModalLabel").text("New Sending Profile")}}function copy(idx){$("#modalSubmit").unbind("click").click(function(){save(-1)});var profile={};profile=profiles[idx];$("#name").val("Copy of "+profile.name);$("#interface_type").val(profile.interface_type);$("#from").val(profile.from_address);$("#host").val(profile.host);$("#username").val(profile.username);$("#password").val(profile.password);$("#ignore_cert_errors").prop("checked",profile.ignore_cert_errors)}function load(){$("#profileTable").hide();$("#emptyMessage").hide();$("#loading").show();api.SMTP.get().success(function(ss){profiles=ss;$("#loading").hide();if(profiles.length>0){$("#profileTable").show();profileTable=$("#profileTable").DataTable({destroy:true,columnDefs:[{orderable:false,targets:"no-sort"}]});profileTable.clear();profileRows=[];$.each(profiles,function(i,profile){profileRows.push([escapeHtml(profile.name),profile.interface_type,moment(profile.modified_date).format("MMMM Do YYYY, h:mm:ss a"),"