Sunday, July 20, 2008

any javascript gurus out there?

Still not approved by apple. Doesn't surprise me, I'm expecting moday at the earliest. I did get news today that my iPhone is on it's way to my AT&T store, so I should have it in my hands by the end of the week. Having the GPS will help immensely for testing the compass rotation. I've had to test the arrow movement while driving around town in the car with a 1st gen iPhone. That's less than ideal.

I also want to give you guys a heads up, I will be out of town for a couple of days, so updates may be sparse. I'm taking my laptop, but I'm not sure if I will have internet access or not. I'll try to check and do what I can to at least find out if I get approved or not. =)

Technical stuff to follow, if you're interested.

I've been working on getting the geocaching.com content via other means than making the user choose links and enter data into text fields. I'm doing pretty okay so far, but I've run into two hangups.

First, I need to figure out how to complete the login process on geocaching.com via javascript. Being brand new at javascript I feel a little in the dark, but it doesn't seem terribly difficult. I just don't have anyone to ask questions to, so it's slow going at times. =) I have code that I thought would submit the login button, but it seems to be rejected for some reason by the webpage. the submit call isn't happy. I can load the text fields and the "remember" checkbox, but submitting the button is giving me an error. I must be missing something fairly simple.

The second is the ability to get a portion of a webpage via a javascript call. I have access to javascript on the page, but not necessarily direct access to the content. So I need to figure out how to grab data from the webpage with javascript. For search listings for example, I need to have a list of surrounding caches that you get in real-time from the website. I can load the page easily using some of apple's technology to do so, but getting the data back out of the web view is another matter. I've looked at document.body and document.documentElement. It looks like documentElement has the best chance at getting what I need so far, but it seems like there should be an easier way. Guess we will see.

Any javascript gurus out there that can point me in the right direction?

Edit:

After reading the groundspeak licensing agreement, they specifically have a clause in there saying that I will need their permission to do this. So while I may get this to work, I may not be able to use it without permission. Ugh, the red tape. =) I Guess I am waiting to hear back from groundspeak and apple both.

12 comments:

DadGuy said...

Well, problem #1 solved. Even if I suspect there is a better way to do this.

document.getElementById('Button1').click();

Now to get the data back out. That should be interesting.

FoxFireX said...

Sounds like you need a brief course on the DOM available through JavaScript. Have a look at this reference and see if it helps. You'll start with the document object and probably have to drill down through several layers to find what you need.

The unfortunate part of this approach is that you're dependent on Groundspeak leaving their site layout alone. If they move around some tags, or change the name of some element, parsing that works perfectly one day may be broken beyond hope the next. Not sure exactly what you're trying to do with the data, but if there's a way to grab the .LOC or .GPX of the cache instead of the web page, you'll probably have more consistent results if the site design changes.

Of course, the best answer is to have Groundspeak reply to your queries and show you a way to get the info more cleanly than doing any website scraping.

DadGuy said...

foxfirex,

Thanks for the reply. I was hoping there would be an easier way than drilling down through the objects, I had seen that mentioned, but it was more involved than I wanted to get. I agree, it's not ideal. I've sent groundspeak 2 emails and heard nothing (though one was yesterday, so that probably hasn't been read).

I'm not worried so much about doing the parsing myself. From what I have heard just browsing around is that there isn't a specific API that they're giving out either, so unless I hear something there's little choice in this. I suppose I can just ignore the internet access part and manage GPX and LOC files that are imported, but that somewhat defeats the fun of having it be on the iPhone.

What I really want is for apple to give access to email via the SDK. I was planning on being able to have PQ's emailed to your iPhone and then importing them. I've not found any kind of access there however, so I'm again stuck doing things the harder way. I guess that's what I get being a 3rd party. =)

thanks for the response. And thanks for the link. I've been looking at more advanced stuff and hopping in at the other end. =)

FoxFireX said...

Well, part of what I'm thinking is the button on the pages labeled "LOC Waypoint File" and "GPX eXchange File". If you could find a way to determine those filenames, either by them always being determined by the GCxxxxx number or the GUID assigned to the object, you could just request those files over the air and use them. Alternately, you could "click" the button on the page just like you did for the login logic. Might be a little more consistent, anyway.

Of course, you also need to be careful of their ToU. You definitely will want to get their buy-in, I think, due to this little gem:

5. Access and Interference

Much of the information on the Site is updated on a real time basis and is proprietary or is licensed to Groundspeak by our users or third parties. You agree that you will not use any robot, spider, scraper or other automated means to access the Site for any purpose without our express written permission. Additionally, you agree that you will not: (a) take any action that imposes, or may impose in our sole discretion an unreasonable or disproportionately large load on our infrastructure; or (b) interfere or attempt to interfere with the proper working of the Site or any activities conducted on the Site or other measures we may use to prevent or restrict access to the Site.


Not an iPhone user at this point, but I'd been wondering how long it'd take for a cool GC program to show up. Hope you can get it going in a way everyone will be able to enjoy. :)

DadGuy said...

Yeah, I re-read that this morning. I'll update my post to reflect that fact. Here's hoping they get back to me in a reasonable timeframe. I'm not assuming anything at this point. =)

Branden Russell said...

I'm interested in doing a geocaching app. I have a fairly basic app done that I'm trying to get some an icon designed and then will try my hand at getting an app submitted to Apple to include in the store.

The reason I'm posting is I believe I may have figured out a way to get LOC and GPX files to the iPhone easily without geocaching.com and (hopefully) not violating any of their restrictions.

email me if you are interested in maybe working together or something.

Matt said...

Your app has been posted to Apple. $3.99? REALLY? For an app that loads a website and then has a compass? I was so excited for a geocaching app. But, this is disappointing. PLUS, you list all these cool features for a "soon to be released" version. You going to charge more for that one? Or will it be a free upgrade for the "lite" people?

reto.spielmann said...

Hello (translate german = english Google )

I have tested it and I'm happy.

am already on the updates

Gruss Reto

Kevin said...

$3.99 for lite?? Are we going to have to pay again once the FULL version comes out? How much is that one going to be? I am not buying until I know that this version will be upgraded to include new features.

Gilbert said...

Hi,

The current version obviously is very nice work although I agree with the people arguing that the current price is a little high for the given functionality. Nevertheless, I have suggestions for the next version:

- Am I right, that I have to enter "lat.", "long." and "Waypoint" manually from the geocaching.com site? If I'm not right: please publish a howto somewhere. Otherwise, that is not very user friendly and should be fixed soon - you should parse it from the website and fill it automatically when viewing a cache.

- I used my 3G iPhone for geocaching by saving one bookmark for the cache on geocaching.com and one for the real google-map showing the cache. When I open the latter, the iPhone google map comes up, showing a red needle for the cache and a blue dot for my current position. This is very useful for navigating near the cache, e.g. when you have to cross bridges to get there. A shortcut would be very nice here as well!

Marlin said...
This comment has been removed by the author.
Marlin said...

I agree with the previous commenters.


1. I feel as though I should not have paid for what the app currently does.

2. Manually entering in the coords is inconvienient, it looks like you are working on this. It will be a welcome fix.

3. My greatest concern is with the compass screen. I realize that the emulator isn't helpful for testing it. On the iphone 3g, I notice that the lat/lon coords are updating and the distance is changing, but I'm not sure about the arrow -- it doesn't seem to be updating . . . Oh, can we have miles & feet instead of kilometers? This area needs attention too.

4. There are quite a few half baked programs in the app store. Most of them are due to rushing them out the door. I feel that geopher lite is one of these. I get sad when I read some of the apps reviews on the app store. It seams tha some developers are getting "booed off the stage".

Don't lose hope. Keep pushing forward. I think that this will be a really great app, in time. I just think it should have had 3 or 4 months more dev / testing time before getting posted to the app store.

The app store reviewers are merciless. . .

Blog Archive

About Me

My photo
DadGuy has been working with apple computers since the mac classic. I love games and puzzles and like to solve problems. I'm having a blast developing for the iPhone and iPad.