Skip to content

Commit a33f0e1

Browse files
committed
add archived timestamp to banner
make it easier to test banner
1 parent 0cbd7e2 commit a33f0e1

File tree

3 files changed

+68
-8
lines changed

3 files changed

+68
-8
lines changed

Diff for: proxy-test.html

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<html>
2+
<head>
3+
<script>
4+
const wbinfo = {};
5+
wbinfo.url = "https://www.cdc.gov/";
6+
wbinfo.timestamp = "20250125223246";
7+
wbinfo.request_ts = "20250125223246000";
8+
wbinfo.mod = "id_";
9+
wbinfo.collName = "CDC";
10+
wbinfo.collUrl = "https://app.browsertrix.com/explore/usgov-archive/collections/cdc";
11+
self.__wbinfo = wbinfo;
12+
</script>
13+
<script src="./proxyui.js?banner=1"></script>
14+
</head>
15+
<body>
16+
Test
17+
</body>
18+
</html>

Diff for: src/proxyreplay/banner.ts

+49-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
import { html, css, LitElement } from "lit";
2+
import { tsToDate } from "../pageutils";
3+
import { dateTimeFormatter } from "../utils/dateTimeFormatter";
4+
import fasRefresh from "@fortawesome/fontawesome-free/svgs/solid/redo-alt.svg";
5+
6+
declare let self: Window & {
7+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8+
__wbinfo: any;
9+
};
210

311
export class WBBanner extends LitElement {
12+
private date: Date | null = null;
13+
14+
constructor() {
15+
super();
16+
17+
if (self.__wbinfo && self.__wbinfo.timestamp) {
18+
this.date = tsToDate(self.__wbinfo.timestamp) as Date;
19+
}
20+
}
21+
422
static get styles() {
523
return css`
624
* {
@@ -29,6 +47,13 @@ export class WBBanner extends LitElement {
2947
border-color: #a39d8f;
3048
border-width: 0.1rem;
3149
}
50+
.refresh-button {
51+
color: white;
52+
background-color: transparent;
53+
border: 0px;
54+
margin-left: auto;
55+
cursor: pointer;
56+
}
3257
.webrecorder-banner-top-line {
3358
display: flex;
3459
justify-items: space-between;
@@ -107,6 +132,8 @@ export class WBBanner extends LitElement {
107132
}
108133

109134
render() {
135+
const dateStr = this.date ? dateTimeFormatter.format(this.date) : "";
136+
110137
return html`
111138
<header class="webrecorder-banner">
112139
<a href="https://webrecorder.net/browsertrix" target="_blank">
@@ -124,7 +151,8 @@ export class WBBanner extends LitElement {
124151
</a>
125152
<details class="webrecorder-banner-text-container">
126153
<summary class="webrecorder-banner-text">
127-
This site is served from a web archive hosted with Browsertrix
154+
You are viewing an archived web page. The page was archived on
155+
${dateStr}. More Details
128156
</summary>
129157
<div class="webrecorder-details-flexcontainer">
130158
<div class="webrecorder-details-container">
@@ -213,11 +241,23 @@ export class WBBanner extends LitElement {
213241
</div>
214242
</div>
215243
</details>
216-
<button style="margin-left: auto;" @click="${this.fullReload}">
217-
Full Reload
244+
<button
245+
class="refresh-button narrow is-borderless"
246+
id="refresh"
247+
@click="${this.fullReload}"
248+
title="Full Reload"
249+
aria-label="Full Reload"
250+
>
251+
<span class="icon is-small">
252+
<fa-icon
253+
size="1.0em"
254+
class="has-text-grey"
255+
aria-hidden="true"
256+
.svg="${fasRefresh}"
257+
></fa-icon>
258+
</span>
218259
</button>
219260
</header>
220-
;
221261
`;
222262
}
223263

@@ -247,9 +287,11 @@ export function addBanner() {
247287
return;
248288
}
249289

250-
customElements.define("rwp-web-archive-banner", WBBanner);
290+
const tagName = "rwp-web-archive-banner";
291+
292+
customElements.define(tagName, WBBanner);
251293

252-
const banner = document.createElement("rwp-web-archive-banner");
294+
const banner = document.createElement(tagName);
253295

254296
const html = document.querySelector("html");
255297
if (html) {
@@ -259,7 +301,7 @@ export function addBanner() {
259301
document.addEventListener("DOMContentLoaded", () => {
260302
document.body.appendChild(banner);
261303
setInterval(() => {
262-
if (!document.querySelector("web-archive-banner")) {
304+
if (!document.querySelector(tagName)) {
263305
document.body.appendChild(banner);
264306
}
265307
}, 1000);

Diff for: src/proxyreplay/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { addBanner } from "./banner";
22
import { addInit } from "./app";
33

44
if (
5-
navigator.serviceWorker.controller &&
5+
//navigator.serviceWorker.controller &&
66
(document.currentScript as HTMLScriptElement).src.endsWith("banner=1")
77
) {
88
addBanner();

0 commit comments

Comments
 (0)