Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
Allow json param in URL
Browse files Browse the repository at this point in the history
  • Loading branch information
umbrae committed Jun 10, 2011
1 parent 4eb83a1 commit b5dc657
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
Binary file added addons/jsonlint-crx/jsonlint-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions addons/jsonlint-crx/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "JSON Lint",
"description": "Always use double quotes.",
"version": "1",
"app": {
"urls": [
"http://www.jsonlint.com/",
"http://jsonlint.com/"
],
"launch": {
"web_url": "http://jsonlint.com/"
}
},
"icons": {
"128": "jsonlint-logo.png"
},
"permissions": []
}
20 changes: 14 additions & 6 deletions c/js/jsl.interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@ jsl.interactions = (function () {
* @return string the url parameter's value, if any
**/
function getURLParameter(name) {
return decodeURI(
(new RegExp(name + '=' + '(.+?)(&|$)').exec(location.search) || ['', null])[1]
);
param = (new RegExp(name + '=' + '(.+?)(&|$)').exec(location.search) || ['', null])[1];
if (param) {
return decodeURI(param);
} else {
return null;
}
}


/******* INTERACTION METHODS *******/

/**
Expand Down Expand Up @@ -163,8 +165,9 @@ jsl.interactions = (function () {
function init() {
reformatParam = getURLParameter('reformat');
reformat = reformatParam !== '0' && reformatParam !== 'no';
compress = reformatParam === 'compress';

compress = reformatParam === 'compress',
jsonParam = getURLParameter('json');

if (compress) {
$('#headerText').html('JSONLint<span class="light">Compressor</span>');
}
Expand Down Expand Up @@ -203,6 +206,11 @@ jsl.interactions = (function () {
$('#faqButton').click(function () {
$('#faq').slideToggle();
});

if (jsonParam) {
$('#json_input').val(jsonParam);
$('#validate').click();
}
}

return {
Expand Down
2 changes: 1 addition & 1 deletion jsonlint.manifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CACHE MANIFEST
CACHE:

# version: 3
# version: 4
c/css/blueprint/compressed/screen.css
c/css/blueprint/plugins/css-classes/css-classes.css
c/css/screen.css
Expand Down

0 comments on commit b5dc657

Please sign in to comment.