mirror of https://github.com/gophish/gophish
Importing a site now works fairly well... just need to be able to save the "Landing Page"
parent
cb1b418594
commit
fad36607e4
|
@ -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()
|
||||
})
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
<input type="text" class="form-control" placeholder="Page name" id="name" autofocus/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button class="btn btn-danger" data-toggle="modal" data-target="#importSiteModal"><i class="fa fa-envelope"></i> Import Site (Coming Soon!)</button>
|
||||
<button class="btn btn-danger" data-toggle="modal" data-target="#importSiteModal"><i class="fa fa-envelope"></i> Import Site</button>
|
||||
</div>
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
|
@ -84,10 +84,11 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" onclick="dismiss()">Cancel</button>
|
||||
<button type="button" data-dismiss="modal" class="btn btn-default" onclick="dismiss()">Cancel</button>
|
||||
<button type="button" class="btn btn-primary" id="modalSubmit">Save Page</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="importSiteModal" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
|
||||
|
@ -106,10 +107,11 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" onclick="dismiss()">Cancel</button>
|
||||
<button type="button" class="btn btn-primary" id="modalSubmit">Import</button>
|
||||
<button type="button" data-dismiss="modal" class="btn btn-default" onclick="dismiss()">Cancel</button>
|
||||
<button type="button" class="btn btn-primary" id="modalSubmit" onclick="importSite()">Import</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
{{define "scripts"}}
|
||||
|
|
Loading…
Reference in New Issue