Permalink
Browse files

Added test for local script and updated display to include the URL

  • Loading branch information...
1 parent 8752750 commit 33cc034427fe716581b2901766a4ce7ae0240e02 @davglass committed Dec 16, 2008
Showing with 38 additions and 3 deletions.
  1. +5 −1 src/js/bp-jslint.js
  2. +7 −2 src/service/JSLint.rb
  3. +1 −0 tests/one.html
  4. +25 −0 tests/two.html
View
6 src/js/bp-jslint.js
@@ -6,8 +6,12 @@
return false;
},
callback: function(data) {
+ console.log(data);
if (data && data.status) {
if (data.errors) {
+ if (data.url) {
+ BPJSLint.log('URL: ' + data.url + '<br>');
+ }
for (var i = 0; i < data.errors.length; i++) {
BPJSLint.log(data.errors[i].line + ', ' + data.errors[i].character + ': <pre>' + data.errors[i].data + '\n' + data.errors[i].reason + '</pre>');
}
@@ -42,7 +46,7 @@
s.border = '1px solid black';
s.position = 'absolute';
//s.height = '50px';
- s.width = '400px';
+ //s.width = '400px';
s.top = '3px';
s.left = '3px';
s.padding = '5px';
View
9 src/service/JSLint.rb
@@ -13,24 +13,29 @@ class JSLint
def initialize(args)
end
- def _lint(txt)
+ def _lint(txt, url)
#@callback.invoke('_lint')
res2 = Net::HTTP.post_form(URI.parse('http://jslint.davglass.com/'), { 'source' => txt })
puts res2.body
#@callback.invoke(res2.body)
obj = JSON.parse(res2.body)
+ if url
+ obj['url'] = url
+ end
@callback.invoke(obj)
end
def _getText(file)
+ #Here I should be able to run jslint locally if they have java installed
+ # if they don't I can fall back to the web service
#@callback.invoke('_getText')
#tmpFil = Tempfile.new('jslint')
#tFile = File.new(tmpFil.path, "w+")
res = Net::HTTP.get_response(URI.parse(file))
#tFile.puts res.body
- _lint(res.body)
+ _lint(res.body, file)
end
def jslint(bp, args)
View
1 tests/one.html
@@ -5,6 +5,7 @@
<body>
<p>
+ This page contains a JavaScript file with syntax errors in it. The BrowserPlus plugin called JSLint will run and show an error message.
</p>
View
25 tests/two.html
@@ -0,0 +1,25 @@
+<html>
+<head>
+ <title>Using BrowserPlus Services</title>
+</head>
+<body>
+
+ <p>
+ This page contains a JavaScript file with syntax errors in it. The BrowserPlus plugin called JSLint will run and show an error message.
+ </p>
+
+
+ <script type="text/javascript" src="http://bp.yahooapis.com/2.1.11/browserplus.js"></script>
+ <script type="text/javascript" src="../src/js/bp-jslint.js"></script>
+ <script type="text/javascript">
+ var bar = function() {};
+ var foo = new bar();
+
+ foo++;
+
+ for (i in test) {
+ alert(i);
+ }
+ </script>
+</body>
+</html>

0 comments on commit 33cc034

Please sign in to comment.