nextcloud/apps/calendar/js/loader.js

82 lines
2.9 KiB
JavaScript
Raw Normal View History

2012-01-14 17:22:30 +04:00
/**
* Copyright (c) 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
2012-01-13 01:06:53 +04:00
Calendar_Import={
importdialog: function(filename){
var path = $('#dir').val();
$('body').append('<div id="calendar_import"></div>');
2012-02-20 14:27:25 +04:00
$('#calendar_import').load(OC.filePath('calendar', 'ajax/import', 'dialog.php'), {filename:filename, path:path}, function(){Calendar_Import.initdialog(filename);});
2012-01-13 01:06:53 +04:00
},
2012-01-13 16:57:46 +04:00
initdialog: function(filename){
2012-01-14 17:22:30 +04:00
$('#calendar_import_dialog').dialog({
2012-01-13 16:57:46 +04:00
width : 500,
close : function() {
$(this).dialog('destroy').remove();
2012-01-14 17:22:30 +04:00
$('#calendar_import').remove();
2012-01-13 16:57:46 +04:00
}
});
2012-01-14 17:22:30 +04:00
$('#import_done_button').click(function(){
$('#calendar_import_dialog').dialog('destroy').remove();
$('#calendar_import').remove();
});
$('#progressbar').progressbar({value: 0});
2012-01-13 16:57:46 +04:00
$('#startimport').click(function(){
var filename = $('#filename').val();
var path = $('#path').val();
2012-01-14 17:22:30 +04:00
var calid = $('#calendar option:selected').val();
2012-01-13 16:57:46 +04:00
if($('#calendar option:selected').val() == 'newcal'){
var method = 'new';
var calname = $('#newcalendar').val();
var calname = $.trim(calname);
if(calname == ''){
$('#newcalendar').css('background-color', '#FF2626');
2012-01-14 17:22:30 +04:00
$('#newcalendar').focus(function(){
$('#newcalendar').css('background-color', '#F8F8F8');
});
2012-01-13 16:57:46 +04:00
return false;
}
}else{
var method = 'old';
}
$('#newcalendar').attr('readonly', 'readonly');
$('#calendar').attr('disabled', 'disabled');
2012-01-14 17:22:30 +04:00
var progressfile = $('#progressfile').val();
2012-03-26 17:37:47 +04:00
$.post(OC.filePath('calendar', 'ajax/import', 'import.php'), {method: String (method), calname: String (calname), path: String (path), file: String (filename), id: String (calid)}, function(data){
2012-01-14 17:22:30 +04:00
if(data.status == 'success'){
$('#progressbar').progressbar('option', 'value', 100);
$('#import_done').css('display', 'block');
}
});
$('#form_container').css('display', 'none');
$('#progressbar_container').css('display', 'block');
window.setTimeout('Calendar_Import.getimportstatus(\'' + progressfile + '\')', 500);
2012-01-13 16:57:46 +04:00
});
$('#calendar').change(function(){
if($('#calendar option:selected').val() == 'newcal'){
$('#newcalform').slideDown('slow');
}else{
$('#newcalform').slideUp('slow');
}
});
2012-01-13 01:06:53 +04:00
},
2012-01-14 17:22:30 +04:00
getimportstatus: function(progressfile){
$.get(OC.filePath('calendar', 'import_tmp', progressfile), function(percent){
$('#progressbar').progressbar('option', 'value', parseInt(percent));
if(percent < 100){
window.setTimeout('Calendar_Import.getimportstatus(\'' + progressfile + '\')', 500);
}else{
2012-02-20 14:27:25 +04:00
$('#import_done').css('display', 'block');
2012-01-14 17:22:30 +04:00
}
});
2012-01-13 01:06:53 +04:00
}
2011-10-04 00:50:10 +04:00
}
$(document).ready(function(){
2012-01-13 01:06:53 +04:00
if(typeof FileActions !== 'undefined'){
FileActions.register('text/calendar','importcal', '', Calendar_Import.importdialog);
FileActions.setDefault('text/calendar','importcal');
};
2012-02-20 14:27:25 +04:00
});