1
1
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
+ } ;
2
10
3
11
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
+
4
22
static get styles ( ) {
5
23
return css `
6
24
* {
@@ -29,6 +47,13 @@ export class WBBanner extends LitElement {
29
47
border-color: #a39d8f;
30
48
border-width: 0.1rem;
31
49
}
50
+ .refresh-button {
51
+ color: white;
52
+ background-color: transparent;
53
+ border: 0px;
54
+ margin-left: auto;
55
+ cursor: pointer;
56
+ }
32
57
.webrecorder-banner-top-line {
33
58
display: flex;
34
59
justify-items: space-between;
@@ -107,6 +132,8 @@ export class WBBanner extends LitElement {
107
132
}
108
133
109
134
render ( ) {
135
+ const dateStr = this . date ? dateTimeFormatter . format ( this . date ) : "" ;
136
+
110
137
return html `
111
138
< header class ="webrecorder-banner ">
112
139
< a href ="https://webrecorder.net/browsertrix " target ="_blank ">
@@ -124,7 +151,8 @@ export class WBBanner extends LitElement {
124
151
</ a >
125
152
< details class ="webrecorder-banner-text-container ">
126
153
< 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
128
156
</ summary >
129
157
< div class ="webrecorder-details-flexcontainer ">
130
158
< div class ="webrecorder-details-container ">
@@ -213,11 +241,23 @@ export class WBBanner extends LitElement {
213
241
</ div >
214
242
</ div >
215
243
</ 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 >
218
259
</ button >
219
260
</ header >
220
- ;
221
261
` ;
222
262
}
223
263
@@ -247,9 +287,11 @@ export function addBanner() {
247
287
return ;
248
288
}
249
289
250
- customElements . define ( "rwp-web-archive-banner" , WBBanner ) ;
290
+ const tagName = "rwp-web-archive-banner" ;
291
+
292
+ customElements . define ( tagName , WBBanner ) ;
251
293
252
- const banner = document . createElement ( "rwp-web-archive-banner" ) ;
294
+ const banner = document . createElement ( tagName ) ;
253
295
254
296
const html = document . querySelector ( "html" ) ;
255
297
if ( html ) {
@@ -259,7 +301,7 @@ export function addBanner() {
259
301
document . addEventListener ( "DOMContentLoaded" , ( ) => {
260
302
document . body . appendChild ( banner ) ;
261
303
setInterval ( ( ) => {
262
- if ( ! document . querySelector ( "web-archive-banner" ) ) {
304
+ if ( ! document . querySelector ( tagName ) ) {
263
305
document . body . appendChild ( banner ) ;
264
306
}
265
307
} , 1000 ) ;
0 commit comments