Source

webcandy / priv / www / index.html

The default branch has multiple heads

Full commit
<html>
<head>
<!-- 
   by Serge S
   http://bitbucket.org/sunneach/
   September 2008            
-->
<title>iSoap</title>
<style type="text/css">
.err {color: #AA0000}
/*input {background-color: #DDDDDD;padding: 3px; font-size: 10pt;border: 1px solid black;}*/

</style>

<script>

var respx

var debugm = false
//var debugm = true
var ie = false
var enc = "json"

function malert(x){if(debugm) alert(x)}
function geto(id){var o=document.getElementById(id);if (!o) o=document.all[id]; return o}
function setV(id,nv,what){if(what == 'h') geto(id).innerHTML = nv;else if(what == 't') geto(id).innerText = nv;else geto(id).value=nv}
function getV(id,what){if(what == 'h') return geto(id).innerHTML;else if(what == 't') return geto(id).innerText;else return geto(id).value}
function check(reqType){ malert('in check'); malert(reqType); setV("reqtype",reqType,true) }
function addCR(hdr){return hdr.replace(/\n/g,"\r")}
function checkenc(encform){enc=encform}


function ajaxFunction()
{  
  setV("res","\n\nWAIT ...",'t')
  setV("hdr","\n\nWAIT ...",'t')
  setV('err','...sending....','h')
  window.status='Sending request...'
  var xmlHttp;
  try
  {  
    xmlHttp=new XMLHttpRequest();   
    malert('got XMLHttpRequest')
  }
  catch (e)
  {       
    try
    {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      malert('got Msxml2.XMLHTTP')
      ie = true
    }
    catch (e)
    {      
       try
       {
           xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
           malert('got Microsoft.XMLHTTP')
           ie = true
       }
       catch (e)
       {
          malert("Your browser does not support AJAX!");
          return false;       
       }
    }
  }
 
  xmlHttp.onreadystatechange=function()
  {
    setV('err','...received....','h')
    window.status='request state changed'
    if(xmlHttp.readyState==4)
    {
         hdr = xmlHttp.status+ "\n" + xmlHttp.getAllResponseHeaders()
         resp = xmlHttp.responseText
         malert(hdr)
         hdr = ie ? addCR(hdr) : hdr
         malert(hdr)
         setV('hdr',hdr,true)
         malert("response from server: " + resp)
         setV('res', resp == '' ? '- EMPTY RESPONSE BODY -':resp,     true)
         setV('err',"Complete",'h')
     }
      window.status='Done'
  }
  malert(encodeURI('={:}check browser')) 
//  if( navigator.appName !='Microsoft Internet Explorer') mal2(navigator.appName+ ":\n"
//                        +'cross-domain request works on IE only!')
  malert('about open') 
  try
  {
    xmlHttp.open(getV('reqtype',true),getV('url',true))
    malert('about header') 
//  
    var sr = getV('request')
    malert("form:\n" + sr)

    var ct
    var rq
    
    if(enc=="json")
    {
      ct =  "application/json; charset=utf-8";
      rq =  sr
    }
    else
    {
      ct = "application/x-www-form-urlencoded; charset=utf-8"
      rq = encodeURI(sr)
    }

    xmlHttp.setRequestHeader("Content-Type", ct);
    xmlHttp.send(rq)
  }
  catch(e)
  {
    setV('err','Server unavailable','h')
    window.status='Done'
    setV('hdr',"- SERVER UNAVAILABLE -",true)
    setV('res',"- SERVER UNAVAILABLE -",true)
  }
}
</script>

</head>

<body>
   <h1>Sticky Notest - MochiWeb - WebMachine test</h1>
   <a href="stickynotes.html" target="new">Go directly to Sticky Notes!</a><hr>
   <form name="myForm" action="javascript:ajaxFunction()">
   <table id="tt">
     <tr><td>URL:          </td><td><input id="url" type="text" size="90" value='/notes'></td></tr>
     <tr><td>REQUEST TYPE: </td>
         <td>
             <input onclick="check(this.value)" name="reqtype" type="radio" value='POST' checked/>POST&nbsp;&nbsp;
             <input onclick="check(this.value)" name="reqtype" type="radio" value='GET'/>GET&nbsp;&nbsp;
             <input onclick="check(this.value)" name="reqtype" type="radio" value='DELETE'/>DELETE&nbsp;&nbsp;
             <input onclick="check(this.value)" name="reqtype" type="radio" value='PUT'/>PUT&nbsp;&nbsp;
             <input onclick="check(this.value)" name="reqtype" type="radio" value='HEAD'/>HEAD
         </td>
     </tr>
     <tr><td>Encoding to send:</td>
         <td>
             <input onclick="checkenc(this.value)" name="enc" type="radio" value='json'        />JSON&nbsp;&nbsp;
             <input onclick="checkenc(this.value)" name="enc" type="radio" value='enc'  checked/>x-www-form-urlencoded&nbsp;&nbsp;
         </td>
     </tr>

     <tr><td></td><td><input id="reqtype" type="hidden" size="90" value='POST'></td></tr>
     <tr><td>REQUEST BODY:</td><td><textarea class="code1" id="request" rows="2" cols="80">json={"action":"read_all"}</textarea></td></tr>
     <tr><td></td><td><input type="submit" value="send"/></td></tr>
   </table>
   <hr/>
   RESPONSE: &nbsp;&nbsp; <span class="err" id="err"></span><br/>
   <textarea class="code1" id="res" rows="10" cols="80"></textarea><br/>
   HEADERS:<br/>
   <textarea class="code1" id="hdr" rows="11" cols="80"></textarea><br/>
</body>

</html>