functiondismiss(){$("#modal\\.flashes").empty(),$("#modal").modal("hide"),$("#resultsTable").dataTable().DataTable().clear().draw()}functiondeleteCampaign(){swal({title:"Are you sure?",text:"This will delete the campaign. This can't be undone!",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Delete Campaign",confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){returnnewPromise(function(a,b){api.campaignId.delete(campaign.id).success(function(b){a()}).error(function(a){b(a.responseJSON.message)})})}}).then(function(){swal("Campaign Deleted!","This campaign has been deleted!","success"),$('button:contains("OK")').on("click",function(){location.href="/campaigns"})})}functioncompleteCampaign(){swal({title:"Are you sure?",text:"Gophish will stop processing events for this campaign",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Complete Campaign",confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){returnnewPromise(function(a,b){api.campaignId.complete(campaign.id).success(function(b){a()}).error(function(a){b(a.responseJSON.message)})})}}).then(function(){swal("Campaign Completed!","This campaign has been completed!","success"),$("#complete_button")[0].disabled=!0,$("#complete_button").text("Completed!"),doPoll=!1})}functionexportAsCSV(a){exportHTML=$("#exportButton").html();varb=null;switch(a){case"results":b=campaign.results;break;case"events":b=campaign.timeline}if(b){$("#exportButton").html('<i class="fa fa-spinner fa-spin"></i>');varc=Papa.unparse(b,{}),d=newBlob([c],{type:"text/csv;charset=utf-8;"});if(navigator.msSaveBlob)navigator.msSaveBlob(d,a+".csv");else{vare=window.URL.createObjectURL(d),f=document.createElement("a");f.href=e,f.setAttribute("download",a+".csv"),document.body.appendChild(f),f.click(),document.body.removeChild(f)}$("#exportButton").html(exportHTML)}}functionreplay(a){functionb(){form.attr({action:url}),form.appendTo("body").submit().remove()}request=campaign.timeline[a],details=JSON.parse(request.details),url=null,form=$("<form>").attr({method:"POST",target:"_blank"}),$.each(Object.keys(details.payload),function(a,b){return"rid"==b||("__original_url"==b?(url=details.payload[b],!0):void$("<input>").attr({name:b}).val(details.payload[b]).appendTo(form))}),swal({title:"Where do you want the credentials submitted to?",input:"text",showCancelButton:!0,inputPlaceholder:"http://example.com/login",inputValue:url||"",inputValidator:function(a){returnnewPromise(function(b,c){a?b():c("Invalid URL.")})}}).then(function(a){url=a,b()})}functionrenderTimeline(a){returnrecord={first_name:a[2],last_name:a[3],email:a[4],position:a[5]},results='<div class="timeline col-sm-12 well well-lg"><h6>Timeline for '+escapeHtml(record.first_name)+" "+escapeHtml(record.last_name)+'</h6><span class="subtitle">Email: '+escapeHtml(record.email)+'</span><div class="timeline-graph col-sm-6">',$.each(campaign.timeline,function(a,b){b.email&&b.email!=record.email||(results+='<div class="timeline-entry"> <div class="timeline-bar"></div>',results+=' <div class="timeline-icon '+statuses[b.message].label+'"> <i class="fa '+statuses[b.message].icon+'"></i></div> <div class="timeline-message">'+escapeHtml(b.message)+' <span class="timeline-date">'+moment(b.time).format("MMMM Do YYYY h:mm a")+"</span>",b.details&&("Submitted Data"==b.message&&(results+='<div class="timeline-replay-button"><button onclick="replay('+a+')" class="btn btn-success">',results+='<i class="fa fa-refresh"></i> Replay Credentials</button></div>',results+='<div class="timeline-event-details"><i class="fa fa-caret-right"></i> View Details</div>'),details=JSON.parse(b.details),details.payload&&(results+='<div class="timeline-event-results">',results+=' <table class="table table-condensed table-bordered table-striped">',results+=" <thead><tr><th>Parameter</th><th>Value(s)</tr></thead><tbody>",$.each(Object.keys(details.payload),function(a,b){return"rid"==b||(results+=" <tr>",results+=" <td>"+escapeHtml(b)+