Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
This project is a JSON webservice for running JSLint via PHP. | |||
|
|||
|
|||
Libraries used: | |||
|
|||
Mozilla Rhino: | |||
http://www.mozilla.org/rhino/ | |||
https://developer.mozilla.org/en/Rhino_License | |||
|
|||
|
|||
JSLint: | |||
Copyright 2002 Douglas Crockford | |||
http://jslint.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,34 @@ | |||
<?php | |||
|
|||
$str = ''; | |||
$java = `which java`; | |||
$dir = realpath('./'); | |||
$jslint = $dir.'/lib/jslint/jslint-console.js'; | |||
$rhino = $dir.'/lib/rhino/js.jar'; | |||
|
|||
|
|||
$json = new stdclass(); | |||
|
|||
if ($_POST['source']) { | |||
$str = $_POST['source']; | |||
$tempName = tempnam(sys_get_temp_dir(), 'jslint-'); | |||
file_put_contents($tempName, stripslashes($str)); | |||
chmod($tempName, 0755); | |||
} | |||
|
|||
|
|||
if ($tempName) { | |||
$cmd = $java.' -jar '.escapeshellarg($rhino).' '.escapeshellarg($jslint).' '.escapeshellarg($tempName); | |||
echo($cmd); | |||
$out = exec($cmd, $data); | |||
|
|||
echo('<pre>'.print_r($out, 1).'</pre>'); | |||
echo('<pre>'.print_r($data, 1).'</pre>'); | |||
} else { | |||
$json->error = new stdclass(); | |||
$json->error->message = 'No javascript to lint.'; | |||
} | |||
|
|||
|
|||
echo(json_encode($json)); | |||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,19 @@ | |||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | |||
<html> | |||
<head> | |||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |||
<title>JSON Web Service Test</title> | |||
</head> | |||
<body> | |||
<h2>Posting Source</h2> | |||
|
|||
<form method="post" action="../index.php"> | |||
<textarea name="source" rows="10" cols="50"> | |||
var arr = new Array('1', '2', '3',); | |||
</textarea> | |||
<br><input type="submit" name="go" value="jslint this code"> | |||
</form> | |||
|
|||
</body> | |||
</html> | |||
|