parent
1629c77eb5
commit
9295f49553
@ -1,83 +1,86 @@ |
||||
/** |
||||
* 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. |
||||
*/ |
||||
Contacts_Import={ |
||||
importdialog: function(filename){ |
||||
var path = $('#dir').val(); |
||||
$('body').append('<div id="contacts_import"></div>'); |
||||
$('#contacts_import').load(OC.filePath('contacts', 'ajax', 'importdialog.php'), {filename:filename, path:path}, function(){Contacts_Import.initdialog(filename);}); |
||||
}, |
||||
initdialog: function(filename){ |
||||
$('#contacts_import_dialog').dialog({ |
||||
width : 500, |
||||
close : function() { |
||||
$(this).dialog('destroy').remove(); |
||||
$('#contacts_import').remove(); |
||||
} |
||||
}); |
||||
$('#import_done_button').click(function(){ |
||||
$('#contacts_import_dialog').dialog('destroy').remove(); |
||||
$('#contacts_import').remove(); |
||||
}); |
||||
$('#progressbar').progressbar({value: 0}); |
||||
$('#startimport').click(function(){ |
||||
var filename = $('#filename').val(); |
||||
var path = $('#path').val(); |
||||
var addressbookid = $('#contacts option:selected').val(); |
||||
if($('#contacts option:selected').val() == 'newaddressbook'){ |
||||
var method = 'new'; |
||||
var addressbookname = $('#newaddressbook').val(); |
||||
var addressbookname = $.trim(addressbookname); |
||||
if(newaddressbook == ''){ |
||||
$('#newaddressbook').css('background-color', '#FF2626'); |
||||
$('#newaddressbook').focus(function(){ |
||||
$('#newaddressbook').css('background-color', '#F8F8F8'); |
||||
}); |
||||
return false; |
||||
} |
||||
}else{ |
||||
var method = 'old'; |
||||
} |
||||
$('#newaddressbook').attr('readonly', 'readonly'); |
||||
$('#contacts').attr('disabled', 'disabled'); |
||||
var progressfile = $('#progressfile').val(); |
||||
$.post(OC.filePath('contacts', '', 'import.php'), {method: String (method), addressbookname: String (addressbookname), path: String (path), file: String (filename), id: String (addressbookid)}, function(data){ |
||||
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('Contacts_Import.getimportstatus(\'' + progressfile + '\')', 500); |
||||
}); |
||||
$('#contacts').change(function(){ |
||||
if($('#contacts option:selected').val() == 'newaddressbook'){ |
||||
$('#newaddressbookform').slideDown('slow'); |
||||
}else{ |
||||
$('#newaddressbookform').slideUp('slow'); |
||||
} |
||||
}); |
||||
}, |
||||
getimportstatus: function(progressfile){ |
||||
$.get(OC.filePath('contacts', 'import_tmp', progressfile), function(percent){ |
||||
$('#progressbar').progressbar('option', 'value', parseInt(percent)); |
||||
if(percent < 100){ |
||||
window.setTimeout('Contacts_Import.getimportstatus(\'' + progressfile + '\')', 500); |
||||
}else{ |
||||
/** |
||||
* 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. |
||||
*/ |
||||
Contacts_Import={ |
||||
importdialog: function(filename){ |
||||
var path = $('#dir').val(); |
||||
$('body').append('<div id="contacts_import"></div>'); |
||||
$('#contacts_import').load(OC.filePath('contacts', 'ajax', 'importdialog.php'), {filename:filename, path:path}, function(){Contacts_Import.initdialog(filename);}); |
||||
}, |
||||
initdialog: function(filename){ |
||||
$('#contacts_import_dialog').dialog({ |
||||
width : 500, |
||||
close : function() { |
||||
$(this).dialog('destroy').remove(); |
||||
$('#contacts_import').remove(); |
||||
} |
||||
}); |
||||
$('#import_done_button').click(function(){ |
||||
$('#contacts_import_dialog').dialog('destroy').remove(); |
||||
$('#contacts_import').remove(); |
||||
}); |
||||
$('#progressbar').progressbar({value: 0}); |
||||
$('#startimport').click(function(){ |
||||
var filename = $('#filename').val(); |
||||
var path = $('#path').val(); |
||||
var method = 'old'; |
||||
var addressbookid = $('#contacts option:selected').val(); |
||||
if($('#contacts option:selected').val() == 'newaddressbook'){ |
||||
var method = 'new'; |
||||
var addressbookname = $('#newaddressbook').val(); |
||||
var addressbookname = $.trim(addressbookname); |
||||
if(addressbookname == ''){ |
||||
$('#newaddressbook').css('background-color', '#FF2626'); |
||||
$('#newaddressbook').focus(function(){ |
||||
$('#newaddressbook').css('background-color', '#F8F8F8'); |
||||
}); |
||||
return false; |
||||
} |
||||
} |
||||
$('#newaddressbook').attr('readonly', 'readonly'); |
||||
$('#contacts').attr('disabled', 'disabled'); |
||||
var progressfile = $('#progressfile').val(); |
||||
$.post(OC.filePath('contacts', '', 'import.php'), {method: String (method), addressbookname: String (addressbookname), path: String (path), file: String (filename), id: String (addressbookid)}, function(jsondata){ |
||||
if(jsondata.status == 'success'){ |
||||
$('#progressbar').progressbar('option', 'value', 100); |
||||
$('#import_done').find('p').html(t('contacts', 'Result: ') + jsondata.data.imported + t('contacts', ' imported, ') + jsondata.data.failed + t('contacts', ' failed.')); |
||||
} else { |
||||
$('#import_done').find('p').html(jsondata.data.message); |
||||
} |
||||
$('#import_done').show().find('p').addClass('bold'); |
||||
$('#progressbar').fadeOut('slow'); |
||||
}); |
||||
$('#form_container').css('display', 'none'); |
||||
$('#progressbar_container').css('display', 'block'); |
||||
window.setTimeout('Contacts_Import.getimportstatus(\'' + progressfile + '\')', 500); |
||||
}); |
||||
$('#contacts').change(function(){ |
||||
if($('#contacts option:selected').val() == 'newaddressbook'){ |
||||
$('#newaddressbookform').slideDown('slow'); |
||||
}else{ |
||||
$('#newaddressbookform').slideUp('slow'); |
||||
} |
||||
}); |
||||
}, |
||||
getimportstatus: function(progressfile){ |
||||
$.get(OC.filePath('contacts', 'import_tmp', progressfile), function(percent){ |
||||
$('#progressbar').progressbar('option', 'value', parseInt(percent)); |
||||
if(percent < 100){ |
||||
window.setTimeout('Contacts_Import.getimportstatus(\'' + progressfile + '\')', 500); |
||||
}else{ |
||||
$('#import_done').css('display', 'block'); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
$(document).ready(function(){ |
||||
if(typeof FileActions !== 'undefined'){ |
||||
FileActions.register('text/vcard','importaddressbook', '', Contacts_Import.importdialog);
|
||||
FileActions.setDefault('text/vcard','importaddressbook'); |
||||
FileActions.register('text/x-vcard','importaddressbook', '', Contacts_Import.importdialog);
|
||||
FileActions.setDefault('text/x-vcard','importaddressbook'); |
||||
}; |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
$(document).ready(function(){ |
||||
if(typeof FileActions !== 'undefined'){ |
||||
FileActions.register('text/vcard','importaddressbook', '', Contacts_Import.importdialog);
|
||||
FileActions.setDefault('text/vcard','importaddressbook'); |
||||
FileActions.register('text/x-vcard','importaddressbook', '', Contacts_Import.importdialog);
|
||||
FileActions.setDefault('text/x-vcard','importaddressbook'); |
||||
}; |
||||
}); |
@ -1,27 +1,27 @@ |
||||
<div id="contacts_import_dialog" title="<?php echo $l->t("Import a contacts file"); ?>">
|
||||
<div id="form_container"> |
||||
<input type="hidden" id="filename" value="<?php echo $_['filename'];?>">
|
||||
<input type="hidden" id="path" value="<?php echo $_['path'];?>">
|
||||
<input type="hidden" id="progressfile" value="<?php echo md5(session_id()) . '.txt';?>">
|
||||
<p style="text-align:center;"><b><?php echo $l->t('Please choose the addressbook'); ?></b>
|
||||
<select style="width:100%;" id="contacts" name="contacts"> |
||||
<?php |
||||
$contacts_options = OC_Contacts_Addressbook::all(OCP\USER::getUser()); |
||||
$contacts_options[] = array('id'=>'newaddressbook', 'displayname'=>$l->t('create a new addressbook')); |
||||
echo OCP\html_select_options($contacts_options, $contacts_options[0]['id'], array('value'=>'id', 'label'=>'displayname')); |
||||
?> |
||||
</select> |
||||
<div id="newaddressbookform" style="display: none;"> |
||||
<input type="text" style="width: 97%;" placeholder="<?php echo $l->t('Name of new addressbook'); ?>" id="newaddressbook" name="newaddressbook">
|
||||
</div> |
||||
<input type="button" value="<?php echo $l->t("Import");?>!" id="startimport">
|
||||
</div> |
||||
<div id="form_container"> |
||||
<input type="hidden" id="filename" value="<?php echo $_['filename'];?>">
|
||||
<input type="hidden" id="path" value="<?php echo $_['path'];?>">
|
||||
<input type="hidden" id="progressfile" value="<?php echo md5(session_id()) . '.txt';?>">
|
||||
<p class="bold" style="text-align:center;"><?php echo $l->t('Please choose the addressbook'); ?></p>
|
||||
<select style="width:100%;" id="contacts" name="contacts"> |
||||
<?php |
||||
$contacts_options = OC_Contacts_Addressbook::all(OCP\USER::getUser()); |
||||
$contacts_options[] = array('id'=>'newaddressbook', 'displayname'=>$l->t('create a new addressbook')); |
||||
echo OCP\html_select_options($contacts_options, $contacts_options[0]['id'], array('value'=>'id', 'label'=>'displayname')); |
||||
?> |
||||
</select> |
||||
<div id="newaddressbookform" style="display: none;"> |
||||
<input type="text" style="width: 97%;" placeholder="<?php echo $l->t('Name of new addressbook'); ?>" id="newaddressbook" name="newaddressbook">
|
||||
</div> |
||||
<input type="button" value="<?php echo $l->t("Import");?>!" id="startimport">
|
||||
</div> |
||||
<div id="progressbar_container" style="display: none"> |
||||
<p style="text-align:center;"><b><?php echo $l->t('Importing contacts'); ?></b>
|
||||
<div id="progressbar"></div> |
||||
<div id="import_done" style="display: none;"> |
||||
<p style="text-align:center;"><b><?php echo $l->t('Contacts imported successfully'); ?></b></p>
|
||||
<input type="button" value="<?php echo $l->t('Close Dialog'); ?>" id="import_done_button">
|
||||
</div> |
||||
</div> |
||||
<p style="text-align:center;"><?php echo $l->t('Importing contacts'); ?></p>
|
||||
<div id="progressbar"></div> |
||||
<div id="import_done" style="display: none;"> |
||||
<p style="text-align:center;"></p> |
||||
<input type="button" value="<?php echo $l->t('Close'); ?>" id="import_done_button">
|
||||
</div> |
||||
</div> |
||||
</div> |
Loading…
Reference in new issue