/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk

« back to all changes in this revision

Viewing changes to codeigniter/js/ace/mode-logiql.js

  • Committer: Gustav Hatvigsson
  • Date: 2013-05-30 12:02:31 UTC
  • mfrom: (85.1.28 lenasys)
  • Revision ID: gustav.hartvigsson@gmail.com-20130530120231-ttqgqjqw2w8enn7g
Merged Ohlsons changes:
added function to get ssn and name for the registrationspages in the user model.
added the registrationpage for students.
edited the registration page for instructors
edited the css for both the registrationpages
minor fix to registration css

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ***** BEGIN LICENSE BLOCK *****
 
2
 * Distributed under the BSD license:
 
3
 *
 
4
 * Copyright (c) 2012, Ajax.org B.V.
 
5
 * All rights reserved.
 
6
 *
 
7
 * Redistribution and use in source and binary forms, with or without
 
8
 * modification, are permitted provided that the following conditions are met:
 
9
 *     * Redistributions of source code must retain the above copyright
 
10
 *       notice, this list of conditions and the following disclaimer.
 
11
 *     * Redistributions in binary form must reproduce the above copyright
 
12
 *       notice, this list of conditions and the following disclaimer in the
 
13
 *       documentation and/or other materials provided with the distribution.
 
14
 *     * Neither the name of Ajax.org B.V. nor the
 
15
 *       names of its contributors may be used to endorse or promote products
 
16
 *       derived from this software without specific prior written permission.
 
17
 *
 
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 
19
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 
20
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 
21
 * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
 
22
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 
23
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 
24
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 
25
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
26
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 
27
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
28
 *
 
29
 * ***** END LICENSE BLOCK ***** */
 
30
 
 
31
define('ace/mode/logiql', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/logiql_highlight_rules', 'ace/mode/folding/coffee', 'ace/token_iterator', 'ace/range'], function(require, exports, module) {
 
32
 
 
33
 
 
34
var oop = require("../lib/oop");
 
35
var TextMode = require("./text").Mode;
 
36
var Tokenizer = require("../tokenizer").Tokenizer;
 
37
var LogiQLHighlightRules = require("./logiql_highlight_rules").LogiQLHighlightRules;
 
38
var FoldMode = require("./folding/coffee").FoldMode;
 
39
var TokenIterator = require("ace/token_iterator").TokenIterator;
 
40
var Range = require("ace/range").Range;
 
41
 
 
42
var Mode = function() {
 
43
    var highlighter = new LogiQLHighlightRules();
 
44
    this.foldingRules = new FoldMode();
 
45
    this.$tokenizer = new Tokenizer(highlighter.getRules());
 
46
};
 
47
oop.inherits(Mode, TextMode);
 
48
 
 
49
(function() {
 
50
    this.lineCommentStart = "//";
 
51
    this.blockComment = {start: "/*", end: "*/"};
 
52
 
 
53
    this.getNextLineIndent = function(state, line, tab) {
 
54
        var indent = this.$getIndent(line);
 
55
        var match = line.match();
 
56
        if (/(-->|<--|<-|->)\s*$/.test(line))
 
57
            indent += tab;
 
58
        return indent;
 
59
    };
 
60
 
 
61
    this.checkOutdent = function(state, line, input) {
 
62
        if (input !== "\n" && input !== "\r\n")
 
63
            return false;
 
64
            
 
65
        if (!/^\s+/.test(line))
 
66
            return false;
 
67
 
 
68
        return true;
 
69
    };
 
70
 
 
71
    this.autoOutdent = function(state, doc, row) {
 
72
        var prevLine = doc.getLine(row);
 
73
        var match = prevLine.match(/^\s+/);
 
74
        var column = prevLine.lastIndexOf(".") + 1;
 
75
        if (!match || !row || !column) return 0;
 
76
 
 
77
        var line = doc.getLine(row + 1);
 
78
        var startRange = this.getMatching(doc, {row: row, column: column});
 
79
        if (!startRange || startRange.start.row == row) return 0;
 
80
 
 
81
        column = match[0].length;
 
82
        var indent = this.$getIndent(doc.getLine(startRange.start.row));
 
83
        doc.replace(new Range(row + 1, 0, row + 1, column), indent);
 
84
    };
 
85
 
 
86
    this.getMatching = function(session, row, column) {
 
87
        if (row == undefined)
 
88
            row = session.selection.lead
 
89
        if (typeof row == "object") {
 
90
            column = row.column;
 
91
            row = row.row;
 
92
        }
 
93
 
 
94
        var startToken = session.getTokenAt(row, column);
 
95
        var KW_START = "keyword.start", KW_END = "keyword.end";
 
96
        var tok;
 
97
        if (!startToken)
 
98
            return;
 
99
        if (startToken.type == KW_START) {
 
100
            var it = new TokenIterator(session, row, column);
 
101
            it.step = it.stepForward;
 
102
        } else if (startToken.type == KW_END) {
 
103
            var it = new TokenIterator(session, row, column);
 
104
            it.step = it.stepBackward;
 
105
        } else
 
106
            return;
 
107
 
 
108
        while (tok = it.step()) {
 
109
            if (tok.type == KW_START || tok.type == KW_END)
 
110
                break;
 
111
        }
 
112
        if (!tok)
 
113
            return;
 
114
 
 
115
        var col = it.getCurrentTokenColumn();
 
116
        var row = it.getCurrentTokenRow();
 
117
        return new Range(row, col, row, col + tok.value.length);
 
118
    };
 
119
}).call(Mode.prototype);
 
120
 
 
121
exports.Mode = Mode;
 
122
});
 
123
 
 
124
define('ace/mode/logiql_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
 
125
 
 
126
 
 
127
var oop = require("../lib/oop");
 
128
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
 
129
 
 
130
var LogiQLHighlightRules = function() {
 
131
 
 
132
    this.$rules = { start: 
 
133
       [ { token: 'comment.block',
 
134
           regex: '/\\*',
 
135
           push: 
 
136
            [ { token: 'comment.block', regex: '\\*/', next: 'pop' },
 
137
              { defaultToken: 'comment.block' } ],
 
138
            },
 
139
         { token: 'comment.single',
 
140
           regex: '//.*',
 
141
            },
 
142
         { token: 'constant.numeric',
 
143
           regex: '\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?',
 
144
            },
 
145
         { token: 'string',
 
146
           regex: '"',
 
147
           push: 
 
148
            [ { token: 'string', regex: '"', next: 'pop' },
 
149
              { defaultToken: 'string' } ],
 
150
            },
 
151
         { token: 'constant.language',
 
152
           regex: '\\b(true|false)\\b',
 
153
            },
 
154
         { token: 'entity.name.type.logicblox',
 
155
           regex: '`[a-zA-Z_:]+(\\d|\\a)*\\b',
 
156
            },
 
157
         { token: 'keyword.start', regex: '->',  comment: 'Constraint' },
 
158
         { token: 'keyword.start', regex: '-->', comment: 'Level 1 Constraint'},
 
159
         { token: 'keyword.start', regex: '<-',  comment: 'Rule' },
 
160
         { token: 'keyword.start', regex: '<--', comment: 'Level 1 Rule' },
 
161
         { token: 'keyword.end',   regex: '\\.', comment: 'Terminator' },
 
162
         { token: 'keyword.other', regex: '!',   comment: 'Negation' },
 
163
         { token: 'keyword.other', regex: ',',   comment: 'Conjunction' },
 
164
         { token: 'keyword.other', regex: ';',   comment: 'Disjunction' },
 
165
         { token: 'keyword.operator', regex: '<=|>=|!=|<|>', comment: 'Equality'},
 
166
         { token: 'keyword.other', regex: '@', comment: 'Equality' },
 
167
         { token: 'keyword.operator', regex: '\\+|-|\\*|/', comment: 'Arithmetic operations'},
 
168
         { token: 'keyword', regex: '::', comment: 'Colon colon' },
 
169
         { token: 'support.function',
 
170
           regex: '\\b(agg\\s*<<)',
 
171
           push: 
 
172
            [ { include: '$self' },
 
173
              { token: 'support.function',
 
174
                regex: '>>',
 
175
                next: 'pop' } ],
 
176
            },
 
177
         { token: 'storage.modifier',
 
178
           regex: '\\b(lang:[\\w:]*)',
 
179
            },
 
180
         { token: [ 'storage.type', 'text' ],
 
181
           regex: '(export|sealed|clauses|block|alias)\\s*\\((?=`)',
 
182
            },
 
183
         { token: 'entity.name',
 
184
           regex: '[a-zA-Z_][a-zA-Z_0-9:]*(@prev|@init|@final)?(?=(\\(|\\[))',
 
185
            },
 
186
         { token: 'variable.parameter',
 
187
           regex: '([a-zA-Z][a-zA-Z_0-9]*|_)\\s*(?=(,|\\.|<-|->|\\)|\\]|=))',
 
188
            } ] }
 
189
    
 
190
    this.normalizeRules();
 
191
};
 
192
 
 
193
oop.inherits(LogiQLHighlightRules, TextHighlightRules);
 
194
 
 
195
exports.LogiQLHighlightRules = LogiQLHighlightRules;
 
196
});
 
197
 
 
198
define('ace/mode/folding/coffee', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode', 'ace/range'], function(require, exports, module) {
 
199
 
 
200
 
 
201
var oop = require("../../lib/oop");
 
202
var BaseFoldMode = require("./fold_mode").FoldMode;
 
203
var Range = require("../../range").Range;
 
204
 
 
205
var FoldMode = exports.FoldMode = function() {};
 
206
oop.inherits(FoldMode, BaseFoldMode);
 
207
 
 
208
(function() {
 
209
 
 
210
    this.getFoldWidgetRange = function(session, foldStyle, row) {
 
211
        var range = this.indentationBlock(session, row);
 
212
        if (range)
 
213
            return range;
 
214
 
 
215
        var re = /\S/;
 
216
        var line = session.getLine(row);
 
217
        var startLevel = line.search(re);
 
218
        if (startLevel == -1 || line[startLevel] != "#")
 
219
            return;
 
220
 
 
221
        var startColumn = line.length;
 
222
        var maxRow = session.getLength();
 
223
        var startRow = row;
 
224
        var endRow = row;
 
225
 
 
226
        while (++row < maxRow) {
 
227
            line = session.getLine(row);
 
228
            var level = line.search(re);
 
229
 
 
230
            if (level == -1)
 
231
                continue;
 
232
 
 
233
            if (line[level] != "#")
 
234
                break;
 
235
 
 
236
            endRow = row;
 
237
        }
 
238
 
 
239
        if (endRow > startRow) {
 
240
            var endColumn = session.getLine(endRow).length;
 
241
            return new Range(startRow, startColumn, endRow, endColumn);
 
242
        }
 
243
    };
 
244
    this.getFoldWidget = function(session, foldStyle, row) {
 
245
        var line = session.getLine(row);
 
246
        var indent = line.search(/\S/);
 
247
        var next = session.getLine(row + 1);
 
248
        var prev = session.getLine(row - 1);
 
249
        var prevIndent = prev.search(/\S/);
 
250
        var nextIndent = next.search(/\S/);
 
251
 
 
252
        if (indent == -1) {
 
253
            session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : "";
 
254
            return "";
 
255
        }
 
256
        if (prevIndent == -1) {
 
257
            if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
 
258
                session.foldWidgets[row - 1] = "";
 
259
                session.foldWidgets[row + 1] = "";
 
260
                return "start";
 
261
            }
 
262
        } else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
 
263
            if (session.getLine(row - 2).search(/\S/) == -1) {
 
264
                session.foldWidgets[row - 1] = "start";
 
265
                session.foldWidgets[row + 1] = "";
 
266
                return "";
 
267
            }
 
268
        }
 
269
 
 
270
        if (prevIndent!= -1 && prevIndent < indent)
 
271
            session.foldWidgets[row - 1] = "start";
 
272
        else
 
273
            session.foldWidgets[row - 1] = "";
 
274
 
 
275
        if (indent < nextIndent)
 
276
            return "start";
 
277
        else
 
278
            return "";
 
279
    };
 
280
 
 
281
}).call(FoldMode.prototype);
 
282
 
 
283
});