summaryrefslogtreecommitdiffstats
path: root/examples/js.html
blob: 419ba82b706e569da065e8ba124360db8dc58252 (plain)
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
<!DOCTYPE html>
<html>
<head>
    <title>SqlFormatter Javascript Examples</title>
    <style>
        .sql-quote {
            color: blue;
        }
        .sql-backtick-quote {
            color: purple;
        }
        .sql-reserved {
            font-weight: bold;
        }
        .sql-function {
            color: brown;
        }
        .sql-number {
            color: green;
        }
        .sql-word {
            color: #333;
        }
        .sql-comment, .sql-block-comment {
            color: #aaa;
        }
        .sql-variable {
            color: orange;
        }
        .sql-error {
            background: lightcoral;
            color: white;
            padding: 2px;
        }
        
        
        
        #input, #output {
            border: 1px solid #ccc;
            box-sizing: border-box;
            padding: 8px;
            font-family: monospace;
            position: fixed;
            top: 0;
            bottom: 0;
            width: 50%;
            margin: 0;
            display: block;
        }
        #input {
            left: 0;
        }
        #output {
            right: 0;
            overflow: auto;
        }
        .clear { clear: both; }
    </style>
</head>
<body>
    <div class='container'>
        <textarea id='input' placeholder='Paste SQL Here...'></textarea>
        <pre id='output'></pre>
    </div>
    
    
<script src='../lib/SqlFormatter.js'></script>
<script>
    (function() {
        var input = document.getElementById('input');
        var output = document.getElementById('output');
        
        input.addEventListener('change',function(e) {
           output.innerHTML = SqlFormatter.format(input.value); 
        });
        input.addEventListener('keyup',function(e) {
           output.innerHTML = SqlFormatter.format(input.value); 
        });
    })();
</script>
</body>
</html>