PDA

View Full Version : atagQuery.js



JG51_Szyporyn
Jun-17-2014, 07:07
S!

Since it is not possible to directly AJAX the service "stats_lookup.php" I have created a JS file which will add the function/method "atagQuery" to the root object (window).

Just add this line to your HTML document in the <head> section


<script src="http://www.szyporyn.com/atag/js/atagquery.js"></script>


The method takes 3 arguments
- name (string)
- callback (function)
- settings (object)

Name:
Simply the string of names you wish to query for

Callback:
The function which will be called once the data has been fetched
Carries an object as its argument (which is the exact object you would have gotten from the service)

Settings:
A settings object with the params ATAG recieves - they are (with default values)

{
start: 0, // What record to begin at (this is used for pagination)
range: 200, // What record to end at (this is used for pagination)
exact: 0, // Does the name have to match exactly for a return?
sort: 'sid', // Internal token
el: null, // Used by ATAG since their service also serves as a view service - not just data service
sort_asc: true // Sort acending (false = sort decending)
}

Here is an example I used to get the JG51 members (had to do some filtering after that as well since there is a squad called 3./JG51_ also)


atagQuery('JG51_', function (o_json) {
console.log('This is the responce object I get from ATAG: ', o_json);
});

The code was jQuery and YUI dependent, but I wrote my own $.param and $.extend so you do not have to load jQuery to have this work.

Nor do you need to load YUI anymore, it is embedded in the code now.

However!

Untill ATAG team fixes their service this is the ONLY way (that I could figure out) you can get their data - but Yahoo Query Language seems to be setting some restrictions on number of queries etc.. and it is not that reliable.

Enjoy

JG51_Szyporyn
Jun-17-2014, 07:48
And once again I have hit the limit - no more stats today.

I hope to talk to the ATAG team and hopefully they will allow me to write a service that will be ajaxable from outside...