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