Skip to content

Commit

Permalink
Merge pull request #566 from oduwsdl/split-datetime
Browse files Browse the repository at this point in the history
Split date from time and position it before URI-R in listing
  • Loading branch information
machawk1 authored Sep 25, 2018
2 parents 7558bc7 + 971249a commit 95d9c7b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
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

0 comments on commit 95d9c7b

Please sign in to comment.