You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@esme.apache.org by rh...@apache.org on 2011/07/17 17:15:47 UTC
svn commit: r1147651 -
/esme/site/trunk/content/docs/clients/pure-javascript-client.mdtext
Author: rhirsch
Date: Sun Jul 17 15:15:47 2011
New Revision: 1147651
URL: http://svn.apache.org/viewvc?rev=1147651&view=rev
Log:
CMS commit to esme by rhirsch
Modified:
esme/site/trunk/content/docs/clients/pure-javascript-client.mdtext
Modified: esme/site/trunk/content/docs/clients/pure-javascript-client.mdtext
URL: http://svn.apache.org/viewvc/esme/site/trunk/content/docs/clients/pure-javascript-client.mdtext?rev=1147651&r1=1147650&r2=1147651&view=diff
==============================================================================
--- esme/site/trunk/content/docs/clients/pure-javascript-client.mdtext (original)
+++ esme/site/trunk/content/docs/clients/pure-javascript-client.mdtext Sun Jul 17 15:15:47 2011
@@ -8,198 +8,198 @@ current implementation, it could be embe
run in a variety of environments including SharePoint, SAP Portal, etc.
This first version offers:
-* Long-polling
-* Flexible design
-* The client uses XSL transformation to create HTML from the XML that
-originates from Apache ESMEâs REST-API.
+ * Long-polling
+ * Flexible design
+ * The client uses XSL transformation to create HTML from the XML that originates from Apache ESMEâs REST-API.
<a name="PureJavaScriptClient-HTMLpage"></a>
-#### HTML page
-{code:lang=javascript}<script type="text/javascript" language="javascript">
-var http_request = false;
-var xslDoc = false;
-function getFirstRequest() {
+### HTML page
+
-Â Â Â //Load XSL File
-Â Â Â xslTest();
-Â Â
-Â Â
-Â Â http_request = GetXmlHttpObject();
-Â Â
-Â Â if (!http_request) {
-Â Â Â Â alert('Cannot create XMLHTTP instance');
-Â Â Â Â return false;
-Â Â }
-Â Â
-Â Â login();
-Â Â
-Â Â getMessages ("http://api.esme.us/esme/api/get_msgs")
-Â Â
-}
-
-function login () {
-Â Â
-Â Â var url = "http://api.esme.us/esme/api/login";
-Â Â var params =
-"token="+encodeURIComponent("NSCPIKQ0QZ0GO2PJXMXGTKRL1O");
-Â Â http_request.open("POST", url, false);
-Â Â //Send the proper header information along with the request
-Â Â http_request.setRequestHeader("Content-type",
-"application/x-www-form-urlencoded");
-Â Â http_request.setRequestHeader("Content-length", params.length);
-Â Â http_request.setRequestHeader("Connection", "close");
-Â Â
-Â Â http_request.send(params);
-Â Â
-}
-
-function getMessages(rest_type) {
-Â Â
-Â Â http_request.open('GET', rest_type, true);
-Â Â http_request.onreadystatechange = pageUpdate;
-Â Â http_request.send(null);
-}
-
-function getNextRequest() {
-Â Â
-Â Â http_request = GetXmlHttpObject();
-Â Â
-Â Â if (!http_request) {
-Â Â Â Â alert('Cannot create XMLHTTP instance');
-Â Â Â Â return false;
-Â Â }
-Â Â
-Â Â login();
-Â Â
-Â Â getMessages ("http://api.esme.us/esme/api/wait_for_msgs")
-Â Â
-}
-
-
-function GetXmlHttpObject() {
-Â Â var xmlHttp = null;
-Â Â try {
-Â Â Â Â // Firefox, Opera 8.0+, Safari
-Â Â Â Â xmlHttp = new XMLHttpRequest();
-Â Â }
-Â Â catch(e) {
-Â Â Â Â // Internet Explorer
-Â Â Â Â try {
-Â Â Â Â Â Â xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
-Â Â Â Â }
-Â Â Â Â catch(e) {
-Â Â Â Â Â Â xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
-Â Â Â Â }
-Â Â }
-Â Â return xmlHttp;
-}
-
-function pageUpdate() {
-Â Â if (http_request.readyState == 0) {
-Â Â Â Â document.getElementById('resultbox').innerHTML = "Sending
-Request...";
-Â Â }
-Â Â if (http_request.readyState == 1) {
-Â Â Â Â document.getElementById('resultbox').innerHTML = "Loading
-Response...";
-Â Â }
-Â Â if (http_request.readyState == 2) {
-Â Â Â Â document.getElementById('resultbox').innerHTML = "Response
-Loaded...";
-Â Â }
-Â Â if (http_request.readyState == 3) {
-Â Â Â Â document.getElementById('resultbox').innerHTML = "Response
-Ready...";
-Â Â }
-Â Â if (http_request.readyState == 4) {
-Â Â Â Â //alert(http_request.responseText);
-Â Â Â Â //addText (http_request.responseText);
-Â Â Â Â loadXML (http_request.responseText);
-Â Â Â Â
-Â Â Â Â http_request.open('GET', "http://api.esme.us/esme/api/logout",
-true);
-Â Â Â Â http_request.send(null);
-Â Â Â Â
-Â Â Â Â getNextRequest();
-Â Â }
-Â Â
-}
-
-function addText (text) {
-Â Â var pTag = document.createElement("p");
-Â Â pTag.setAttribute("align","center");
-Â Â pTag.innerHTML = text;
-Â Â var div = Â document.getElementById("details")
-Â Â div.insertBefore(pTag, div.childNodes[0](0.html)
-);
-Â Â
-}
-
-function loadXML (text) {
-Â Â
-Â Â try //Internet Explorer
-Â Â {
-Â Â Â Â xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
-Â Â Â Â xmlDoc.async="false";
-Â Â Â Â xmlDoc.loadXML(text);
-Â Â }
-Â Â catch(e)
-Â Â {
-Â Â Â Â try //Firefox, Mozilla, Opera, etc.
-Â Â Â Â {
-Â Â Â Â Â Â parser=new DOMParser();
-Â Â Â Â Â Â xmlDoc=parser.parseFromString(text,"text/xml");
-Â Â Â Â }
-Â Â Â Â catch(e) {alert(e.message)}
-Â Â }
-Â Â try
-Â Â {
-Â Â Â Â var sResult = xmlDoc.documentElement.transformNode(xslDoc);
-Â Â Â Â //alert (sResult);
-Â Â Â Â addText (sResult);
-Â Â }
-Â Â catch(e) {
-Â Â Â Â alert(e.message)
-Â Â }
-Â Â
-}
-
-function xslTest () {
-try //Internet Explorer
-{
-Â Â xslDoc=new ActiveXObject("Microsoft.XMLDOM");
-}
-catch(e)
-{
-Â Â try //Firefox, Mozilla, Opera, etc.
-Â Â {
-Â Â Â Â xslDoc=document.implementation.createDocument("","",null);
-Â Â }
-Â Â catch(e) {alert(e.message)}
-}
-try
-{
-Â Â xslDoc.async=false;
-Â Â xslDoc.load("d:/temp/esme.xsl");
-}
-catch(e) {alert(e.message)}
-}
-
-
-
-</script>
-<body onload="getFirstRequest()">
-
-<div id="resultbox"></div>
-<div id="details"><p> </p></div>
-</body>
+ <script type="text/javascript" language="javascript">
+ var http_request = false;
+ var xslDoc = false;
+ function getFirstRequest() {
+
+ Â Â Â //Load XSL File
+ Â Â Â xslTest();
+ Â Â
+ Â Â
+ Â Â http_request = GetXmlHttpObject();
+ Â Â
+ Â Â if (!http_request) {
+ Â Â Â Â alert('Cannot create XMLHTTP instance');
+ Â Â Â Â return false;
+ Â Â }
+ Â Â
+ Â Â login();
+ Â Â
+ Â Â getMessages ("http://api.esme.us/esme/api/get_msgs")
+ Â Â
+ }
+
+ function login () {
+ Â Â
+ Â Â var url = "http://api.esme.us/esme/api/login";
+ Â Â var params =
+ "token="+encodeURIComponent("NSCPIKQ0QZ0GO2PJXMXGTKRL1O");
+ Â Â http_request.open("POST", url, false);
+ Â Â //Send the proper header information along with the request
+ Â Â http_request.setRequestHeader("Content-type",
+ "application/x-www-form-urlencoded");
+ Â Â http_request.setRequestHeader("Content-length", params.length);
+ Â Â http_request.setRequestHeader("Connection", "close");
+ Â Â
+ Â Â http_request.send(params);
+ Â Â
+ }
+
+ function getMessages(rest_type) {
+ Â Â
+ Â Â http_request.open('GET', rest_type, true);
+ Â Â http_request.onreadystatechange = pageUpdate;
+ Â Â http_request.send(null);
+ }
+
+ function getNextRequest() {
+ Â Â
+ Â Â http_request = GetXmlHttpObject();
+ Â Â
+ Â Â if (!http_request) {
+ Â Â Â Â alert('Cannot create XMLHTTP instance');
+ Â Â Â Â return false;
+ Â Â }
+ Â Â
+ Â Â login();
+ Â Â
+ Â Â getMessages ("http://api.esme.us/esme/api/wait_for_msgs")
+ Â Â
+ }
+
+
+ function GetXmlHttpObject() {
+ Â Â var xmlHttp = null;
+ Â Â try {
+ Â Â Â Â // Firefox, Opera 8.0+, Safari
+ Â Â Â Â xmlHttp = new XMLHttpRequest();
+ Â Â }
+ Â Â catch(e) {
+ Â Â Â Â // Internet Explorer
+ Â Â Â Â try {
+ Â Â Â Â Â Â xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
+ Â Â Â Â }
+ Â Â Â Â catch(e) {
+ Â Â Â Â Â Â xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
+ Â Â Â Â }
+ Â Â }
+ Â Â return xmlHttp;
+ }
+
+ function pageUpdate() {
+ Â Â if (http_request.readyState == 0) {
+ Â Â Â Â document.getElementById('resultbox').innerHTML = "Sending
+ Request...";
+ Â Â }
+ Â Â if (http_request.readyState == 1) {
+ Â Â Â Â document.getElementById('resultbox').innerHTML = "Loading
+ Response...";
+ Â Â }
+ Â Â if (http_request.readyState == 2) {
+ Â Â Â Â document.getElementById('resultbox').innerHTML = "Response
+ Loaded...";
+ Â Â }
+ Â Â if (http_request.readyState == 3) {
+ Â Â Â Â document.getElementById('resultbox').innerHTML = "Response
+ Ready...";
+ Â Â }
+ Â Â if (http_request.readyState == 4) {
+ Â Â Â Â //alert(http_request.responseText);
+ Â Â Â Â //addText (http_request.responseText);
+ Â Â Â Â loadXML (http_request.responseText);
+ Â Â Â Â
+ Â Â Â Â http_request.open('GET', "http://api.esme.us/esme/api/logout",
+ true);
+ Â Â Â Â http_request.send(null);
+ Â Â Â Â
+ Â Â Â Â getNextRequest();
+ Â Â }
+ Â Â
+ }
+
+ function addText (text) {
+ Â Â var pTag = document.createElement("p");
+ Â Â pTag.setAttribute("align","center");
+ Â Â pTag.innerHTML = text;
+ Â Â var div = Â document.getElementById("details")
+ Â Â div.insertBefore(pTag, div.childNodes[0](0.html)
+ );
+ Â Â
+ }
+
+ function loadXML (text) {
+ Â Â
+ Â Â try //Internet Explorer
+ Â Â {
+ Â Â Â Â xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
+ Â Â Â Â xmlDoc.async="false";
+ Â Â Â Â xmlDoc.loadXML(text);
+ Â Â }
+ Â Â catch(e)
+ Â Â {
+ Â Â Â Â try //Firefox, Mozilla, Opera, etc.
+ Â Â Â Â {
+ Â Â Â Â Â Â parser=new DOMParser();
+ Â Â Â Â Â Â xmlDoc=parser.parseFromString(text,"text/xml");
+ Â Â Â Â }
+ Â Â Â Â catch(e) {alert(e.message)}
+ Â Â }
+ Â Â try
+ Â Â {
+ Â Â Â Â var sResult = xmlDoc.documentElement.transformNode(xslDoc);
+ Â Â Â Â //alert (sResult);
+ Â Â Â Â addText (sResult);
+ Â Â }
+ Â Â catch(e) {
+ Â Â Â Â alert(e.message)
+ Â Â }
+ Â Â
+ }
+
+ function xslTest () {
+ try //Internet Explorer
+ {
+ Â Â xslDoc=new ActiveXObject("Microsoft.XMLDOM");
+ }
+ catch(e)
+ {
+ Â Â try //Firefox, Mozilla, Opera, etc.
+ Â Â {
+ Â Â Â Â xslDoc=document.implementation.createDocument("","",null);
+ Â Â }
+ Â Â catch(e) {alert(e.message)}
+ }
+ try
+ {
+ Â Â xslDoc.async=false;
+ Â Â xslDoc.load("d:/temp/esme.xsl");
+ }
+ catch(e) {alert(e.message)}
+ }
+
+
+
+ </script>
+ <body onload="getFirstRequest()">
+
+ <div id="resultbox"></div>
+ <div id="details"><p> </p></div>
+ </body>
- h4. XLS File
+##XLS File
- {code:lang=xml}<?xml version="1.0"?>
- <xsl:stylesheet version="1.0"
-xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <?xml version="1.0"?>
+ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
@@ -207,10 +207,8 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Tr
<tr>
<td>
<img>
- <xsl:attribute name="src"><xsl:value-of select="@image"
-/></xsl:attribute>
- <xsl:attribute name="alt"><xsl:value-of select="@name"
-/></xsl:attribute>
+ <xsl:attribute name="src"><xsl:value-of select="@image"/></xsl:attribute>
+ <xsl:attribute name="alt"><xsl:value-of select="@name"/></xsl:attribute>
</img>
From: <xsl:value-of select="@name" />
</td>