2009-06-15 18:47 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* utils/hbmk2/hbmk2.prg
- Deleted hb_DirBase() DJGPP hack after Przemek's fix.
- Deleted gcc compiler command line hack after Przemek's fix.
* contrib/hbxbp/xbp.ch
+ Added extra protection for Windows-only debug line.
* contrib/hbxbp/apig.ch
* Minor in comment.
* contrib/rddado/adordd.prg
* Minor formatting.
* Changed it to use non-legacy OLE interface.
PLEASE REVIEW & TEST.
* contrib/hbwin/legacy.prg
+ Added support for TOleAuto():cClassName var.
+ Added RTE generation in case the OLE object cannot be created.
PLEASE REVIEW & TEST.
+ contrib/rddado/tests/test.mdb
+ Added. It's generated by access2.prg to avoid any problems.
* contrib/rddado/tests/access1.prg
* Minor formatting.
; TOFIX: Does't work:
---
Error BASE/3012 Argument error: OPEN
Called from WIN_OLEAUTO:OPEN(0)
Called from ADO_OPEN(0)
Called from DBUSEAREA(0)
Called from MAIN(11)
---
- examples/uhttpd
+ examples/httpsrv
- examples/httpsrv/uhttpd.ini
+ examples/httpsrv/httpsrv.ini
- examples/httpsrv/uhttpdgd.hbp
+ examples/httpsrv/httpsrvg.hbp
- examples/httpsrv/uhttpdc.c
+ examples/httpsrv/httpsrvc.c
- examples/httpsrv/uhttpd.prg
+ examples/httpsrv/httpsrv.prg
* examples/httpsrv/cookie.prg
* examples/httpsrv/cgifunc.prg
* examples/httpsrv/session.prg
* examples/httpsrv/readme.txt
* Renamed uhttpd to httpsrv.
NOTE: If there are better names proposed I can rename
it to anything else. Mindaugas's new uhttpd will
be name uhttpd2 to avoid any ambiguity.
This commit is contained in:
89
harbour/examples/httpsrv/home/counter.html
Normal file
89
harbour/examples/httpsrv/home/counter.html
Normal file
@@ -0,0 +1,89 @@
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Show Graphic Counter</title>
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<link rel="stylesheet" type="text/css" href="/css/base.css" />
|
||||
<script type="text/javascript" src="/js/ajax.js"></script>
|
||||
<script type="text/javascript">
|
||||
// <![CDATA[
|
||||
|
||||
var divpart;
|
||||
|
||||
/**
|
||||
* Requests table data for a specific page.
|
||||
*
|
||||
* @param pageNum the page number to request data for
|
||||
*/
|
||||
function sendData( force )
|
||||
{
|
||||
var qstr = getquerystring();
|
||||
if ( force || qstr.length > 4 )
|
||||
{
|
||||
//qstr = 'w1=' + escape(qstr); // NOTE: no '?' before querystring
|
||||
//xmlPost('/cgi-bin/showcounter.hrb', qstr + "&sid=" + Math.random(), tableResponseHandler);
|
||||
divpart = 'result';
|
||||
updatepage( escape( qstr ) );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getquerystring()
|
||||
{
|
||||
var form = document.forms[ 'f1' ];
|
||||
var word = form.word.value;
|
||||
//alert( 'qstr: ' + qstr );
|
||||
return word;
|
||||
}
|
||||
|
||||
function updatepage( str )
|
||||
{
|
||||
//document.getElementById( divpart ).innerHTML = str; /* "<img src='/counter/" + str + "' />"; */
|
||||
document.getElementById( divpart ).innerHTML = "<img src='/cgi-bin/showcounter.hrb?w=" + str + "' />";
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for server's response to table requests.
|
||||
* Table content is pulled from response XML and a HTML
|
||||
* table is built. The table is then inserted into the
|
||||
* 'tableSection' DIV.
|
||||
*/
|
||||
function tableResponseHandler()
|
||||
{
|
||||
// Make sure the request is loaded (readyState = 4)
|
||||
if (req.readyState == 4)
|
||||
{
|
||||
// Make sure the status is "OK"
|
||||
if (req.status == 200)
|
||||
{
|
||||
// shutdown Ajax loading progress
|
||||
EndProgress();
|
||||
|
||||
// transform
|
||||
//document.write( xsldoc );
|
||||
updatepage( req.responseText );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
EndProgress();
|
||||
alert("There was a problem retrieving the XML data:\n" +
|
||||
req.statusText);
|
||||
}
|
||||
}
|
||||
}
|
||||
// ]]>
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
This is a simple ajax test. Please type a number (at least 4 digits).
|
||||
<form name="f1" onsubmit='JavaScript:sendData(true);return false'>
|
||||
<p>Number: <input name="word" type="text" onkeyup='JavaScript:sendData(false);return false'>
|
||||
<input value="Go" type="button" onclick='JavaScript:sendData(true)'></p>
|
||||
<div id="result"></div>
|
||||
</form>
|
||||
Return to <a href="/">Main Page</a>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
66
harbour/examples/httpsrv/home/css/base.css
Normal file
66
harbour/examples/httpsrv/home/css/base.css
Normal file
@@ -0,0 +1,66 @@
|
||||
|
||||
body {font-family:Tahoma,Helvetica, Arial;font-size:10pt;color:black;}
|
||||
|
||||
a.pageSection:link {color: #ff0000}
|
||||
a.pageSection:visited {color: #0000ff}
|
||||
a.pageSection:hover {background: #66ff66}
|
||||
|
||||
/*
|
||||
a:link {color: #ff0000}
|
||||
a:visited {color: #0000ff}
|
||||
a:hover {background: #66ff66}
|
||||
*/
|
||||
|
||||
A {
|
||||
color: #0000FF;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
A:hover { color: #6699cc; text-decoration: underline; }
|
||||
A.urls { color: #0A68B6; text-decoration: none; }
|
||||
A.urls:hover { color: #6699cc; text-decoration: underline; }
|
||||
A.tags { color: #008080; text-decoration: none; }
|
||||
A.tags:hover { color: #6699cc; text-decoration: underline; }
|
||||
|
||||
|
||||
|
||||
table.pagetable td
|
||||
{
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
table.datatable
|
||||
{
|
||||
width: 100%;
|
||||
font-family: Verdana;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
table.datatable tr th
|
||||
{
|
||||
border-bottom:1px solid black;
|
||||
padding: 2px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
table.datatable tr td
|
||||
{
|
||||
vertical-align: top;
|
||||
padding: 2px;
|
||||
border-bottom: 1px solid white;
|
||||
}
|
||||
|
||||
table.datatable tr.odd
|
||||
{
|
||||
background-color: #7FFFD4;
|
||||
}
|
||||
|
||||
table.datatable tr.even
|
||||
{
|
||||
background-color: #F0F0F0;
|
||||
}
|
||||
|
||||
table.datatable tr.blank
|
||||
{
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
BIN
harbour/examples/httpsrv/home/favicon.ico
Normal file
BIN
harbour/examples/httpsrv/home/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.9 KiB |
BIN
harbour/examples/httpsrv/home/images/ajax-loader.gif
Normal file
BIN
harbour/examples/httpsrv/home/images/ajax-loader.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
44
harbour/examples/httpsrv/home/index.html
Normal file
44
harbour/examples/httpsrv/home/index.html
Normal file
@@ -0,0 +1,44 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Harbour uHTTPD Server example</title>
|
||||
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Simple uHTTPD server demo</h1>
|
||||
<br />
|
||||
Examples:
|
||||
<br />
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="testajax.html">Test Ajax</a> (*)
|
||||
</li>
|
||||
<li>
|
||||
<a href="testxmldb.html">Test Ajax XML Database</a> (*)
|
||||
</li>
|
||||
<li>
|
||||
<a href="counter.html">Test Ajax Counter</a> (*) (**)
|
||||
</li>
|
||||
<li>
|
||||
<a href="/serverstatus">Server Status</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/info">Alias to /cgi-bin/info.hrb page with server variables</a> (*)
|
||||
</li>
|
||||
<li>
|
||||
<a href="postsample.html">Post method example</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/cookie">Cookie example</a> (*)
|
||||
</li>
|
||||
</ul>
|
||||
<br />
|
||||
(*) Before run these examples, please build files in /uhttpd/modules folder using bldhrb.bat
|
||||
<br />
|
||||
(**) This example requires LIBGD
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
257
harbour/examples/httpsrv/home/js/ajax.js
Normal file
257
harbour/examples/httpsrv/home/js/ajax.js
Normal file
@@ -0,0 +1,257 @@
|
||||
/*
|
||||
Global data var declaration
|
||||
*/
|
||||
|
||||
/**
|
||||
* Open a connection to the specified URL, which is
|
||||
* intended to provide an XML message. The specified data
|
||||
* is sent to the server as parameters. This is the same as
|
||||
* calling xmlOpen("POST", url, toSend, responseHandler).
|
||||
*
|
||||
* @param string url The URL to connect to.
|
||||
* @param string toSend The data to send to the server; must be URL encoded.
|
||||
* @param function responseHandler The Javascript function handling server response.
|
||||
*/
|
||||
function xmlPost(url, toSend, responseHandler)
|
||||
{
|
||||
StartProgress();
|
||||
xmlOpen("POST", url, toSend, responseHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a connection to the specified URL, which is
|
||||
* intended to provide an XML message. No other data is
|
||||
* sent to the server. This is the same as calling
|
||||
* xmlOpen("GET", url, null, responseHandler).
|
||||
*
|
||||
* @param string url The URL to connect to.
|
||||
* @param function responseHandler The Javascript function handling server response.
|
||||
*/
|
||||
function xmlGet(url, responseHandler)
|
||||
{
|
||||
StartProgress();
|
||||
xmlOpen("GET", url, null, responseHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a connection to the specified URL, which is
|
||||
* intended to respond with an XML message.
|
||||
*
|
||||
* @param string method The connection method; either "GET" or "POST".
|
||||
* @param string url The URL to connect to.
|
||||
* @param string toSend The data to send to the server; must be URL encoded.
|
||||
* @param function responseHandler The Javascript function handling server response.
|
||||
*/
|
||||
function xmlOpen(method, url, toSend, responseHandler)
|
||||
{
|
||||
req = null;
|
||||
if (window.XMLHttpRequest)
|
||||
{
|
||||
// browser has native support for XMLHttpRequest object
|
||||
req = new XMLHttpRequest();
|
||||
}
|
||||
else if (window.ActiveXObject)
|
||||
{
|
||||
// try XMLHTTP ActiveX (Internet Explorer) version
|
||||
req = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
}
|
||||
|
||||
if(req)
|
||||
{
|
||||
req.onreadystatechange = responseHandler;
|
||||
req.open(method, url, true);
|
||||
req.setRequestHeader("content-type","application/x-www-form-urlencoded");
|
||||
req.send(toSend);
|
||||
}
|
||||
else
|
||||
{
|
||||
alert('Your browser does not seem to support XMLHttpRequest.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first child node of <code>parent</code> with the
|
||||
* specified tag name.
|
||||
*
|
||||
* @param parent the parent XML DOM node to search
|
||||
* @param tagName the tag name of the child node to search for
|
||||
*/
|
||||
function getNode(parent, tagName)
|
||||
{
|
||||
var i;
|
||||
var max = parent.childNodes.length;
|
||||
|
||||
// Check each child node
|
||||
for(i = 0; i < max; i++)
|
||||
{
|
||||
if(parent.childNodes[i].tagName)
|
||||
{
|
||||
if(parent.childNodes[i].tagName.toUpperCase() == tagName.toUpperCase())
|
||||
{
|
||||
// We found a matching child node; return it.
|
||||
return parent.childNodes[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
// One was not found; return null
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first child node of <code>parent</code> with the
|
||||
* specified tag name and whose value of the 'key' attribute
|
||||
* is <code>key</code>.
|
||||
*
|
||||
* @param parent the parent XML DOM node to search
|
||||
* @param tagName the tag name of the child nodes to search in
|
||||
* @param key the value of the 'key' attribute to search on
|
||||
*/
|
||||
function getNodesWithKey(parent, tagName, key)
|
||||
{
|
||||
var i;
|
||||
var cellNodes = parent.getElementsByTagName(tagName);
|
||||
var max = cellNodes.length;
|
||||
|
||||
// Check each cell node for the specified value for
|
||||
// the 'key' attribute
|
||||
for(i = 0; i < max; i++)
|
||||
{
|
||||
if(cellNodes[i].getAttribute('key') == key)
|
||||
{
|
||||
// We found a matching cell node; return it.
|
||||
return cellNodes[i];
|
||||
}
|
||||
}
|
||||
// One was not found; return null
|
||||
return null;
|
||||
}
|
||||
|
||||
// ----- xslT functions --------------------------------------------------------------------
|
||||
|
||||
// Immediately try to load the xsl file asynchronously
|
||||
var xsldocloaded = false;
|
||||
var xsldoc;
|
||||
|
||||
function xslGet( xslfile )
|
||||
{
|
||||
|
||||
if (window.XSLTProcessor)
|
||||
{
|
||||
// support Mozilla/Gecko based browsers
|
||||
xsldoc = document.implementation.createDocument("", "", null);
|
||||
xsldoc.addEventListener("load", onXslLoad, false);
|
||||
xsldoc.load( xslfile );
|
||||
}
|
||||
else if(window.ActiveXObject)
|
||||
{
|
||||
// support Windows / ActiveX
|
||||
xsldoc = new ActiveXObject("Microsoft.XMLDOM");
|
||||
xsldoc.ondataavailable = onXslLoad;
|
||||
xsldoc.load( xslfile );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onXslLoad()
|
||||
{
|
||||
// flag that the xsl is loaded
|
||||
xsldocloaded = true;
|
||||
//alert( "xsl loaded: " + xsldocloaded )
|
||||
}
|
||||
|
||||
// ----- xslT to HTML functions -----------
|
||||
|
||||
function combine_XLM_XSLT_HTML( xlm, xsl, html, html_id )
|
||||
{
|
||||
|
||||
var swappableSection = html.getElementById( html_id );
|
||||
|
||||
if (window.XSLTProcessor)
|
||||
{
|
||||
// support Mozilla/Gecko based browsers
|
||||
var xsltProcessor = new XSLTProcessor();
|
||||
xsltProcessor.importStylesheet( xsl );
|
||||
var outputXHTML = xsltProcessor.transformToFragment( xlm.responseXML, html );
|
||||
//alert( outputXHTML );
|
||||
swappableSection.innerHTML = "";
|
||||
swappableSection.appendChild( outputXHTML );
|
||||
}
|
||||
else if(window.ActiveXObject)
|
||||
{
|
||||
// support Windows/ActiveX enabled browsers
|
||||
var outputXHTML = xlm.responseXML.transformNode( xsl );
|
||||
//alert( outputXHTML );
|
||||
swappableSection.innerHTML = outputXHTML;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ----- show or hide a progress indicator -----
|
||||
|
||||
var progress = false;
|
||||
var progressTimer = null;
|
||||
|
||||
// show a progress indicator if it takes longer...
|
||||
function StartProgress()
|
||||
{
|
||||
//alert( "progress = " + progress );
|
||||
progress = true;
|
||||
if (progressTimer != null)
|
||||
window.clearTimeout(progressTimer);
|
||||
progressTimer = window.setTimeout(ShowProgress, 220);
|
||||
} // StartProgress
|
||||
|
||||
|
||||
// hide any progress indicator soon.
|
||||
function EndProgress()
|
||||
{
|
||||
progress = false;
|
||||
if (progressTimer != null)
|
||||
window.clearTimeout(progressTimer);
|
||||
progressTimer = window.setTimeout(ShowProgress, 20);
|
||||
} // EndProgress
|
||||
|
||||
|
||||
// this function is called by a timer to show or hide a progress indicator
|
||||
function ShowProgress()
|
||||
{
|
||||
//alert( "Showprogress = " + progress );
|
||||
progressTimer = null;
|
||||
var a = document.getElementById("AjaxProgressIndicator");
|
||||
|
||||
if (progress && (a != null)) {
|
||||
// just display the existing object
|
||||
a.style.top = document.documentElement.scrollTop + 2 + "px";
|
||||
a.style.display = "";
|
||||
|
||||
} else if (progress) {
|
||||
|
||||
// find a relative link to the ajaxcore folder containing ajax.js
|
||||
var path = "/images/"
|
||||
//for (var n in document.scripts) {
|
||||
// s = document.scripts[n].src;
|
||||
// if ((s != null) && (s.length >= 7) && (s.substr(s.length -7).toLowerCase() == "ajax.js"))
|
||||
// path = s.substr(0,s.length -7);
|
||||
//} // for
|
||||
|
||||
// create new standard progress object
|
||||
a = document.createElement("div");
|
||||
a.id = "AjaxProgressIndicator";
|
||||
a.style.position = "absolute";
|
||||
a.style.right = "2px";
|
||||
a.style.top = document.documentElement.scrollTop + 2 + "px";
|
||||
a.style.width = "130px";
|
||||
a.style.height = "16px"
|
||||
a.style.padding = "2px";
|
||||
a.style.verticalAlign = "bottom";
|
||||
a.style.backgroundColor="#9FCDFF";
|
||||
|
||||
a.innerHTML = "<img style='vertical-align:bottom' src='" + path + "ajax-loader.gif?a'> please wait...";
|
||||
document.body.appendChild(a);
|
||||
|
||||
} else if (a) {
|
||||
a.style.display="none";
|
||||
} // if
|
||||
} // ShowProgress
|
||||
|
||||
23
harbour/examples/httpsrv/home/postsample.html
Normal file
23
harbour/examples/httpsrv/home/postsample.html
Normal file
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Harbour uHTTPD Server post example</title>
|
||||
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Simple uHTTPD server method POST</h1>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<form name=test action="/info" method="post">
|
||||
Type something: <input type="text" name="word">
|
||||
<input type="submit">
|
||||
</form>
|
||||
Pressing button you will redirect to /info page. Look at POST and REQUEST values.
|
||||
<br>You will see a "word" variable name.
|
||||
<br>
|
||||
<br>Return to <a href="/">Main Page</a>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
56
harbour/examples/httpsrv/home/testajax.html
Normal file
56
harbour/examples/httpsrv/home/testajax.html
Normal file
@@ -0,0 +1,56 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Simple Ajax Example</title>
|
||||
<script language="Javascript">
|
||||
|
||||
function xmlhttpPost(strURL)
|
||||
{
|
||||
var xmlHttpReq = false;
|
||||
var self = this;
|
||||
// Mozilla/Safari
|
||||
if ( window.XMLHttpRequest )
|
||||
{
|
||||
self.xmlHttpReq = new XMLHttpRequest();
|
||||
}
|
||||
// IE
|
||||
else if ( window.ActiveXObject )
|
||||
{
|
||||
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
}
|
||||
self.xmlHttpReq.open('POST', strURL, true);
|
||||
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
self.xmlHttpReq.onreadystatechange = function()
|
||||
{
|
||||
if ( self.xmlHttpReq.readyState == 4 )
|
||||
{
|
||||
updatepage( self.xmlHttpReq.responseText );
|
||||
}
|
||||
}
|
||||
self.xmlHttpReq.send( getquerystring() );
|
||||
}
|
||||
|
||||
function getquerystring()
|
||||
{
|
||||
var form = document.forms[ 'f1' ];
|
||||
var word = form.word.value;
|
||||
qstr = 'w=' + escape(word); // NOTE: no '?' before querystring
|
||||
return qstr;
|
||||
}
|
||||
|
||||
function updatepage( str )
|
||||
{
|
||||
document.getElementById( "result" ).innerHTML = str;
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
This is a simple ajax test. Please type a string in input field and press GO button.
|
||||
<form name="f1">
|
||||
<p>word: <input name="word" type="text">
|
||||
<input value="Go" type="button" onclick='JavaScript:xmlhttpPost("/cgi-bin/testajax.hrb")'></p>
|
||||
<div id="result"></div>
|
||||
</form>
|
||||
Return to <a href="/">Main Page</a>
|
||||
</body>
|
||||
</html>
|
||||
90
harbour/examples/httpsrv/home/testxmldb.html
Normal file
90
harbour/examples/httpsrv/home/testxmldb.html
Normal file
@@ -0,0 +1,90 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Part 4 Example</title>
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<link rel="stylesheet" type="text/css" href="/css/base.css" />
|
||||
<script type="text/javascript" src="/js/ajax.js"></script>
|
||||
<script type="text/javascript">
|
||||
// <![CDATA[
|
||||
|
||||
var divpart;
|
||||
|
||||
/**
|
||||
* Requests table data for a specific page.
|
||||
*
|
||||
* @param pageNum the page number to request data for
|
||||
*/
|
||||
function getTableData(pageNum)
|
||||
{
|
||||
xslGet( "/xsl/based.xsl" );
|
||||
xmlGet( '/cgi-bin/tableservletdb.hrb?page=' + pageNum + "&sid=" + Math.random(), tableResponseHandler);
|
||||
divpart = 'tableSection';
|
||||
}
|
||||
|
||||
function getTablePages()
|
||||
{
|
||||
xslGet( "/xsl/basep.xsl" );
|
||||
xmlGet( '/cgi-bin/tableservletdb.hrb?count=true' + "&sid=" + Math.random(), tableResponseHandler);
|
||||
divpart = 'pageSection';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handler for server's response to table requests.
|
||||
* Table content is pulled from response XML and a HTML
|
||||
* table is built. The table is then inserted into the
|
||||
* 'tableSection' DIV.
|
||||
*/
|
||||
function tableResponseHandler()
|
||||
{
|
||||
// Make sure the request is loaded (readyState = 4)
|
||||
if (req.readyState == 4)
|
||||
{
|
||||
// Make sure the status is "OK"
|
||||
if (req.status == 200)
|
||||
{
|
||||
// shutdown Ajax loading progress
|
||||
EndProgress();
|
||||
|
||||
// Make sure the XSL document is loaded
|
||||
if (!xsldocloaded)
|
||||
{
|
||||
alert('Unable to transform data. XSL is not yet loaded.');
|
||||
// break out of the function
|
||||
return;
|
||||
}
|
||||
|
||||
// transform
|
||||
//document.write( xsldoc );
|
||||
combine_XLM_XSLT_HTML( req, xsldoc, document, divpart );
|
||||
|
||||
xsldocloaded = null;
|
||||
xsldoc = null;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
alert("There was a problem retrieving the XML data:\n" +
|
||||
req.statusText);
|
||||
}
|
||||
}
|
||||
}
|
||||
// ]]>
|
||||
</script>
|
||||
</head>
|
||||
<body onload="getTablePages()">
|
||||
<BIG>Simple XML servlet</BIG>
|
||||
<br>
|
||||
<br>Tested with IE6+, Firefox 2+ and Opera 9+. Not working with Google Chrome, Safari.
|
||||
<br>Please note that tableservletdb.prg simulates a slow reply of 0.5 seconds.
|
||||
If you want to check real speed please comment #define SIMULATE_SLOW_REPLY in source.
|
||||
<br>Return to <a href="/">Main Page</a>
|
||||
<br>
|
||||
<br>Select a Page
|
||||
<div style="border: 1px solid black; padding: 10px;" id="pageSection"> </div>
|
||||
<br />
|
||||
|
||||
<div style="border: 1px solid black; padding: 10px;" id="tableSection"> </div>
|
||||
</body>
|
||||
</html>
|
||||
74
harbour/examples/httpsrv/home/xsl/based.xsl
Normal file
74
harbour/examples/httpsrv/home/xsl/based.xsl
Normal file
@@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
<xsl:output method="html" omit-xml-declaration="yes" indent="no"/>
|
||||
|
||||
<xsl:variable name="numCols" select="count(table/header/cell)" />
|
||||
<xsl:variable name="numToPad" select="23 - count(table/row)" />
|
||||
<xsl:template match="/">
|
||||
|
||||
<!-- start Data Section table -->
|
||||
<table cellspacing="0" cellpadding="0" class="datatable">
|
||||
|
||||
<tr>
|
||||
|
||||
<xsl:for-each select="table/header/cell">
|
||||
<th><xsl:value-of select="." /></th>
|
||||
</xsl:for-each>
|
||||
|
||||
</tr>
|
||||
|
||||
<xsl:if test="count(table/row) = 0">
|
||||
<tr class="blank">
|
||||
<td width="100%" colspan="{$numCols}" align="center" style="font-style: italic; padding:10px;">No Records Found</td>
|
||||
</tr>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:for-each select="table/row">
|
||||
<xsl:variable name="rowClass">
|
||||
<xsl:choose>
|
||||
<xsl:when test="position() mod 2">even</xsl:when>
|
||||
<xsl:otherwise>odd</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<tr class="{$rowClass}">
|
||||
<xsl:call-template name="buildCell">
|
||||
<xsl:with-param name="rowNode" select="." />
|
||||
</xsl:call-template>
|
||||
</tr>
|
||||
</xsl:for-each>
|
||||
|
||||
<xsl:call-template name="padding">
|
||||
<xsl:with-param name="max_count" select="$numToPad"/>
|
||||
<xsl:with-param name="counter" select="'0'"/>
|
||||
</xsl:call-template>
|
||||
|
||||
</table>
|
||||
<!-- end Data Section table -->
|
||||
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="buildCell">
|
||||
<xsl:param name="rowNode"/>
|
||||
|
||||
<xsl:for-each select="/table/header/cell">
|
||||
<xsl:variable name="colName" select="@key" />
|
||||
<td><xsl:value-of select="$rowNode/*[@key=$colName]" disable-output-escaping="yes"/> </td>
|
||||
</xsl:for-each>
|
||||
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="padding">
|
||||
<xsl:param name="max_count"/>
|
||||
<xsl:param name="counter"/>
|
||||
<xsl:if test="$counter < $max_count">
|
||||
<tr class="blank">
|
||||
<td colspan="{$numCols + 1}"> </td>
|
||||
</tr>
|
||||
<xsl:call-template name="padding">
|
||||
<xsl:with-param name="max_count" select="$max_count"/>
|
||||
<xsl:with-param name="counter" select="$counter + 1"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
24
harbour/examples/httpsrv/home/xsl/basep.xsl
Normal file
24
harbour/examples/httpsrv/home/xsl/basep.xsl
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
<xsl:output method="html" omit-xml-declaration="yes" indent="no"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
|
||||
<!-- start Data Section table -->
|
||||
<table cellspacing="0" cellpadding="0" class="pagetable">
|
||||
|
||||
<tr>
|
||||
|
||||
<xsl:for-each select="pages/page">
|
||||
<td>
|
||||
<xsl:variable name="pagenumber"><xsl:value-of select="." /></xsl:variable>
|
||||
<a class="pageSection" href="javascript: getTableData({$pagenumber});"><xsl:value-of select="$pagenumber" />
|
||||
</a>
|
||||
</td>
|
||||
</xsl:for-each>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
Reference in New Issue
Block a user