Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
Digital Lifestyle
Web Design and Hosting
Help with JavaScript and PhoneBook widget
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="garymm" data-source="post: 120945"><p>For starters, I have very limited experience with JavaScript. That out of the way, I want to modify the phonebook widget so that when I click on an address, I get directions to it rather than a map of it. The pertinent section of PhoneBook.js (or at least this is the only thing that I think is pertinent but I have no idea how to use javascript) follows (can be accessed via the "show package contents" on the PhoneBook widget file in Library/Widgets):</p><p></p><p>var mapURL = "http://www.mapquest.com/maps/map.adp?country=us&address=";</p><p></p><p>mapURL += URLEncode( singleResult.address );</p><p>mapURL += "&city=";</p><p>mapURL += URLEncode( singleResult.city );</p><p>mapURL += "&state=";</p><p>mapURL += URLEncode( singleResult.state );</p><p>mapURL += "&zip=";</p><p>mapURL += URLEncode( singleResult.zip );</p><p></p><p>addressSpansContainer.setAttribute("maplink", mapURL );</p><p>addressSpansContainer.onclick = function(event)</p><p>{</p><p>if( window.widget )</p><p>widget.openURL(this.getAttribute("maplink"));</p><p>}</p><p></p><p>Here are the mapquest guidelines for creating a link to directions (instead of a map): <a href="http://www.mapquest.com/features/main.adp?page=lf_dir" target="_blank">link</a> </p><p></p><p>I can figure out how to simply enter my home address into the base URL and have it permanently stored in the PhoneBook.js, but what I really want is a way to make it check my address from my card in Address Book. Is there a way to do this with JavaScript or at all?</p><p></p><p>Thanks for the help. I will definitely share the edited widget.</p></blockquote><p></p>
[QUOTE="garymm, post: 120945"] For starters, I have very limited experience with JavaScript. That out of the way, I want to modify the phonebook widget so that when I click on an address, I get directions to it rather than a map of it. The pertinent section of PhoneBook.js (or at least this is the only thing that I think is pertinent but I have no idea how to use javascript) follows (can be accessed via the "show package contents" on the PhoneBook widget file in Library/Widgets): var mapURL = "http://www.mapquest.com/maps/map.adp?country=us&address="; mapURL += URLEncode( singleResult.address ); mapURL += "&city="; mapURL += URLEncode( singleResult.city ); mapURL += "&state="; mapURL += URLEncode( singleResult.state ); mapURL += "&zip="; mapURL += URLEncode( singleResult.zip ); addressSpansContainer.setAttribute("maplink", mapURL ); addressSpansContainer.onclick = function(event) { if( window.widget ) widget.openURL(this.getAttribute("maplink")); } Here are the mapquest guidelines for creating a link to directions (instead of a map): [URL=http://www.mapquest.com/features/main.adp?page=lf_dir]link[/URL] I can figure out how to simply enter my home address into the base URL and have it permanently stored in the PhoneBook.js, but what I really want is a way to make it check my address from my card in Address Book. Is there a way to do this with JavaScript or at all? Thanks for the help. I will definitely share the edited widget. [/QUOTE]
Verification
Post reply
Forums
Digital Lifestyle
Web Design and Hosting
Help with JavaScript and PhoneBook widget
Top