Skip to content

Commit

Permalink
fix empty external links render & adapt render to trakt broken links …
Browse files Browse the repository at this point in the history
…list
  • Loading branch information
nliautaud committed Aug 20, 2017
1 parent 242876b commit 1fc4207
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions js/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ layout = function() {

addExternalLinks = function() {
var list = document.querySelector('.sidebar .external')
if(!list) return
if(!list || !options.layoutExternalLinks) return

var title = document.querySelector('h1').innerText

Expand All @@ -18,9 +18,10 @@ addExternalLinks = function() {

options.layoutExternalLinks.split(',').forEach(function(domain) {
var goourl = 'http://www.google.com/search?btnI&q='
var new_el = list.firstChild.cloneNode(true)
new_el.firstChild.href = goourl + title + ' ' + domain
new_el.firstChild.innerHTML = new_el.firstChild.innerHTML.replace(/[^<]+/, domain)
list.appendChild(new_el)
var firstlink = list.querySelector('a')
var new_el = firstlink.cloneNode(true)
new_el.href = goourl + title + ' ' + domain
new_el.innerHTML = domain
firstlink.parentElement.appendChild(new_el)
})
}

0 comments on commit 1fc4207

Please sign in to comment.