-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathlist.js
107 lines (87 loc) · 3.1 KB
/
list.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
$(function(){
get_designs_list("load_designs_list");
jquery_list("load_designs_list","Load",load_design);
//jquery_list("input_sensor_list",list_initial_value,update_sensor_fields);
//var list_div = document.getElementById('load_designs_list');
//if (list_div.addEventListener) list_div.addEventListener('DOMMouseScroll', wheelEvent_list, false);
//list_div.onmousewheel = wheelEvent_list;
});
function load_design(src,i){
console.log("Loading lens design: "+designs[i]);
var path = "";
var file = "";
if (designs[i].indexOf(pattern_remote)!=-1){
path = path_remote;
file = designs[i].replace(pattern_remote,"");
}else{
path = path_local;
file = designs[i].replace(pattern_local,"");
}
getDesign(file,path);
}
function get_designs_list_sync(url,prefix) {
$.ajax({
//url: "./get_designs_list.php",
url: url,
async: false,
dataType: "xml",
success: function(data){fill_designs_list(data.getElementsByTagName("file"),prefix);}
});
}
var designs = Array();
function fill_designs_list(designs_list,prefix){
for (var i=0;i<designs_list.length;i++){
var tmp = designs_list[i];
if (tmp.length != 0) {
if (typeof(tmp.childNodes[0])!='undefined') designs.push(prefix+tmp.childNodes[0].nodeValue);
else designs.push = "";
}
}
}
function get_designs_list(element_id) {
var some_folder = "";
var folder_list = "";
if (some_folder!="Load") {
//get local list
get_designs_list_sync("./get_designs_list.php","local: ");
//get remote list from elphel's github
var list = "<div class='list_view'><ul>";
for(var i=0; i<designs.length; i++) {
list = list + "<li>"+designs[i]+"</li>";
}
get_designs_list_sync("./get_remote_designs_list.php","github: ");
for(var j=i; j<designs.length; j++) {
list = list + "<li>"+designs[j]+"</li>";
}
list = list + "</ul></div>";
}else{
list = "<div class='list_view'><ul></ul></div>";
}
$("#"+element_id).html(list);
//create links
$("#link_local").html("<a href='"+path_local+"'>Local files</a>");
$("#link_remote").html("<a href='"+path_remote_browse+"'>Remote files</a>");
}
function wheelEvent_list(event){
var delta = 0;
if (!event) event = window.event; // IE
if (event.wheelDelta) { //IE+Opera
delta = event.wheelDelta/120;
if (window.opera) delta = -delta;
} else if (event.detail) { // Mozilla
delta = -event.detail;
}
if (delta)
handleWheel_list(event,delta);
if (event.preventDefault)
event.preventDefault();
event.returnValue = false;
}
function handleWheel_list(event,delta) {
var tmp = $(".list_view ul").position().top;
console.log($(".list_view ul").position().top+" "+$(".list_view ul").offset().top);
var tmp2 = +tmp+20*delta;
if (tmp2 > -12) tmp2=-12;
if (tmp2 < (-$(".list_view ul").height()+$(".list_view").height()-12) ) tmp2=-$(".list_view ul").height()+$(".list_view").height()-12;
$(".list_view ul").css({top:tmp2+'px'});
}