From 7c5a7f56ce377691ee6eec797a351121bb3db165 Mon Sep 17 00:00:00 2001 From: Hao Liu Date: Mon, 30 Mar 2015 01:06:08 +0800 Subject: [PATCH] add enter key process for rest --- controller/login.js | 3 --- controller/rest.js | 2 ++ views/rest.html | 24 +++++++++++++++++++----- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/controller/login.js b/controller/login.js index 5cfb34c..8b8f195 100644 --- a/controller/login.js +++ b/controller/login.js @@ -4,9 +4,6 @@ var jsforce = require("jsforce") , util = require("./util"); exports.login = function(req, res, next) { - console.log(req.hostname); - console.log(req.hostname === "localhost"); - console.log(req.hostname == "localhost"); oauth2 = req.hostname === "localhost" ? config.test : config.heroku; oauth2.loginUrl = req.body.login_url; req.session.oauth2 = oauth2; diff --git a/controller/rest.js b/controller/rest.js index d191ae1..b25a650 100644 --- a/controller/rest.js +++ b/controller/rest.js @@ -23,6 +23,8 @@ exports.executeRest = function(req, res, next) { } } + console.log(_request); + var conn = new jsforce.Connection({ accessToken: req.session.accessToken, instanceUrl: req.session.instanceUrl diff --git a/views/rest.html b/views/rest.html index 2fb431e..78ca1d9 100644 --- a/views/rest.html +++ b/views/rest.html @@ -8,7 +8,7 @@

Execute Rest

<% if (notLogin) { %> <% include ./template/notLogin.html %> <%} else { %> -
+
@@ -44,13 +44,13 @@

Place HTTP method, REST URI and Body here:

- +
-
@@ -148,6 +148,15 @@

Execution Result:

} }) + $("#rest_uri").keydown(function(e) { + if (e.keyCode == 13) { + executeRest(); + return false; + } + + return true; + }) + $("#executeRest").on("click", function() { if ($("#rest_body").is(":visible") && !$("#rest_body").val()) { $("#rest_body_div").addClass("has-error"); @@ -156,6 +165,11 @@

Execution Result:

else { $("#rest_body_div").removeClass("has-error"); } + + executeRest(); + }) + + function executeRest() { rest_method = $(".radioBtn.active").children().val(); rest_url = $("#rest_uri").val(); rest_body = $("#rest_body").val(); @@ -177,7 +191,7 @@

Execution Result:

$("#RawJson").val(JSON.stringify(resp, null, " ")); process(); }); - }); + } });