annotate xul/content/annota.js @ 209:f8c82fea551a

Servlet version 1.18b9 -- cleanup and bugfixes - fixed bug with slow color JPEGs - better pathname handling - better filehandle cleanup (hopefully)
author robcast
date Fri, 12 Mar 2004 19:52:07 +0100
parents bf945fcf9105
children 8e4724b71b67
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
203
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
1 include ('chrome://jslib/content/io/dir.js');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
2 include ('chrome://jslib/content/io/file.js');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
3 /*include ('chrome://jslib/content/io/rdfBase.js');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
4 include ('chrome://jslib/content/io/rdfResource.js');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
5 include ('chrome://jslib/content/io/rdfContainer.js');*/
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
6 include ('chrome://jslib/content/io/rdf.js');/*
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
7 include ('chrome://jslib/content/io/rdfFile.js');*/
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
8 include ('chrome://jslib/content/io/fileUtils.js');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
9
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
10 var slash='/';
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
11 if (navigator.platform=="Win32"){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
12 slash='\\';
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
13 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
14
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
15 var directory=slash;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
16 var digilib_path=slash;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
17
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
18 getProfile();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
19
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
20 function makePathCompatible(path){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
21 if (navigator.platform=="Win32"){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
22 // slash durch backslash ersetzten
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
23 path=path.replace(/\//g,"\\");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
24 // nur 2 backslashs am anfang
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
25 path=path.replace(/^\\{3}/,"\\\\");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
26 // vor Laufwerkbuchstaben kein Backslash
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
27 if (path.indexOf(":")>0){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
28 path=path.replace(/^\\/g,"");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
29 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
30 // nur ein Slash gibt Absturz
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
31 path=path.replace(/^\\$/,"c:\\");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
32 //alert(path);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
33 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
34 return path;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
35 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
36
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
37 function file_open(){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
38 var nsIFilePicker = Components.interfaces.nsIFilePicker;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
39 var fp = Components.classes["@mozilla.org/filepicker;1"]
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
40 .createInstance(nsIFilePicker);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
41 fp.init(window, "Select a Directory", nsIFilePicker.modeGetFolder);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
42
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
43 // set default direcotry
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
44 var aLocalFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
45 directory=makePathCompatible(directory);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
46 aLocalFile.initWithPath(directory);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
47 fp.displayDirectory=aLocalFile;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
48
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
49 var res=fp.show();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
50 if (res==nsIFilePicker.returnOK){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
51 directory=fp.fileURL.path;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
52 directory=makePathCompatible(directory);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
53 setTreeDirectory();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
54 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
55 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
56
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
57 function setTreeDirectory(){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
58 var t=document.getElementById("file_tree");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
59 t.setAttribute("datasources","file://"+directory+'test.rdf');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
60 //alert('datasource: '+ t.getAttribute("datasources"));
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
61 //alert('Directory: file://'+directory+'/test.rdf');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
62 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
63
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
64 function refreshTree(){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
65 var t=document.getElementById("file_tree");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
66 t.builder.rebuild();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
67 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
68
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
69 function getAttributeOfSelectedNode(attribute) {
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
70 var tree=document.getElementById("file_tree");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
71 try {
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
72 return tree.view.getCellText(tree.currentIndex,attribute);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
73 } catch(e) {
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
74 return '';
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
75 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
76 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
77
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
78 /*
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
79 function createSequence(completeURN) {
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
80 if(completeURN.indexOf(slash) != -1) {
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
81 alert('Recursion: '+completeURN);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
82 //lowest sequence
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
83 var seqNodeContainer = dataSource.getNode(completeURN.substring(0,completeURN.lastIndexOf(":")));
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
84 seqNodeContainer.makeSeq();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
85 //lowest description
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
86 var rootNodeContainer = dataSource.getNode(completeURN.substring(0,completeURN.lastIndexOf(":")));
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
87 var fnTemp = completeURN.substring(0,completeURN.lastIndexOf(":"));
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
88 rootNodeContainer.addTarget("http://echo.unibe.ch/digilib/rdf#fn",completeURN.substring(
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
89 fnTemp.lastIndexOf(":")+1,completeURN.lastIndexOf(":")));
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
90
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
91 completeURN = completeURN.replace(slash,':');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
92
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
93 //next higher sequence
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
94 var seqNode = dataSource.getNode(completeURN.substring(0,completeURN.lastIndexOf(":")));
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
95 seqNode.makeSeq();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
96 //next higher description
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
97 var rootNode = dataSource.getNode(completeURN.substring(0,completeURN.lastIndexOf(":")));
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
98 fnTemp = completeURN.substring(0,completeURN.lastIndexOf(":"));
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
99 rootNode.addTarget("http://echo.unibe.ch/digilib/rdf#fn",completeURN.substring(
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
100 fnTemp.lastIndexOf(":")+1,completeURN.lastIndexOf(":")));
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
101 seqNodeContainer.addChild(rootNode);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
102 alert('Recursion end: '+completeURN);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
103
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
104 if(completeURN.lastIndexOf(slash) == -1) {
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
105 alert('Recursion finished : '+completeURN);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
106 var node = dataSource.getNode(completeURN);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
107 var arrayParams=window.content.listParameters();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
108 for (i=0; i< arrayParams.length; i++){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
109 var value=window.content.getParameter(arrayParams[i]);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
110 //alert(arrayParams[i]+":"+value);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
111 node.addTarget("http://echo.unibe.ch/digilib/rdf#"+arrayParams[i],value);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
112 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
113 node.addTarget("http://echo.unibe.ch/digilib/rdf#lv","1");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
114 seqNode.addChild(node);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
115 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
116 this.createSequence(completeURN);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
117 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
118 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
119 */
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
120
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
121 /**
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
122 * @todo isn't complex yet...
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
123 */
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
124 function createComplexRDFEntry(completeURN) {
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
125 var title = window.prompt("Please enter a title for this Annotation",this.getAttributeOfSelectedNode('name'));
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
126 alert('Title: '+title);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
127 var echoContainer = dataSource.getNode("urn:echo");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
128 echoContainer.makeSeq();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
129
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
130 echoContainer.addChild(completeURN);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
131 var node = dataSource.getNode(completeURN);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
132 var arrayParams=window.content.listParameters();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
133 for (i=0; i< arrayParams.length; i++){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
134 var value=window.content.getParameter(arrayParams[i]);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
135 //alert(arrayParams[i]+":"+value);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
136 node.addTarget("http://echo.unibe.ch/digilib/rdf#"+arrayParams[i],value);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
137 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
138 node.addTarget("http://echo.unibe.ch/digilib/rdf#lv","1");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
139 node.addTarget("http://purl.org/dc/elements/1.0/title",title);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
140 node.addTarget("http://purl.org/dc/elements/1.0/creator","");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
141 node.addTarget("http://purl.org/dc/elements/1.0/date","");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
142 node.addTarget("http://www.w3.org/2000/10/annotation-ns#created","");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
143 node.addTarget("http://www.w3.org/2000/10/annotation-ns#Annotation","targetof");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
144 var node2 = dataSource.getNode("targetof");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
145 node2.addTarget("http://echo.unibe.ch/digilib/rdf#lv","1");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
146 /*ar subNode = dataSource.getNode('specialised');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
147 node.addChild(subNode,true);*/
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
148 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
149
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
150 function file_save(){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
151
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
152 // get Digilib-Parameter form Browser
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
153 //alert(window.content.location.href);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
154
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
155 var documentpath='';
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
156 try{
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
157 documentpath=window.content.getParameter('fn');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
158 documentpath=documentpath.replace(':',';');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
159 }catch (e){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
160 documentpath='';
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
161 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
162 if (documentpath != ''){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
163 //documentpath=documentpath.replace(slash,':');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
164 //alert(documentpath);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
165 var docPath='urn:echo:'+documentpath;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
166
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
167 var t=document.getElementById("file_tree");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
168 dataSource = new RDFDataSource(t.getAttribute("datasources"));
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
169 this.createComplexRDFEntry(docPath);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
170
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
171 /* //Create new Node
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
172 var node = dataSource.getNode(docPath);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
173 var arrayParams=window.content.listParameters();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
174 for (i=0; i< arrayParams.length; i++){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
175 var value=window.content.getParameter(arrayParams[i]);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
176 //alert(arrayParams[i]+":"+value);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
177 node.addTarget("http://echo.unibe.ch/digilib/rdf#"+arrayParams[i],value);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
178 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
179 node.addTarget("http://echo.unibe.ch/digilib/rdf#lv","1");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
180 //Add the node to the Seq
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
181 var seqNode = dataSource.getNode(docPath.substring(0,docPath.lastIndexOf(":")));
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
182 if(seqNode.isContainer()) {
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
183 seqNode.addChild(node);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
184 } else {
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
185 seqNode.makeSeq();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
186 seqNode.addChild(node);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
187 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
188 */
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
189 dataSource.save();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
190 refreshTree();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
191 /*
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
192 var ds=new RDFDataSource();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
193 ds.parseFromString(rdfString,"http://echo.unibe.ch/digilib/rdf/digilib.rdf");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
194 var node=ds.getNode(docPath);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
195 var arrayParams=window.content.listParameters();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
196 for (i=0; i< arrayParams.length; i++){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
197 var value=window.content.getParameter(arrayParams[i]);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
198 //alert(arrayParams[i]+":"+value);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
199 node.addTarget("http://echo.unibe.ch/digilib/rdf#"+arrayParams[i],value);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
200 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
201 node.addTarget("http://echo.unibe.ch/digilib/rdf#lv","1");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
202 //alert(ds.serializeToString());
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
203 var nsIFilePicker = Components.interfaces.nsIFilePicker;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
204 var fp = Components.classes["@mozilla.org/filepicker;1"]
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
205 .createInstance(nsIFilePicker);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
206 fp.init(window, "Select a File", nsIFilePicker.modeSave);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
207
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
208 // set default direcotry
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
209 var aLocalFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
210 directory=makePathCompatible(directory);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
211 aLocalFile.initWithPath(directory);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
212 fp.displayDirectory=aLocalFile;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
213
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
214 fp.appendFilter("Annotations","*.rdf; *.RDF");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
215 var res=fp.show();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
216 if (res==nsIFilePicker.returnOK){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
217 var thefile=fp.file;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
218 // --- do something with the file here ---
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
219 //alert(fp.file);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
220 //alert(fp.fileURL.path);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
221
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
222 var strFilePath=fp.file.path;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
223 strFilePath=strFilePath.toLowerCase();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
224 if (strFilePath.indexOf('.rdf')<0){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
225 strFilePath=fp.fileURL.path+".rdf";
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
226 }else{
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
227 strFilePath=fp.fileURL.path;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
228 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
229 strFilePath=makePathCompatible(strFilePath);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
230 var f=new File(strFilePath);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
231 //var boolFileExists=f.exists();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
232 //alert(boolFileExists);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
233 f.create();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
234 f.open('w');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
235 f.write(ds.serializeToString());
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
236 f.close();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
237 refreshTree();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
238 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
239 //*/
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
240 } else{
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
241 alert("Error: no alcatraz component. can't create an annotation.");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
242 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
243 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
244
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
245
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
246 function file_local(){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
247 // noch nicht programmiert
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
248 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
249
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
250 function file_annotaDB(){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
251 alert("At the moment it is not possible to use the annota DB! This feature is not yet programmed.");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
252 var menu_item=document.getElementById('local');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
253 menu_item.setAttribute('checked','true');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
254 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
255
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
256 function tree_click(){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
257 var t=document.getElementById("file_tree"); //tree element
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
258 var l=t.view.getItemAtIndex(t.currentIndex); //aus baum treeitem herausholen mit dem selected index (currentIndex)
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
259 //l.firstChild ist treeitem
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
260 var d=l.firstChild.firstChild; //treecell
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
261 var firstLabel=d.getAttribute("label");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
262 var cols=document.getElementById("cols");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
263 var col=cols.childNodes;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
264 var nodes=l.firstChild.childNodes;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
265 var rdf_file="";
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
266 for (var i=0;i<nodes.length;i++){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
267 if (col[i].getAttribute("label")=="URL"){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
268 rdf_file=nodes[i].getAttribute("label");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
269 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
270 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
271 if (rdf_file!=""){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
272 send_annotation(rdf_file);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
273 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
274 alert(rdf_file);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
275 return rdf_file;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
276 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
277
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
278
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
279 /***
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
280 * Diese Funktion wird gebraucht um im Dialog den Pfad zu digilib zu setzen
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
281 *
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
282 ***/
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
283 function setDigilibPath(digilibPathValue){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
284 digilib_path=digilibPathValue;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
285 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
286
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
287 /***
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
288 * Dialog tools momentan kann man nur den Pfad zu digilib setzen
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
289 *
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
290 ***/
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
291 function show_dialog(dialog){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
292 if (dialog=="tool path"){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
293 window.openDialog("tools_dialog.xul","funny dialog",
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
294 "chrome",digilib_path,setDigilibPath);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
295 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
296 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
297
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
298
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
299 /***
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
300 * Gibt den Inhalt eines Files als String zurueck
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
301 *
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
302 ***/
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
303 function readFile(str_Filename){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
304 var f=new File(str_Filename);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
305 var str="";
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
306 if (f.isFile()){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
307 f.open();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
308 str=f.read();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
309 f.close();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
310 } else {
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
311 alert(str_Filename + " is not a file");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
312 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
313 return str;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
314 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
315
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
316
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
317
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
318 function send_annotation(rdf_file){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
319 rdf_file=rdf_file.replace(/^file:\/\//,"");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
320 rdf_file=makePathCompatible(rdf_file);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
321 digilib_path="http://pythia2.unibe.ch:8080/docuserver/digitallibrary";
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
322 alert("Send Annotation: "+rdf_file);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
323 strRdfFile=readFile(rdf_file);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
324 if (strRdfFile!=""){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
325 var formid='mainform';
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
326 alert(digilib_path+"/digilib.jsp");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
327 var form = createForm(formid, digilib_path+"/digilib.jsp", "post", "_content");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
328 //var form = createForm(formid, "http://sophia.unibe.ch:8080/examples/servlet/RequestRDF", "post", "_content");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
329 //var form = createForm(formid, "http://hera.unibe.ch:8080/examples/servlet/RequestRDF", "post", "_content");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
330 setFormData(form, formid, strRdfFile);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
331 form.submit();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
332 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
333 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
334
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
335 function createForm(formid, action, method, target)
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
336 {
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
337 var form = document.getElementById(formid);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
338 if(form != null)
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
339 document.documentElement.removeChild(form);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
340
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
341 var form = document.createElementNS("http://www.w3.org/1999/xhtml", "form");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
342 form.setAttribute("id", formid);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
343 form.setAttribute("action", action);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
344 form.setAttribute("method", method);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
345 form.setAttribute("target", target);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
346 document.documentElement.appendChild(form);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
347 return form;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
348 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
349
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
350 function setFormData(form, formid, rdf)
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
351 {
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
352 var val1 = document.createElementNS("http://www.w3.org/1999/xhtml", "input");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
353 val1.setAttribute('type', 'hidden');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
354 val1.setAttribute('name', 'rdf');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
355 val1.setAttribute('value', rdf);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
356 form.appendChild(val1);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
357 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
358
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
359
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
360 function getProfileDirectory(){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
361 // First get the directory service and query interface it to
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
362 // nsIProperties
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
363 var dirService = Components.
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
364 classes['@mozilla.org/file/directory_service;1'].
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
365 getService(Components.interfaces.nsIProperties);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
366
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
367 // Next get the "ProfD" property of type nsIFile from the directory
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
368 // service, FYI this constant is defined in
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
369 // mozilla/xpcom/io/nsAppDirectoryServiceDefs.h
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
370
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
371 const NS_APP_USER_PROFILE_50_DIR = "ProfD";
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
372 profileDir = dirService.get(NS_APP_USER_PROFILE_50_DIR,
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
373 Components.interfaces.nsIFile);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
374
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
375 // Now that we have it we can show it's path. See nsIFile for the
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
376 // other things you that can be done with profileDir
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
377 //alert(profileDir.path);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
378 return profileDir.path;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
379 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
380
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
381 function getProfile(){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
382 var strProfile=readFile(getProfileDirectory()+slash+"annota.dat");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
383 if (strProfile==""){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
384 directory=slash;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
385 digilib_path="http://hera.unibe.ch:8080/alcatraz";
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
386 setProfile();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
387 }else{
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
388 var params=strProfile.split("\n");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
389 for (var i=0;i<params.length;i++){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
390 var key_value=params[i].split("|");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
391 if (key_value[0]=='directory'){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
392 directory=key_value[1];
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
393 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
394 if (key_value[0]=='tool path'){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
395 digilib_path=key_value[1];
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
396 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
397 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
398 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
399 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
400
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
401 function setProfile(){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
402 var f=new File(getProfileDirectory()+slash+'annota.dat');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
403 f.create();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
404 f.open('w');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
405 f.write('directory|'+directory+'\n'+'tool path|'+digilib_path+'\n');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
406 f.close();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
407 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
408
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
409 function traverse(node){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
410 if (node.hasChildNodes){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
411 var arr_nodes=node.childNodes;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
412 for (var i=0;i<arr_nodes.length;i++){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
413 if (arr_nodes[i].getAttribute("open")){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
414 //alert(arr_nodes[i].getAttribute("open"));
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
415 if (arr_nodes[i].hasChildNodes && arr_nodes[i].firstChild.hasChildNodes){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
416 alert(arr_nodes[i].firstChild.firstChild.getAttribute("label"));
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
417 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
418 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
419 traverse(arr_nodes[i]);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
420 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
421 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
422 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
423
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
424 function traverseTree(){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
425 var t=document.getElementById("file_tree");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
426 traverse(t);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
427 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
428
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
429
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
430 /* @beat: ich habe mich erfrecht, diese billige methode in dein
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
431 javascript zu verschieben, weil ich eigentlich jetzt zu
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
432 dir gehoert und nicht mehr in ein alcatraz.js (das gar
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
433 nicht mehr existiert). alcatraz.xul ist nur noch ein
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
434 container fuer andere xul-files und hat deshalb auch
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
435 keine eigenen funktionialitaeten mehr - christian
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
436 */
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
437 function dialog_annotate() {
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
438 window.openDialog("chrome://alcatraz/content/dialog_annotate.xul", "dialog_annotate", "chrome,dialog,resizable=no", "");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
439 }