我有一个使用 cloudponge 导入联系人的小部件。他们进行了设置,以便将所有内容导入到文本文件中。我希望将所有内容都放入两个输入字段中。
他们给我发了这段代码,并说可以修改它以将联系人放入输入文件中,但我不知道该怎么做。
<!DOCTYPE html>
<html>
<body>
<a class="cs_import">Add from Address Book</a>
<textarea id="contact_list" style="width:450px;height:82px"></textarea>
<script type='text/javascript'>
// these values will hold the owner information
var owner_email, owner_first_name, owner_last_name;
var appendInTextarea = true; // whether to append to existing contacts in the textarea
var emailSep = ", "; // email address separator to use in textarea
function populateTextarea(contacts, source, owner) {
var contact, name, email, entry;
var emails = [];
var textarea = document.getElementById('contact_list');
// preserve the original value in the textarea
if (appendInTextarea && textarea.value.strip().length > 0) {
emails = textarea.value.split(emailSep);
}
// format each email address properly
for (var i = 0; i < contacts.length; i++) {
contact = contacts[i];
name = contact.fullName();
email = contact.selectedEmail();
entry = name + "<" + email +">";
if (emails.indexOf(entry) < 0) {
emails.push(entry);
}
}
// dump everything into the textarea
textarea.value = emails.join(emailSep);
// capture the owner information
owner_email = (owner && owner.email && owner.email[0] && owner.email[0].address) || "";
owner_first_name = (owner && owner.first_name) || "";
owner_last_name = (owner && owner.last_name) || "";
}
// Replace the domain_key and stylesheet with valid values.
var csPageOptions = {
domain_key:"YOUR_DOMAIN_KEY",
afterSubmitContacts:populateTextarea
};
</script>
<script type="text/javascript" src="https://api.cloudsponge.com/address_books.js"></script>
</body>
</html>**strong text**