summaryrefslogtreecommitdiff
path: root/app/utils/static/next-prev-links.js
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2018-02-05 10:55:36 -0600
committerluxagraf <sng@luxagraf.net>2018-02-05 10:55:36 -0600
commitc037ed30f9d5845e46672ce5fdc39ef206b52040 (patch)
tree62fd7d6c4498db0c5b87522267287db6163cc1f0 /app/utils/static/next-prev-links.js
parent4b2df9841a0cfd7e5630162d81c4c8369cf3ba0a (diff)
added static dirs
Diffstat (limited to 'app/utils/static/next-prev-links.js')
-rw-r--r--app/utils/static/next-prev-links.js34
1 files changed, 34 insertions, 0 deletions
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();
+});