--- trunk2/out/js/search.js 2004/09/24 18:04:48 469 +++ trunk2/out/js/search.js 2004/10/10 06:03:06 496 @@ -79,17 +79,26 @@ From David Flanagan's, _Javascript:_The Definitive_Guide_, pg. 294-5, published by O'Reilly, 4th edition, 2002 */ + +var debug_div = null; + function debug(msg) { // return; // Disable debugging - var debug_div = element_id('debug'); + if (! debug_div) debug_div = document.getElementById('debug'); - if (debug_div) debug_div.innerHTML += msg+"
\n"; + // this will create debug div if it doesn't exist. + if (! debug_div) { + debug_div = document.createElement('div'); + document.body.appendChild(debug_div); + } + if (debug_div) { + debug_div.appendChild(document.createTextNode(msg)); + debug_div.appendChild(document.createElement("br")); + } } -// - // Convert a number into a base 62 alphanumeric number string function convert(num) { @@ -151,6 +160,7 @@ // And tell it what URL to load xmldoc.load(url); + return true; } // Otherwise use Microsoft's proprietary API for Internet Explorer // Something about not following standards once again @@ -164,7 +174,34 @@ if (xmldoc.readyState == 4) handler(xmldoc, url, data, result_handler); } xmldoc.load(url); // Start loading! + return true; + } + // else fallback on usage of iframes to load xml (Opera 7.53 without Java and maybe old Mac browsers) + else { + debug("using iframe xml loader - experimental and slow"); + if (! window.xml_iframe) { + debug("creating iframe"); + window.xml_iframe = document.createElement('div'); + window.xml_iframe.innerHTML = ''; + document.body.appendChild(window.xml_iframe); + } else { + debug("loading xml in existing iframe"); + window.frames.xml_iframe.window.document.location.href = url; + } + + // set timeout to re-check if iframe is loaded + window.iframe_timeout = window.setInterval('iframe_xml_loaded();',100); + + // save some data for iframe_xml_loaded() + window.xml_handler = handler; + window.xml_url = url; + window.xml_data = data; + window.xml_result_handler = result_handler; + return true; } + clearTimeout(watchdog_id); + debug("Browser incompatilibity: can't request XML document by one of supported methods"); + return false; } catch(ex) { @@ -178,6 +215,19 @@ return true; } +function iframe_xml_loaded() { + debug("iframe_xmldoc_loaded"); + if (! window.frames['xml_iframe']) return; + var xml = eval('window.frames.xml_iframe.window.document'); + if (xml) { + clearTimeout(window.iframe_timeout); + debug("calling handler with ("+window.xml_url+","+window.xml_data+",...)"); + window.xml_handler(window.frames.xml_iframe.window.document, window.xml_url, window.xml_data, window.xml_result_handler); + } else { + debug("can't eval iframe with xml"); + } +} + function loadData(xmldoc, url, pos, result_handler) { clearTimeout(watchdog_id);