Changeset 23934 for gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/client/GS3MapLibrary.java
- Timestamp:
- 2011-04-19T10:11:46+12:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/client/GS3MapLibrary.java
r23906 r23934 1 package org.greenstone. client;1 package org.greenstone.atlas.client; 2 2 3 3 import com.google.gwt.core.client.EntryPoint; … … 158 158 protected String _currentCollection = ""; 159 159 protected String _currentURL = ""; 160 protected final String _GREENSTONEURL = "http:// taniwha.resnet.scms.waikato.ac.nz:8080/greenstone3";160 protected final String _GREENSTONEURL = "http://localhost:8486/greenstone3"; 161 161 //protected final String _GREENSTONEURL = "http://www.nzdl.org/atlasgreenstone3"; 162 162 protected final String _GREENSTONEDEVURL = _GREENSTONEURL + "/dev"; … … 176 176 _geocoder = new Geocoder(); 177 177 178 ((ServiceDefTarget) _findPlaceService).setServiceEntryPoint("http:// taniwha.resnet.scms.waikato.ac.nz:8080/ATLAS/findPlace");178 ((ServiceDefTarget) _findPlaceService).setServiceEntryPoint("http://localhost:8486/ATLAS/findPlace"); 179 179 //((ServiceDefTarget) _findPlaceService).setServiceEntryPoint("http://www.nzdl.org/ATLAS/findPlace"); 180 180 … … 191 191 192 192 //Load the Greenstone home page 193 loadPageFromUrl( "http://taniwha.resnet.scms.waikato.ac.nz:8080/greenstone3/dev?a=p&sa=home");193 loadPageFromUrl(_GREENSTONEDEVURL + "?a=p&sa=home"); 194 194 } 195 195 … … 250 250 _statusBar.addUpdate("Loading new page", "LoadPage"); 251 251 252 getNewPage(url); 252 getNewPage(url.contains("?") ? (url + "&excerpttag=body") : (url + "?excerpttag=body"), 253 new ResponseFunction(){ 254 public void function(String response){ 255 HTML newPage = new HTML(response); 256 newPage.getElement().setId("newpage"); 257 Element oldNewPage = (Element) Document.get().getElementById("newpage"); 258 if(oldNewPage != null) 259 { 260 oldNewPage.removeFromParent(); 261 } 262 getElementsByTagName("body").get(0).appendChild(newPage.getElement()); 263 newPage.setVisible(false); 264 265 showLoadedPage(); 266 } 267 } 268 ); 253 269 } 254 270 … … 271 287 } 272 288 273 public void getNewPage(String url )274 { 275 RequestBuilder newPageRequest = new RequestBuilder(RequestBuilder.GET, url .contains("?") ? (url + "&excerpttag=body") : (url + "?excerpttag=body"));289 public void getNewPage(String url, final ResponseFunction responseFunc) 290 { 291 RequestBuilder newPageRequest = new RequestBuilder(RequestBuilder.GET, url); 276 292 try{ 277 293 newPageRequest.sendRequest(null, new RequestCallback() … … 281 297 if(response.getStatusCode() == Response.SC_OK) 282 298 { 283 HTML newPage = new HTML(response.getText()); 284 newPage.getElement().setId("newpage"); 285 Element oldNewPage = (Element) Document.get().getElementById("newpage"); 286 if(oldNewPage != null) 287 { 288 oldNewPage.removeFromParent(); 289 } 290 getElementsByTagName("body").get(0).appendChild(newPage.getElement()); 291 newPage.setVisible(false); 292 293 showLoadedPage(); 299 responseFunc.function(response.getText()); 294 300 } 295 301 } … … 383 389 384 390 //Add <link> and <script> elements to <head> 385 //changeCSSLinksAndScripts(); 391 getNewPage(_currentURL.contains("?") ? (_currentURL + "&excerpttag=head") : (_currentURL + "?excerpttag=head"), 392 new ResponseFunction(){ 393 public void function(String response){ 394 HTML newPage = new HTML(response); 395 changeCSSLinksAndScripts(newPage.getElement()); 396 } 397 } 398 ); 386 399 } 387 400 else 388 401 { 389 402 //Add <link> and <script> elements to <head> 390 //changeCSSLinksAndScripts(); 403 getNewPage(_currentURL.contains("?") ? (_currentURL + "&excerpttag=head") : (_currentURL + "?excerpttag=head"), 404 new ResponseFunction(){ 405 public void function(String response){ 406 HTML newPage = new HTML(response); 407 changeCSSLinksAndScripts(newPage.getElement()); 408 } 409 } 410 ); 391 411 392 412 //Fix webpage elements so that they point to the correct address … … 529 549 } 530 550 531 if(headerElem == null) 532 { 533 alert("header is null"); 534 } 535 if(bodyElem == null) 536 { 537 alert("body is null"); 538 } 539 if(footerElem == null) 540 { 541 alert("footer is null"); 542 } 551 if(headerElem == null){alert("header is null");} 552 if(bodyElem == null){alert("body is null");} 553 if(footerElem == null){alert("footer is null");} 543 554 544 555 // Add header … … 875 886 * Remove old CSS links from the page and add new ones, the href attributes are also corrected 876 887 */ 877 public void changeCSSLinksAndScripts( )888 public void changeCSSLinksAndScripts(Element newHead) 878 889 { 879 //Get the head section of the HTML page880 890 Element head = getDocumentHead(); 881 891 882 892 //Get all of the <link> elements from the HTML header 883 893 NodeList<com.google.gwt.dom.client.Element> currentLinks = head.getElementsByTagName("link"); … … 885 895 //Get all of the <script> elements from the HTML header 886 896 NodeList<com.google.gwt.dom.client.Element> currentScripts = head.getElementsByTagName("script"); 887 897 888 898 //Add the new links 889 com.google.gwt.xml.client.NodeList newLinks = _currentNewPageDoc.getElementsByTagName("link");899 NodeList<com.google.gwt.dom.client.Element> newLinks = newHead.getElementsByTagName("link"); 890 900 for (int i = 0; i < newLinks.getLength(); i++) 891 901 { 892 com.google.gwt. xml.client.Element e = (com.google.gwt.xml.client.Element) newLinks.item(i);902 com.google.gwt.dom.client.Element e = newLinks.getItem(i); 893 903 boolean found = false; 904 894 905 for(int j = 0; j < currentLinks.getLength(); j++) 895 906 { … … 902 913 } 903 914 } 915 916 if(!found) 917 { 918 Element newElem = DOM.createElement("link"); 919 newElem.setAttribute("href", e.getAttribute("href")); 920 newElem.setAttribute("type", e.getAttribute("type")); 921 newElem.setAttribute("rel", e.getAttribute("rel")); 922 923 if(!newElem.getAttribute("href").startsWith("http://")) 924 { 925 newElem.setAttribute("href", _GREENSTONEURL + "/" + newElem.getAttribute("href")); 926 } 927 head.appendChild(newElem); 928 } 929 } 930 931 //Add the new scripts on the page 932 NodeList<com.google.gwt.dom.client.Element> newScripts = newHead.getElementsByTagName("script"); 933 for (int i = 0; i < newScripts.getLength(); i++) 934 { 935 com.google.gwt.dom.client.Element e = newScripts.getItem(i); 936 boolean found = false; 937 for(int j = 0; j < currentScripts.getLength(); j++) 938 { 939 Element elem = (Element) currentLinks.getItem(j); 940 if(e.getAttribute("src").equals(elem.getAttribute("src")) 941 && e.getAttribute("type").equals(elem.getAttribute("type"))) 942 { 943 found = true; 944 } 945 } 904 946 905 947 if(!found) 906 948 { 907 Element newElem = DOM.createElement("link"); 908 909 NamedNodeMap map = e.getAttributes(); 910 for(int k = 0; k < e.getAttributes().getLength(); k++) 911 { 912 newElem.setAttribute(map.item(k).getNodeName(), map.item(k).getNodeValue()); 913 } 914 915 if(!newElem.getAttribute("href").startsWith("http://")) 916 { 917 newElem.setAttribute("href", _GREENSTONEURL + "/" + newElem.getAttribute("href")); 918 } 919 head.appendChild(newElem); 920 } 921 } 922 923 //Add the new scripts on the page 924 com.google.gwt.xml.client.NodeList newScripts = _currentNewPageDoc.getElementsByTagName("script"); 925 for (int i = 0; i < newScripts.getLength(); i++) 926 { 927 com.google.gwt.xml.client.Element e = (com.google.gwt.xml.client.Element) newScripts.item(i); 928 boolean found = false; 929 for(int j = 0; j < currentScripts.getLength(); j++) 930 { 931 Element elem = (Element) currentLinks.getItem(j); 932 if(e.getAttribute("src").equals(elem.getAttribute("src")) 933 && e.getAttribute("type").equals(elem.getAttribute("type")) 934 && e.getAttribute("charset").equals(elem.getAttribute("charset"))) 935 { 936 found = true; 937 } 938 } 939 940 if(!found) 941 { 942 Element newElem = DOM.createElement("link"); 943 944 NamedNodeMap map = e.getAttributes(); 945 for(int k = 0; k < e.getAttributes().getLength(); k++) 946 { 947 newElem.setAttribute(map.item(k).getNodeName(), map.item(k).getNodeValue()); 948 } 949 950 949 Element newElem = DOM.createElement("script"); 950 newElem.setAttribute("src", e.getAttribute("src")); 951 newElem.setAttribute("type", e.getAttribute("type")); 952 951 953 if(!e.getAttribute("src").startsWith("http://")) 952 954 { … … 993 995 continue; 994 996 } 997 998 if(e.getAttribute("href").startsWith("javascript:")) 999 { 1000 continue; 1001 } 1002 995 1003 if (!e.getAttribute("href").startsWith("http://") && !e.getAttribute("href").startsWith("/")) 996 1004 { … … 1045 1053 $wnd.loadPageFromFormJS = function(form) 1046 1054 { 1047 [email protected]. client.GS3MapLibrary::loadPageFromForm(Lcom/google/gwt/user/client/Element;) (form);1055 [email protected].atlas.client.GS3MapLibrary::loadPageFromForm(Lcom/google/gwt/user/client/Element;) (form); 1048 1056 }; 1049 1057 }-*/; … … 1057 1065 $wnd.loadPageFromUrlJS = function(url) 1058 1066 { 1059 [email protected]. client.GS3MapLibrary::loadPageFromUrl(Ljava/lang/String;) (url);1067 [email protected].atlas.client.GS3MapLibrary::loadPageFromUrl(Ljava/lang/String;) (url); 1060 1068 }; 1061 1069 }-*/; … … 1069 1077 $wnd.loadSpatialSearchPageJS = function() 1070 1078 { 1071 [email protected]. client.GS3MapLibrary::loadSpatialSearchPage() ();1079 [email protected].atlas.client.GS3MapLibrary::loadSpatialSearchPage() (); 1072 1080 }; 1073 1081 }-*/;
Note:
See TracChangeset
for help on using the changeset viewer.