-
Notifications
You must be signed in to change notification settings - Fork 3
/
drawer.js
59 lines (42 loc) · 1.4 KB
/
drawer.js
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
52
53
54
55
56
57
58
59
function default_drawer(node, target_div) {
target_div = target_div || div_main
//console.info(node)
}
function capture_drawer(node, target_div) {
target_div = target_div || div_main
var data = node.data
var tbl = document.createElement("table");
var tblBody = document.createElement("tbody");
var img = document.createElement("img");
img.src = data["filepath"][curr_image_type]//.replace('\.','./processed')
var imageTypes = data["filepath"];
for(var itype in imageTypes){
var button = document. createElement("button");
button.innerHTML = itype;
funcSetType = function(typeToSet){
return function() {
curr_image_type = typeToSet
var stateObj = {};
history.pushState(stateObj, node.path, "?u=" + node.path+"&cit="+curr_image_type);
img.src = data["filepath"][curr_image_type]
}
}
button.addEventListener ("click", funcSetType(itype));
target_div.appendChild(button);
}
target_div.appendChild(document.createElement("br"));
for(var v in data){
var row = document.createElement("tr");
row.appendChild(blue_td_with_text(v))
row.appendChild(td_with_text(node.data[v] + ""))
tbl.appendChild(row)
}
//target_div.innerHTML = JSON.stringify(node.data)
tbl.appendChild(tblBody)
target_div.appendChild(img)
target_div.appendChild(tbl)
}
drawers = {}
drawers["default"] = default_drawer
drawers["capture"] = capture_drawer
curr_image_type = curr_image_type || "PNG"