User:Dagger/Widget drafts/API dye unlocks.js
From Guild Wars 2 Wiki
Jump to navigationJump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
$(function() {
if (!window.API || $(".api-dyeunlocked").length == 0) return;
$.when(API.fetch("account/dyes")).then(function(data) {
$(".api-dyeunlocked").each(function() {
var colorId = parseInt(this.getAttribute("data-colorid"));
if (!colorId) return;
if (data.indexOf(colorId) > -1)
$(this).text("Yes");
else
$(this).text("No");
});
}, function onFail(f) {
$(".api-dyeunlocked").html("<i>API Error</i>").attr("title", JSON.stringify(f));
API.log("Error: ", f);
});
});