User talk:Dagger/Widget drafts/API

From Guild Wars 2 Wiki
Jump to: navigation, search

"(in particular I don't even know any pages with multiple skins to try it out on...)" Iron's Tailpipe Bandana has multiple skins set. -Chieftain AlexUser Chieftain Alex sig.png 23:53, 21 December 2015 (UTC)

Okay, let's see. "Acquiring the item for the first time will unlock all three armor classes in the wardrobe", which means in this case it'd be ok to just take any one of the skin IDs, since all 3 will have the same unlock status. Is that true for all items with multiple skins though? -- Dagger (talk) 00:08, 22 December 2015 (UTC)
Should be, although I can't think of many other items off the top of my head (Nightfury is one, and behaves in the same way. Winter's Presence is likely another). -Chieftain AlexUser Chieftain Alex sig.png 00:17, 22 December 2015 (UTC)
So we can just do the same thing as on dye pages: add an "Unlocked" row after the "Skin" row, use {{{#explode:{{{skin}}}|,|0}}} and be correct in either all or very nearly all cases. (In fact the explode isn't even needed, because JS parseInt() stops at the first comma anyway.) -- Dagger (talk) 00:38, 22 December 2015 (UTC)

Questions and thoughts[edit]

Questions (I can't read javascript too well):

  1. Is it right that it fetches the required account API information the first time each endpoint it is required, then stores the whole API query in localstorage (for the cache duration) for subsequent requests on other pages, then refreshes it only when necessary?


  1. Poke mentioned that he'd "like to have this kind of information visually separated in the infobox though to make it clear that this is personalized information and does not come directly from the wiki" .
    My interpretation of this is that (in an ideal world) we'd have the API information towards the bottom of the infobox (beneath the external links [gw2spidy/gw2tp/gw2shinies] section).
  2. Similarly dye/mini/skin unlock status should preferably be below "default item param" in item infobox.
  3. I'd expect to find the "Unlocked on" section on Template:Recipe at the bottom, just above the ingredients section.
  4. Currency is too awkward to bother with at the moment.

Templates where results should show up:

-Chieftain AlexUser Chieftain Alex sig.png 14:38, 8 January 2016 (UTC)

Re: questions: Yep. Or specifically, it stores the cache forever (localstorage doesn't support automatic expiry), and refreshes it when it's too old. (If you clear your API key then it also clears the cache.)
Re thoughts:
1. That's my interpretation too. But it felt weird at the bottom (External Links feels like it should be last), and for the skin unlock row in {{Item infobox}} it's going to lead to this random "Unlocked" row at the bottom where it's not very clear that it's related to the skin. (There's not enough room to write out "Skin unlocked" without it wrapping.)
But what I'm wondering is: is it really going to be that easy to not realize this info is from your account? All of these rows will be completely hidden unless and until you set an API key. It should be fairly obvious that this stuff, which only shows up after you set an API key, is coming from your account. Especially if the settings page (looks like this at the moment) mentions what's going to happen, which is obviously a good idea anyway.
2-3. Similar deal here. I did spend rather a long time staring at different locations... chat links (and external links) feel like they're the sort of thing that should be snuggled at the bottom of the box. (But wait, {{Item Infobox}} doesn't do that, it puts the trade post price under the chat link. For consistency I suppose I should be suggesting moving the chat links to just above the external links in {{Default item parameter}}.)
4. I was thinking the same. There's nowhere to put it and I haven't even written the currency formatting code. It's got to be useful somewhere ("can I afford this item that requires dungeon tokens?"), but let's worry about that at some other time.
Unless I've forgotten anything, that list of templates looks right.
-- Dagger (talk) 16:48, 8 January 2016 (UTC)
Aaand mockups. (Yeah, I ended up copying the infobox HTML, or it would've been a pain to make multiple different versions.) The recipe box actually looks okay in either order, but what do you think about the item infobox? -- Dagger (talk) 20:51, 8 January 2016 (UTC)
Thank you (I know mockups suck to produce but they are useful). Just in the knowledge that the API stuff will load after the the rest of the page, and hence make anything below it drop down, I still think putting it at the bottom of every infobox is the way to go (this means youhave would go at the bottom of default item param, and dye/miniunlocked beneath default item param in each relevant infobox) -Chieftain AlexUser Chieftain Alex sig.png 00:23, 9 January 2016 (UTC)
Ah... yeah, that's a good reason, and something I was worried about. But that's been happening for me for the past two weeks and it actually hasn't been annoying me much. Not sure if that's just because I wrote the code and thus opted myself into the annoyance though.
I did think it might be possible to change the "hide" class to something specific ("api-hide"), and rather than removing the class from each node, instead run "if (API key set) { manipulate the CSS stylesheet to remove the effect of .api-hide; }" before the rest of the page rendered. But that involves running sync JS on page load, and I'm not quite sure how to even test that. -- Dagger (talk) 01:01, 10 January 2016 (UTC)