Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[ui] better displays testing stubs

  • Loading branch information...
commit fd2748225af0240e2e1b7cee7a68a55d8548b8f7 1 parent bd351da
@Marak Marak authored
Showing with 21 additions and 20 deletions.
  1. +20 −19 client/js/app.js
  2. +1 −1  server.js
View
39 client/js/app.js
@@ -154,7 +154,10 @@ $(function() {
// custom .trigger logger
var _trigger = $.fn.trigger;
$.fn.trigger = function(name,args,p){
- console.log(name, args, _trigger);
+ // perform some logic to determine what to debug
+ if(typeof name != 'object'){
+ console.log(name, args, _trigger);
+ }
return _trigger.apply(this,arguments);
};
@@ -168,18 +171,16 @@ $(function() {
// jQuery event pooling can be fun for UI events!!!
// http://www.michaelhamrah.com/blog/2008/12/event-pooling-with-jquery-using-bind-and-trigger-managing-complex-javascript/
-
- $(document).bind('ws.submitAST', function(e, data){
-
- $.ajax({
- url: '/export', /* TODO: Need real URL to submit to */
- type: "POST",
- data: JSON.stringify(stubAST),
- success: function(data) {
- //console.log(data);
- //$('#export-data code').html(data);
- }
- });
+ $(document).bind('ws.submitAST', function(e, callback){
+ $.ajax({
+ url: '/export', /* TODO: Need real URL to submit to */
+ type: "POST",
+ dataType: "JSON",
+ data: JSON.stringify(stubAST),
+ success: function(data) {
+ callback(JSON.parse(data));
+ }
+ });
})
$(document).bind('step.activate', function(e, step){
@@ -308,12 +309,8 @@ $(function() {
modal: true,
dialogClass: "shadow",
buttons: {
- "ok": function() {
-
- // put ajax post here
- $(document).trigger('ws.submitAST');
+ "close": function() {
$(this).dialog("close");
-
}
}
});
@@ -343,7 +340,11 @@ $(function() {
setTimeout(progressSlider, 200);
$("footer").click(function() {
- exportAction.dialog("open");
+ // put ajax post here
+ $(document).trigger('ws.submitAST', function(rsp){
+ $('#export-data').html(rsp.text);
+ $('#export-data').dialog("open");
+ });
});
// render milestones
View
2  server.js
@@ -29,7 +29,7 @@ require('http').createServer(function (req, resp) {
// request.uri.params
var jsonAST = JSON.parse(req.body.toString());
// request processing logic goes here
- resp.writeHead(200, {'Content-Type': 'text/plain'});
+ resp.writeHead(200, {'Content-Type': 'application/json'});
resp.write(JSON.stringify(kyuri.compile(jsonAST)));
resp.end();
}
Please sign in to comment.
Something went wrong with that request. Please try again.