Skip to content

Commit

Permalink
Added new chili version. Added JSON formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed Aug 4, 2011
1 parent 2e4ee2d commit 3d6a45b
Show file tree
Hide file tree
Showing 11 changed files with 392 additions and 49 deletions.
Binary file modified resources/screen1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/screen2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/screen3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions simple-rest-client/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,5 @@
"response": {"message": "Response"},
"processing": {"message": "Processing"},
"status": {"message": "Status"},
"bad_request": {"message": "Bad request"},
"source": {"message": "<a href='http://github.com/jeremys/Simple-Rest-Client-Chrome-Extension'>Source code</a> licensed under the Apache License"},
"icon": {"message": "icon by <a href='http://jasonrayner.deviantart.com/art/Internet-Icon-icns-and-png-130014831'>Jason Rayner</a>"}
"bad_request": {"message": "Bad request"}
}
18 changes: 0 additions & 18 deletions simple-rest-client/_locales/fr/messages.json

This file was deleted.

7 changes: 7 additions & 0 deletions simple-rest-client/improved_style.css
Original file line number Diff line number Diff line change
Expand Up @@ -397,4 +397,11 @@ li .right {

* html .clearfix {
zoom: 1;
}


#langFormat {
position: absolute;
margin-top: -20px;
margin-left: 100px;
}
15 changes: 10 additions & 5 deletions simple-rest-client/index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<html><head>
<meta charset="utf-8"/>
<title>POSTMan for Google Chrome</title>
<link rel="stylesheet" type="text/css" href="improved_style.css"/>
<link rel="stylesheet" type="text/css" href="css/ui-lightness/jquery-ui-1.8.14.custom.css"/>
<link rel="stylesheet" type="text/css" href="css/ui-lightness/jquery-ui-1.8.14.custom.css"/>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
//<![CDATA[
Expand Down Expand Up @@ -108,8 +108,6 @@ <h4>Edit Params</h4>
<div class="buttonLayout">
<a href="javascript:void(0);" class="editTextButton" onclick="showBodyParamsEditor()"
id="bodyParamsButton" style="margin-left:5px">Params</a>
<a href="javascript:void(0);" class="editTextButton" onclick="showFileSelector()"
id="bodyFileButton" style="margin-left:5px">File</a>
<a href="javascript:void(0);" class="editTextButton" onclick="showRawEditor()"
id="bodyRawButton" style="margin-left:5px">Raw body</a>
</div>
Expand Down Expand Up @@ -162,9 +160,16 @@ <h4>Edit Params</h4>

<div id="respData" style="display:none">
<label for="responseData" class="labelText">Data</label>
<div id="langFormat">
<label for="language" class="labelText">Select format</label>
<select id="language">
<option value="html">HTML/XML</option>
<option value="javascript">JSON</option>
</select>
</div>

<div name="responseData" id="responseData" contenteditable="true">
<pre><code name="codeData" id="codeData" class="chili-lang-html">&nbsp;</code></pre>
<pre><code name="codeData" id="codeData" class="chili-lang-html" data-formatted="false">&nbsp;</code></pre>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions simple-rest-client/jquery.chili.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

367 changes: 347 additions & 20 deletions simple-rest-client/jquery.chili.recipes.js

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions simple-rest-client/requester.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ function readResponse() {
requestEndTime = new Date().getTime();
var diff = requestEndTime - requestStartTime;
$('#ptime span').html(diff + " ms");

$.chili.options.automatic.active = true;
$.chili.options.decoration.lineNumbers = false;
var $chili = $('#codeData').chili();
Expand Down Expand Up @@ -279,6 +280,11 @@ function init() {

//Initialize file input handler
// $("bodyFile").addEventListener("change", handleFileSelect, false);

$('#langFormat').change(function() {
var format = $('#language').val();
setResponseFormat(format);
})
}

function requestExists(requestItem) {
Expand Down Expand Up @@ -842,4 +848,22 @@ function addHeaderAutoComplete() {
source: availableHeaders,
delay: 50
});
}

function setResponseFormat(format) {
$('#codeData').removeClass();
$('#codeData').addClass('chili-lang-' + format);

var val = $('#codeData').html();
var isFormatted = $('#codeData').attr('data-formatted');

if(format === 'javascript' && isFormatted === 'false') {
var jsonObject = JSON.parse(val);
var text = JSON.stringify(jsonObject, null, '\t');
$('#codeData').html(text);
$('#codeData').attr('data-formatted', 'true');
}

$.chili.options.automatic.active = true;
var $chili = $('#codeData').chili();
}
2 changes: 1 addition & 1 deletion simple-rest-client/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@ textarea {
#urlParamsEditor,
#bodyParamsEditor {
display: none;
}
}

0 comments on commit 3d6a45b

Please sign in to comment.