annotate xul/content/annota.js @ 476:f87cefeafd7b

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