diff options
author | luxagraf <sng@luxagraf.net> | 2019-11-05 11:15:30 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2019-11-05 11:15:30 -0500 |
commit | b1057c9dc9ff6b6e1786d31e3401ad9571eb7f1d (patch) | |
tree | c3247bc40c63bf5df1c6fecee75a81b7c2ebafde /app/products/static | |
parent | 725e3d2f798d228a386466823490b6f25647a4db (diff) |
added products
Diffstat (limited to 'app/products/static')
-rw-r--r-- | app/products/static/product-loader.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/app/products/static/product-loader.js b/app/products/static/product-loader.js new file mode 100644 index 0000000..20ec0d6 --- /dev/null +++ b/app/products/static/product-loader.js @@ -0,0 +1,47 @@ +function add_products(){ + var el = document.getElementById("id_body_markdown"); + if (el){ + var iframe = '<iframe frameborder="0" style="border: #dddddd 1px solid;margin-left: 20px;width:330px; height:720px;" src="/luxproduct/insert/?textarea='+el.id+'"></iframe>'; + el.insertAdjacentHTML('afterend', iframe); + } + + var featured_image = document.getElementById("id_featured_image") + + if (featured_image) { + featured_image.querySelectorAll('li').forEach(function(element) { + var cur = element.dataset.imageid; + var loop = Number(element.dataset.loopcounter); + if (cur != "") { + if (loop <= 100) { + console.log(loop); + var request = new XMLHttpRequest(); + request.open('GET', '/photos/luximage/data/admin/tn/'+cur+'/', true); + request.onload = function() { + if (request.status >= 200 && request.status < 400) { + var data = JSON.parse(request.responseText); + var el = element.getElementsByTagName('label')[0]; + url = "url('"+data['url']+"');"; + //console.log(url); + el.style.backgroundImage = 'url('+data["url"]+')'; + + //console.log(el.style); + } else { + console.log("server error", request.statusText); + } + }; + request.onerror = function() { + console.log("error on request"); + }; + request.send(); + } + } + }); + } + +} +document.addEventListener("DOMContentLoaded", function(event) { + add_products(); + md = document.forms["entry_form"].elements["body_markdown"]; + md.style.maxHeight = "300rem"; + md.style.maxWidth = "300rem"; +}); |