blob: ca965657b8440c371071851d0980b06fc33068c2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
function add_images(){
var el = document.getElementById("id_body_markdown");
if (el){
var iframe='<iframe id="images_frame" frameborder="0" style="border: #dddddd 1px solid;margin-left: 20px;width:330px; height:720px;" src="/luximages/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('/photos/data/admin/tn/'+cur+'/');
var request = new XMLHttpRequest();
request.open('GET', '/photos/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_images();
if (document.forms["post_form"]) {
md = document.forms["post_form"].elements["body_markdown"];
} else {
md = document.forms["track_form"].elements["body_markdown"];
}
md.style.maxHeight = "300rem";
md.style.maxWidth = "300rem";
});
|