2012-04-01 02:41:43 +04:00
$ ( document ) . ready ( function ( ) {
// Do the export
$ ( '#exportbtn' ) . click ( function ( ) {
// Show loader
$ ( '.loading' ) . show ( ) ;
$ . getJSON (
OC . filePath ( 'user_migrate' , 'ajax' , 'export.php' ) ,
{ operation : 'create' } ,
function ( result ) {
if ( result . status == 'success' ) {
// Download the file
2012-06-07 15:08:42 +04:00
window . location = OC . linkTo ( 'user_migrate' , 'ajax/export.php' ) + '?operation=download' ;
2012-04-01 02:41:43 +04:00
$ ( '.loading' ) . hide ( ) ;
$ ( '#exportbtn' ) . val ( t ( 'user_migrate' , 'Export' ) ) ;
} else {
// Cancel loading
$ ( '#exportbtn' ) . html ( 'Failed' ) ;
// Show Dialog
OC . dialogs . alert ( t ( 'user_migrate' , 'Something went wrong while the export file was being generated' ) , t ( 'user_migrate' , 'An error has occurred' ) , function ( ) {
2012-04-01 02:47:38 +04:00
$ ( '#exportbtn' ) . html ( t ( 'user_migrate' , 'Export' ) + '<img style="display: none;" class="loading" src="' + OC . filePath ( 'core' , 'img' , 'loading.gif' ) + '" />' ) ;
2012-04-01 02:41:43 +04:00
} ) ;
}
}
// End ajax
) ;
} ) ;
} ) ;