annotate xul/content/annota_ohne_annota.js @ 477:cb654584a685

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