From fad36607e443c4209fb2e424bf55eecfeb86c2d7 Mon Sep 17 00:00:00 2001 From: Jordan Wright Date: Tue, 25 Aug 2015 18:56:58 -0500 Subject: [PATCH] Importing a site now works fairly well... just need to be able to save the "Landing Page" --- static/js/app/landing_pages.js | 50 ++++++++++++++++++++++++++++++++-- static/js/gophish.js | 3 ++ templates/landing_pages.html | 10 ++++--- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/static/js/app/landing_pages.js b/static/js/app/landing_pages.js index 267335b6..849b3004 100644 --- a/static/js/app/landing_pages.js +++ b/static/js/app/landing_pages.js @@ -33,7 +33,6 @@ function save(idx){ function dismiss(){ $("#modal\\.flashes").empty() - $("#modal").modal('hide') $("#name").val("") $("#html_editor").val("") } @@ -48,6 +47,26 @@ function deleteTemplate(idx){ } } +function importSite(){ + url = $("#url").val() + if (!url){ + modalError("No URL Specified!") + } else { + api.clone_site({ + url: url, + include_resources: false + }) + .success(function(data){ + console.log($("#html_editor")) + $("#html_editor").val(data.html) + $("#importSiteModal").modal("hide") + }) + .error(function(data){ + modalError(data.responseJSON.message) + }) + } +} + function edit(idx){ $("#modalSubmit").unbind('click').click(function(){save(idx)}) $("#html_editor").ckeditor() @@ -91,8 +110,33 @@ function load(){ $("#loading").hide() errorFlash("Error fetching pages") }) + // Setup multiple modals + // Code based on http://miles-by-motorcycle.com/static/bootstrap-modal/index.html + $('.modal').on('hidden.bs.modal', function( event ) { + $(this).removeClass( 'fv-modal-stack' ); + $('body').data( 'fv_open_modals', $('body').data( 'fv_open_modals' ) - 1 ); + }); + $( '.modal' ).on( 'shown.bs.modal', function ( event ) { + // Keep track of the number of open modals + if ( typeof( $('body').data( 'fv_open_modals' ) ) == 'undefined' ) + { + $('body').data( 'fv_open_modals', 0 ); + } + // if the z-index of this modal has been set, ignore. + if ( $(this).hasClass( 'fv-modal-stack' ) ) + { + return; + } + $(this).addClass( 'fv-modal-stack' ); + // Increment the number of open modals + $('body').data( 'fv_open_modals', $('body').data( 'fv_open_modals' ) + 1 ); + // Setup the appropriate z-index + $(this).css('z-index', 1040 + (10 * $('body').data( 'fv_open_modals' ))); + $( '.modal-backdrop' ).not( '.fv-modal-stack' ).css( 'z-index', 1039 + (10 * $('body').data( 'fv_open_modals' ))); + $( '.modal-backdrop' ).not( 'fv-modal-stack' ).addClass( 'fv-modal-stack' ); + }); } -$(document).ready(function(){ - load() +$(document).ready(function(){ + load() }) diff --git a/static/js/gophish.js b/static/js/gophish.js index 5f0951d6..f3086cf9 100644 --- a/static/js/gophish.js +++ b/static/js/gophish.js @@ -131,5 +131,8 @@ var api = { delete: function(id){ return query("/landing_pages/" + id, "DELETE", {}) } + }, + clone_site : function(req){ + return query("/import/site", "POST", req) } } diff --git a/templates/landing_pages.html b/templates/landing_pages.html index bc734017..129095bf 100644 --- a/templates/landing_pages.html +++ b/templates/landing_pages.html @@ -70,7 +70,7 @@
- +