Skip to content

Commit

Permalink
Merge branch 'master' into rhinocmdline
Browse files Browse the repository at this point in the history
Merged new changes from upstream.

Conflicts:
	rhino.js
  • Loading branch information
AndyStricker committed Jan 3, 2011
2 parents b99778d + 73c2fe3 commit a233c37
Show file tree
Hide file tree
Showing 8 changed files with 509 additions and 459 deletions.
20 changes: 13 additions & 7 deletions README
Expand Up @@ -3,18 +3,24 @@ JSLint, The JavaScript Code Quality Tool
Douglas Crockford
douglas@crockford.com

2010-11-12
2010-12-02

fulljslint.js contains the fully commented JSLINT function.

fulljslint.html runs the JSLINT function in a web page. The page also depends
on adsafe.js and json2.js (which are not included in this project) and web.js
(which is).
on adsafe.js [www.ADsafe.org] and json2.js [www.JSON.org] (which are not
included in this project) and intercept.js and fullinit_ui.js (which are). The
js files should all be minified, and all except fullinit_ui.js are concatenated
together to form fullwebjslint.js.

web.js scripts the fulljslint.html ui.
intercept.js augments ADsafe, giving widgets access to cookies and the JSLINT
function.

rhino.js is a sample companion script to run fulljslint.js on Rhino.

wsh.js is a sample companion script to run fulljslint.js on WSH.
fullinit_ui.js hooks the HTML ui components to ADsafe.

lint.html describes JSLint's usage.

Direct questions and comments to http://tech.groups.yahoo.com/group/jslint_com/.

JSLint can be run anywhere that JavaScript (or Java) can run. See for example
http://tech.groups.yahoo.com/group/jslint_com/database?method=reportRows&tbl=1
151 changes: 151 additions & 0 deletions fullinit_ui.js
@@ -0,0 +1,151 @@
// init_ui.js
// 2010-12-13

// This is the web browser companion to fulljslint.js. It is an ADsafe
// lib file that implements a web ui by adding behavior to the widget's
// html tags.

// It stores a function in lib.init_ui. Calling that function will
// start up the JSLint widget ui.

// option = {adsafe: true, fragment: false}

/*members check, cookie, each, edition, get, getTitle, getValue, indent,
isArray, join, jslint, lib, maxerr, maxlen, on, passfail, predef, push,
q, select, set, split, value, white
*/

ADSAFE.lib("init_ui", function (lib) {
"use strict";

return function (dom) {
var checkboxes = dom.q('input_checkbox'),
goodparts = checkboxes.q('&goodpart'),
indent = dom.q('#JSLINT_INDENT'),
input = dom.q('#JSLINT_INPUT'),
jslintstring = dom.q('#JSLINT_JSLINTSTRING'),
maxerr = dom.q('#JSLINT_MAXERR'),
maxlen = dom.q('#JSLINT_MAXLEN'),
option = lib.cookie.get(),
output = dom.q('#JSLINT_OUTPUT'),
predefined = dom.q('#JSLINT_PREDEF');

function show_jslint_options() {

// Build and display a jslint control comment.

// The comment can be copied into a .js file.

var a = [], name;
for (name in option) {
if (typeof ADSAFE.get(option, name) === 'boolean') {
a.push(name + ': true');
}
}
if (+option.maxerr > 0) {
a.push('maxerr: ' + option.maxerr);
}
if (+option.maxlen > 0) {
a.push('maxlen: ' + option.maxlen);
}
if (+option.indent > 0) {
a.push('indent: ' + option.indent);
}
jslintstring.value('/*jslint ' + a.join(', ') + ' */');
}

function update_options() {

// Make an object containing the current options.

var value;
option = {};
checkboxes.q(':checked').each(function (bunch) {
ADSAFE.set(option, bunch.getTitle(), true);
});
if (option.white) {
value = +indent.getValue();
if (value && value !== 4) {
option.indent = value;
}
}
if (!option.passfail) {
value = +maxerr.getValue();
if (value && value !== 50) {
option.maxerr = value;
}
}
value = +maxlen.getValue();
option.maxlen = value && value > 0 ? value : 0;
value = predefined.getValue();
if (value) {
option.predef = value.split(/\s*,\s*/);
}
show_jslint_options();
}

// Restore the options from a JSON cookie.

if (!option || typeof option !== 'object') {
option = {};
} else {
checkboxes.each(function (bunch) {
bunch.check(ADSAFE.get(option, bunch.getTitle()));
});
indent.value(option.indent || '4');
maxlen.value(option.maxlen || '');
maxerr.value(option.maxerr || '50');
predefined.value(ADSAFE.isArray(option.predef) ?
option.predef.join(',') : '');
}
show_jslint_options();

// Display the edition.

dom.q('#JSLINT_EDITION').value('Edition ' + lib.edition());

// Add click event handlers to the [JSLint] and [clear] buttons.

dom.q('input&jslint').on('click', function (e) {

// Make a JSON cookie of the option object.

lib.cookie.set(option);

// Call JSLint and display the report.

lib.jslint(input.getValue(), option, output);
input.select();
return false;
});

dom.q('input&clear').on('click', function (e) {
output.value('');
input.value('').select();
});

dom.q('#JSLINT_CLEARALL').on('click', function (e) {
checkboxes.check(false);
indent.value(option.indent || '4');
maxlen.value(option.maxlen || '');
maxerr.value(option.maxerr || '50');
update_options();
});

dom.q('#JSLINT_GOODPARTS').on('click', function (e) {
goodparts.check(true);
update_options();
});

checkboxes.on('click', update_options);
indent.on('change', update_options);
maxerr.on('change', update_options);
maxlen.on('change', update_options);
predefined.on('change', update_options);
input
.on('change', function (e) {
output.value('');
})
.select();
};
});
16 changes: 6 additions & 10 deletions fulljslint.html 100644 → 100755
Expand Up @@ -145,11 +145,7 @@
above and click a <input type="button" name="jslint" value="JSLint">
button. </div>
<div style="margin: 1em; border: 2px solid black; padding: 1em; background-color: lightpink;">
<p>Use of strict mode is highly recommended, but do not use strict mode unless you
fully understand what it does. Strict mode, by design, will break programs.
</p><p>
Do not concatenate strict mode and non-strict mode code together. Doing so can
cause the non-strict code to fail.</p>
<p><a href="http://www.yuiblog.com/blog/2010/12/14/strict-mode-is-coming-to-town/">Strict mode is coming to town.</a></p>
</div>
</div>
<br clear="all">
Expand Down Expand Up @@ -200,7 +196,7 @@
<br>
<input type="checkbox" id="JSLINT_FRAGMENT" title="fragment"><label for="JSLINT_FRAGMENT" title="fragment">Tolerate <tt>HTML</tt> fragments</label>
<br>
<input type="checkbox" id="JSLINT_ES5" title="es5"><label for="JSLINT_ES5" title="es5">Tolerate ES5 syntax</label>
<input type="checkbox" id="JSLINT_ESV" title="es5"><label for="JSLINT_ESV" title="es5">Tolerate ES5 syntax</label>
</div>
<div class="leftcolumn">
<input type="checkbox" id="JSLINT_ONEVAR" title="onevar" name=goodpart><label for="JSLINT_ONEVAR" title="onevar">Allow one <tt>var</tt> statement per function</label>
Expand Down Expand Up @@ -252,20 +248,20 @@
<a href="http://tech.groups.yahoo.com/group/jslint_com/" target="_blank">Join
the JSLint Group.</a> </p>
<script>
"use strict";
ADSAFE.id("JSLINT_");
</script>
<script src="widget.js"></script>
<script src="fullinit_ui.js"></script>
<script>
"use strict";
ADSAFE.go("JSLINT_", function (dom, lib) {
lib.init_jslint_ui(dom);
"use strict";
lib.init_ui(dom);
});
</script>

</div>
<a href="http://www.JSLint.com/"><img src="jslintpill.gif" width="36" height="17" border="0"></a>
<a href="http://tech.groups.yahoo.com/group/jslint_com/"><img src="y.gif" width="31" height="17" border="0"></a>
<a href="https://github.com/douglascrockford/JSLint"><img src="github.gif" width="39" height="16" border="0"></a>
<a href="http://www.ADsafe.org/"><img src="adsafepill.gif" width="36" height="17" border="0"></a>
<a href="http://www.JSON.org/"><img src="jsonpill.gif" width="36" height="17" border="0"></a>
<a href="http://www.1and1.com/?k_id=10219574"><img src="1and1pill.gif" width="36" height="17" border="0"></a>
Expand Down

0 comments on commit a233c37

Please sign in to comment.