Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

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

0 comments on commit 33cc034

Please sign in to comment.
Something went wrong with that request. Please try again.