Widget talk:Daily achievements
Well I rewrote it a bit to use the names, but some of the low level PvE events slip through since https://api.guildwars2.com/v2/achievements?page=0 doesn't mention level limits. Also I couldn't think of a simpler way of determining the category other than hard-coding the ids. Suggestions on where to get all the ids from? -Chieftain Alex 09:51, 20 October 2015 (UTC)
- We may have to use both endpoints and join them on ID. I'm pretty sure there's no "repository" of all possible achievements. —Dr Ishmael 15:21, 20 October 2015 (UTC)
- Couldn't we like, ask the ANet API dev guys to just put all the information in the one query? :p -Chieftain Alex 15:26, 20 October 2015 (UTC)
- Strung the two query result sets together. -Chieftain Alex 17:04, 20 October 2015 (UTC)
- (Reset indent) looks like the special halloween event dailies aren't in here. -Chieftain Alex 10:40, 23 October 2015 (UTC)
- And it looks like something broke in it. A few days ago I noticed there was a little mark at the corner of an item that indicated if it was only for HoT or not. Today I noticed it wasn't there anymore and after checking the code of this widget I found out why. The API seems to not differentiate it anymore, all items show
["GuildWars2","HeartOfThorns"]
forrequired_access
and I don't see a way to know if any is exclusive for HoT players (maybe there's not any exclusive anymore?) Just letting you guys know, in case anyone didn't notice it. --Txon Atana - (talk) 04:14, 11 June 2016 (UTC)- The mark was setup to only appear when the required_access specified one campaign instead of two. The dailies appear to match what I'm seeing ingame, with the exception of the #2901 daily [ascalonian catacombs] being missing from the API, so i think everything is working as intended. Some days there are just days which don't differentiate the dailies available between the different campaigns. -Chieftain Alex 07:23, 11 June 2016 (UTC)
- And it looks like something broke in it. A few days ago I noticed there was a little mark at the corner of an item that indicated if it was only for HoT or not. Today I noticed it wasn't there anymore and after checking the code of this widget I found out why. The API seems to not differentiate it anymore, all items show
- Ah ok, I got it. I thought there would be always items that are exclusive to HoT players and ones for non-HoT, then it looked like something changed.
- Btw, is there some other way to indicate which ones are only for low lvl accounts? Without a caption or legend it's hard to tell what those gray items mean, also grayed items usually means "disabled". Maybe putting like table headers? It could even be used to separate PvE, PvP and WvW without needing a column for that? If needed I could come up with a scratch to show what I mean. --Txon Atana - (talk) 17:11, 11 June 2016 (UTC)
Update[edit]
Since the gw2timer reddit thread using the achievements API I've updated this table to work properly. -Chieftain Alex 13:18, 6 December 2015 (UTC)
- It is pretty slow at the moment however. Anyone capable of speeding it up? (I think its mostly limited by the two api queries) -Chieftain Alex 13:32, 6 December 2015 (UTC)
- Maybe if we provide the widget a dictionary of all the daily ID-achievements, this would reduce it to one HTTP request? --BryghtShadow (talk) 03:40, 9 December 2015 (UTC)
Lower level daily support[edit]
Can we add support for lower level daily list, i.e. 1-10 and 11-30? Because v2/achievements/daily returns everything for the day: unspecified level parameter outputs dailies for 1-10 and 11-30 and 31-80, while specified level parameter displays dailies for 1-10 or 11-30 or 31-80. --BryghtShadow (talk) 03:40, 9 December 2015 (UTC)
- I'm not very "with it" with the API, can you give an example url to retrieve the low/mid/high level results? (or do you mean I should parameterise the widget so that we can filter results for the appropriate range). -Chieftain Alex 11:55, 9 December 2015 (UTC)
skip sorting[edit]
function makeTableHTML( daily_data, achievement_array ) { var result = "<table class='table mech1' style='margin-bottom:0px;'><tr><th>Category</th><th>Daily name</th></tr>"; $.each( daily_data, function( category, achievement_index ) { $.each( achievement_index, function( key, val ) { var id = val['id']; switch(category) { case "pvp": category = "PvP"; break; case "pve": category = "PvE"; break; case "wvw": category = "WvW"; break; } result += "<tr id='"+id+"' title='"+achievement_array[id]['description']+"'><td>"+category+"</td><td>"+achievement_array[id]['name']+"</td></tr>"; }); }); result += "</table>"; return result; } $(function () { $.getJSON('https://api.guildwars2.com/v2/achievements/daily').done(function (daily_data) { // Acquire data with sortkeys for category and level var k = 0; var ids = []; $.each( daily_data, function( category, achievement_index ) { $.each( achievement_index, function( key, val ) { ids.push(val['id']); }); }); ids = ids.join(","); $.getJSON('https://api.guildwars2.com/v2/achievements?ids='+ids).done(function (achievement_data) { // Add "name" and "description" from second API call to existing data var achievement_array = {}; $.each( achievement_data, function( key, val ) { achievement_array[val['id']] = val; }); // Display data document.getElementById('dailytable').innerHTML = makeTableHTML(daily_data,achievement_array); }) }) })
Stop being a baddy and avoid sorting anything.--Relyk ~ talk < 06:16, 9 December 2015 (UTC)
- Just for my own reference I've annotated your version so that I have a clue what is going on:
function makeTableHTML( daily_data, achievement_array ) { var result = "<table class='table mech1' style='margin-bottom:0px;'><tr><th>Category</th><th>Daily name</th></tr>"; // Generate an html row with the given data // for each category, and each achievement inside that... $.each( daily_data, function( category, achievement_index ) { $.each( achievement_index, function( key, val ) { var id = val['id']; var categoryname = ''; switch(category) { case 'pve': categoryname = 'PvE'; break; case 'pvp': categoryname = 'PvP'; break; case 'wvw': categoryname = "WvW"; break; } console.log(daily_data[category][key]['level']['min']+ '-' +daily_data[category][key]['level']['max']) result += "<tr id='"+id+"' title='"+achievement_array[id]['requirement'].replace(/'/g, "'")+"'><td>"+categoryname+"</td><td>"+achievement_array[id]['name']+"</td></tr>"; }); }); result += "</table>"; return result; } $(function () { $.getJSON('https://api.guildwars2.com/v2/achievements/daily').done(function (daily_data) { // API data laid out by category, then with a key (0-4) for each achievement, and achievement data within // Generate a list of ids to query for names in API // for each category, and each achievement key inside that... var ids = []; $.each( daily_data, function( category, achievement_index ) { $.each( achievement_index, function( key, val ) { ids.push(val['id']); }); }); ids = ids.join(","); $.getJSON('https://api.guildwars2.com/v2/achievements?ids='+ids).done(function (achievement_data) { // API data laid out by key (0-12), not necessarily in same order as asked by query // Create a new array where the achievement ID is used as the identifier for the old data var achievement_array = {}; $.each( achievement_data, function( key, val ) { achievement_array[val['id']] = val; }); // Display data document.getElementById('dailytable').innerHTML = makeTableHTML(daily_data,achievement_array); }) }) })
- Could do, but I want to sort the low level events out of the middle of the pve events. (on the current revision the low lvl ones are currently hidden but the data is available + sorted) -Chieftain Alex 11:37, 9 December 2015 (UTC)
TypeError: categoryname[category] is undefined[edit]
"fractals"
was added to /v2/achievements/daily, and this prevents the whole table from showing. Please gracefully fallback when category
isn't in categoryname
(e.g. category in categoryname ? categoryname[category]['a'] : category
).
The change in the API breaks this line:
result += '<tr id="'+data['id']+'" '+rowspec+'><td>'+categoryname[category]['a']+'</td><td class="'+ cellclass +'">'+data['name']+'</td></tr>';
--BryghtShadow (talk) 07:38, 25 February 2017 (UTC)
- Thanks for pointing this out. I've added the graceful fallback as requested.
- I should probably rewrite the widget given that the fractal achievements are available with one query with the regular dailies, but for the moment I'm just going to ignore the fractals category. -Chieftain Alex 21:05, 25 February 2017 (UTC)
[edit]
Might be more intuitive if instead of clicking on the table cell to unexpectedly navigate, that we link the achievement names instead and use anchor hrefs? -Chieftain Alex 23:00, 3 April 2021 (UTC)
Redirect[edit]
The correct page is "Daily (achievements)" not the redirect page "Daily achievements". Not sure if I have one has to escape parentheses, etc... --Tolkyria (talk) 22:56, 13 November 2021 (UTC)
- Good spot. And there's no need to escape the braces in this case (as e.g. would be needed in a string for matching (a) brace(s) with regular expresions). I'll change it. Nightsky (talk) 23:23, 13 November 2021 (UTC)
End of Dragons[edit]
I wonder; should a red corner be prepared already in case End of Dragons adds additional dailies, to be used for base game only dailies, replacing a then repurposed blue corner? Nightsky (talk) 21:05, 24 February 2022 (UTC)
- Excellent idea, done. -Chieftain Alex 21:38, 24 February 2022 (UTC)