@ -5,72 +5,113 @@
* See the COPYING - README file .
* /
Calendar _Import = {
importdialog : function ( filename ) {
var path = $ ( '#dir' ) . val ( ) ;
$ ( 'body' ) . append ( '<div id="calendar_import"></div>' ) ;
$ ( '#calendar_import' ) . load ( OC . filePath ( 'calendar' , 'ajax/import' , 'dialog.php' ) , { filename : filename , path : path } , function ( ) { Calendar _Import . initdialog ( filename ) ; } ) ;
} ,
initdialog : function ( filename ) {
$ ( '#calendar_import_dialog' ) . dialog ( {
width : 500 ,
close : function ( ) {
$ ( this ) . dialog ( 'destroy' ) . remove ( ) ;
$ ( '#calendar_import' ) . remove ( ) ;
}
} ) ;
$ ( '#import_done_button' ) . click ( function ( ) {
$ ( '#calendar_import_dialog' ) . dialog ( 'destroy' ) . remove ( ) ;
Store : {
file : '' ,
path : '' ,
id : 0 ,
method : '' ,
calname : '' ,
progresskey : '' ,
percentage : 0
}
Dialog : {
open : function ( filename ) {
Calendar _Import . Store . file = filename ;
Calendar _Import . Store . path = $ ( '#dir' ) . val ( ) ;
$ ( 'body' ) . append ( '<div id="calendar_import"></div>' ) ;
$ ( '#calendar_import' ) . load ( OC . filePath ( 'calendar' , 'ajax/import' , 'dialog.php' ) , { filename : Calendar _Import . Store . file , path : Calendar _Import . Store . path } , function ( ) {
Calendar _Import . Dialog . init ( ) ;
} ) ;
} ,
close : function ( ) {
$ ( this ) . dialog ( 'destroy' ) . remove ( ) ;
$ ( '#calendar_import' ) . remove ( ) ;
} ) ;
$ ( '#progressbar' ) . progressbar ( { value : 0 } ) ;
$ ( '#startimport' ) . click ( function ( ) {
var filename = $ ( '#filename' ) . val ( ) ;
var path = $ ( '#path' ) . val ( ) ;
var calid = $ ( '#calendar option:selected' ) . val ( ) ;
if ( $ ( '#calendar option:selected' ) . val ( ) == 'newcal' ) {
var method = 'new' ;
var calname = $ ( '#newcalendar' ) . val ( ) ;
var calname = $ . trim ( calname ) ;
if ( calname == '' ) {
$ ( '#newcalendar' ) . css ( 'background-color' , '#FF2626' ) ;
$ ( '#newcalendar' ) . focus ( function ( ) {
$ ( '#newcalendar' ) . css ( 'background-color' , '#F8F8F8' ) ;
} ) ;
return false ;
} ,
init : function ( ) {
//init dialog
$ ( '#calendar_import_dialog' ) . dialog ( {
width : 500 ,
close : function ( ) {
Calendar _Import . Dialog . close ( ) ;
}
} ) ;
//init buttons
$ ( '#import_done_button' ) . click ( function ( ) {
Calendar _Import . closedialog ( ) ;
} ) ;
$ ( '#startimport' ) . click ( function ( ) {
Calendar _import . Core . process ( ) ;
}
$ ( '#calendar' ) . change ( function ( ) {
if ( $ ( '#calendar option:selected' ) . val ( ) == 'newcal' ) {
$ ( '#newcalform' ) . slideDown ( 'slow' ) ;
} else {
$ ( '#newcalform' ) . slideUp ( 'slow' ) ;
}
} ) ;
//init progressbar
$ ( '#progressbar' ) . progressbar ( { value : Calendar _Import . Store . percentage } ) ;
Calendar _Import . Store . progresskey = $ ( '#progresskey' ) . val ( ) ;
} ,
mergewarning : function ( ) {
} ,
update : function ( ) {
/ * $ . p o s t ( O C . f i l e P a t h ( ' c a l e n d a r ' , ' a j a x / i m p o r t ' , ' i m p o r t . p h p ' ) , { p r o g r e s s : 1 , p r o g r e s s k e y : p r o g r e s s k e y } , f u n c t i o n ( p e r c e n t ) {
$ ( '#progressbar' ) . progressbar ( 'option' , 'value' , parseInt ( percent ) ) ;
if ( percent < 100 ) {
window . setTimeout ( 'Calendar_Import.getimportstatus(\'' + progresskey + '\')' , 500 ) ;
} else {
$ ( '#import_done' ) . css ( 'display' , 'block' ) ;
}
} ) ; * /
return 0 ;
} ,
warning : function ( validation ) {
}
} ,
Core : {
process : function ( ) {
var validation = Calendar . Core . prepare ( ) ;
if ( validation ) {
$ ( '#newcalendar' ) . attr ( 'readonly' , 'readonly' ) ;
$ ( '#calendar' ) . attr ( 'disabled' , 'disabled' ) ;
Calendar . Core . send ( ) ;
} else {
var method = 'old' ;
Calendar . Dialog . warning ( validation ) ;
}
$ ( '#newcalendar' ) . attr ( 'readonly' , 'readonly' ) ;
$ ( '#calendar' ) . attr ( 'disabled' , 'disabled' ) ;
var progresskey = $ ( '#progresskey' ) . val ( ) ;
$ . post ( OC . filePath ( 'calendar' , 'ajax/import' , 'import.php' ) , { progresskey : progresskey , method : String ( method ) , calname : String ( calname ) , path : String ( path ) , file : String ( filename ) , id : String ( calid ) } , function ( data ) {
} ,
send : function ( ) {
$ . post ( OC . filePath ( 'calendar' , 'ajax/import' , 'import.php' ) ,
{ progresskey : Calendar _Import . Store . progresskey , method : String ( Calendar _Import . Store . method ) , calname : String ( Calendar _Import . Store . calname ) , path : String ( Calendar _Import . Store . path ) , file : String ( Calendar _Import . Store . filename ) , id : String ( Calendar _Import . Store . calid ) } , function ( data ) {
if ( data . status == 'success' ) {
$ ( '#progressbar' ) . progressbar ( 'option' , 'value' , 100 ) ;
$ ( '#import_done' ) . css ( 'display' , 'block' ) ;
$ ( '#status' ) . html ( data . message ) ;
}
} ) ;
$ ( '#form_container' ) . css ( 'display' , 'none' ) ;
$ ( '#progressbar_container' ) . css ( 'display' , 'block' ) ;
window . setTimeout ( 'Calendar_Import.getimportstatus(\'' + progresskey + '\')' , 500 ) ;
} ) ;
$ ( '#calendar' ) . change ( function ( ) {
window . setTimeout ( 'Calendar_Import.Dialog.update' , 500 ) ;
} ,
prepare : function ( ) {
Calendar _Import . Store . id = $ ( '#calendar option:selected' ) . val ( ) ;
if ( $ ( '#calendar option:selected' ) . val ( ) == 'newcal' ) {
$ ( '#newcalform' ) . slideDown ( 'slow' ) ;
} else {
$ ( '#newcalform' ) . slideUp ( 'slow' ) ;
}
} ) ;
} ,
getimportstatus : function ( progresskey ) {
$ . post ( OC . filePath ( 'calendar' , 'ajax/import' , 'import.php' ) , { progress : 1 , progresskey : progresskey } , function ( percent ) {
$ ( '#progressbar' ) . progressbar ( 'option' , 'value' , parseInt ( percent ) ) ;
if ( percent < 100 ) {
window . setTimeout ( 'Calendar_Import.getimportstatus(\'' + progresskey + '\')' , 500 ) ;
Calendar _Import . Store . method = 'new' ;
Calendar _Import . Store . calname = $ . trim ( $ ( '#newcalendar' ) . val ( ) ) ;
if ( Calendar _Import . Store . calname == '' ) {
$ ( '#newcalendar' ) . css ( 'background-color' , '#FF2626' ) ;
$ ( '#newcalendar' ) . focus ( function ( ) {
$ ( '#newcalendar' ) . css ( 'background-color' , '#F8F8F8' ) ;
} ) ;
return false ;
}
} else {
$ ( '#import_done' ) . css ( 'display' , 'block' ) ;
var method = 'old' ;
}
} ) ;
}
}
}
$ ( document ) . ready ( function ( ) {