input_bar_utils.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. InputBarUtils = function(){
  2. this.processKey = function( event ){
  3. if( event.keyCode == KEY_ENTER ){
  4. var query = $('#mainInput')[0].value.split('(')[0].trim();
  5. var acceptedQueries = ["getCount", "toggleIncUpdate"];
  6. if(query=="help"){
  7. alert("See the text in the developer console (In Chrome, press F12)");
  8. console.log("WARNING :: All commands can be issued after a transformation is loaded!");
  9. console.log("INFO :: You can query the graph before/during/after a transformation using this system.");
  10. console.log("INFO :: Available queries: "+acceptedQueries.toString());
  11. console.log("INFO :: Query usage help");
  12. console.log("getCount :: type 'getCount(\"TypeName\")' to get the number of a specific type in the graph");
  13. console.log("getCount :: You can get the type names in the attribute popup of each element.");
  14. console.log("toggleIncUpdate :: type 'toggleIncUpdate()' to toggle incremental updates (default is on, which will update the model at each step)");
  15. console.log("toggleIncUpdate :: If you turn incremental updates off, the model will be updated at the end.");
  16. }
  17. else if ($.inArray(query, acceptedQueries) > -1) {
  18. console.log("Query '"+query+"' sent! Waiting for reply.");
  19. HttpUtils.httpReq(
  20. 'PUT',
  21. '/__mt/query.transform?wid='+__wid,
  22. {'query':$('#mainInput')[0].value.trim()});
  23. } else {
  24. console.log("ERROR :: Query '"+query+"' is not accepted.\n\tAccepted queries: "+acceptedQueries.toString());
  25. }
  26. }
  27. }
  28. return this;
  29. }();