Go to Post sometimes you have to dig through the trash and clean off the layers of dirt and grime in order to find diamonds in the rough. - Travis Hoffman [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 30-01-2016, 13:48
Mr_Moko's Avatar
Mr_Moko Mr_Moko is offline
[INSERT TITLE HERE]
AKA: Jaye
FRC #2729 (STORM Robotics)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2012
Location: Jersey. You know, the New one
Posts: 29
Mr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond repute
[Help Needed] Javascript Team Finder

Greetings Chief Delphi members!
I'm from from FRC 2729 Storm Robotics and I was wondering if someone could help with an issue that we're having with our Team Number Finder in JavaScript.
We can get one page of team numbers (500 numbers) off of any given page using The Blue Alliance api due to the fact that the HTTP request only executes on the last iteration of the for loop. The problem we are having is that when we try to get more than one page, the values become undefined.
If someone could look through the code and lend us a hand, that would be wonderful!

HTML
JavaScript

Thanks in advance for any help that is given!

Last edited by Mr_Moko : 30-01-2016 at 14:00.
  #2   Spotlight this post!  
Unread 30-01-2016, 13:53
jlmcmchl jlmcmchl is offline
FF - The Breakfast Company
AKA: Jordan McMichael
FRC #0027 (Team RUSH 27)
Team Role: Alumni
 
Join Date: Feb 2012
Rookie Year: 2011
Location: Clarkston,MI
Posts: 327
jlmcmchl has much to be proud ofjlmcmchl has much to be proud ofjlmcmchl has much to be proud ofjlmcmchl has much to be proud ofjlmcmchl has much to be proud ofjlmcmchl has much to be proud ofjlmcmchl has much to be proud ofjlmcmchl has much to be proud of
Re: [Help Needed] Javascript Team Finder

Could you post a pastebin link, instead of quoting the code? It's really hard to read when you lose all the formatting.
__________________


Field reset: Kettering Kickoff ('13, '14), Kettering ('14, '15), Bedford ('14), Woodhaven ('16), Carver ('16), Einstein! ('16)
Referee: Bedford ('15), MARC ('15, '16), Kettering Kickoff ('15, '16), Kettering District (#1&2: '16), Troy ('16)
  #3   Spotlight this post!  
Unread 30-01-2016, 14:01
Mr_Moko's Avatar
Mr_Moko Mr_Moko is offline
[INSERT TITLE HERE]
AKA: Jaye
FRC #2729 (STORM Robotics)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2012
Location: Jersey. You know, the New one
Posts: 29
Mr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond repute
Re: [Help Needed] Javascript Team Finder

Quote:
Originally Posted by jlmcmchl View Post
Could you post a pastebin link, instead of quoting the code? It's really hard to read when you lose all the formatting.
Replaced the Quotes with Hyperlinks to Pastebin.
Thanks for the advice! I'm not quite sure why I didn't think of that to begin with.
  #4   Spotlight this post!  
Unread 30-01-2016, 14:01
hardcopi hardcopi is offline
Registered User
AKA: Rich Lester
FRC #2959 (The Robotarians)
Team Role: Mentor
 
Join Date: Apr 2013
Rookie Year: 2013
Location: Coloma, MI
Posts: 274
hardcopi has much to be proud ofhardcopi has much to be proud ofhardcopi has much to be proud ofhardcopi has much to be proud ofhardcopi has much to be proud ofhardcopi has much to be proud ofhardcopi has much to be proud ofhardcopi has much to be proud ofhardcopi has much to be proud of
Re: [Help Needed] Javascript Team Finder

PHP Code:
document.getElementById("blank").innerHTML out

You appear to be overwriting the html of your div every iteration. Not sure in core javascript but in jquery it would be
PHP Code:
$('#blank').append(out); 
A jsfiddle or pastbin would have been easier to debug though.
  #5   Spotlight this post!  
Unread 30-01-2016, 14:08
Mr_Moko's Avatar
Mr_Moko Mr_Moko is offline
[INSERT TITLE HERE]
AKA: Jaye
FRC #2729 (STORM Robotics)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2012
Location: Jersey. You know, the New one
Posts: 29
Mr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond repute
Re: [Help Needed] Javascript Team Finder

Quote:
Originally Posted by hardcopi View Post
PHP Code:
document.getElementById("blank").innerHTML out

You appear to be overwriting the html of your div every iteration. Not sure in core javascript but in jquery it would be
PHP Code:
$('#blank').append(out); 
A jsfiddle or pastbin would have been easier to debug though.
You posted just before I updated the post to have inks to Pastebin instead of quotes, thank your for opinion, I'll see if that helps!
  #6   Spotlight this post!  
Unread 30-01-2016, 14:34
Andrew Lobos Andrew Lobos is offline
Registered User
FRC #0225 (TechFire)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2011
Location: Lancaster, PA
Posts: 61
Andrew Lobos is a jewel in the roughAndrew Lobos is a jewel in the roughAndrew Lobos is a jewel in the rough
Re: [Help Needed] Javascript Team Finder

I think this JS will output what you expect (or something close): https://gist.github.com/4ndr3w/b924b0762416c0ba6885

In Chrome I get a big comma separated list of teams from 1 to something in the 6000's Note that the output has no guarantee of order since the HTTP requests are returning asynchronously.

hardcopi is right that it's probably better to append to the div. Your implementation will work since you are appending output to a global string and then writing the whole string back out to the div every loop, but it's not as clean
__________________
2012-2014: 225 Driver, Programmer & Co-Captain
2012-2014: FTC 4977 Driver, Programmer, & Team Captain
2011: 225 Operator & Programmer

2013: FRC: Springside-Chestnut Hill Winner (w/341 & 1495), Midknight Mayhem Winner (w/316, 369, & 869), Battle O' Baltimore Winner (w/1640, 2914 & 339), Duel on the Delaware Finalist (w/816 & 369), Ramp Riot Winner (w/341, 304, & 4637) FTC: PA State Finalist
2014: FRC: Springside-Chestnut Hill Winner (w/316 & 1495), Greater DC Winner (w/1731 & 4464), Midknight Mayhem Winner (w/25, 1626 & 329) FTC: PA State Champion

Last edited by Andrew Lobos : 30-01-2016 at 14:41.
  #7   Spotlight this post!  
Unread 30-01-2016, 15:03
Mr_Moko's Avatar
Mr_Moko Mr_Moko is offline
[INSERT TITLE HERE]
AKA: Jaye
FRC #2729 (STORM Robotics)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2012
Location: Jersey. You know, the New one
Posts: 29
Mr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond reputeMr_Moko has a reputation beyond repute
Re: [Help Needed] Javascript Team Finder

Quote:
Originally Posted by Andrew Lobos View Post
I think this JS will output what you expect (or something close): https://gist.github.com/4ndr3w/b924b0762416c0ba6885

In Chrome I get a big comma separated list of teams from 1 to something in the 6000's Note that the output has no guarantee of order since the HTTP requests are returning asynchronously.

hardcopi is right that it's probably better to append to the div. Your implementation will work since you are appending output to a global string and then writing the whole string back out to the div every loop, but it's not as clean
Thank you so much for your fix! If we use your version then I'll make sure to credit you for the fix.
I also agree with hardcopi and I'll possibly see what I can do about doing that, but for now, thanks again for now I believe we'll use your version.
Again, thank you!
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 01:33.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi