Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split date from time and position it before URI-R in listing #566

Merged
merged 10 commits into from
Sep 25, 2018
2 changes: 2 additions & 0 deletions ipwb/assets/webui.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ details label#daemonStatusLabel {height: 10px; margin-top: 0; vertical-align: to
details label.twoRowLabel {height: 2.0em;}

form input[type=submit] {display: block; clear: both; margin: 0.5em auto 0 auto;}

span.datetime {color: #999; font-size: 0.8em; margin-right: 5px;}
14 changes: 10 additions & 4 deletions ipwb/assets/webui.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function handleSubmit () {
}

function shortestFirst (a, b) {
return a.length - b.length
return a.replace(/\/+$/, '').split('/').length - b.replace(/\/+$/, '').split('/').length
}

function hideURIs () {
Expand All @@ -15,6 +15,10 @@ function hideURIs () {
window.localStorage.setItem('showURIs', 'false')
}

function splitDatetime (datetime) {
return datetime.replace(/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/, '$1-$2-$3 $4:$5:$6')
}

function addURIListToDOM () {
let ul = document.getElementById('uriList')
const uriKeys = Object.keys(uris).sort(shortestFirst)
Expand All @@ -23,12 +27,14 @@ function addURIListToDOM () {
uris[urir].forEach(function (memento) {
let li = document.createElement('li')
let a = document.createElement('a')
let dt = document.createElement('span')
a.href = 'memento/' + memento['datetime'] + '/' + urir
a.appendChild(document.createTextNode(urir))
dt = document.createTextNode(' (' + memento['datetime'] + ')')
a.appendChild(document.createTextNode(memento['title'] || urir))
dt.setAttribute('class', 'datetime')
dt.appendChild(document.createTextNode(splitDatetime(memento['datetime'])))

li.appendChild(a)
li.appendChild(dt)
li.appendChild(a)

li.setAttribute('data-mime', memento['mime'])
li.setAttribute('data-status', memento['status'])
Expand Down