<%@ language = "JavaScript" %>
<%
/*
    $Revision$
    $Id$
*/
ANONYMOUS_Allowed = 1;
%>
<!-- #include file="../../Shared/common.inc" -->
<!DOCTYPE html>
<html>

    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
        <script src="jquery-1.11.3.min.js"></script>
        <script src="tester.js"></script>
        <script src="jquery.iecors.js"></script>
        <script>
            $(document).ready(function()
                {
                    $(doInit);
                    $(doBuild);
                });
        </script>
        <style>
            pre { font-size: 1.2em;
                  -moz-tab-size:4;
                }
            td { vertical-align: top;}
            th {border-bottom: 1px solid #666;line-height:20px;}
            input[type=button],input[type=submit], button {font-weight: bold;}
        </style>
    </head>
    <body style='background-color:#E5EAF1; font-family: Helvetica; font-size: 0.8em;'>
        <form method="post" onsubmit="doSubmit();return false;">
          <table>
            <th colspan="2">FACILITOR API2 tester  -  FOR INTERNAL USE ONLY [ <a href="http://facws001/trunk/api2/">API reference</a> ]</th>
            <tr><td><label>Format</label></td>
                <td><input type='radio' id='format' name='format' value='json' checked='1'>json</input>
                    <input type='radio' id='format' name='format' value='xml'>xml</input>
                    <input type='radio' id='format' name='format' value='html'>html (formatted json)</input>
                    <input type='radio' id='format' name='format' value='api'>api</input>
                </td>
            </tr>
            <tr><td><label>fac_id</label></td>
                <td><input id="facid" type="text" style="width:100px" value="">
                </td>
            </tr>
            <tr><td><label>APIKEY</label></td>
                <td><input id="apikey" type="text" style="width:250px" value="APIPFO">
                </td>
            </tr>
            <tr><td><label>API2</label></td>
                <td><select id="api" style="width:250px">
                    </select>
                </td>
            </tr>
            <tr><td><label>Website</label></td>
<!--                <td><input id="urlbase" type="text" style="width:250px" value="http://uwva.5iwork/Facilitor5iwork"> -->
                <td><input id="urlbase" type="text" style="width:250px" value="<%=safe.htmlattr(HTTP.urlzelf())%>">
                </td>
            </tr>
            <tr><td><label>Scope</label></td>
                <td><select id="scope" style="width:50px">
                        <option></option>
                        <option>fe</option>
                        <option>fo</option>
                        <option>bo</option>
                        <option>mi</option>
                    </select>
                </td>
            </tr>
            <tr><td><label>Pretty JSON</label></td>
                <td><input id="pretty" type="checkbox" checked='1'>
                </td>
            </tr>
            <tr><td><label>Logging</label></td>
                <td><input id="log" type="checkbox" checked='1'></td>
            </tr>
            <tr><td></td><td><input type="button" onclick="doBuild();" value="Build URL"></td></tr>
            <tr><td><label>URL</label></td>
                <td><input id="url" type="text" style="width:800px">
                    <div id="urltest" style="width:800px;color:#888;"></div>
                </td>
            </tr>
            <tr><td><label>Method</label></td>
                <td><input type='radio' id='method' name='method' value='GET' checked='1'>GET</input>
                    <input type='radio' id='method' name='method' value='PUT'>PUT (update)</input>
                    <input type='radio' id='method' name='method' value='POST'>POST (insert)</input>
                    <input type='radio' id='method' name='method' value='DELETE'>DELETE</input>
                </td>
            </tr>
            <tr><td><label>Request body</label></td>
                <td><textarea id="xml" style="height:200px;width:800px">
{
  "appointment": {
    "id": 3328303,
    "from": "2014-06-20T06:00:00Z",
    "to": "2014-06-20T18:00:00Z",
    "description": "Een test afspraak",
    "action": {
      "id": 5,
      "name": "Op laten halen (bellen)"
    },
    "visitors": [
      {
        "id": 5287608,
        "name": "Bezoekernaam",
        "company": "Bezoekerbedrijf",
        "badge": null,
        "in": null,
        "out": null
      }
    ]
  }
}
                    </textarea>
                </td>
            </tr>
            <tr><td></td><td><input type="submit" onclick="doSubmit();return false;" value="Submit"></td></tr>
          </table>
        </form>
        <table>
            <tr><td>Status:</td><td><span id="Status"></span></td></tr>
            <tr><td>StatusText:</td><td><span id="StatusText"></span></td></tr>
            <tr><td>Duration:</td><td><span id="Duration"></span></td></tr>
            <tr><td>Records:</td><td><span id="Records"></span></td></tr>
            <tr><td>Result:<button onclick='$("#xml").val($("#Result").text().replace("\r\n", "\n"))'>^^^</button></td>
                <td style='border:1px solid #666;font-size:0.8em;background-color:#fafafa;min-width:800px;'>
                    <pre id="Result" style="padding:0 8px 0 2px;"></pre>
                </td>
            </tr>
        </table>
    </body>
</html>