Thursday, July 22, 2010

Wow.js

I recently completed a preliminary JavaScript version of a World of Warcraft Armory client. The project is currently being hosted at github and is therefore completely open source.  To get started one needs only to download the client script, and its dependency jQuery. It really is simple...

To create a client object:
var client = new Wow.Armory.Client();
To retrieve the character sheet:
client.getCharacterSheet({
  character: 'Wetall',
  realm: 'Dunemaul',
  success: function(character, s, xhr) {
    /* do something with the JSON version of the character sheet here */
  },
  failure: function(xhr, s, e) {
    /* we failed somewhere along the line with the request */
  }
});
To retrieve item information:
client.getItemInfo({
  itemId: 22630,
  success: function(item, s, xhr) {
    /* do something with the JSON version of the item here */
  },
  failure: function(xhr, s, e) {
    /* we failed somewhere along the line with the request */
  }
});
To do a general search query:
client.search({
  searchType: Wow.Armory.SearchType.Characters, /* as well as All, Items, and Guilds */
  searchQuery: 'Calox', /* this parameter is optional! */
  success: function(results, s, xhr) {
    /* do something with the JSON results here */
  },
  failure: function(xhr, s, e) {
    /* we failed somewhere along the line with the request */
  }
});
This is merely scratching the surface! With serious usage the mileage may vary, but should any serious problems arise please report them at github so that I can do my best to rectify the situation.

No comments: