IP Phone: Difference between revisions

From Medien Wiki
Line 8: Line 8:


<source lang="applescript">
<source lang="applescript">
-- AppleScript(+JavaScript) to dial phone numbers with a Cisco IP Phone from the Mac OS Address Book via the Webdialer URL.
-- AppleScript(+JavaScript) to dial phone numbers with a Cisco IP Phone from the Mac OS Address Book via the Webdialer URL
-- Put it into ~/Library/Address Book plugins/
-- 2011 Max Neupert, Bauhaus-Universität Weimar
-- 2011 Max Neupert, Bauhaus-Universität Weimar


Line 38: Line 37:
on perform action for p with e
on perform action for p with e
set ABPhoneNumber to value of e
set theNumberInAddressBook to value of e
set ABPhoneNumber to ABPhoneNumber as string
set theNumberInAddressBook to theNumberInAddressBook as string
                -- the following line replaces +49 with 0
-- the following line replaces the international prefix for germany (+49) with 0
set theNumber to findReplace("+49", "0", ABPhoneNumber)
set theNumberInAddressBook to findReplace("+49", "0", theNumberInAddressBook)
-- the following line replaces any other international prefix (+) with 00
set theFormattedNumber to findReplace("+", "00", theNumberInAddressBook)
-- the following line adds a 0 = “Amtsholung”
-- the following line adds a 0 = “Amtsholung”
set theNicePhoneNumber to "0" & theNumber
set theNumberToBeDialed to "0" & theFormattedNumber
tell application "Safari"
tell application "Safari"
Line 56: Line 57:
end repeat
end repeat
do JavaScript "document.forms['loginForm'].elements['destination'].value ='" & theNicePhoneNumber & "'" in document 1
do JavaScript "document.forms['loginForm'].elements['destination'].value ='" & theNumberToBeDialed & "'" in document 1
do JavaScript "document.forms['loginForm'].elements['dial'].click()" in document 1
do JavaScript "document.forms['loginForm'].elements['dial'].click()" in document 1
end tell
end tell
return true
return true
Line 65: Line 67:


Known Bugs:
Known Bugs:
# only works with phone numbers in Germany so far
# doen't work with phone number which start like 0049...., (0049), (49)
# browser window opens and resizes
# browser window opens and resizes
# <s>only works with phone numbers in Germany so far</s> fixed
# <s>doesn't work if page loading in browser takes longer than 1 sec.</s> fixed.
# <s>doesn't work if page loading in browser takes longer than 1 sec.</s> fixed.