gophish/static/js/dist/app/campaigns.min.js

1 line
9.9 KiB
JavaScript
Raw Normal View History

function launch(){swal({title:"Are you sure?",text:"This will schedule the campaign to be launched.",type:"question",animation:!1,showCancelButton:!0,confirmButtonText:"Launch",confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,showLoaderOnConfirm:!0,preConfirm:function(){return new Promise(function(e,a){groups=[],$.each($("#groupTable").DataTable().rows().data(),function(e,a){groups.push({name:unescapeHtml(a[0])})}),campaign={name:$("#name").val(),template:{name:$("#template").val()},url:$("#url").val(),page:{name:$("#page").val()},smtp:{name:$("#profile").val()},launch_date:moment($("#launch_date").val(),"MM/DD/YYYY hh:mm a").format(),groups:groups},api.campaigns.post(campaign).success(function(a){e(),campaign=a}).error(function(e){$("#modal\\.flashes").empty().append('<div style="text-align:center" class="alert alert-danger"> <i class="fa fa-exclamation-circle"></i> '+e.responseJSON.message+"</div>"),swal.close()})})}}).then(function(){swal("Campaign Scheduled!","This campaign has been scheduled for launch!","success"),$('button:contains("OK")').on("click",function(){window.location="/campaigns/"+campaign.id.toString()})})}function sendTestEmail(){var e={template:{name:$("#template").val()},first_name:$("input[name=to_first_name]").val(),last_name:$("input[name=to_last_name]").val(),email:$("input[name=to_email]").val(),position:$("input[name=to_position]").val(),url:$("#url").val(),page:{name:$("#page").val()},smtp:{name:$("#profile").val()}};btnHtml=$("#sendTestModalSubmit").html(),$("#sendTestModalSubmit").html('<i class="fa fa-spinner fa-spin"></i> Sending'),api.send_test_email(e).success(function(e){$("#sendTestEmailModal\\.flashes").empty().append('<div style="text-align:center" class="alert alert-success"> <i class="fa fa-check-circle"></i> Email Sent!</div>'),$("#sendTestModalSubmit").html(btnHtml)}).error(function(e){$("#sendTestEmailModal\\.flashes").empty().append('<div style="text-align:center" class="alert alert-danger"> <i class="fa fa-exclamation-circle"></i> '+e.responseJSON.message+"</div>"),$("#sendTestModalSubmit").html(btnHtml)})}function dismiss(){$("#modal\\.flashes").empty(),$("#name").val(""),$("#template").val(""),$("#page").val(""),$("#url").val(""),$("#profile").val(""),$("#groupSelect").val(""),$("#modal").modal("hide"),$("#groupTable").dataTable().DataTable().clear().draw()}function deleteCampaign(e){swal({title:"Are you sure?",text:"This will delete the campaign. This can't be undone!",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Delete "+campaigns[e].name,confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){return new Promise(function(a,t){api.campaignId.delete(campaigns[e].id).success(function(e){a()}).error(function(e){t(e.responseJSON.message)})})}}).then(function(){swal("Campaign Deleted!","This campaign has been deleted!","success"),$('button:contains("OK")').on("click",function(){location.reload()})})}function edit(e){group_bh.clear(),template_bh.clear(),page_bh.clear(),profile_bh.clear(),"new"==e&&(api.groups.get().success(function(e){return 0==e.length?(modalError("No groups found!"),!1):void group_bh.add(e)}),api.templates.get().success(function(e){return 0==e.length?(modalError("No templates found!"),!1):void template_bh.add(e)}),api.pages.get().success(function(e){return 0==e.length?(modalError("No pages found!"),!1):void page_bh.add(e)}),api.SMTP.get().success(function(e){return 0==e.length?(modalError("No profiles found!"),!1):void profile_bh.add(e)}))}function copy(e){group_bh.clear(),template_bh.clear(),page_bh.clear(),profile_bh.clear(),api.groups.get().success(function(e){return 0==e.length?(modalError("No groups found!"),!1):void group_bh.add(e)}),api.templates.get().success(function(e){return 0==e.length?(modalError("No templates found!"),!1):void template_bh.add(e)}),api.pages.get().success(function(e){return 0==e.length?(modalError("No pages found!"),!1):void page_bh.add(e)}),api.SMTP.get().success(function(e){return 0==e.length?(modalError("No profiles found