annotate xul/content/annota_ohne_annota.js @ 252:59250ea2ad55

servlet version 1.19b5 - filename and dpi in request - filename and dpi in dlInfo-*
author robcast
date Wed, 25 Aug 2004 01:06:30 +0200
parents bf945fcf9105
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
203
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
1 include ('chrome://jslib/content/io/dir.js');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
2 include ('chrome://jslib/content/io/file.js');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
3 include ('chrome://jslib/content/io/rdfBase.js');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
4 include ('chrome://jslib/content/io/rdfResource.js');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
5 include ('chrome://jslib/content/io/rdfContainer.js');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
6 include ('chrome://jslib/content/io/rdf.js');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
7 include ('chrome://jslib/content/io/rdfFile.js');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
8 include ('chrome://jslib/content/io/fileUtils.js');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
9
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
10 var slash='/';
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
11 if (navigator.platform=="Win32"){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
12 slash='\\';
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
13 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
14
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
15 var directory=slash;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
16 var digilib_path=slash;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
17
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
18 getProfile();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
19
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
20 function makePathCompatible(path){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
21 if (navigator.platform=="Win32"){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
22 // slash durch backslash ersetzten
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
23 path=path.replace(/\//g,"\\");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
24 // nur 2 backslashs am anfang
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
25 path=path.replace(/^\\{3}/,"\\\\");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
26 // vor Laufwerkbuchstaben kein Backslash
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
27 if (path.indexOf(":")>0){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
28 path=path.replace(/^\\/g,"");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
29 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
30 // nur ein Slash gibt Absturz
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
31 path=path.replace(/^\\$/,"c:\\");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
32 //alert(path);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
33 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
34 return path;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
35 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
36
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
37 function file_open(){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
38 var nsIFilePicker = Components.interfaces.nsIFilePicker;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
39 var fp = Components.classes["@mozilla.org/filepicker;1"]
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
40 .createInstance(nsIFilePicker);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
41 fp.init(window, "Select a Directory", nsIFilePicker.modeGetFolder);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
42
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
43 // set default direcotry
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
44 var aLocalFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
45 directory=makePathCompatible(directory);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
46 aLocalFile.initWithPath(directory);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
47 fp.displayDirectory=aLocalFile;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
48
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
49 var res=fp.show();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
50 if (res==nsIFilePicker.returnOK){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
51 directory=fp.fileURL.path;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
52 directory=makePathCompatible(directory);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
53 setTreeDirectory();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
54 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
55 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
56
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
57 function setTreeDirectory(){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
58 var t=document.getElementById("file_tree");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
59 t.setAttribute("ref","file://"+directory);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
60 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
61
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
62 function refreshTree(){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
63 var t=document.getElementById("file_tree");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
64 t.builder.rebuild();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
65 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
66
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
67 function file_save(){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
68
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
69 // get Digilib-Parameter form Browser
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
70 // alert(window.content.location.href);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
71
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
72 var documentpath='';
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
73 try{
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
74 documentpath=window.content.getParameter('fn');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
75 }catch (e){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
76 documentpath='';
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 if (documentpath != ''){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
79 var docPath='urn:echo:'+documentpath;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
80
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
81 var rdfString='<?xml version="1.0"?>' +
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
82 '<RDF:RDF xmlns:NS1="http://echo.unibe.ch/digilib/rdf#"' +
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
83 ' xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"' +
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
84 ' xmlns:d="http://purl.org/dc/elements/1.0/"' +
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
85 ' xmlns:a="http://www.w3.org/2000/10/annotation-ns#">' +
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
86 ' <RDF:Seq RDF:about="urn:echo">' +
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
87 ' <RDF:li RDF:resource="'+docPath+'"/>' +
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
88 ' </RDF:Seq>' +
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
89 ' <RDF:Description RDF:about="'+docPath+'" NS1:page=0"/>'+
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
90 '</RDF:RDF>';
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
91
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
92 var ds=new RDFDataSource();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
93 ds.parseFromString(rdfString,"http://echo.unibe.ch/digilib/rdf/digilib.rdf");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
94 var node=ds.getNode(docPath);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
95 var arrayParams=window.content.listParameters();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
96 for (i=0; i< arrayParams.length; i++){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
97 var value=window.content.getParameter(arrayParams[i]);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
98 //alert(arrayParams[i]+":"+value);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
99 node.addTarget("http://echo.unibe.ch/digilib/rdf#"+arrayParams[i],value);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
100 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
101 node.addTarget("http://echo.unibe.ch/digilib/rdf#lv","1");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
102 //alert(ds.serializeToString());
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
103 var nsIFilePicker = Components.interfaces.nsIFilePicker;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
104 var fp = Components.classes["@mozilla.org/filepicker;1"]
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
105 .createInstance(nsIFilePicker);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
106 fp.init(window, "Select a File", nsIFilePicker.modeSave);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
107
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
108 // set default direcotry
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
109 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
110 directory=makePathCompatible(directory);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
111 aLocalFile.initWithPath(directory);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
112 fp.displayDirectory=aLocalFile;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
113
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
114 fp.appendFilter("Annotations","*.rdf; *.RDF");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
115 var res=fp.show();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
116 if (res==nsIFilePicker.returnOK){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
117 var thefile=fp.file;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
118 // --- do something with the file here ---
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
119 //alert(fp.file);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
120 //alert(fp.fileURL.path);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
121
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
122 var strFilePath=fp.file.path;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
123 strFilePath=strFilePath.toLowerCase();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
124 if (strFilePath.indexOf('.rdf')<0){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
125 strFilePath=fp.fileURL.path+".rdf";
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
126 }else{
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
127 strFilePath=fp.fileURL.path;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
128 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
129 strFilePath=makePathCompatible(strFilePath);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
130 var f=new File(strFilePath);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
131 //var boolFileExists=f.exists();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
132 //alert(boolFileExists);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
133 f.create();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
134 f.open('w');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
135 f.write(ds.serializeToString());
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
136 f.close();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
137 refreshTree();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
138 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
139 }else{
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
140 alert("Error: no alcatraz component. can't create an annotation.");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
141 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
142 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
143
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
144 function file_local(){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
145 // noch nicht programmiert
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
146 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
147
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
148 function file_annotaDB(){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
149 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
150 var menu_item=document.getElementById('local');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
151 menu_item.setAttribute('checked','true');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
152 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
153
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
154 function tree_click(){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
155 var t=document.getElementById("file_tree"); //tree element
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
156 var l=t.view.getItemAtIndex(t.currentIndex); //aus baum treeitem herausholen mit dem selected index (currentIndex)
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
157 //l.firstChild ist treeitem
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
158 var d=l.firstChild.firstChild; //treecell
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
159 var firstLabel=d.getAttribute("label");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
160 var cols=document.getElementById("cols");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
161 var col=cols.childNodes;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
162 var nodes=l.firstChild.childNodes;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
163 var rdf_file="";
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
164 for (var i=0;i<nodes.length;i++){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
165 if (col[i].getAttribute("label")=="URL"){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
166 rdf_file=nodes[i].getAttribute("label");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
167 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
168 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
169 if (rdf_file!=""){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
170 send_annotation(rdf_file);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
171 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
172 return rdf_file;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
173 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
174
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
175
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
176 /***
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
177 * 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
178 *
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
179 ***/
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
180 function setDigilibPath(digilibPathValue){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
181 digilib_path=digilibPathValue;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
182 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
183
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
184 /***
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
185 * Dialog tools momentan kann man nur den Pfad zu digilib setzen
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
186 *
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
187 ***/
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
188 function show_dialog(dialog){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
189 if (dialog=="tool path"){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
190 window.openDialog("tools_dialog.xul","funny dialog",
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
191 "chrome",digilib_path,setDigilibPath);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
192 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
193 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
194
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
195
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
196 /***
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
197 * Gibt den Inhalt eines Files als String zurueck
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
198 *
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
199 ***/
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
200 function readFile(str_Filename){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
201 var f=new File(str_Filename);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
202 var str="";
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
203 if (f.isFile()){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
204 f.open();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
205 str=f.read();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
206 f.close();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
207 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
208 return str;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
209 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
210
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
211
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
212
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
213 function send_annotation(rdf_file){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
214 rdf_file=rdf_file.replace(/^file:\/\//,"");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
215 rdf_file=makePathCompatible(rdf_file);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
216 strRdfFile=readFile(rdf_file);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
217 if (strRdfFile!=""){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
218 var formid='mainform';
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
219 var form = createForm(formid, digilib_path+"/digilib.jsp", "post", "_content");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
220 //var form = createForm(formid, "http://sophia.unibe.ch:8080/examples/servlet/RequestRDF", "post", "_content");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
221 //var form = createForm(formid, "http://hera.unibe.ch:8080/examples/servlet/RequestRDF", "post", "_content");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
222 setFormData(form, formid, strRdfFile);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
223 form.submit();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
224 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
225 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
226
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
227 function createForm(formid, action, method, target)
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
228 {
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
229 var form = document.getElementById(formid);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
230 if(form != null)
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
231 document.documentElement.removeChild(form);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
232
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
233 var form = document.createElementNS("http://www.w3.org/1999/xhtml", "form");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
234 form.setAttribute("id", formid);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
235 form.setAttribute("action", action);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
236 form.setAttribute("method", method);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
237 form.setAttribute("target", target);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
238 document.documentElement.appendChild(form);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
239 return form;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
240 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
241
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
242 function setFormData(form, formid, rdf)
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
243 {
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
244 var val1 = document.createElementNS("http://www.w3.org/1999/xhtml", "input");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
245 val1.setAttribute('type', 'hidden');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
246 val1.setAttribute('name', 'rdf');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
247 val1.setAttribute('value', rdf);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
248 form.appendChild(val1);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
249 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
250
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
251
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
252 function getProfileDirectory(){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
253 // First get the directory service and query interface it to
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
254 // nsIProperties
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
255 var dirService = Components.
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
256 classes['@mozilla.org/file/directory_service;1'].
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
257 getService(Components.interfaces.nsIProperties);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
258
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
259 // Next get the "ProfD" property of type nsIFile from the directory
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
260 // service, FYI this constant is defined in
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
261 // mozilla/xpcom/io/nsAppDirectoryServiceDefs.h
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
262
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
263 const NS_APP_USER_PROFILE_50_DIR = "ProfD";
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
264 profileDir = dirService.get(NS_APP_USER_PROFILE_50_DIR,
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
265 Components.interfaces.nsIFile);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
266
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
267 // Now that we have it we can show it's path. See nsIFile for the
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
268 // other things you that can be done with profileDir
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
269 //alert(profileDir.path);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
270 return profileDir.path;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
271 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
272
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
273 function getProfile(){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
274 var strProfile=readFile(getProfileDirectory()+slash+"annota.dat");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
275 if (strProfile==""){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
276 directory=slash;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
277 digilib_path="http://hera.unibe.ch:8080/alcatraz";
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
278 setProfile();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
279 }else{
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
280 var params=strProfile.split("\n");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
281 for (var i=0;i<params.length;i++){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
282 var key_value=params[i].split("|");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
283 if (key_value[0]=='directory'){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
284 directory=key_value[1];
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
285 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
286 if (key_value[0]=='tool path'){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
287 digilib_path=key_value[1];
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
288 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
289 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
290 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
291 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
292
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
293 function setProfile(){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
294 var f=new File(getProfileDirectory()+slash+'annota.dat');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
295 f.create();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
296 f.open('w');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
297 f.write('directory|'+directory+'\n'+'tool path|'+digilib_path+'\n');
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
298 f.close();
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
299 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
300
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
301 function traverse(node){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
302 if (node.hasChildNodes){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
303 var arr_nodes=node.childNodes;
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
304 for (var i=0;i<arr_nodes.length;i++){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
305 if (arr_nodes[i].getAttribute("open")){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
306 //alert(arr_nodes[i].getAttribute("open"));
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
307 if (arr_nodes[i].hasChildNodes && arr_nodes[i].firstChild.hasChildNodes){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
308 alert(arr_nodes[i].firstChild.firstChild.getAttribute("label"));
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
309 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
310 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
311 traverse(arr_nodes[i]);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
312 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
313 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
314 }
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
315
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
316 function traverseTree(){
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
317 var t=document.getElementById("file_tree");
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
318 traverse(t);
bf945fcf9105 restarting with version control of xul sidebar/toolbar
luginbue
parents:
diff changeset
319 }