diff options
author | luxagraf <sng@luxagraf.net> | 2018-02-05 10:55:36 -0600 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2018-02-05 10:55:36 -0600 |
commit | c037ed30f9d5845e46672ce5fdc39ef206b52040 (patch) | |
tree | 62fd7d6c4498db0c5b87522267287db6163cc1f0 /app/photos/static | |
parent | 4b2df9841a0cfd7e5630162d81c4c8369cf3ba0a (diff) |
added static dirs
Diffstat (limited to 'app/photos/static')
-rw-r--r-- | app/photos/static/image-preview.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/app/photos/static/image-preview.js b/app/photos/static/image-preview.js new file mode 100644 index 0000000..13445f2 --- /dev/null +++ b/app/photos/static/image-preview.js @@ -0,0 +1,37 @@ +function build_image_preview () { + var style = document.createElement('style'); + var url = window.location.href + var cur = url.split('/')[6]; + var container = document.createElement("div"); + container.className = "form-row field-image"; + var wrapper = document.createElement("div"); + var label = document.createElement("label"); + label.textContent = "Image:"; + var pwrap = document.createElement("p"); + var img = document.createElement("img"); + var request = new XMLHttpRequest(); + request.open('GET', '/photos/data/admin/preview/'+cur+'/', true); + request.onload = function() { + if (request.status >= 200 && request.status < 400) { + resp = request.responseText; + //console.log(resp); + img.src = resp; + } else { + console.log("server error"); + } + }; + request.onerror = function() { + console.log("error on request"); + }; + request.send(); + pwrap.appendChild(img); + wrapper.appendChild(label); + wrapper.appendChild(pwrap); + container.appendChild(wrapper); + parent = document.getElementById("luximage_form"); + node = parent.children[1].children[0]; + node.parentNode.insertBefore(container, node.previousSibling); +} +document.addEventListener("DOMContentLoaded", function(event) { + build_image_preview(); +}); |