1 | var opt;
|
---|
2 | var winW = 630, winH = 460;
|
---|
3 | var NID;
|
---|
4 | function GD(obj){
|
---|
5 | NID = obj.parentNode.id;
|
---|
6 | opt = "info";
|
---|
7 | //alert(NID);
|
---|
8 | //reconfig();
|
---|
9 | ajaxSearch(NID);
|
---|
10 | }
|
---|
11 |
|
---|
12 | function GX(obj){
|
---|
13 | NID = obj.parentNode.id;
|
---|
14 | opt = "url";
|
---|
15 | //reconfig();
|
---|
16 | ajaxSearch(NID);
|
---|
17 | }
|
---|
18 |
|
---|
19 | function reconfig(){
|
---|
20 |
|
---|
21 | var request2 ='<request type="system" to=""><system type="configure" subset="collectionList"/></request>';
|
---|
22 | var message2 = newElement('message', request2 );
|
---|
23 | var soapMessage2 = messageToSOAP(message2);
|
---|
24 | makeRequest(soapMessage2);
|
---|
25 |
|
---|
26 | }
|
---|
27 |
|
---|
28 |
|
---|
29 | function windowSize(){
|
---|
30 | if (parseInt(navigator.appVersion)>3) {
|
---|
31 | if (navigator.appName=="Netscape") {
|
---|
32 | winW = window.innerWidth;
|
---|
33 | winH = window.innerHeight;
|
---|
34 | }
|
---|
35 |
|
---|
36 | if (navigator.appName.indexOf("Microsoft")!=-1) {
|
---|
37 | winW = document.body.offsetWidth;
|
---|
38 | winH = document.body.offsetHeight;
|
---|
39 | }
|
---|
40 | }
|
---|
41 | }
|
---|
42 |
|
---|
43 |
|
---|
44 | function getwindowHeight(){
|
---|
45 |
|
---|
46 | var Height;
|
---|
47 |
|
---|
48 | if (parseInt(navigator.appVersion)>3) {
|
---|
49 | if (navigator.appName=="Netscape") {
|
---|
50 | Height = window.innerHeight;
|
---|
51 | }
|
---|
52 | if (navigator.appName.indexOf("Microsoft")!=-1) {
|
---|
53 | winW = document.body.offsetWidth;
|
---|
54 | Height = document.body.offsetHeight;
|
---|
55 | }
|
---|
56 | return Height;
|
---|
57 | }
|
---|
58 | }
|
---|
59 |
|
---|
60 |
|
---|
61 | function newwindows(url){
|
---|
62 |
|
---|
63 | if(url!=''){
|
---|
64 | windowSize();
|
---|
65 | window.open(url,'mywindow',winW+','+winH+','+'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');
|
---|
66 | }
|
---|
67 |
|
---|
68 | else{
|
---|
69 | alert("NO URL AVAILABLE");
|
---|
70 | }
|
---|
71 | //document.body.style.cursor = "default";
|
---|
72 | //document.body.style.cursor = "default";
|
---|
73 | }
|
---|
74 |
|
---|
75 |
|
---|
76 | function newwin(nameList,valueList){
|
---|
77 | var newwindo;
|
---|
78 | var htm="<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><title>Metadata Element Detail</title><style type=text/css >body{font-family:arial;}</style></head>";
|
---|
79 | htm+="<body><table border=2>";
|
---|
80 |
|
---|
81 | var internalElement = new Array();
|
---|
82 |
|
---|
83 | for(var i =0;i<nameList.length; i++){
|
---|
84 | if (/^[A-Z]+$/.test(nameList[i].charAt(0))) {
|
---|
85 | //if(nameList[i]=="URL" && (valueList[i]. substring(0,4)=="http")){
|
---|
86 | if(valueList[i]. substring(0,4)=="http"){
|
---|
87 | htm+="<tr><td>"+nameList[i]+"<td><a href="+valueList[i]+" target=_blank >"+valueList[i];
|
---|
88 | }
|
---|
89 | else{
|
---|
90 | if(valueList[i].length>=200){
|
---|
91 | htm+="<tr><td>"+nameList[i]+"<td>"+valueList[i].substr(0,200)+" ...";
|
---|
92 | }
|
---|
93 | else{
|
---|
94 | htm+="<tr><td>"+nameList[i]+"<td>"+valueList[i];
|
---|
95 | }
|
---|
96 |
|
---|
97 | }
|
---|
98 | }
|
---|
99 | else{ internalElement.push(i);}
|
---|
100 | }
|
---|
101 |
|
---|
102 | for(var i =0; i<internalElement.length; i++){
|
---|
103 | var num = internalElement[i];
|
---|
104 | //if(nameList[num]=="URL" && (valueList[num]. substring(0,4)=="http")){
|
---|
105 | if(valueList[num]. substring(0,4)=="http"){
|
---|
106 | htm+="<tr><td>"+nameList[num]+"<td><a href="+valueList[num]+" target=_blank >"+valueList[num];
|
---|
107 | }
|
---|
108 | else{
|
---|
109 | if(valueList[num].length>=200){
|
---|
110 | htm+="<tr><td>"+nameList[num]+"<td>"+valueList[num].substr(0,200)+" ...";
|
---|
111 | }
|
---|
112 | else{
|
---|
113 | htm+="<tr><td>"+nameList[num]+"<td>"+valueList[num];
|
---|
114 | }
|
---|
115 |
|
---|
116 | }
|
---|
117 |
|
---|
118 | }
|
---|
119 |
|
---|
120 | htm+="</table><p align=center><input type=button onclick=window.close() value=Close /></p></body></html>";
|
---|
121 | newwindo=window.open('','mywindow',winW+','+winH+','+'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');
|
---|
122 | //newwindo=window.open('','mywindow','460','630','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');
|
---|
123 | newwindo.document.write(htm);
|
---|
124 | newwindo.document.close();
|
---|
125 | //document.body.style.cursor = "default";
|
---|
126 | }
|
---|
127 |
|
---|
128 |
|
---|
129 | function ajaxSearch(request) {
|
---|
130 |
|
---|
131 | //alert("wait");
|
---|
132 | //alert("This process takes a few seconds");
|
---|
133 | //alert("done");
|
---|
134 | //document.body.style.cursor = "wait";
|
---|
135 | var bodyTag = document.getElementsByTagName('body');
|
---|
136 | var collection = (bodyTag[0].getAttribute('id'));
|
---|
137 | request = 'HASH'+request;
|
---|
138 |
|
---|
139 | docID = newElementAtt('param', '', new Array('name', 'value'), new Array('metadata', 'all') ) ;
|
---|
140 | paramList = newElement('paramList',docID);
|
---|
141 | NodeID = newElementAtt('documentNode', '', new Array('nodeID'), new Array(request) ) ;
|
---|
142 | documentNodeList = newElement('documentNodeList',NodeID);
|
---|
143 |
|
---|
144 | request = newElementAtt5('request', paramList,documentNodeList, new Array('lang', 'to', 'type'), new Array('en',collection+'/DocumentMetadataRetrieve', 'process' ) );
|
---|
145 | message = newElement('message', request );
|
---|
146 | soapMessage = messageToSOAP(message);
|
---|
147 |
|
---|
148 | makeRequest(soapMessage);
|
---|
149 | //loadAsync(soapMessage);
|
---|
150 | //alert(soapMessage);
|
---|
151 | //alert("Please wait...");
|
---|
152 | }
|
---|
153 |
|
---|
154 | function newElementAtt5(name, content,content2, nameArray, valueArray) {
|
---|
155 |
|
---|
156 | e = '<' + name + ' ' ;
|
---|
157 | for (i=0; i < nameArray.length; i++) {
|
---|
158 | e += newAttribute(nameArray[i], valueArray[i])
|
---|
159 | }
|
---|
160 | e += '>' + content+content2;
|
---|
161 | e += '</' + name + '>';
|
---|
162 |
|
---|
163 | return e;
|
---|
164 | }
|
---|
165 |
|
---|
166 | function messageToSOAP(message) {
|
---|
167 | soapBody = '<soapenv:Body>' + message + '</soapenv:Body>'
|
---|
168 | soap = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' + soapBody + '</soapenv:Envelope>'
|
---|
169 | x= '<?xml version="1.0" encoding="UTF-8"?>' + soap;
|
---|
170 | return x;
|
---|
171 | }
|
---|
172 |
|
---|
173 | function newElement(name, content) {
|
---|
174 | e = '<' + name + '>' + content;
|
---|
175 | e += '</' + name + '>';
|
---|
176 | return e;
|
---|
177 | }
|
---|
178 |
|
---|
179 | function newElementAtt(name, content, nameArray, valueArray) {
|
---|
180 | e = '<' + name + ' ' ;
|
---|
181 | for (i=0; i < nameArray.length; i++) {
|
---|
182 | e += newAttribute(nameArray[i], valueArray[i])
|
---|
183 | }
|
---|
184 | e += '>' + content;
|
---|
185 | e += '</' + name + '>';
|
---|
186 | return e;
|
---|
187 | }
|
---|
188 |
|
---|
189 |
|
---|
190 | function newAttribute(name, value) {
|
---|
191 | return ' ' + name + '="' + value + '"';
|
---|
192 | }
|
---|
193 |
|
---|
194 | function makeRequest(postData){
|
---|
195 | YAHOO.util.Connect.initHeader('SOAPAction','http://tempuri.org/GetMagnetometerStation',true);
|
---|
196 | var request = YAHOO.util.Connect.asyncRequest('POST', '/greenstone3/services/localsite', callback, postData);
|
---|
197 | }
|
---|
198 |
|
---|
199 |
|
---|
200 | var handleSuccess = function(o){
|
---|
201 | //document.body.style.cursor='wait';
|
---|
202 | //alert(o.responseText);
|
---|
203 |
|
---|
204 | //document.body.style.cursor = "default";
|
---|
205 | var nameList = new Array();
|
---|
206 | var valueList = new Array();
|
---|
207 | var xmldoc = o.responseXML;
|
---|
208 | var nodes = xmldoc.getElementsByTagName('metadata');
|
---|
209 | var mesg = "";
|
---|
210 | var msg = "";
|
---|
211 | var urllocation ="";
|
---|
212 | //alert(o.responseText);
|
---|
213 | for(var i=0; i<nodes.length; i++) {
|
---|
214 | mesg = nodes[i].firstChild.nodeValue;
|
---|
215 | //alert(mesg+" "+mesg.indexOf('^'));
|
---|
216 |
|
---|
217 | if(mesg==valueList[valueList.length-1]){}
|
---|
218 | else{
|
---|
219 | msg = nodes[i].getAttribute('name');
|
---|
220 | if(msg.indexOf('^')!=-1){
|
---|
221 | msg = msg.replace('^','.');
|
---|
222 | }
|
---|
223 | if(msg!='prettymd' && msg.substring(0,12)!='metadatafreq' && msg.substring(0,12)!='metadatalist'&& msg.substring(0,10)!='metadataset' ){
|
---|
224 |
|
---|
225 | if(msg.substring(0,3)=='dc.'){
|
---|
226 | valueList.push(mesg);
|
---|
227 | nameList.push(msg);
|
---|
228 | }
|
---|
229 | else if(msg.substring(0,14)=='nzir_internal.'){
|
---|
230 | valueList.push(mesg);
|
---|
231 | nameList.push(msg);
|
---|
232 | }
|
---|
233 | else if(msg.substring(0,1)=='.'){
|
---|
234 | valueList.push(mesg);
|
---|
235 | nameList.push(msg);
|
---|
236 | }
|
---|
237 | }
|
---|
238 |
|
---|
239 | if((msg=="URL" && mesg.substring(0,4)=="http") ||(mesg.substring(0,4)=="http") ){
|
---|
240 | //alert(msg+ " "+mesg);
|
---|
241 | urllocation = mesg;
|
---|
242 | }
|
---|
243 | }
|
---|
244 |
|
---|
245 | }
|
---|
246 | //document.ajax.dyn.value="Received:";
|
---|
247 | //alert(nameList)
|
---|
248 | if(opt=="info" && nameList.length!=0){
|
---|
249 | //alert(nameList.length+nameList[0]);
|
---|
250 | newwin(nameList,valueList);
|
---|
251 | }
|
---|
252 | else if(opt=="url" && nameList.length!=0){
|
---|
253 | newwindows(urllocation);
|
---|
254 | }
|
---|
255 | //document.body.style.cursor = "default";
|
---|
256 | };
|
---|
257 |
|
---|
258 | var handleFailure = function(o){
|
---|
259 | //alert(o.responseText);
|
---|
260 | //alert("fail");
|
---|
261 | };
|
---|
262 |
|
---|
263 | var callback =
|
---|
264 | {
|
---|
265 | success:handleSuccess,
|
---|
266 | failure:handleFailure,
|
---|
267 | argument:['foo','bar']
|
---|
268 | }; |
---|