root / src / pithos / content / pithos.js @ 29:ec9750e9cceb
History | View | Annotate | Download (2.6 kB)
1 |
|
---|---|
2 |
// event to quit toolbar button
|
3 |
function quit_client() { |
4 |
alert('Pithos Firefox client will now disconnect from the server');
|
5 |
window.location.replace('https://pithos.grnet.gr/Shibboleth.sso/Logout');
|
6 |
} |
7 |
|
8 |
function open_shared() { |
9 |
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
10 |
window.showModalDialog("shared/shared.xul", undefined, "dialogwidth: 640; dialogheight:480"); |
11 |
} |
12 |
|
13 |
function open_trash() { |
14 |
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
15 |
window.showModalDialog("trash/trash.xul", undefined, "dialogwidth: 640; dialogheight:480"); |
16 |
} |
17 |
|
18 |
function TreeModel(tree_id) { |
19 |
// public members
|
20 |
this.children_tag = document.getElementById(tree_id);
|
21 |
// private members
|
22 |
|
23 |
var leftTree = (tree_id == 'treech-left'); |
24 |
var current = this; |
25 |
|
26 |
// public functions
|
27 |
|
28 |
this.populate = function(dir_obj) { |
29 |
while(current.children_tag.hasChildNodes()) {
|
30 |
current.children_tag.removeChild(current.children_tag.firstChild); |
31 |
} |
32 |
|
33 |
// add previous dir
|
34 |
if(dir_obj.parentFolder != null) { |
35 |
var a = new Array(); |
36 |
|
37 |
a[0] = "../skin/up.png"; |
38 |
a[1] = ".."; |
39 |
a[2] = "<PARENT-DIR>"; |
40 |
a[3] = ""; |
41 |
a[4] = ""; |
42 |
addData(dir_obj.parentFolder, a, false);
|
43 |
} |
44 |
// add the following
|
45 |
for (var fldr in dir_obj.folders) { |
46 |
this.addFolder(dir_obj.folders[fldr]);
|
47 |
} |
48 |
|
49 |
for (var fl in dir_obj.files) { |
50 |
this.addFile(dir_obj.files[fl]);
|
51 |
} |
52 |
} |
53 |
|
54 |
this.addFolder = function(folder_obj) { |
55 |
var a = new Array(); |
56 |
|
57 |
a[0] = folder_obj.contentImage;
|
58 |
a[1] = folder_obj.name;
|
59 |
a[2] = "<DIRECTORY>"; |
60 |
a[3] = ""; |
61 |
a[4] = ""; |
62 |
|
63 |
addData(folder_obj.URI, a, false);
|
64 |
} |
65 |
|
66 |
this.addFile = function(file_obj) { |
67 |
var a = new Array(); |
68 |
var d = new Date(); |
69 |
d.setTime(file_obj.creationDate); |
70 |
|
71 |
a[0] = file_obj.contentImage;
|
72 |
a[1] = file_obj.name;
|
73 |
a[2] = file_obj.size;
|
74 |
a[3] = d.getDate() + '/' + (d.getMonth() + 1) + '/' + d.getFullYear(); |
75 |
a[4] = file_obj.version;
|
76 |
|
77 |
addData(file_obj.URI, a, true);
|
78 |
} |
79 |
|
80 |
// private functions
|
81 |
function addData(id, data_array, isFile) { |
82 |
var treeitem = document.createElement('treeitem'); |
83 |
current.children_tag.appendChild(treeitem); |
84 |
// treerow addition
|
85 |
var treerow = document.createElement('treerow'); |
86 |
treerow.setAttribute('id', id);
|
87 |
treerow.setAttribute('isFile', isFile);
|
88 |
treeitem.appendChild(treerow); |
89 |
// treecell addition
|
90 |
for (var i in data_array) { |
91 |
var treecell = document.createElement('treecell'); |
92 |
if(i == 0) { |
93 |
treecell.setAttribute('src', data_array[i]);
|
94 |
} else {
|
95 |
treecell.setAttribute('label', data_array[i]);
|
96 |
} |
97 |
treerow.appendChild(treecell); |
98 |
} |
99 |
} |
100 |
|
101 |
// initialisation
|
102 |
} |
103 |
|