forked from daniellmb/JavaScript-Scope-Context-Coloring
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscope-coloring.html
More file actions
112 lines (109 loc) · 3.71 KB
/
Copy pathscope-coloring.html
File metadata and controls
112 lines (109 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Scope Context Coloring</title>
<link rel="stylesheet" href="../CodeMirror/lib/codemirror.css">
<link rel="stylesheet" href="../CodeMirror/theme/ambiance.css">
<link rel="stylesheet" href="demo.css">
</head>
<body>
<h1>JavaScript Scope Context Coloring</h1>
<div class="samples">
<strong>Code Samples:</strong>
<a href="#minimonad" id="mini">Mini Monad</a>,
<a href="#fullmonad" id="full">Full Monad</a>,
<a href="#level8" id="eight">8 Levels</a>
</div>
<span id="fork"><a href="https://github.com/daniellmb/JavaScript-Scope-Context-Coloring">Fork me on GitHub</a></span>
<form>
<input type="radio" name="mode" id="n00b" value="n00b">
<label for="n00b">Syntax Coloring</label>
<input type="radio" name="mode" id="grownup" value="pro" checked>
<label for="grownup">Scope Coloring</label>
<span class="legend">
<span class="level0">Level 0</span>
<span class="level1">Level 1</span>
<span class="level2">Level 2</span>
<span class="level3">Level 3</span>
<span class="level4">Level 4</span>
<span class="level5">Level 5</span>
<span class="level6">Level 6</span>
<span class="level7">Level 7</span>
<span class="level8">Level 8</span>
</span>
<br>
<textarea id="editor"></textarea>
</form>
<script src="../CodeMirror/lib/codemirror.js"></script>
<script src="../CodeMirror/mode/javascript/javascript.js"></script>
<script src="../JSLint/jslint.js"></script>
<script src="../scope.js"></script>
<!-- scope coloring samples -->
<script id="minimonad" type="text/html">function MONAD() {
'use strict';
return function unit(value) {
var monad = Object.create(null);
monad.bind = function (func) {
return func(value);
};
return monad;
};
}</script>
<script id="fullmonad" type="text/html">function MONAD(modifier) {
'use strict';
var prototype = Object.create(null);
prototype.is_monad = true;
function unit(value) {
var monad = Object.create(prototype);
monad.bind = function (func, args) {
return func.apply(
undefined,
[value].concat(Array.prototype.slice.apply(args || []))
);
};
if (typeof modifier === 'function') {
value = modifier(monad, value);
}
return monad;
}
unit.method = function (name, func) {
prototype[name] = func;
return unit;
};
unit.lift_value = function (name, func) {
prototype[name] = function () {
return this.bind(func, arguments);
};
return unit;
};
unit.lift = function (name, func) {
prototype[name] = function () {
var result = this.bind(func, arguments);
return result && result.is_monad === true ? result : unit(result);
};
return unit;
};
return unit;
}</script>
<script id="level8" type="text/html">function Level0() {
'use strict';
return function Level1() {
return function Level2() {
return function Level3() {
return function Level4() {
return function Level5() {
return function Level6() {
return function Level7() {
console.warn('Seriously, 8 Levels!?');
};
};
};
};
};
};
};
}</script>
<script src="demo.js"></script>
</body>
</html>