W
windandwaves
Hi Folk
Can you please have a look at http://www.friars.co.nz/map.php and let
me know if the map is working on IE6 (just do a simple search).
Unfortunately, I do not have IE6 anymore and so I can not test it.
I think there maybe some trouble with retrieving the AJAX xml. Below
is the code for this:
var i = new Array();
var j = 0;
var jmax = 4;
var http_request = false;
Thanks a million
Nicolaas
//------------------------------------ Main functions
//main function to chang the map
function changemap() {
var variables = getformparameters(document.getElementById('mapform'),
'')+ "&h=1&k=1&l=1&m=1";
var onready = "updatemap";
UpdateHtml('_GSmap.php', 'GSmaptype=8' + variables, onready);
//initMapGSmap();
createGSlayer('GSmaptype=1' + variables);
//reset
j = 0;
i = new Array();
return true;
}
// run a search (prior to updating the map)
function getsearchdata() {
var variables = getformparameters(document.getElementById('sea'), '');
variables = variables + "&map=1";
var el = document.getElementById('c2');
el.checked = true;
var el = document.getElementById('syes');
el.checked = true;
var onready = "updatesearchresults";
var url = "searcher.php";
UpdateHtml(url, variables, onready);
return true;
}
//------------------------------------ FORM interaction
//gets all variables from a form
function getformparameters(obj, getstr) {
j++;
for (i[j]=0; i[j] < obj.childNodes.length; i[j]++) {
var newobj = obj.childNodes[i[j]];
tgname = newobj.tagName
if(tgname) {
tgname.toLowerCase;
if (tgname == "INPUT") {
var tvalue = newobj.value;
if(tvalue != 0 && tvalue != "") {
var ttype = newobj.type;
var tname = newobj.name;
if (ttype == "text") {
getstr += "&" + tname + "=" + tvalue ;
}
if (ttype == "checkbox") {
if (newobj.checked) {
getstr += "&" + tname + "=" + tvalue;
}
else {
getstr += "&" + tname + "=0";
}
}
if (ttype == "radio") {
if (newobj.checked) {
getstr += "&" + tname + "=" + tvalue;
}
}
}
}
if (tgname == "SELECT") {
var sel = newobj;
var tvalue = sel.options[sel.selectedIndex].value;
if(tvalue != 0 && tvalue != "") {
getstr += "&" + sel.name + "=" + tvalue;
}
}
}
if(newobj.childNodes.length > 0 && j < jmax) {
getstr = getformparameters(newobj, getstr);
}
}
j--;
return getstr;
}
//------------------------------------ AJAX STARTER
//open xml sheet on the server and specify the function to run when the
xml is loaded
function UpdateHtml(url, parameters, onready) {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
// set type accordingly to anticipated content type
http_request.overrideMimeType('text/xml');
//http_request.overrideMimeType('text/html');
}
}
else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
alert('could not load data');
}
}
}
if (!http_request) {
alert('Cannot create XMLHTTP instance');
return false;
}
if(onready == "updatemap") {
http_request.onreadystatechange = updatemap;
}
else {
http_request.onreadystatechange = updatesearchresults;
}
var geturl = url + '?' + parameters;
document.getElementById(idname + 'title').innerHTML = "loading new map
.... "; //+ geturl;
http_request.open('GET', geturl, true);
http_request.async = false;
http_request.send(null);
}
// -------------- process XML ----------------------------
//process map data
function updatemap() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
//alert(http_request.responseText);
var xmlDoc = http_request.responseXML;
var titlearray = xmlDoc.getElementsByTagName('title');
var infoarray = xmlDoc.getElementsByTagName('info');
var zoomarray = xmlDoc.getElementsByTagName('zoom');
var longitudearray = xmlDoc.getElementsByTagName('longitude');
var lattitudearray = xmlDoc.getElementsByTagName('lattitude');
var info = serializeNode(infoarray[0]);
var a = lattitudearray[0].firstChild.nodeValue;
var o = longitudearray[0].firstChild.nodeValue;
var z = zoomarray[0].firstChild.nodeValue;
if(document.getElementById(idname + 'title')) {
document.getElementById(idname + 'title').innerHTML =
titlearray[0].firstChild.nodeValue;
}
if (document.getElementById(idname + 'info') && 1 == 2) {
document.getElementById(idname + 'info').innerHTML = info;
}
if(document.getElementById('outerinfo')) {
document.getElementById('outerinfo').innerHTML = '' + info + '';
}
GSrezoom(o,a,z);
}
else {
alert('There was a problem with the request.');
}
}
else {
}
}
//process search results
function updatesearchresults() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
var xmlDoc = http_request.responseXML;
var humansqlarray = xmlDoc.getElementsByTagName('humansql');
var humansql = serializeNode(humansqlarray[0]);
document.getElementById('humansql').innerHTML = humansql;
changemap();
}
else {
alert('There was a problem with the request.');
}
}
}
// -------------- XML details ----------------------------
//retrieve data from XML sheet
function serializeNode(node) {
if(node != undefined) {
var xml = "";
if(_browser.isSafari) {
xml = xmlText(node);
}
else if(_browser.isIE) {
xml = node.xml;
}
else {
var serializer = new XMLSerializer();
xml = serializer.serializeToString(node);
}
return xml;
}
else {
return undefined;
}
}
var DOM_ELEMENT_NODE = 1;
var DOM_TEXT_NODE = 3;
/**
* Returns the representation of a node as XML text.
*/
function xmlText(node) {
var ret = '';
if (node.nodeType == DOM_TEXT_NODE) {
ret += node.nodeValue;
}
else if (node.nodeType == DOM_ELEMENT_NODE) {
ret += '<' + node.nodeName;
for (var i = 0; i < node.attributes.length; ++i) {
var a = node.attributes;
if (a && a.nodeName && a.nodeValue) {
ret += ' ' + a.nodeName;
ret += '="' + a.nodeValue + '"';
}
}
if (node.childNodes.length == 0) {
ret += '/>';
}
else {
ret += '>';
for (var i = 0; i < node.childNodes.length; ++i) {
ret += arguments.callee(node.childNodes);
}
ret += '</' + node.nodeName + '>';
}
}
return ret;
}
Can you please have a look at http://www.friars.co.nz/map.php and let
me know if the map is working on IE6 (just do a simple search).
Unfortunately, I do not have IE6 anymore and so I can not test it.
I think there maybe some trouble with retrieving the AJAX xml. Below
is the code for this:
var i = new Array();
var j = 0;
var jmax = 4;
var http_request = false;
Thanks a million
Nicolaas
//------------------------------------ Main functions
//main function to chang the map
function changemap() {
var variables = getformparameters(document.getElementById('mapform'),
'')+ "&h=1&k=1&l=1&m=1";
var onready = "updatemap";
UpdateHtml('_GSmap.php', 'GSmaptype=8' + variables, onready);
//initMapGSmap();
createGSlayer('GSmaptype=1' + variables);
//reset
j = 0;
i = new Array();
return true;
}
// run a search (prior to updating the map)
function getsearchdata() {
var variables = getformparameters(document.getElementById('sea'), '');
variables = variables + "&map=1";
var el = document.getElementById('c2');
el.checked = true;
var el = document.getElementById('syes');
el.checked = true;
var onready = "updatesearchresults";
var url = "searcher.php";
UpdateHtml(url, variables, onready);
return true;
}
//------------------------------------ FORM interaction
//gets all variables from a form
function getformparameters(obj, getstr) {
j++;
for (i[j]=0; i[j] < obj.childNodes.length; i[j]++) {
var newobj = obj.childNodes[i[j]];
tgname = newobj.tagName
if(tgname) {
tgname.toLowerCase;
if (tgname == "INPUT") {
var tvalue = newobj.value;
if(tvalue != 0 && tvalue != "") {
var ttype = newobj.type;
var tname = newobj.name;
if (ttype == "text") {
getstr += "&" + tname + "=" + tvalue ;
}
if (ttype == "checkbox") {
if (newobj.checked) {
getstr += "&" + tname + "=" + tvalue;
}
else {
getstr += "&" + tname + "=0";
}
}
if (ttype == "radio") {
if (newobj.checked) {
getstr += "&" + tname + "=" + tvalue;
}
}
}
}
if (tgname == "SELECT") {
var sel = newobj;
var tvalue = sel.options[sel.selectedIndex].value;
if(tvalue != 0 && tvalue != "") {
getstr += "&" + sel.name + "=" + tvalue;
}
}
}
if(newobj.childNodes.length > 0 && j < jmax) {
getstr = getformparameters(newobj, getstr);
}
}
j--;
return getstr;
}
//------------------------------------ AJAX STARTER
//open xml sheet on the server and specify the function to run when the
xml is loaded
function UpdateHtml(url, parameters, onready) {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
// set type accordingly to anticipated content type
http_request.overrideMimeType('text/xml');
//http_request.overrideMimeType('text/html');
}
}
else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
alert('could not load data');
}
}
}
if (!http_request) {
alert('Cannot create XMLHTTP instance');
return false;
}
if(onready == "updatemap") {
http_request.onreadystatechange = updatemap;
}
else {
http_request.onreadystatechange = updatesearchresults;
}
var geturl = url + '?' + parameters;
document.getElementById(idname + 'title').innerHTML = "loading new map
.... "; //+ geturl;
http_request.open('GET', geturl, true);
http_request.async = false;
http_request.send(null);
}
// -------------- process XML ----------------------------
//process map data
function updatemap() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
//alert(http_request.responseText);
var xmlDoc = http_request.responseXML;
var titlearray = xmlDoc.getElementsByTagName('title');
var infoarray = xmlDoc.getElementsByTagName('info');
var zoomarray = xmlDoc.getElementsByTagName('zoom');
var longitudearray = xmlDoc.getElementsByTagName('longitude');
var lattitudearray = xmlDoc.getElementsByTagName('lattitude');
var info = serializeNode(infoarray[0]);
var a = lattitudearray[0].firstChild.nodeValue;
var o = longitudearray[0].firstChild.nodeValue;
var z = zoomarray[0].firstChild.nodeValue;
if(document.getElementById(idname + 'title')) {
document.getElementById(idname + 'title').innerHTML =
titlearray[0].firstChild.nodeValue;
}
if (document.getElementById(idname + 'info') && 1 == 2) {
document.getElementById(idname + 'info').innerHTML = info;
}
if(document.getElementById('outerinfo')) {
document.getElementById('outerinfo').innerHTML = '' + info + '';
}
GSrezoom(o,a,z);
}
else {
alert('There was a problem with the request.');
}
}
else {
}
}
//process search results
function updatesearchresults() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
var xmlDoc = http_request.responseXML;
var humansqlarray = xmlDoc.getElementsByTagName('humansql');
var humansql = serializeNode(humansqlarray[0]);
document.getElementById('humansql').innerHTML = humansql;
changemap();
}
else {
alert('There was a problem with the request.');
}
}
}
// -------------- XML details ----------------------------
//retrieve data from XML sheet
function serializeNode(node) {
if(node != undefined) {
var xml = "";
if(_browser.isSafari) {
xml = xmlText(node);
}
else if(_browser.isIE) {
xml = node.xml;
}
else {
var serializer = new XMLSerializer();
xml = serializer.serializeToString(node);
}
return xml;
}
else {
return undefined;
}
}
var DOM_ELEMENT_NODE = 1;
var DOM_TEXT_NODE = 3;
/**
* Returns the representation of a node as XML text.
*/
function xmlText(node) {
var ret = '';
if (node.nodeType == DOM_TEXT_NODE) {
ret += node.nodeValue;
}
else if (node.nodeType == DOM_ELEMENT_NODE) {
ret += '<' + node.nodeName;
for (var i = 0; i < node.attributes.length; ++i) {
var a = node.attributes;
if (a && a.nodeName && a.nodeValue) {
ret += ' ' + a.nodeName;
ret += '="' + a.nodeValue + '"';
}
}
if (node.childNodes.length == 0) {
ret += '/>';
}
else {
ret += '>';
for (var i = 0; i < node.childNodes.length; ++i) {
ret += arguments.callee(node.childNodes);
}
ret += '</' + node.nodeName + '>';
}
}
return ret;
}