text
stringlengths
0
15.7k
source
stringlengths
6
112
set allContacts to contactStore's unifiedContactsMatchingPredicate:(missing value) keysToFetch:({|⌘|'s CNContactEmailAddressesKey, |⌘|'s CNContactGivenNameKey, |⌘|'s CNContactFamilyNameKey}) |error|:(missing value)
lns2.scpt
set predicateForHavingAddressInDomain to |⌘|'s class "NSPredicate"'s predicateWithFormat:("ANY emailAddresses.value ENDSWITH %@") argumentArray:({emailDomain})
lns2.scpt
set contactsWithAddressInDomain to allContacts's filteredArrayUsingPredicate:(predicateForHavingAddressInDomain)
lns2.scpt
set desiredResult to |⌘|'s class "NSMutableArray"'s new()
lns2.scpt
set nameFormat to |⌘|'s class "NSString"'s stringWithString:("%@ %@")
lns2.scpt
set predicateForEndingWithDomain to |⌘|'s class "NSPredicate"'s predicateWithFormat:("self ENDSWITH %@") argumentArray:({emailDomain})
lns2.scpt
repeat with thisContact in contactsWithAddressInDomain
lns2.scpt
set givenName to thisContact's givenName()
lns2.scpt
set familyName to thisContact's familyName()
lns2.scpt
if ((|⌘|'s class "CNContactFormatter"'s nameOrderForContact:(thisContact)) is |⌘|'s CNContactDisplayNameOrderGivenNameFirst) then
lns2.scpt
set displayName to |⌘|'s class "NSString"'s stringWithFormat_(nameFormat, givenName, familyName)
lns2.scpt
set displayName to |⌘|'s class "NSString"'s stringWithFormat_(nameFormat, familyName, givenName)
lns2.scpt
set thisContactsEmailAddresses to (thisContact's valueForKeyPath:("emailAddresses.value"))
lns2.scpt
set addressesInDomain to (thisContactsEmailAddresses's filteredArrayUsingPredicate:(predicateForEndingWithDomain))
lns2.scpt
tell desiredResult to addObject:{displayName, addressesInDomain}
lns2.scpt
return desiredResult as list
lns2.scpt
set allContainers to contactStore's containersMatchingPredicate:(missing value) |error|:(missing value)
lns2.scpt
set allContacts to |⌘|'s class "NSMutableArray"'s new()
lns2.scpt
repeat with thisContainer in allContainers
lns2.scpt
set predicateForContactsInContainer to (|⌘|'s class "CNContact"'s predicateForContactsInContainerWithIdentifier:(thisContainer's identifier()))
lns2.scpt
set contactsInContainer to (contactStore's unifiedContactsMatchingPredicate:(predicateForContactsInContainer) keysToFetch:({|⌘|'s CNContactEmailAddressesKey, |⌘|'s CNContactGivenNameKey, |⌘|'s CNContactFamilyNameKey}) |error|:(missing value))
lns2.scpt
tell allContacts to addObjectsFromArray:(contactsInContainer)
lns2.scpt
tell allContacts to filterUsingPredicate:(predicateForHavingAddressInDomain)
lns2.scpt
set contactsWithAddressInDomain to allContacts -- Change of variable name to reflect filtered contents.
lns2.scpt
use MkLib : script "MarksLib" # JMTX Add
lns2.scpt
set theEmails to (every email where its value contains "gmail") of every person # JMTX Chg
lns2.scpt
set nameEmailList to {} # JMTX Add
lns2.scpt
set perName to "" # JMTX Add
lns2.scpt
set emailList to {} # JMTX Add
lns2.scpt
set thePerson to MkLib's containerOf(contents of anItem as record) # JMTX Chg
lns2.scpt
if (perName = "") then set perName to name of thePerson # JMTX Add
lns2.scpt
set end of emailList to value of contents of anItem # JMTX Add
lns2.scpt
set end of theNames to (thePerson's name) # JMTX Chg
lns2.scpt
if (perName ≠ "") then
lns2.scpt
set end of nameEmailList to {perName, emailList}
lns2.scpt
set perName to ""
lns2.scpt
set emailList to {}
lns2.scpt
return nameEmailList # JMTX Add
lns2.scpt
tell application "Contacts" to set {contactNames, emailAddresses} to {name, value of emails} of people
lns2.scpt
set nameEmailList to {}
lns2.scpt
repeat with i from 1 to (count emailAddresses)
lns2.scpt
set theseAddresses to item i of emailAddresses
lns2.scpt
if (theseAddresses is not {}) then
lns2.scpt
set addressesInDomain to {}
lns2.scpt
repeat with thisAddress in theseAddresses
lns2.scpt
if (thisAddress ends with emailDomain) then set end of addressesInDomain to thisAddress's contents
lns2.scpt
if (addressesInDomain is not {}) then set end of nameEmailList to {item i of contactNames, addressesInDomain}
lns2.scpt
return nameEmailList
lns2.scpt
use AppleScript version "2.4" -- Mac OS 10.10 (Yosemite) or later.
lns2.scpt
use framework "AddressBook" -- The Xcode documentation recommends using the Contacts framework instead in 10.11 or later.
lns2.scpt
set addressBook to |⌘|'s class "ABAddressBook"'s addressBook()
lns2.scpt
set emailDomain to |⌘|'s class "NSString"'s stringWithFormat_("%@%@", "@", emailDomain)
lns2.scpt
set searchForContactsHavingEmailInDomain to |⌘|'s class "ABPerson"'s searchElementForProperty:(|⌘|'s kABEmailProperty) label:(missing value) |key|:(missing value) value:(emailDomain) comparison:(|⌘|'s kABContainsSubStringCaseInsensitive)
lns2.scpt
set contactsHavingEmailInDomain to addressBook's recordsMatchingSearchElement:(searchForContactsHavingEmailInDomain)
lns2.scpt
set defaultNameOrder to addressBook's defaultNameOrdering() -- The user's name ordering preference.
lns2.scpt
repeat with thisPerson in contactsHavingEmailInDomain
lns2.scpt
set givenName to (thisPerson's valueForProperty:(|⌘|'s kABFirstNameProperty))
lns2.scpt
set familyName to (thisPerson's valueForProperty:(|⌘|'s kABLastNameProperty))
lns2.scpt
set nameOrder to ((thisPerson's valueForProperty:(|⌘|'s kABPersonFlags)) as integer) mod 64 div 8 * 8 -- |⌘|'s kABNameOrderingMask = 56, although bit 3 isn't used.
lns2.scpt
if (nameOrder is (|⌘|'s kABDefaultNameOrdering as integer)) then set nameOrder to defaultNameOrder
lns2.scpt
if (nameOrder is (|⌘|'s kABFirstNameFirst as integer)) then
lns2.scpt
set addressesInDomain to |⌘|'s class "NSMutableArray"'s new()
lns2.scpt
set thisPersonsEmailMultivalue to (thisPerson's valueForProperty:(|⌘|'s kABEmailProperty))
lns2.scpt
repeat with i from 0 to (thisPersonsEmailMultivalue's |count|()) - 1
lns2.scpt
set thisAddress to (thisPersonsEmailMultivalue's valueAtIndex:(i))
lns2.scpt
if ((thisAddress's hasSuffix:(emailDomain)) as boolean) then tell addressesInDomain to addObject:(thisAddress)
lns2.scpt
tell desiredResult to addObject:({displayName, addressesInDomain})
lns2.scpt
use framework "FMDBAS"
lns2.scpt
script forInheritance
lns2.scpt
on scriptObjectDbInit()
lns2.scpt
property parent : forInheritance
lns2.scpt
property theRealSQLDb : missing value
lns2.scpt
on underlyingFMDatabase()
lns2.scpt
return theRealSQLDb
lns2.scpt
end underlyingFMDatabase
lns2.scpt
on openReadOnly()
lns2.scpt
theRealSQLDb's openWithFlagsAS:1
lns2.scpt
end openReadOnly
lns2.scpt
on openReadWrite()
lns2.scpt
theRealSQLDb's openWithFlagsAS:2
lns2.scpt
end openReadWrite
lns2.scpt
on openReadWriteCreate()
lns2.scpt
theRealSQLDb's openWithFlagsAS:6
lns2.scpt
end openReadWriteCreate
lns2.scpt
on |close|()
lns2.scpt
theRealSQLDb's closeAS()
lns2.scpt
set my theRealSQLDb to missing value -- so script doesn't need to store pointer
lns2.scpt
end |close|
lns2.scpt
on writeOpenInMemoryDbToFile:fileOrPath
lns2.scpt
theRealSQLDb's writeOpenInMemoryDatabaseToFileOrPathAS:fileOrPath
lns2.scpt
end writeOpenInMemoryDbToFile:
lns2.scpt
on beginTransaction()
lns2.scpt
theRealSQLDb's beginTransactionAS()
lns2.scpt
end beginTransaction
lns2.scpt
on commit()
lns2.scpt
theRealSQLDb's commitAS()
lns2.scpt
on rollback()
lns2.scpt
theRealSQLDb's rollbackAS()
lns2.scpt
end rollback
lns2.scpt
end scriptObjectDbInit
lns2.scpt