jslint 1.0.5 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,86 +0,0 @@
1
- // intercept.html
2
- // 2009-08-21
3
-
4
- // This file makes it possible for JSLint to run as an ADsafe widget by
5
- // adding lib features.
6
-
7
- // It provides a JSON cookie facility. Each widget is allowed to create a
8
- // single JSON cookie.
9
-
10
- // It also provides a way for the widget to call JSLint. The widget cannot
11
- // call JSLint directly because it is loaded as a global variable. I don't
12
- // want to change that because other versions of JSLint depend on that.
13
-
14
- /*jslint nomen: false */
15
-
16
- /*global ADSAFE, document, JSLINT */
17
-
18
- /*members ___nodes___, _intercept, cookie, edition, get, getTime,
19
- indexOf, innerHTML, jslint, length, parse, replace, report, set,
20
- setTime, slice, stringify, toGMTString
21
- */
22
-
23
-
24
- "use strict";
25
- ADSAFE._intercept(function (id, dom, lib, bunch) {
26
-
27
- // Give every widget access to a cookie. The name of the cookie will be the
28
- // same as the id of the widget.
29
-
30
- lib.cookie = {
31
- get: function () {
32
-
33
- // Get the raw cookie. Extract this widget's cookie, and parse it.
34
-
35
- var c = ' ' + document.cookie + ';',
36
- s = c.indexOf((' ' + id + '=')),
37
- v;
38
- try {
39
- if (s >= 0) {
40
- s += id.length + 2;
41
- v = JSON.parse(c.slice(s, c.indexOf(';', s)));
42
- }
43
- } catch (ignore) {}
44
- return v;
45
- },
46
- set: function (value) {
47
-
48
- // Set a cookie. It must be under 2000 in length. Escapify equal sign
49
- // and semicolon if necessary.
50
-
51
- var d,
52
- text = JSON.stringify(value)
53
- .replace(/[=]/g, '\\u003d')
54
- .replace(/[;]/g, '\\u003b');
55
-
56
- if (text.length < 2000) {
57
- d = new Date();
58
- d.setTime(d.getTime() + 1e9);
59
- document.cookie = id + "=" + text +
60
- ';expires=' + d.toGMTString();
61
- }
62
- }
63
- };
64
- });
65
-
66
- ADSAFE._intercept(function (id, dom, lib, bunch) {
67
-
68
- // Give only the JSLINT_ widget access to the JSLINT function.
69
- // We add a jslint function to its lib that calls JSLINT and
70
- // then calls JSLINT.report, and stuffs the html result into
71
- // a node provided by the widget. A widget does not get direct
72
- // access to nodes.
73
-
74
- // We also add an edition function to the lib that gives the
75
- // widget access to the current edition string.
76
-
77
- if (id === 'JSLINT_') {
78
- lib.jslint = function (source, options, output) {
79
- JSLINT(source, options);
80
- output.___nodes___[0].innerHTML = JSLINT.report();
81
- };
82
- lib.edition = function () {
83
- return JSLINT.edition;
84
- };
85
- }
86
- });