Mercurial > hg > digilib
annotate xul/content/annota.js @ 209:28e861dc3467
Enhanced the robustness of the annotation tab.
author | slarti |
---|---|
date | Thu, 25 Mar 2004 17:45:31 +0100 |
parents | 49cb8a445126 |
children | e1c302129599 |
rev | line source |
---|---|
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
1 include ('chrome://jslib/content/io/dir.js'); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
2 include ('chrome://jslib/content/io/file.js'); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
3 /*include ('chrome://jslib/content/io/rdfBase.js'); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
4 include ('chrome://jslib/content/io/rdfResource.js'); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
5 include ('chrome://jslib/content/io/rdfContainer.js');*/ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
6 include ('chrome://jslib/content/io/rdf.js');/* |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
7 include ('chrome://jslib/content/io/rdfFile.js');*/ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
8 include ('chrome://jslib/content/io/fileUtils.js'); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
9 |
209 | 10 /* Konstanten */ |
11 var BEGIN_OF_URI = 'urn:echo'; | |
12 var TREE_ID = 'annotation_tree'; | |
13 var ECHO = 'http://echo.unibe.ch/digilib/rdf#'; | |
14 var HEADER_URI = 'urn:header:'; | |
15 | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
16 var slash='/'; |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
17 if (navigator.platform=="Win32"){ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
18 slash='\\'; |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
19 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
20 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
21 var directory=slash; |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
22 var digilib_path=slash; |
209 | 23 var creator = 'unknown'; |
24 var rdfTree; | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
25 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
26 getProfile(); |
209 | 27 getAnnotations(); |
28 | |
29 | |
30 /** | |
31 * Opens a Dialog to make a text annotation. | |
32 */ | |
33 function dialog_annotate() { | |
34 if(this.getAttributeOfSelectedNode('url') != '') { | |
35 window.openDialog("chrome://alcatraz/content/dialog_annotate.xul", "dialog_annotate", "chrome,dialog,resizable=no", ""); | |
36 } else { | |
37 alert('No Annotation is selected!'); | |
38 } | |
39 } | |
40 | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
41 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
42 function makePathCompatible(path){ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
43 if (navigator.platform=="Win32"){ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
44 // slash durch backslash ersetzten |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
45 path=path.replace(/\//g,"\\"); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
46 // nur 2 backslashs am anfang |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
47 path=path.replace(/^\\{3}/,"\\\\"); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
48 // vor Laufwerkbuchstaben kein Backslash |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
49 if (path.indexOf(":")>0){ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
50 path=path.replace(/^\\/g,""); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
51 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
52 // nur ein Slash gibt Absturz |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
53 path=path.replace(/^\\$/,"c:\\"); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
54 //alert(path); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
55 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
56 return path; |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
57 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
58 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
59 function file_open(){ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
60 var nsIFilePicker = Components.interfaces.nsIFilePicker; |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
61 var fp = Components.classes["@mozilla.org/filepicker;1"] |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
62 .createInstance(nsIFilePicker); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
63 fp.init(window, "Select a Directory", nsIFilePicker.modeGetFolder); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
64 |
209 | 65 // set default directory |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
66 var aLocalFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
67 directory=makePathCompatible(directory); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
68 aLocalFile.initWithPath(directory); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
69 fp.displayDirectory=aLocalFile; |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
70 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
71 var res=fp.show(); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
72 if (res==nsIFilePicker.returnOK){ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
73 directory=fp.fileURL.path; |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
74 directory=makePathCompatible(directory); |
209 | 75 this.setTreeDirectory(); |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
76 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
77 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
78 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
79 function setTreeDirectory(){ |
209 | 80 this.rdfTree = new RDFTree(this.TREE_ID); |
81 this.rdfTree.addDataSource('file://'+this.getProfileDirectory()+slash+'annotations.rdf'); | |
82 } | |
83 | |
84 function setCreatorName() { | |
85 | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
86 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
87 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
88 function refreshTree(){ |
209 | 89 this.rdfTree = new RDFTree(this.TREE_ID); |
90 this.rdfTree.rebuild(); | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
91 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
92 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
93 function getAttributeOfSelectedNode(attribute) { |
209 | 94 this.rdfTree = new RDFTree(this.TREE_ID); |
95 var tree = this.rdfTree.tree; | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
96 try { |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
97 return tree.view.getCellText(tree.currentIndex,attribute); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
98 } catch(e) { |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
99 return ''; |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
100 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
101 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
102 |
209 | 103 function getURIOfSelectedNode() { |
104 var url = this.getAttributeOfSelectedNode('url'); | |
105 if(url != '') { | |
106 return id = this.BEGIN_OF_URI + ':' + url | |
107 + '|' + this.getAttributeOfSelectedNode('pagenumber') | |
108 + '|' + this.getAttributeOfSelectedNode('name'); | |
109 } | |
110 return ''; | |
111 } | |
112 | |
113 /** | |
114 * Deletes the selected Annotation | |
115 */ | |
116 function deleteAnnotation() { | |
117 var name = this.getAttributeOfSelectedNode('name'); | |
118 if(name != '') { | |
119 var isSure = window.confirm('Do you really want to delete the Annotations "' | |
120 + name + '?'); | |
121 if(isSure) { | |
122 var dataSource = new RDFDataSource('file://'+this.getProfileDirectory()+slash+'annotations.rdf'); | |
123 containerNode = dataSource.getNode(this.BEGIN_OF_URI); | |
124 var uri = this.getURIOfSelectedNode(); | |
125 containerNode.removeChild(dataSource.getNode(uri)); | |
126 // alert(this.HEADER_URI+this.getURIOfSelectedNode()); | |
127 //alert(uri); | |
128 dataSource.deleteRecursive(this.HEADER_URI+uri); // Delete the Header | |
129 dataSource.deleteRecursive(uri); | |
130 this.refreshTree(); | |
131 dataSource.save(); | |
132 } | |
133 } | |
134 | |
135 } | |
136 | |
137 /** | |
138 * Adds a Textannotation to an existing annotation. | |
139 */ | |
140 function addTextAnnotation(text) { | |
141 var id = this.getURIOfSelectedNode(); | |
142 dataSource = new RDFDataSource('file://'+this.getProfileDirectory()+slash+'annotations.rdf'); | |
143 var node = dataSource.getNode(id); | |
144 if(node.propertyExists('http://purl.org/dc/elements/1.0/title')) { | |
145 /** Do something */ | |
146 } else { // Should never be reached | |
147 alert('AddTextAnnotation: No Annotation is selected!'); | |
148 } | |
149 //alert(text); | |
150 } | |
151 | |
152 function getCurrentDate() { | |
153 var now = new Date(); | |
154 return date = ((now.getYear() < 999) ? (now.getYear()+1900) : now.getYear()) + '-' | |
155 +now.getDate() + '-' + now.getDay() + ', ' | |
156 +now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds() + ' ' | |
157 +(now.getTimezoneOffset()/60) + ':00 GMT'; | |
158 } | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
159 |
209 | 160 /** |
161 * Creates A Complex RDF entry and adds it to the base Container. | |
162 * @params String The urn of the new node without(!) title (so far). | |
163 * @todo isn't complex yet... | |
164 */ | |
165 function createComplexRDFEntry(inCompleteURN) { | |
166 var title = window.prompt("Please enter a title for this Annotation" | |
167 ,this.getAttributeOfSelectedNode('name')); | |
168 if(title != null) { | |
169 var completeURN = inCompleteURN+title; | |
170 var echoContainer = dataSource.getNode(BEGIN_OF_URI); | |
171 echoContainer.makeSeq(); | |
172 | |
173 echoContainer.addChild(completeURN); | |
174 /* var node = dataSource.getNode(completeURN); | |
175 node.addTarget(ECHO + 'template','text_digilib'); | |
176 node.addTarget(ECHO + 'echo','basic'); | |
177 node.addTarget(ECHO + 'lv","1"); | |
178 node.addTarget("http://purl.org/dc/elements/1.0/title",title); | |
179 node.addTarget("http://purl.org/dc/elements/1.0/creator",""); | |
180 node.addTarget("http://purl.org/dc/elements/1.0/date",""); | |
181 node.addTarget("http://www.w3.org/2000/10/annotation-ns#created",""); | |
182 node.addTarget("http://www.w3.org/1999/02/22-rdf-syntax-ns#type",'Annotation'); | |
183 | |
184 var arrayParams=window.content.listParameters(); | |
185 | |
186 var s = ''; | |
187 for (i=0; i< arrayParams.length; i++){ | |
188 s += arrayParams[i] + ' ' + window.content.getParameter(arrayParams[i]) + '\n'; | |
189 //var value=window.content.getParameter(arrayParams[i]); | |
190 //alert(arrayParams[i]+":"+value); | |
191 //node.addTarget(ECHO + '+arrayParams[i],value); | |
192 } | |
193 alert(s); | |
194 | |
195 node.addTarget(ECHO + 'lv',"1"); | |
196 node.addTarget("http://purl.org/dc/elements/1.0/title",title); | |
197 node.addTarget("http://purl.org/dc/elements/1.0/creator",""); | |
198 node.addTarget("http://purl.org/dc/elements/1.0/date",""); | |
199 node.addTarget("http://www.w3.org/2000/10/annotation-ns#created",""); | |
200 //node.addTarget("http://www.w3.org/2000/10/annotation-ns#Annotation","targetof"); | |
201 //var node2 = dataSource.getNode("targetof"); | |
202 //node2.addTarget(ECHO + 'lv',"1"); | |
203 */ | |
204 var date = this.getCurrentDate(); | |
205 var node = dataSource.getNode(this.HEADER_URI + completeURN); | |
206 var created = ''; | |
207 /** @Todo Doesn't work correctly, if the selected one isn't the overwritten one! */ | |
208 if(!node.propertyExists('http://purl.org/dc/elements/1.0/title')) { | |
209 created = date; | |
210 } else { | |
211 created = this.getAttributeOfSelectedNode('created'); | |
212 } | |
213 var fn = window.content.getParameter('fn'); | |
214 var pn = window.content.getParameter('pn'); | |
215 var ws = window.content.getParameter('ws'); | |
216 var mk = window.content.getParameter('mk'); | |
217 var wx = window.content.getParameter('wx'); | |
218 var wy = window.content.getParameter('wy'); | |
219 var ww = window.content.getParameter('ww'); | |
220 var wh = window.content.getParameter('wh'); | |
221 var pt = window.content.getParameter('pt'); | |
222 | |
223 var brgt = window.content.getParameter('brgt'); | |
224 var cont = window.content.getParameter('cont'); | |
225 var rot = window.content.getParameter('rot'); | |
226 var rgba = window.content.getParameter('rgba'); | |
227 var rgbm = window.content.getParameter('rgbm'); | |
228 var ddpix = window.content.getParameter('ddpix'); | |
229 var ddpiy = window.content.getParameter('ddpiy'); | |
230 | |
231 var lv = 1; /** @todo get the parameter right */ | |
232 | |
233 | |
234 var rdfHeader = '<?xml version="1.0" ?>\n' | |
235 +'<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n' | |
236 +' xmlns:echo="' + ECHO + '"\n' | |
237 +' xmlns:a="http://www.w3.org/2000/10/annotation-ns#"\n' | |
238 +' xmlns:d="http://purl.org/dc/elements/1.0/">\n\n' | |
239 var rdfFooter = '</RDF:RDF>\n'; | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
240 |
209 | 241 var rdf = rdfHeader; |
242 if(true) { // annotation is basic | |
243 rdf += ' <RDF:Description RDF:about="' + completeURN + '">\n' | |
244 + ' <!-- Annotations Type -->\n' | |
245 + ' <RDF:type rdf:resource="http://www.w3.org/2000/10/annotation-ns#Annotation"/>\n' | |
246 + ' <echo:type rdf:resource="' + ECHO + 'Digilib"/>\n' //echo -> RDF | |
247 + ' <!-- Echo Digilib Parameters -->\n' | |
248 + ' <echo:fn>' + fn + '</echo:fn>\n' | |
249 + ' <echo:pn>' + pn + '</echo:pn>\n' | |
250 + ' <echo:ws>' + ws + '</echo:ws>\n' | |
251 + ' <echo:mk>' + mk + '</echo:mk>\n' // As there isn't a textmark yet, I only set mk | |
252 + ' <echo:wx>' + wx + '</echo:wx>\n' | |
253 + ' <echo:wy>' + wy + '</echo:wy>\n' | |
254 + ' <echo:ww>' + ww + '</echo:ww>\n' | |
255 + ' <echo:wh>' + wh + '</echo:wh>\n' | |
256 + ' <echo:pt>' + pt + '</echo:pt>\n' | |
257 + ' <echo:brgt>' + brgt + '</echo:brgt>\n' | |
258 + ' <echo:cont>' + cont + '</echo:cont>\n' | |
259 + ' <echo:rot>' + rot + '</echo:rot>\n' | |
260 + ' <echo:rgba>' + rgba + '</echo:rgba>\n' | |
261 + ' <echo:rgbm>' + rgbm + '</echo:rgbm>\n' | |
262 + ' <echo:ddpix>' + ddpix + '</echo:ddpix>\n' | |
263 + ' <echo:ddpiy>' + ddpiy + '</echo:ddpiy>\n' | |
264 + ' <echo:lv>' + lv + '</echo:lv>\n' | |
265 + ' <!-- Dublin Core -->\n' | |
266 + ' <d:title>' + title + '</d:title>\n' | |
267 + ' <d:creator>' + creator + '</d:creator>\n' | |
268 + ' <d:date>' + date + '</d:date>\n' | |
269 + ' <!-- WWW.W3.org Annotations -->\n' | |
270 + ' <a:created>' + created + '</a:created>\n' | |
271 + ' </RDF:Description>\n'; | |
272 } else { // annotation is complex /** @Todo The other components aren't correct yet*/ | |
273 | |
274 rdf +=' <RDF:Description RDF:about="' + this.HEADER_URI + completeURN + '">\n' | |
275 + ' <RDF:type rdf:resource="http://www.w3.org/2000/10/annotation-ns#Annotation"/>\n' | |
276 + ' <echo:template>text_digilib</echo:template>\n' // are there other templates? | |
277 + ' <!-- Dublin Core -->\n' | |
278 + ' <d:title>' + title + '</d:title>\n' | |
279 + ' <d:creator>' + creator + '</d:creator>\n' | |
280 + ' <d:date>' + date + '</d:date>\n' | |
281 + ' <!-- WWW.W3.org Annotations -->\n' | |
282 + ' <a:created>' + created + '</a:created>\n'; | |
283 | |
284 rdf +=' <echo:type rdf:resource="' + ECHO + 'complex"/>\n'; //echo -> RDF | |
285 + ' <echo:annotation RDF:resource="' + completeURN +'"/>\n' | |
286 + ' </RDF:Description>\n\n'; | |
287 } | |
288 | |
289 rdf += rdfFooter; | |
290 //alert(rdf); | |
291 var ds = new RDFDataSource(); | |
292 | |
293 //Remove the original to add the new one | |
294 dataSource.deleteRecursive(this.HEADER_URI+completeURN); | |
295 ds.parseFromString(rdf,'file://'+this.getProfileDirectory()+slash+'annotations.rdf'); | |
296 ds.copyAllToDataSource(dataSource); | |
297 | |
298 /******************************************************* | |
299 | |
300 var rdf ='<?xml version="1.0" ?>' | |
301 +'<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"' | |
302 +' xmlns:echo="' + ECHO + '"' | |
303 +' xmlns:a="http://www.w3.org/2000/10/annotation-ns#"' | |
304 +' xmlns:d="http://purl.org/dc/elements/1.0/">' | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
305 |
209 | 306 +' <RDF:Description rdf:about="'+completeURN+'">' |
307 +' <echo:template>text_digilib</echo:template>' | |
308 +' <echo:type rdf:resource="' + ECHO + 'complex"/>' //echo -> RDF | |
309 +' <RDF:type rdf:resource="http://www.w3.org/2000/10/annotation-ns#Annotation"/>' | |
310 +' <echo:annotation>' | |
311 +' <RDF:Description>' | |
312 +' <!-- Annotations Type -->' | |
313 +' <RDF:type rdf:resource="http://www.w3.org/2000/10/annotation-ns#Annotation"/>' | |
314 +' <echo:type rdf:resource="' + ECHO + 'Digilib"/>' //echo -> RDF | |
315 +' <!-- Echo Digilib Parameters -->' | |
316 +' <echo:fn>histbot/botany</echo:fn>' | |
317 +' <echo:pn>1</echo:pn>' | |
318 +' <echo:ws>1.0</echo:ws>' | |
319 +' <echo:text_mark echo:mk="0.6021/0.8411">' | |
320 +' <RDF:Description>' | |
321 +' <!-- Annotations Type -->' | |
322 +' <RDF:type rdf:resource="http://www.w3.org/2000/10/annotation-ns#Annotation" />' | |
323 +' <echo:type rdf:resource="' + ECHO + 'Text" />'//echo -> RDF | |
324 +' <!-- Alcatraz Text -->' | |
325 +' <echo:txt>Mark 1 shows the root of the Anthoxanthum odoratum <br /> there is a lot of textand textt and text and text and text</echo:txt>' | |
326 +' <!-- Dublin Core -->' | |
327 +' <d:title>Text Annotation of Mark1</d:title>' | |
328 +' <d:creator>erwin.mueller@philo.unibe.ch</d:creator>' | |
329 +' <d:date>2003-07-11T19:13:52+01:00</d:date>' | |
330 +' <!-- WWW.W3.org Annotations -->' | |
331 +' <a:created>2003-07-11T19:13:16+01:00</a:created>' | |
332 +' </RDF:Description>' | |
333 +' </echo:text_mark>' | |
334 +' <echo:wx>0.2626</echo:wx>' | |
335 +' <echo:wy>0.8123</echo:wy>' | |
336 +' <echo:ww>0.4747</echo:ww>' | |
337 +' <echo:wh>0.1484</echo:wh>' | |
338 +' <echo:pt>249</echo:pt>' | |
339 +' <echo:lv>1</echo:lv>' | |
340 +' <!-- Dublin Core -->' | |
341 +' <d:title>Ruchgras</d:title>' | |
342 +' <d:creator>daniel.engler@philo.unibe.ch</d:creator>' | |
343 +' <d:date>2003-05-11T16:42:52+01:00</d:date>' | |
344 +' <!-- WWW.W3.org Annotations -->' | |
345 +' <a:created>2003-05-11T16:34:16+01:00</a:created>' | |
346 +' </RDF:Description>' | |
347 +' </echo:annotation>' // rdf:resource="echo00765"/>' | |
348 +' <d:title>Complex Annotation Digilib and Text</d:title>' | |
349 +' <d:creator>karl.gerber@germ.unibe.ch</d:creator>' | |
350 +' <d:date>2003-01-13T19:13:52+01:00</d:date>' | |
351 +' <!-- WWW.W3.org Annotations -->' | |
352 +' <a:created>2003-01-13T19:13:16+01:00</a:created>' | |
353 +' </RDF:Description>' | |
354 +'</RDF:RDF>'; | |
355 ds = new RDFDataSource(); | |
356 ds.parseFromString(rdf,"http://echo.unibe.ch/digilib/rdf/digilib.rdf"); | |
357 //alert('Beispiel einer komplexen Annotation:\n\n'+ds.serializeToString()); | |
358 ***************************************************************/ | |
359 } | |
360 } | |
361 | |
362 /** | |
363 * Saves the open echo-site in the annotation.rdf-file without asking. | |
364 * @todo The <code>about</code> has to be modified if the URN's are changing! | |
365 */ | |
366 function quickSave() { | |
367 var about=''; | |
368 try { | |
369 var identify; | |
370 try { | |
371 identify = (typeof(window.content.identify()) != 'undefined') | |
372 ? window.content.identify() : false; | |
373 } catch(e) { | |
374 identify = false; | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
375 } |
209 | 376 about = window.content.getParameter('fn'); |
377 about += '|' + window.content.getParameter('pn') + '|'; | |
378 } catch (e){ | |
379 about = ''; | |
380 } | |
381 if (about != ''){ | |
382 //alert('Creator: '+this.creator); | |
383 while(this.creator == 'unknown' || this.creator == '') { | |
384 this.creator = window.prompt("Please enter a username:",this.creator); | |
385 } | |
386 this.setProfile(); | |
387 | |
388 //URN isn't complete yet! | |
389 var urn = BEGIN_OF_URI + ':' + about; | |
390 //alert('Documentpath: '+documentpath); | |
391 | |
392 dataSource = new RDFDataSource('file://'+this.getProfileDirectory()+slash+'annotations.rdf'); | |
393 | |
394 this.createComplexRDFEntry(urn); | |
395 dataSource.save(); | |
396 refreshTree(); | |
397 } else{ | |
398 alert("Error: no alcatraz component. can't create an annotation."); | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
399 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
400 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
401 |
209 | 402 /** @todo Allow the users to save their RDF-Files anywhere. |
403 function saveAs(){ | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
404 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
405 // get Digilib-Parameter form Browser |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
406 //alert(window.content.location.href); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
407 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
408 var documentpath=''; |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
409 try{ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
410 documentpath=window.content.getParameter('fn'); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
411 documentpath=documentpath.replace(':',';'); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
412 }catch (e){ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
413 documentpath=''; |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
414 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
415 if (documentpath != ''){ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
416 //documentpath=documentpath.replace(slash,':'); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
417 //alert(documentpath); |
209 | 418 var docPath = BEGIN_OF_URI + ':' + documentpath; |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
419 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
420 var t=document.getElementById("file_tree"); |
209 | 421 dataSource = new RDFDataSource(); |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
422 this.createComplexRDFEntry(docPath); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
423 |
209 | 424 //dataSource.save(); |
425 //refreshTree(); | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
426 var nsIFilePicker = Components.interfaces.nsIFilePicker; |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
427 var fp = Components.classes["@mozilla.org/filepicker;1"] |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
428 .createInstance(nsIFilePicker); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
429 fp.init(window, "Select a File", nsIFilePicker.modeSave); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
430 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
431 // set default direcotry |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
432 var aLocalFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
433 directory=makePathCompatible(directory); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
434 aLocalFile.initWithPath(directory); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
435 fp.displayDirectory=aLocalFile; |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
436 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
437 fp.appendFilter("Annotations","*.rdf; *.RDF"); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
438 var res=fp.show(); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
439 if (res==nsIFilePicker.returnOK){ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
440 var thefile=fp.file; |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
441 // --- do something with the file here --- |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
442 //alert(fp.file); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
443 //alert(fp.fileURL.path); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
444 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
445 var strFilePath=fp.file.path; |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
446 strFilePath=strFilePath.toLowerCase(); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
447 if (strFilePath.indexOf('.rdf')<0){ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
448 strFilePath=fp.fileURL.path+".rdf"; |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
449 }else{ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
450 strFilePath=fp.fileURL.path; |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
451 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
452 strFilePath=makePathCompatible(strFilePath); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
453 var f=new File(strFilePath); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
454 //var boolFileExists=f.exists(); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
455 //alert(boolFileExists); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
456 f.create(); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
457 f.open('w'); |
209 | 458 f.write(dataSource.serializeToString()); |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
459 f.close(); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
460 refreshTree(); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
461 } |
209 | 462 |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
463 } else{ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
464 alert("Error: no alcatraz component. can't create an annotation."); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
465 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
466 } |
209 | 467 //*/ |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
468 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
469 function file_local(){ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
470 // noch nicht programmiert |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
471 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
472 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
473 function file_annotaDB(){ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
474 alert("At the moment it is not possible to use the annota DB! This feature is not yet programmed."); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
475 var menu_item=document.getElementById('local'); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
476 menu_item.setAttribute('checked','true'); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
477 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
478 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
479 function tree_click(){ |
209 | 480 var rdfFile = this.getURIOfSelectedNode(); |
481 if (rdfFile!=''){ | |
482 //alert('New identifier: '+ rdfFile); | |
483 this.send_annotation(rdfFile); | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
484 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
485 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
486 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
487 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
488 /*** |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
489 * Diese Funktion wird gebraucht um im Dialog den Pfad zu digilib zu setzen |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
490 * |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
491 ***/ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
492 function setDigilibPath(digilibPathValue){ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
493 digilib_path=digilibPathValue; |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
494 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
495 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
496 /*** |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
497 * Dialog tools momentan kann man nur den Pfad zu digilib setzen |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
498 * |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
499 ***/ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
500 function show_dialog(dialog){ |
209 | 501 if (dialog=="tool path"){ |
502 window.openDialog("tools_dialog.xul","funny dialog", | |
503 "chrome",digilib_path,setDigilibPath); | |
504 } | |
505 if (dialog == 'creator') { | |
506 var creatorName = window.prompt('Enter the name of the creator of the annotations:' | |
507 ,this.creator); | |
508 if(creatorName != '') { | |
509 this.creator = creatorName; | |
510 } | |
511 } | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
512 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
513 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
514 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
515 /*** |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
516 * Gibt den Inhalt eines Files als String zurueck |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
517 * |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
518 ***/ |
209 | 519 function readFile(fileName){ |
520 var file = new File(fileName); | |
521 var string = ''; | |
522 if (file.isFile()){ | |
523 file.open(); | |
524 string=file.read(); | |
525 file.close(); | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
526 } |
209 | 527 return string; |
528 } | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
529 |
209 | 530 /** |
531 * @todo digilib.jsp sollte hier nicht auf die urn schauen, sondern auf den fn parameter! | |
532 */ | |
533 function getContentOfRdfDescription(id) { | |
534 dataSource = new RDFDataSource('file://'+this.getProfileDirectory()+slash+'annotations.rdf'); | |
535 var inMemoryDataSource = new RDFDataSource(); | |
536 var node = dataSource.getNode(id); | |
537 var properties = node.getProperties(); | |
538 var urn = this.getAttributeOfSelectedNode('url'); | |
539 urn = urn.replace(/^file:\/\//,""); | |
540 urn = this.makePathCompatible(urn); | |
541 var inMemoryNode = inMemoryDataSource.getNode(this.BEGIN_OF_URI+':'+urn); | |
542 while(properties.hasMoreElements()) { | |
543 var property = properties.getNext(); | |
544 var target = node.getTarget(property); | |
545 inMemoryNode.addTarget(property,target); | |
546 } | |
547 return inMemoryDataSource.serializeToString(); | |
548 } | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
549 |
209 | 550 /** |
551 * @todo check if it is platform independant | |
552 */ | |
553 function send_annotation(rdfFilePath){ | |
554 //digilib_path = 'http://pythia2.unibe.ch:8080/docuserver/digitallibrary'; | |
555 strRdfFile = this.getContentOfRdfDescription(rdfFilePath); | |
556 //alert(strRdfFile); | |
557 if (strRdfFile!=''){ | |
558 var formid = 'mainform'; | |
559 var form = this.createForm(formid, digilib_path+"/digilib.jsp", "post", "_content"); | |
560 this.setFormData(form, formid, strRdfFile); | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
561 form.submit(); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
562 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
563 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
564 |
209 | 565 function createForm(formid, action, method, target) { |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
566 var form = document.getElementById(formid); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
567 if(form != null) |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
568 document.documentElement.removeChild(form); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
569 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
570 var form = document.createElementNS("http://www.w3.org/1999/xhtml", "form"); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
571 form.setAttribute("id", formid); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
572 form.setAttribute("action", action); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
573 form.setAttribute("method", method); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
574 form.setAttribute("target", target); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
575 document.documentElement.appendChild(form); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
576 return form; |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
577 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
578 |
209 | 579 function setFormData(form, formid, rdf) { |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
580 var val1 = document.createElementNS("http://www.w3.org/1999/xhtml", "input"); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
581 val1.setAttribute('type', 'hidden'); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
582 val1.setAttribute('name', 'rdf'); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
583 val1.setAttribute('value', rdf); |
209 | 584 form.appendChild(val1); |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
585 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
586 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
587 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
588 function getProfileDirectory(){ |
209 | 589 // First get the directory service and query interface it to |
590 // nsIProperties | |
591 var dirService = Components. | |
592 classes['@mozilla.org/file/directory_service;1']. | |
593 getService(Components.interfaces.nsIProperties); | |
594 | |
595 // Next get the "ProfD" property of type nsIFile from the directory | |
596 // service, FYI this constant is defined in | |
597 // mozilla/xpcom/io/nsAppDirectoryServiceDefs.h | |
598 | |
599 const NS_APP_USER_PROFILE_50_DIR = "ProfD"; | |
600 profileDir = dirService.get(NS_APP_USER_PROFILE_50_DIR, | |
601 Components.interfaces.nsIFile); | |
602 | |
603 // Now that we have it we can show it's path. See nsIFile for the | |
604 // other things you that can be done with profileDir | |
605 //alert(profileDir.path); | |
606 return profileDir.path; | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
607 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
608 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
609 function getProfile(){ |
209 | 610 var strProfile=readFile(getProfileDirectory()+slash+"annota.dat"); |
611 if (strProfile==""){ | |
612 directory=slash; | |
613 digilib_path="http://hera.unibe.ch:8080/alcatraz"; | |
614 creator = 'unknown' | |
615 setProfile(); | |
616 } else { | |
617 var params=strProfile.split("\n"); | |
618 for (var i=0;i<params.length;i++){ | |
619 var key_value=params[i].split("|"); | |
620 if (key_value[0]=='directory'){ | |
621 directory=key_value[1]; | |
622 } | |
623 if (key_value[0]=='tool path'){ | |
624 digilib_path=key_value[1]; | |
625 } | |
626 if(key_value[0] == 'creator') { | |
627 creator = key_value[1]; | |
628 } | |
629 } | |
630 } | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
631 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
632 |
209 | 633 /** |
634 * @todo Menuentry where the user can set the creator name. | |
635 */ | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
636 function setProfile(){ |
209 | 637 var file = new File(getProfileDirectory()+slash+'annota.dat'); |
638 file.create(); | |
639 file.open('w'); | |
640 file.write('directory|'+directory+'\n' | |
641 +'tool path|'+digilib_path+'\n' | |
642 +'creator|'+this.creator+'\n'); | |
643 file.close(); | |
644 } | |
645 | |
646 function getAnnotations() { | |
647 var annotations = this.readFile(this.getProfileDirectory()+slash+'annotations.rdf'); | |
648 if(annotations=='') { | |
649 this.setAnnotations(); | |
650 } | |
651 } | |
652 | |
653 function setAnnotations() { | |
654 var file = new File(this.getProfileDirectory()+slash+'annotations.rdf'); | |
655 //alert(this.getProfileDirectory()+slash+'annotations.rdf'); | |
656 file.create(); | |
657 file.open('w'); | |
658 file.write('<?xml version="1.0"?>\n' | |
659 +'<RDF:RDF xmlns:ECHO="' + ECHO + '"\n' | |
660 +' xmlns:ANNOTATION=\"http://www.w3.org/2000/10/annotation-ns#"' | |
661 +' xmlns:DC=\"http://purl.org/dc/elements/1.0/"' | |
662 +' xmlns:RDF=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#">' | |
663 +'</RDF:RDF>\n'); | |
664 file.close(); | |
199
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
665 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
666 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
667 function traverse(node){ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
668 if (node.hasChildNodes){ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
669 var arr_nodes=node.childNodes; |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
670 for (var i=0;i<arr_nodes.length;i++){ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
671 if (arr_nodes[i].getAttribute("open")){ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
672 //alert(arr_nodes[i].getAttribute("open")); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
673 if (arr_nodes[i].hasChildNodes && arr_nodes[i].firstChild.hasChildNodes){ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
674 alert(arr_nodes[i].firstChild.firstChild.getAttribute("label")); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
675 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
676 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
677 traverse(arr_nodes[i]); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
678 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
679 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
680 } |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
681 |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
682 function traverseTree(){ |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
683 var t=document.getElementById("file_tree"); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
684 traverse(t); |
49cb8a445126
restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff
changeset
|
685 } |