Skip to content

Commit 2fdc553

Browse files
authored
Merge pull request #279 from machawk1/issue-181
Add nav links when viewing a memento
2 parents a04cd8a + 6c8dd5e commit 2fdc553

File tree

5 files changed

+76
-6
lines changed

5 files changed

+76
-6
lines changed

mink-plugin/css/minkui.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ h1 {font-size: 14px; font-family: 'Futura', 'Century Gothic', AppleGothic, sans-
3333
#drilldownBox ul li span.memCount {float: right; font-family: Monaco, Courier, sans-serif; padding: 0px 3px; margin-right: 5px; border-radius: 2px; line-height: 10px;}
3434

3535
.disabled {color: #999;}
36+
button.viewingMemento {text-decoration: underline;}
37+
button#memento_first {margin-left: 2.0em;}

mink-plugin/js/displayMinkUI.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,39 @@ function appendHTMLToShadowDOM () {
4848
$('#title_dropdown').addClass('hidden')
4949
$('#archiveNow').addClass('hidden')
5050
$('#viewingMementoInterface').removeClass('hidden')
51+
5152
$('#mementosAvailable').html('Viewing memento at ' + (new Date(items.timemaps[document.URL].datetime)))
53+
54+
const firstButton = $('#memento_first')
55+
const lastButton = $('#memento_last')
56+
const prevButton = $('#memento_prev')
57+
const nextButton = $('#memento_next')
58+
59+
items.timemaps[document.URL].mementos.forEach(function (mem) {
60+
let targetButton
61+
if (mem.first === true) {
62+
targetButton = firstButton
63+
}
64+
if (mem.last === true) {
65+
targetButton = lastButton
66+
}
67+
if (mem.next === true) {
68+
targetButton = nextButton
69+
}
70+
if (mem.prev === true) {
71+
targetButton = prevButton
72+
}
73+
74+
if (typeof targetButton !== 'undefined') {
75+
if (mem.uri === window.document.URL) {
76+
targetButton.addClass('viewingMemento')
77+
}
78+
79+
targetButton.removeAttr('disabled')
80+
targetButton.attr('data-uri', mem.uri)
81+
}
82+
})
83+
5284
cb = createShadowDOM
5385
} else if (mCount > MAX_MEMENTOS_IN_DROPDOWN) {
5486
$('.dropdown').addClass('hidden')
@@ -520,6 +552,7 @@ function setupUI () {
520552
bindGoBackToMainInterfaceButton()
521553
bindArchiveLogos()
522554
bindGoBackToLiveWebButton()
555+
bindNavigationButtons()
523556

524557
$('#viewMementoButton').click(function () {
525558
window.location = $(this).attr('alt')
@@ -748,6 +781,14 @@ function bindGoBackToLiveWebButton () {
748781
})
749782
}
750783

784+
function bindNavigationButtons () {
785+
['first', 'last', 'next', 'prev'].forEach(function attachURI (rel) {
786+
document.getElementById('memento_' + rel).addEventListener('click', event => {
787+
window.location = event.target.getAttribute('data-uri')
788+
})
789+
})
790+
}
791+
751792
if ($('#minkWrapper').length === 0) {
752793
appendHTMLToShadowDOM()
753794
} else {

mink-plugin/minkui.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@ <h1 id="mementosAvailable"><span id="mementoCount"></span> <span id="mementoPlur
1313
<span class="archiveNowInterface">Archive Page To...</span>
1414
<img src="images/iaLogo.png" alt="Internet Archive" id="archivelogo_ia" class="archiveNowInterface archiveLogo" />
1515
<img src="images/archiveisLogo.png" alt="Archive.is" id="archivelogo_ais" class="archiveNowInterface archiveLogo" />
16-
<img src="images/webcitelogo.png" alt="WebCite" id="archivelogo_webcite" class="archiveNowInterface archiveLogo"/>
16+
<img src="images/webcitelogo.png" alt="WebCite" id="archivelogo_webcite" class="archiveNowInterface archiveLogo"/>
1717
<img src="images/allListedArchives.png" alt="All Listed Archives" id="archivelogo_ala" class="archiveNowInterface archiveLogo" />
1818
<button class="archiveNowInterface hideInNoMementosInterface" id="goBackButton">&lt; Go Back</button>
1919
</span>
2020
<span id="viewingMementoInterface" class="hidden">
21-
<button id="backToLiveWeb">Back to Live Web</button><!--
22-
<button>Temporally previous memento</button>
23-
<button>Temporally next memento</button>-->
21+
<button id="backToLiveWeb">Back to Live Web</button>
22+
<button id="memento_first" >First</button>
23+
<button id="memento_prev" disabled>Previous</button>
24+
&nbsp;&bull;&nbsp;
25+
<button id="memento_next" disabled>Next</button>
26+
<button id="memento_last" disabled>Last</button>
2427
</span>
2528
<!--<input type="button" value="?" id="helpButton" />-->
2629

mink-plugin/style.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
/* Do not display UI elements for non-selected view of list of mementos */
8181
.hiddenUI {display: none;}
8282

83-
8483
/* This isn't working, the image ought to be pulled from the extension, not the current page */
8584
/* option.ia {background-image: url('images/archives/ia.png');}*/
8685

mink-plugin/timemap.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function Timemap (fromString) {
4242
const mementoregex = new RegExp(mementoRelMementoExpression) // Regex to get a memento
4343

4444
const mementoRelSelfExpression = /rel=.*self.*/gi
45-
const mselfregex = new RegExp(mementoRelSelfExpression) // Regex to get a memento
45+
const mselfregex = new RegExp(mementoRelSelfExpression) // Regex to get self
4646

4747
this.mementos = []
4848

@@ -105,6 +105,31 @@ function Memento (fromStr) {
105105
this.uri = this.str.substring(this.str.indexOf('<') + 1, this.str.indexOf('>'))
106106
this.datetime = this.str.substr(this.str.indexOf('datetime')) // Abbreviation to just include datetime string and on
107107
this.datetime = this.datetime.substr(this.datetime.indexOf('"')).replace(/"/g, '').trim()
108+
109+
const mementoRelFirstExpression = /rel=.*first.*/gi
110+
const mfirstregex = new RegExp(mementoRelFirstExpression) // Regex to get first
111+
112+
const mementoRelLastExpression = /rel=.*last.*/gi
113+
const mlastregex = new RegExp(mementoRelLastExpression) // Regex to get last
114+
115+
const mementoRelNextExpression = /rel=.*next.*/gi
116+
const mnextregex = new RegExp(mementoRelNextExpression) // Regex to get next
117+
118+
const mementoRelPrevExpression = /rel=.*prev.*/gi
119+
const mprevregex = new RegExp(mementoRelPrevExpression) // Regex to get next
120+
121+
if (fromStr.match(mfirstregex)) {
122+
this.first = true
123+
}
124+
if (fromStr.match(mlastregex)) {
125+
this.last = true
126+
}
127+
if (fromStr.match(mnextregex)) {
128+
this.next = true
129+
}
130+
if (fromStr.match(mprevregex)) {
131+
this.prev = true
132+
}
108133
}
109134

110135
/* ***************************

0 commit comments

Comments
 (0)