blob: 043172acf5b0891f479161c5a2eaa0691d111cec [file] [log] [blame]
<?xml version="1.0"?>
<!--
Copyright 2005 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE script PUBLIC
"-//Apache Software Foundation//Tapestry Script Specification 3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Script_3_0.dtd">
<script>
<input-symbol key="url" class="java.lang.String"/>
<input-symbol key="sendFunctionName" class="java.lang.String"/>
<input-symbol key="receiveFunctionName" class="java.lang.String"/>
<input-symbol key="errorFunctionName" class="java.lang.String"/>
<input-symbol key="disableCaching" class="java.lang.String"/>
<body>
function ${sendFunctionName}()
{
var requestObject = getRequest();
if (!requestObject) {
<if expression="errorFunctionName != null">
${errorFunctionName}();
</if>
return;
}
var url = "${url}";
var arguments = ${sendFunctionName}.arguments;
var argumentCount = arguments.length;
for (i = 0; i &lt; argumentCount; i++) {
url = url + "&amp;sp=" + encodeURI(arguments[i]);
}
<if expression="disableCaching != null">
url = url + "&amp;rand=" + Math.random();
</if>
requestObject.onreadystatechange = function() {
if (requestObject.readyState == 4) {
if (requestObject.status == 200) {
var data = extractData(requestObject);
${receiveFunctionName}(data);
}
<if expression="errorFunctionName != null">
else
${errorFunctionName}(requestObject);
</if>
}
}
requestObject.open("GET", url, true);
requestObject.send(null);
}
<unique>
<![CDATA[
function getRequest()
{
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function extractData(response)
{
var xml = response.responseXML.documentElement;
var dataList = new Array();
if (xml) dataList = xml.getElementsByTagName('sp');
var dataLen = dataList.length;
var data = new Array();
for (i = 0; i < dataLen; i++) {
var child = dataList[i].firstChild;
if (child)
data[i] = child.data;
else
data[i] = "";
}
return data;
}
]]>
</unique>
</body>
</script>