diff --git a/rockstar/rockstar.css b/rockstar/rockstar.css index 90ab4c9a..d15d2034 100644 --- a/rockstar/rockstar.css +++ b/rockstar/rockstar.css @@ -27,4 +27,7 @@ } .hoverDiv:hover { background-color: #f0f0f0; -} \ No newline at end of file +} +.rs_headerTable td { + padding: 8px; +} diff --git a/rockstar/rockstar.js b/rockstar/rockstar.js index a4fb0d37..b657ca2b 100644 --- a/rockstar/rockstar.js +++ b/rockstar/rockstar.js @@ -979,14 +979,34 @@ } requestJSON({url, method: method.value, data: data.value}).then((objects, status, jqXHR) => { $(results).html("
"); - var linkHeader = jqXHR.getResponseHeader("Link"); // TODO: maybe show X-Rate-Limit-* headers, too. + var linkHeader = jqXHR.getResponseHeader("Link"); + var remaining = jqXHR.getResponseHeader("X-Rate-Limit-Remaining"); + var limit = jqXHR.getResponseHeader("X-Rate-Limit-Limit"); + var reset = new Date(jqXHR.getResponseHeader("X-Rate-Limit-Reset") * 1000); + var headersTable = + ` +
Headers
+
Rate Limit ${limit} +
Rate Limit Remaining ${remaining} +
Rate Limit Reset ${reset} + `; if (linkHeader) { - $(results).html("
Headers
Link" + linkHeader.replace(/") + "

"); + $(results).html( + headersTable + + '
Link' + + linkHeader.replace(/") + + '

' + ); var links = getLinks(linkHeader); if (links.next) { var nextUrl = new URL(links.next); // links.next is an absolute URL; we need a relative URL. nextUrl = nextUrl.pathname + nextUrl.search; } + } else if (!linkHeader) { + $(results).html( + headersTable + + '
' + ); } $(results).append("Status: " + jqXHR.status + " " + jqXHR.statusText + "
"); if (objects) {