Permalink
Browse files

Remove scrollbar for response preview when show a web page or json te…

…xtbox
  • Loading branch information...
1 parent ef1bc80 commit d2ff87e3387c141cf5c67b646d1bdcf28ef40a6b @chao committed Apr 20, 2012
Showing with 45 additions and 42 deletions.
  1. +6 −2 content/css/restclient.css
  2. +17 −15 content/js/restclient.http.js
  3. +12 −9 content/js/restclient.main.js
  4. +10 −16 content/restclient.html
@@ -57,8 +57,8 @@ a, a:hover {
margin-right: 10px;
font-weight: normal;
line-height: 34px;
- background-color: #ccc;
- color: #444;
+ background-color: #ddd;
+ color: #333;
text-shadow: 0 -1px 0 rgba(255, 255, 255, 0.25);
cursor: pointer;
}
@@ -317,6 +317,10 @@ span.header-value {
.popover-inner {
width: 480px !important;
}
+
+#response .overflow {
+ overflow: auto;
+}
@media (min-width: 1200px) {
#request-url {
width: 742px !important;
@@ -104,22 +104,24 @@ restclient.http = {
var contentType = xhr.getResponseHeader("Content-Type");
var displayHandler = 'display';
-
- if(contentType.indexOf('html') >= 0) {
- displayHandler = 'displayHtml';
- }
- if(contentType.indexOf('xml') >= 0) {
- displayHandler = 'displayXml';
- }
- if(contentType.indexOf('json') >= 0) {
- displayHandler = 'displayJson';
- }
- if(contentType.indexOf('image') >= 0) {
- if(restclient.http.mimeType === false)
- displayHandler = 'displayImageRaw';
- else
- displayHandler = 'displayImage';
+ if(contentType && contentType != '') {
+ if(contentType.indexOf('html') >= 0) {
+ displayHandler = 'displayHtml';
+ }
+ if(contentType.indexOf('xml') >= 0) {
+ displayHandler = 'displayXml';
+ }
+ if(contentType.indexOf('json') >= 0) {
+ displayHandler = 'displayJson';
+ }
+ if(contentType.indexOf('image') >= 0) {
+ if(restclient.http.mimeType === false)
+ displayHandler = 'displayImageRaw';
+ else
+ displayHandler = 'displayImage';
+ }
}
+
//console.log(displayHandler);
//console.log(contentType);
restclient.main.checkMimeType.apply(restclient.http, []);
@@ -743,7 +743,8 @@ restclient.main = {
},
showRequest: function(e) {
window.scrollTo(0,0);
- e.preventDefault();
+ if(e)
+ e.preventDefault();
return false;
},
showResponse: function() {
@@ -761,7 +762,7 @@ restclient.main = {
$('#response-body-raw pre').text('');
$('#response-body-highlight pre').text('');
restclient.main.setResponseHeader();
- $("#response-body-preview div.pre").css('overflow', 'auto');
+ $("#response-body-preview div.pre").addClass('overflow');
//$('[href="#response-headers"]').click();
},
checkMimeType: function(){
@@ -814,7 +815,8 @@ restclient.main = {
.attr("type", "content")
.attr("src", "data:text/html," + encodeURIComponent(responseData));
$("#response-body-preview div.pre").append(iframe);
-
+ $("#response-body-preview div.pre").removeClass('overflow');
+
$('#response-body-highlight pre').text(responseData);
}
@@ -860,7 +862,7 @@ restclient.main = {
reformatted = JSON.stringify(JSON.parse(responseData), null, " ");
}catch(e) {}
$('#response-body-highlight pre').text(reformatted);
- $("#response-body-preview div.pre").css('overflow', 'none').append($('<textarea></textarea>').text(reformatted));
+ $("#response-body-preview div.pre").removeClass('overflow').append($('<textarea></textarea>').text(reformatted));
},
displayImage: function() {
var responseData = this.xhr.responseText,
@@ -984,14 +986,14 @@ restclient.main = {
request.body = (request.requestBody) ? request.requestBody : false;
var headers = (request.headers && typeof request.headers == 'object')
? request.headers : false;
- console.log(headers);
+ //console.log(headers);
request.headers = [];
if(headers)
for(var i=0; i < headers.length; i++)
{
request.headers.push([headers[i], headers[++i]]);
}
- console.log(request);
+ //console.log(request);
restclient.main.applyRequest(request);
}catch(e){ alert('Cannot load this request.'); }
});
@@ -1130,13 +1132,14 @@ restclient.main = {
return false;
},
applyRequest: function(request){
+
$('#request-body').val('');
$('#request-url').val('');
- $('#request-method option[value="GET"]').attr('selected', true);
+ $('#request-method').val('GET');
restclient.main.removeHttpRequestHeaders();
- if(request.method) {
- $('#request-method option[value="' + request.method + '"]').attr('selected', true);
+ if(typeof request.method == 'string') {
+ $('#request-method').val(request.method.toUpperCase());
}
if(request.url) {
View
@@ -1,19 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
- <meta charset="utf-8">
<title>RESTClient</title>
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta name="description" content="RESTClient, a debugger for RESTful web services.">
- <meta name="author" content="Chao ZHOU (chao@zhou.fr)">
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta name="description" content="RESTClient, a debugger for RESTful web services." />
+ <meta name="author" content="Chao ZHOU (chao@zhou.fr)" />
<link rel="shortcut icon" href="images/favicon.ico" />
- <style>
- .hide{
- display: none;
- }
- </style>
</head>
-
<body data-spy="scroll" data-target=".subnav" data-offset="50">
<div class="navbar navbar-fixed-top hide showForStartup" style="display:none;">
@@ -28,6 +22,12 @@
<div class="nav-collapse">
<ul class="nav">
<li class="dropdown">
+ <a class="dropdown-toggle" data-toggle="dropdown" href="#">File <b class="caret"></b></a>
+ <ul class="dropdown-menu">
+ <li><a style="cursor:pointer" onclick="restclient.main.loadRequest();return false;">Load request</a></li>
+ </ul>
+ </li>
+ <li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Authorization <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#" onclick="restclient.main.showModal('modal-basic-authorization');return false;">Basic Authorization</a></li>
@@ -51,12 +51,6 @@
<li><a style="cursor:pointer" onclick="restclient.main.showResponse();return false;">Response</a></li>
</ul>
</li>
- <li class="dropdown">
- <a class="dropdown-toggle" data-toggle="dropdown" href="#">File <b class="caret"></b></a>
- <ul class="dropdown-menu">
- <li><a style="cursor:pointer" onclick="restclient.main.loadRequest();return false;">Load request</a></li>
- </ul>
- </li>
</ul>
<ul class="nav pull-right">
<li class="dropdown">

0 comments on commit d2ff87e

Please sign in to comment.