Commit 069e5326 authored by Tristan Cavelier's avatar Tristan Cavelier

example-queries updated

parent 265e7e0d
...@@ -16,11 +16,11 @@ ...@@ -16,11 +16,11 @@
<table> <table>
<tr> <tr>
<td>Query (String):<br /><textarea id="str">1:abc AND 2:def</textarea></td> <td>Query (String):<br /><textarea id="str">1:abc AND 2:def</textarea></td>
<td>Query (Object):<br /><textarea id="obj">{&quot;type&quot;:&quot;complex&quot;,&quot;operator&quot;:&quot;AND&quot;,&quot;query_list&quot;:[{&quot;type&quot;:&quot;simple&quot;,&quot;operator&quot;:&quot;=&quot;,&quot;id&quot;:&quot;1&quot;,&quot;value&quot;:&quot;abc&quot;},{&quot;type&quot;:&quot;simple&quot;,&quot;operator&quot;:&quot;=&quot;,&quot;id&quot;:&quot;2&quot;,&quot;value&quot;:&quot;def&quot;}]}</textarea></td> <td>Query (Object):<br /><textarea id="obj">{&quot;type&quot;:&quot;complex&quot;,&quot;operator&quot;:&quot;AND&quot;,&quot;query_list&quot;:[{&quot;type&quot;:&quot;simple&quot;,&quot;operator&quot;:&quot;=&quot;,&quot;key&quot;:&quot;1&quot;,&quot;value&quot;:&quot;abc&quot;},{&quot;type&quot;:&quot;simple&quot;,&quot;operator&quot;:&quot;=&quot;,&quot;key&quot;:&quot;2&quot;,&quot;value&quot;:&quot;def&quot;}]}</textarea></td>
</tr> </tr>
<tr> <tr>
<td>Object List:<br /><textarea id="list">[{&quot;1&quot;:&quot;abc&quot;,&quot;2&quot;:&quot;def&quot;},{&quot;1&quot;:&quot;def&quot;,&quot;2&quot;:&quot;abc&quot;}]</textarea></td> <td>Item list (to filter, from 'Query (Object)'):<br /><textarea id="list">[{&quot;1&quot;:&quot;abc&quot;,&quot;2&quot;:&quot;def&quot;},{&quot;1&quot;:&quot;def&quot;,&quot;2&quot;:&quot;abc&quot;}]</textarea></td>
<td>Result (Query String):<br /><textarea id="result">[{&quot;1&quot;:&quot;abc&quot;,&quot;2&quot;:&quot;def&quot;}]</textarea></td> <td>Result list:<br /><textarea id="result">[{&quot;1&quot;:&quot;abc&quot;,&quot;2&quot;:&quot;def&quot;}]</textarea></td>
</tr> </tr>
<tr> <tr>
<td><label for="wildcard">Wildcard char: </label></td> <td><label for="wildcard">Wildcard char: </label></td>
...@@ -39,8 +39,8 @@ ...@@ -39,8 +39,8 @@
<td><input type="text" id="limit" name="limit" value="[0,100]" /></td> <td><input type="text" id="limit" name="limit" value="[0,100]" /></td>
</tr> </tr>
</table> </table>
<button onclick="parse()">Parse</button> <button onclick="searchTextToJson()">Search text to JSON</button>
<button onclick="serialize()">Serialize</button> <button onclick="jsonToSearchText()">JSON to Search text</button>
<button onclick="query()">Query</button> <button onclick="query()">Query</button>
<script type="text/javascript" src="../lib/md5/md5.js"></script> <script type="text/javascript" src="../lib/md5/md5.js"></script>
<script type="text/javascript" src="../lib/jsSha2/sha2.js"></script> <script type="text/javascript" src="../lib/jsSha2/sha2.js"></script>
...@@ -51,26 +51,24 @@ ...@@ -51,26 +51,24 @@
src="http://code.jquery.com/jquery-1.8.2.min.js"></script> src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
<!-- <!--
var parse = function () { var searchTextToJson = function () {
$('#obj').attr('value',JSON.stringify(jIO.ComplexQueries.parse($('#str').attr('value')))); $("#obj").attr("value", JSON.stringify(complex_queries.Query.parseStringToObject($("#str").attr("value"))));
}; };
var serialize = function () { var jsonToSearchText = function () {
$('#str').attr('value',jIO.ComplexQueries.serialize(JSON.parse($('#obj').attr('value')))); $("#str").attr("value", complex_queries.QueryFactory.create(JSON.parse($("#obj").attr("value"))).toString());
}; };
var query = function () { var query = function () {
$('#result').attr('value',JSON.stringify( var list = JSON.parse($("#list").attr("value"));
jIO.ComplexQueries.query( $("#str").attr("value", complex_queries.QueryFactory.create(JSON.parse($("#obj").attr("value"))).exec(
{ list,
query:$('#str').attr('value'), {
filter:{ "wildcard_character": $('#wildcard').attr('value'),
sort_on:JSON.parse($('#sort_on').attr('value')), "sort_on": JSON.parse($("#sort_on").attr("value")),
limit:JSON.parse($('#limit').attr('value')), "limit": JSON.parse($("#limit").attr("value")),
select_list:JSON.parse($('#select_list').attr('value')) "select_list": JSON.parse($("#select_list").attr("value"))
}, }
wildcard_character:$('#wildcard').attr('value') ));
}, JSON.parse($('#list').attr('value')) $("#result").attr("value", JSON.stringify(list));
)
));
}; };
// --> // -->
</script> </script>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment