From c037ed30f9d5845e46672ce5fdc39ef206b52040 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Mon, 5 Feb 2018 10:55:36 -0600 Subject: added static dirs --- app/utils/static/next-prev-links.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/utils/static/next-prev-links.js (limited to 'app/utils/static/next-prev-links.js') diff --git a/app/utils/static/next-prev-links.js b/app/utils/static/next-prev-links.js new file mode 100644 index 0000000..7af1b66 --- /dev/null +++ b/app/utils/static/next-prev-links.js @@ -0,0 +1,34 @@ +function build_next_prev() { + var url = window.location.href + var style = document.createElement('style'); + style.type = 'text/css'; + style.innerHTML = '.np-container {padding-left: 0;} .prev, .next {display: inline-block; margin-right: .5em;} .prev:after { content: "|"; margin-left:.5em;} .prev a:before {content: "\u00AB"; margin-right: 3px;} .next a:after{content: "\u00BB"; margin-left: 3px;}'; + document.getElementsByTagName('head')[0].appendChild(style); + var cur = Number(url.split('/')[6]); + var base_url = url.split(cur)[0]; + var next = cur+1; + var prev = cur-1; + var container = document.createElement("ul"); + var next_li = document.createElement("li"); + var next_link = document.createElement("a"); + var prev_li = document.createElement("li"); + var prev_link = document.createElement("a"); + prev_li.className = "prev"; + next_li.className = "next"; + container.className = "np-container"; + next_link.href = base_url + next + "/change/"; + next_link.textContent = "Next"; + prev_link.href = base_url + prev + "/change/"; + prev_link.textContent = "Prev"; + next_li.appendChild(next_link); + prev_li.appendChild(prev_link); + container.appendChild(prev_li); + container.appendChild(next_li); + console.log(container); + Array.from(document.getElementsByClassName('object-tools')).forEach(function(item) { + item.parentNode.insertBefore(container, item.nextSibling); + }) +}; +document.addEventListener("DOMContentLoaded", function(event) { + build_next_prev(); +}); -- cgit v1.2.3-70-g09d2