<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>JIO Query Example</title> <style type="text/css" media="screen"> table, textarea, input { width: 100%; } textarea { height: 10em; } </style> </head> <body> <table> <tr> <td>Query (String):<br /><textarea id="str">title:abc AND format:def</textarea></td> <td>Query (Object):<br /><textarea id="obj">{"type":"complex","operator":"AND","query_list":[{"type":"simple","key":"title","value":"abc"},{"type":"simple","key":"format","value":"def"}]}</textarea></td> </tr> <tr> <td>Item list (to filter, from 'Query (Object)'):<br /><textarea id="list">[{"title":"abc","format":"def"},{"title":"def","format":"abc"}]</textarea></td> <td>Result list:<br /><textarea id="result"></textarea></td> </tr> <tr> <td><label for="sort_on">Sort on: </label></td> <td><input type="text" id="sort_on" name="sort_on" value="[["title","ascending"],["format","descending"]]" /></td> </tr> <tr> <td><label for="select_list">Select_list: </label></td> <td><input type="text" id="select_list" name="select_list" value="["title","format"]" /></td> </tr> <tr> <td><label for="limit">Limit: </label></td> <td><input type="text" id="limit" name="limit" value="[0,100]" /></td> </tr> </table> <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/rsvp/rsvp-custom.js"></script> <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script> <script type="text/javascript"> <!-- function searchTextToJson() { $("#obj").attr( "value", JSON.stringify( jIO.QueryFactory.create( $("#str").attr("value") ).serialized() ) ); } function jsonToSearchText() { $("#str").attr( "value", jIO.QueryFactory.create( JSON.parse( $("#obj").attr("value") ) ).toString() ); } function query() { var list = JSON.parse($("#list").attr("value")); jIO.QueryFactory.create( JSON.parse( $("#obj").attr("value") ) ).exec( list, { "sort_on": JSON.parse($("#sort_on").attr("value")), "limit": JSON.parse($("#limit").attr("value")), "select_list": JSON.parse($("#select_list").attr("value")) } ).then(function (list) { $("#result").attr("value", JSON.stringify(list)); }); } // --> </script> </body> </html>