<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Jaggery - Delicious Javascript</title>
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    <!-- Le styles -->
    <link href="../css/bootstrap.css" rel="stylesheet">
    <style type="text/css">
        body {
            padding-top: 60px;
        }
    </style>
    <link href="../css/prettify.css" rel="stylesheet">
    <!-- Le fav and touch icons -->
    <link rel="shortcut icon" href="../images/favicon.ico">
    <link rel="apple-touch-icon" href="../images/apple-touch-icon.png">
    <link rel="apple-touch-icon" sizes="72x72"
          href="../images/apple-touch-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="114x114"
          href="../images/apple-touch-icon-114x114.png">
</head>

<body>

<%
include('/includes/topnavi.jag');
%>

<div class="container-fluid" style="width: 960px; margin: auto;">
    <div class="row">
        <div class="span16">
            <div class="page-header">
                <h1>
                    Documentation
                    <small>API documentation for Jaggery.js</small>
                </h1>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="span4">
            <div class="well">
                <%
                include('/includes/navi.jag');
                %>

            </div>

        </div>
        <div class="span12">
            <div class="content" id="xhr" name="xhr">
                <h3>URIMatcher</h3>
<%
var context = request.getContextPath(),
	parts = context.split("/"),
	length = parts.length,
	i = 0, j = 0, part, matcher = "/";
for(i = 0; i < length; i++) {
	part = parts[i];

	if(part != "") {
		matcher += "{dir" + j++ + "}/";
	}
}
matcher += "{dir" + j + "}/{page}";
%>
                <pre class="prettyprint linenums">
&lt%
var uriMatcher = new URIMatcher(request.getRequestURI());

//Provide a pattern to be matched against the URL
if(uriMatcher.match('<%=matcher%>')) {
    //If pattern matches, elements can be accessed from their keys
    print("dir<%=String(j)%> element is : " + uriMatcher.elements().dir<%=String(j)%>)
}
%&gt
</pre>
                <%
                var xhrCode = '&lt%'
                + '\n var uriMatcher = new URIMatcher(request.getRequestURI());\n'
                + '\n if(uriMatcher.match("' + matcher + '")) {'
                + '\n       print("dir' + j + ' element is : " + uriMatcher.elements().dir' + j + ');'
                + '\n }'
                + '\n %&gt';

                var codeSnip = encodeURIComponent(xhrCode);

                var urlString = '../tryitframe.jag?code='+codeSnip;


                %>
                <div id="tryitwindow" class="modal hide fade">
                    <div class="modal-header">
                        <a href="#" class="close">&times;</a>

                        <h3>Try it now</h3>
                    </div>
                    <div class="modal-body">
                        <iframe src="<%=urlString%>" style="border: none;" width="98%"
                                height="520px" scrolling="no"></iframe>
                    </div>

                </div>

                <p align="right">
                    <button class="btn primary" data-keyboard="true" data-backdrop="true"
                            data-controls-modal="tryitwindow">Try it now
                    </button>
                </p>


        <% hasMembers = false; %>
            <div id="pageLinks">
                <a class="navilink" href="#overview">Overview</a>
                <%if(hasMembers) {%>
                    <a class="navilink" href="#members">Members</a>
                    <%}%>
                    <%if(hasOps) {%>
                        <a class="navilink" href="#operations">Operations</a>
                        <%}%>
                        </div>
                 <section id="overview">


                <h4>Overview</h4>
                <p class="description"> <code>URIMatcher</code> provides the functionality of comparing a given uri with a
                template. This API function will be useful for REST service composition</p>
                </section>
                <section id="operations">
                    <h4>Operations</h4>
                    <table class="clsStd operations-table">

                        <tbody>

                            <tr>

                                <th>Member</th>
                                <th>Returns</th>
                                <th>Description</th>

                            </tr>

                            <tr>
                                <td><code>URIMatcher(uri)</code></td>
                                <td>URIMatcher Object</td>
                                <td>Returns the URIMatcher Object<br><br>
                                    <pre class="prettyprint">var uriMatcher = new URIMatcher(request.uri);</pre>
                                </td>
                            </tr>
                            <tr>

                                <td><code>match(pattern)</code></td>
                                <td>Boolean</td>
                                <td>Returns the bolean for matched <br><br>
                                    <pre class="prettyprint">uriMatcher.match('/{context}/{dir}/{page}');</pre>
                                </td>

                            </tr>
                                    <tr>
                                        <td><code>elements()</code></td>
                                        <td>Object</td>
                                        <td>returns the set of elements, which were matched with the provided uri, and provided template
                                            <br><br>
                                                <pre class="prettyprint">uriMatcher.elements();</pre>
                                            </td>
                                            </tr>
                        </tbody>
                    </table>
                </section>


            </div>
            <!-- /uri div -->
            <br>
            <br>
        </div>

    </div>
    <%
    include('/includes/footer.jag');
    %>

</div>

<!-- /container -->
<%
include('/includes/scripts.jag')
%>
<script>
$(document).ready(function(){
        $('#urimatcher').toggleClass('active')
        $('#docs').addClass('active')
        })

</script>
</body>
</html>