forked from GitHub/gf-core
minibar/pgf_online.js: pass arguments to the browse function in the same way as the other functions
Also document it in gf-web-api-examples.html.
This commit is contained in:
@@ -143,10 +143,20 @@ full API.
|
|||||||
"brackets":{"cat":"_","fid":0,"index":0,"children":[{"cat":"Item","fid":7,"index":0,"children":[{"token":"that"},{"cat":"Kind","fid":6,"index":0,"children":[{"token":"pizza"}]}]},{"token":"is"},{"token":"very"}]},
|
"brackets":{"cat":"_","fid":0,"index":0,"children":[{"cat":"Item","fid":7,"index":0,"children":[{"token":"that"},{"cat":"Kind","fid":6,"index":0,"children":[{"token":"pizza"}]}]},{"token":"is"},{"token":"very"}]},
|
||||||
"completions":["boring","delicious","expensive","fresh","Italian","very","warm"],
|
"completions":["boring","delicious","expensive","fresh","Italian","very","warm"],
|
||||||
"text":""}]
|
"text":""}]
|
||||||
|
<dt class=js><em>// Get info about a category in the abstract syntax</em>
|
||||||
|
<br>server.browse({id:"Kind"},callback)
|
||||||
|
<dt>http://localhost:41296/grammars/Foods.pgf?command=browse&id=Kind&format=json
|
||||||
|
<dd>{"def":"cat Kind",
|
||||||
|
"producers":["Cheese","Fish","Mod","Pizza","Wine"],
|
||||||
|
"consumers":["Mod","That","These","This","Those"]}
|
||||||
|
<dt class=js><em>// Get info about a function in the abstract syntax</em>
|
||||||
|
<br>server.browse({id:"This"},callback)
|
||||||
|
<dt>http://localhost:41296/grammars/Foods.pgf?command=browse&id=This&format=json
|
||||||
|
<dd>{"def":"fun This : Kind -> Item","producers":[],"consumers":[]}
|
||||||
</dl>
|
</dl>
|
||||||
<hr>
|
<hr>
|
||||||
<div class=modtime><small>
|
<div class=modtime><small>
|
||||||
<!-- hhmts start --> Last modified: Tue Oct 18 16:36:36 CEST 2011 <!-- hhmts end -->
|
<!-- hhmts start --> Last modified: Tue Apr 10 15:08:14 CEST 2012 <!-- hhmts end -->
|
||||||
</small></div>
|
</small></div>
|
||||||
<address><a href="http://www.cse.chalmers.se/~hallgren/">TH</a></address>
|
<address><a href="http://www.cse.chalmers.se/~hallgren/">TH</a></address>
|
||||||
|
|
||||||
@@ -444,7 +444,7 @@ Input.prototype.browse=function(id,cont) {
|
|||||||
t.grammar.browse[id]=info;
|
t.grammar.browse[id]=info;
|
||||||
cont(info);
|
cont(info);
|
||||||
}
|
}
|
||||||
t.server.browse(id,browsed);
|
t.server.browse({id:id},browsed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,8 +68,9 @@ function pgf_online(options) {
|
|||||||
translategroup: function(args,cont,err) { // from, input, cat, to
|
translategroup: function(args,cont,err) { // from, input, cat, to
|
||||||
this.pgf_call("translategroup",args,cont,err);
|
this.pgf_call("translategroup",args,cont,err);
|
||||||
},
|
},
|
||||||
browse: function(id,cont,err) {
|
browse: function(args,cont,err) { // id, format
|
||||||
this.pgf_call("browse",{id:id,format:"json"},cont,err);
|
if(!args.format) args.format="json"; // sife effect!!
|
||||||
|
this.pgf_call("browse",args,cont,err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
for(var o in options) server[o]=options[o];
|
for(var o in options) server[o]=options[o];
|
||||||
|
|||||||
Reference in New Issue
Block a user