Commit 1b356742 authored by Tristan Cavelier's avatar Tristan Cavelier

example-queries.js is now up to date

parent 9fb9b7f5
......@@ -15,12 +15,12 @@
<body>
<table>
<tr>
<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;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>
<td>Query (String):<br /><textarea id="str">title:abc AND format: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;key&quot;:&quot;title&quot;,&quot;value&quot;:&quot;abc&quot;},{&quot;type&quot;:&quot;simple&quot;,&quot;operator&quot;:&quot;=&quot;,&quot;key&quot;:&quot;format&quot;,&quot;value&quot;:&quot;def&quot;}]}</textarea></td>
</tr>
<tr>
<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 list:<br /><textarea id="result">[{&quot;1&quot;:&quot;abc&quot;,&quot;2&quot;:&quot;def&quot;}]</textarea></td>
<td>Item list (to filter, from 'Query (Object)'):<br /><textarea id="list">[{&quot;title&quot;:&quot;abc&quot;,&quot;format&quot;:&quot;def&quot;},{&quot;title&quot;:&quot;def&quot;,&quot;format&quot;:&quot;abc&quot;}]</textarea></td>
<td>Result list:<br /><textarea id="result"></textarea></td>
</tr>
<tr>
<td><label for="wildcard">Wildcard char: </label></td>
......@@ -28,11 +28,11 @@
</tr>
<tr>
<td><label for="sort_on">Sort on: </label></td>
<td><input type="text" id="sort_on" name="sort_on" value="[[&quot;1&quot;,&quot;ascending&quot;],[&quot;2&quot;,&quot;descending&quot;]]" /></td>
<td><input type="text" id="sort_on" name="sort_on" value="[[&quot;title&quot;,&quot;ascending&quot;],[&quot;format&quot;,&quot;descending&quot;]]" /></td>
</tr>
<tr>
<td><label for="select_list">Select_list: </label></td>
<td><input type="text" id="select_list" name="select_list" value="[&quot;1&quot;,&quot;2&quot;]" /></td>
<td><input type="text" id="select_list" name="select_list" value="[&quot;title&quot;,&quot;format&quot;]" /></td>
</tr>
<tr>
<td><label for="limit">Limit: </label></td>
......@@ -42,24 +42,39 @@
<button onclick="searchTextToJson()">Search text to JSON</button>
<button onclick="jsonToSearchText()">JSON to Search text</button>
<button onclick="query()">Query</button>
<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/sjcl/sjcl.min.js"></script>
<script type="text/javascript" src="../jio.min.js"></script>
<script type="text/javascript" src="../complex_queries.min.js"></script>
<script type="text/javascript" src="../lib/rsvp/rsvp-custom.js"></script>
<script type="text/javascript" src="../complex_queries.js"></script>
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
<!--
var searchTextToJson = function () {
$("#obj").attr("value", JSON.stringify(complex_queries.Query.parseStringToObject($("#str").attr("value"))));
};
var jsonToSearchText = function () {
$("#str").attr("value", complex_queries.QueryFactory.create(JSON.parse($("#obj").attr("value"))).toString());
};
var query = function () {
function searchTextToJson() {
$("#obj").attr(
"value",
JSON.stringify(
complex_queries.QueryFactory.create(
$("#str").attr("value")
).serialized()
)
);
}
function jsonToSearchText() {
$("#str").attr(
"value",
complex_queries.QueryFactory.create(
JSON.parse(
$("#obj").attr("value")
)
).toString()
);
}
function query() {
var list = JSON.parse($("#list").attr("value"));
$("#str").attr("value", complex_queries.QueryFactory.create(JSON.parse($("#obj").attr("value"))).exec(
complex_queries.QueryFactory.create(
JSON.parse(
$("#obj").attr("value")
)
).exec(
list,
{
"wildcard_character": $('#wildcard').attr('value'),
......@@ -67,9 +82,10 @@ var query = function () {
"limit": JSON.parse($("#limit").attr("value")),
"select_list": JSON.parse($("#select_list").attr("value"))
}
));
$("#result").attr("value", JSON.stringify(list));
};
).then(function (list) {
$("#result").attr("value", JSON.stringify(list));
});
}
// -->
</script>
</body>
......
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