SC2SEA.com - Starcraft 2 SEA eSports Community Site


  • Home
  • About
  • Streams
  • Features
  • Tournaments
  • Forums
SC2SEA.com - Starcraft 2 SEA eSports Community Site > General Forums > General > Need Help with JavaScript for Clan :S Please! :D
About Us
An Overview of sc2sea
About Us
Contact us
Join our team!
Features
Live Streams
Replays
SEABets
Site Achievements
Articles
Article Archive
Who's Who
sc2sea.com Weekly Tournaments
Tournaments
Every Saturday BSG Open - (Bronze, Silver, Gold)
Every Sunday GPD Open - (Gold, Platinum, Diamond)
Monthly Sunday Masters Cup
Oseanic Championship Series 2015
Point Standings
The Grandmaster Manual
1. Introduction
2. Basics
3. Advanced
4. Anti-Cheese
5. Protoss
6. Zerg
7. Terran
8. Summary
9. Bonus Content!
Coaching
TGM Member Only Forums
TGM Official Coaches
Misc
Help us Rate TGM!!
Suggest what you'll like to see!
Need help? Contact Support!
Community Links
Members List
Search Forums
 
Advanced Search
Search Downloads
Advanced Search
Go to Page...
Community
House Clans
Clans
No recent threads.
Community
No recent threads.
Tournaments
No recent threads.
Latest Blogs New
tier list of people...
asdfSchnitzel
My Life Was Turned...
Sc2Clare
I've been playing...
SLCN.Wally
My Starcraft/eSpor...
syfChadMann
My Starcraft/eSpor...
syfChadMann
General
Stickied Threads
No recent threads.
General Threads
No recent threads.
StarCraft II
Starcraft General
No recent threads.
Strategy Discussion
No recent threads.
BSG Discussion
No recent threads.
Other Games
Other Games
No recent threads.
Sports
No recent threads.
News
News Archive
No recent threads.
Tournament News
No recent threads.
Articles Archive
Replays
Photo Gallery
Mark all forums as read
Reply
Display Modes
Thread Tools
View First Unread View First Unread
Unread Tue, 13th-Mar-2012, 2:07 PM Race: Location: Brisbane  Total Posts Made: 39 # 1
ChaynesOre
ChaynesOre's Avatar
Tourneys Joined: 5
Great Beginnings
Achievements (1)
Smiley: Question Need Help with JavaScript for Clan :S Please! :D

Hey guys, I've got what I assume is a very simple task but I can't work it out using Google search because I have no knowledge of the basics I assume. I've got a limited understanding of programming (as a mechanical engineer) and how it works etc, but next to no knowledge of javascript and web programming.


THE GOAL:

I want to create a simple web page for my clan (FaDe) that has a list of all members, with contact information, real id emails, etc, and also have it link to data extracted from Sc2Ranks (namely, League, Rank, Win/Loss, Race, etc). It's basically a customizable list of our team members, that talks to Sc2Ranks. I think this should be pretty simple, but I am clueless.


WHAT I'VE WORKED OUT:

I've worked out that I need to use the API from Sc2Ranks to achieve this ( http://sc2ranks.com/api ). Reading this, I've worked out how to correctly construct the API URL. For example, my account for "Character with Base Team Info" would be as follows, for the three available outputs:

http://sc2ranks.com/api/char/teams/s...appKey=zxq.com (XML)
http://sc2ranks.com/api/char/teams/s...appKey=zxq.com (JSON)
http://sc2ranks.com/api/char/teams/s...appKey=zxq.com (JSONP)


THE PROBLEM:

I have no idea what to do next. I can't seem to find anything on Google that simply tells me how to tell my web page to talk to these API URLs and manipulate the data so that I can put it in a table as I need to. I'm sure this is an extremely simple task, but I've spent hours looking and am just completely stuck. I understand that jQuery.getJSON is supposed to be useful, but I still can't work it out. Please can anyone help?! :S

Quick Comments
 RicocheT:  
Thanks for your hard work babe <3

Last edited by ChaynesOre; Tue, 13th-Mar-2012 at 2:26 PM.
ChaynesOre is offline   OLD POST Reply With Quote
ChaynesOre
View Public Profile
Send a private message to ChaynesOre
Find all posts by ChaynesOre
Unread Tue, 13th-Mar-2012, 2:39 PM Who's Who:   BnetId: ToRErasmus.733  Race: Clan: ToR  Location: Sydney  Total Posts Made: 1,454 # 2
|Erasmus|
|Erasmus|'s Avatar
Tourneys Joined: 11
SC2SEA Supporter!Community Builder
Achievements (2)
There is a decent ajax tutorial here: http://www.w3schools.com/ajax/ajax_x...quest_send.asp

Code:
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

xmlhttp.open("GET","http://sc2ranks.com/api/char/teams/sea/FaDeChaynes!401514/1/0.json?appKey=zxq.com", true);
xmlhttp.send();
If you use that kind of javascript with the url that returns JSON formatted data (the tutorial explains how to use the readystatechange stuff with this) you can just use the built in eval() function in javascript to get the json info as a javascript object.

This is a bit of stuff if it was to happen whenever the page is loaded. I think you're better off storing your own data in a file on the server with the webpage, and give each player in your table an 'update now' button which runs a query past sc2ranks to grab the latest profile info. (or an 'update all' button if it's too much to update everyone.

I hope that helps. paperclip or veteris can probably explain web stuff better than I can, but you're welcome to ask me questions if you need and I'll try to help.

Quick Comments
 RicocheT:  
 ChaynesOre:  
extremely appreciated!!
 nirvAnA:  
|Erasmus| is offline Send a message via MSN to |Erasmus| Send a message via Skype™ to |Erasmus|   OLD POST Reply With Quote
|Erasmus|
View Public Profile
Send a private message to |Erasmus|
Find all posts by |Erasmus|
Unread Tue, 13th-Mar-2012, 4:29 PM Who's Who:   BnetId: xpaperclip.405  Race: Location: Melbourne, Australia  Total Posts Made: 177 # 3
xpaperclip
Guardian of SC2SEA
xpaperclip's Avatar
Tourneys Joined / Won: 42/1
Community BuilderThere is no fate but what we make for ourselvesAyo TechnologyUnearthed TalentSeasoned Tournament Player
Achievements (5)
jQuery is your friend for anything client-side.

The code in the spoiler fetches the clan FaDe custom division and inserts each player as a row into a table. Because you are loading data cross-site, you have to use a JSONP callback because most modern browsers will refuse to do an AJAX fetch cross-domain. Otherwise, the code is very simple, so you should be able to follow it. (As an aside, tablesorter is something I didn't include but that you might find useful.)

+ Show +

HTML Code:
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
function loaddata()
{
    url = 'http://sc2ranks.com/api/clist/10640/all/all/1/0.json?appKey=yourdomain.com';
    $.ajax({
        url: url,
        dataType: "jsonp",
        jsonp : "jsonp",
        jsonpCallback: "jsonpcallback"
        });
}

function jsonpcallback(data)
{
    tbl = $("#playerstable");
    $.each(data, function(idx, record) {
        tbl.after('<tr><td>' + record.members[0].name + '</td><td>' + record.league + '</td><td>' + record.division_rank + '</td></tr>');
    });
}

$(document).ready(loaddata);
</script>
</head>

<body>

<table>
    <tbody id="playerstable">
        <tr><td>Name</td><td>League</td><td>Rank</td></tr>
    </tbody>
</table>


</body>
</html>


However! This is definitely not the way to proceed. As Erasmus said, something like this should really be done on the server-side with a database. The sc2ranks API terms even specifically says to cache the results and not fetch everything every time the page is loaded. Depending on your host, this may or may not be viable. Let us know how your site is hosted if you want any additional help.

Quick Comments
 RicocheT:  
 ChaynesOre:  
miracle worker indeed!! :D
 nirvAnA:  
xpaperclip is offline   OLD POST Reply With Quote
xpaperclip
View Public Profile
Send a private message to xpaperclip
Find all posts by xpaperclip
Unread Tue, 13th-Mar-2012, 5:12 PM Race: Location: Brisbane  Total Posts Made: 39 # 4
ChaynesOre
ChaynesOre's Avatar
Tourneys Joined: 5
Great Beginnings
Achievements (1)
!!!!!! OMG! Wow thank-you so much guys. It works and is talking to it correctly. That is amazingly cool. I'll spend some time looking at it and understanding it. I'm one of those people that understands by way of example so having this directly applicable code to follow is going to be perfect.

The page is going to be hosted anywhere that's free. I found this place yesterday http://www.zymic.com/ and it's already setup with an FTP server etc, so I think I should be able to cache the data as you say. I'll look into this now. I think I've stumbled across some tutorial pages that touched on this already so hopefully I'll be able to take it from here.

Thank you so much again for taking the time to help. Sc2 people are so nice
ChaynesOre is offline   OLD POST Reply With Quote
ChaynesOre
View Public Profile
Send a private message to ChaynesOre
Find all posts by ChaynesOre

Reply

« Previous Thread | Next Thread »

Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page
Display Modes
View All Posts View All
Linear Mode Linear Mode
Hybrid Mode Switch to Hybrid Mode
Threaded Mode Switch to Threaded Mode

Similar Threads
Thread Thread Starter Forum Replies Last Post
New Clan Recruiting! PK Clan All levels welcomed/ Philipd122 Clans 11 Fri, 16th-Dec-2011 4:40 PM
Show Match: Clan RUSH vs Clan aLt Edrahil Tournaments 9 Sun, 24th-Apr-2011 12:11 AM
A Vietnamese clan seeking inter-clan friendly matches Seq Clans 0 Fri, 19th-Nov-2010 12:42 PM

Events
Upcoming Events Add
No events scheduled in
the next 7 days.
OSC SEA Participation Bonus
Live Streams
No streams online.
Open SEABets
No open bets.
2015 OSEANIC Series
Latest Results
Americas Open #110 KeeN
OSC SEA Weekly #24 Probe
SC2Online Comm Open #38 aLive
February EU Ladder Heroes Nerchio
February NA Ladder Heroes TRUE
ANZ Cup #12 iaguz
Filthy NA Weekly #16 Semper
Proxy Tempest Open #43 PiLiPiLi
Top 20 OSC Rankings
1ByuN
2Seither
3DemiLove
4PiLiPiLi
5Kelazhur
6Cham
7iaguz
8aLive
9Solar
10KeeN
11EnDerr
12KingkOng
13TRUE
14GuMiho
15Probe
16puCK
17Snute
18PandaBearMe
19PiG
20Ryung
Full Point Standings
Earn extra points with Challenge Matches!
Bounties
Defeat these players and collect the $'s!
ByuN$100
INnoVation$75
Solar$75
Neeb$60
herO$50
GuMiho$50
Nerchio$50
TRUE$50
uThermal$50
Kelazhur$40
MajOr$40
Scarlett$40
Snute$40
aLive$30
Bly$30
iAsonu$30
KeeN$30
PiLiPiLi$30
puCK$30
Ryung$30
Cham$25
Cyan$25
iaguz$25
Guru$25
Seither$25
Semper$25
JonSnow$15
PandaBearMe$15
Probe$15
Latest Collected
Yours 2-0 Neeb $60
SC2ONLINE Comm Open #38
Azure 2-0 Seither $25
ANZ Cup #12
Cham 2-0 Cyan $25
OSC All Stars #24
FuturE 2-0 KeeN $30
ESL Americas Open #109
Donations
Donate using Paypal!

Even the smallest donations help keep sc2sea running! All donations go towards helping our site run including our monthly server hosting fees and sc2sea sponsored community tournaments we host. Find out more here.
Home - Contact Us - FAQ - Members List - Advertise - Terms of Service - Top - Mobile-friendly (alpha)
Powered by vBadvanced CMPS v3.2.2
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
The contents of this webpage are copyright of sc2sea.com © 2010-2015. All Rights Reserved.
The Grandmaster Manual is a Starcraft 2 Guide created and owned by sc2sea.com
Starcraft2 is a trademark of Blizzard Entertainment, this is a community fan site and no infringement is intended.
Custom artwork by Zeus, Banner designed by Cute, other artworks is used with permission with credits listed here. vBulletin skin by CompletevB.com