Change layout to grab ionicons css framework from local files
This commit is contained in:
11
public/css/lib/ionicons/ionicons.min.css
vendored
Executable file
11
public/css/lib/ionicons/ionicons.min.css
vendored
Executable file
File diff suppressed because one or more lines are too long
1
public/js/lib/codemirror-accessible/.gitignore
vendored
Executable file
1
public/js/lib/codemirror-accessible/.gitignore
vendored
Executable file
@ -0,0 +1 @@
|
|||||||
|
.DS_Store
|
3
public/js/lib/codemirror-accessible/README.md
Executable file
3
public/js/lib/codemirror-accessible/README.md
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
# CodeMirror Accessible
|
||||||
|
|
||||||
|
Read more at the project page: http://bgrins.github.io/codemirror-accessible/
|
80
public/js/lib/codemirror-accessible/accessible.js
Executable file
80
public/js/lib/codemirror-accessible/accessible.js
Executable file
@ -0,0 +1,80 @@
|
|||||||
|
window.onload=function(){
|
||||||
|
if (!window.waitToLoad) {
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function load() {
|
||||||
|
if (window.loaded) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.loaded = true;
|
||||||
|
|
||||||
|
var myTextArea = document.getElementById("editor");
|
||||||
|
var textareaEditor = document.getElementById('textarea-editor');
|
||||||
|
var clonedTextArea = document.getElementById('editor2');
|
||||||
|
|
||||||
|
textareaEditor.value = clonedTextArea.value = myTextArea.value;
|
||||||
|
|
||||||
|
document.getElementById("original-demo").appendChild(clonedTextArea);
|
||||||
|
var myScreenreader = document.getElementById("editor-screenreader");
|
||||||
|
|
||||||
|
var myContentEditable = document.getElementById("content-editable");
|
||||||
|
var button = document.getElementById("toggle-textarea-visibility");
|
||||||
|
|
||||||
|
|
||||||
|
var editor = window.editor = CodeMirror.fromTextArea(myTextArea, {
|
||||||
|
lineNumbers: true,
|
||||||
|
matchBrackets: true,
|
||||||
|
continueComments: "Enter",
|
||||||
|
extraKeys: {"Ctrl-Q": "toggleComment"}
|
||||||
|
});
|
||||||
|
|
||||||
|
var editor2 = window.editor2 = CodeMirrorOriginal.fromTextArea(clonedTextArea, {
|
||||||
|
lineNumbers: true,
|
||||||
|
matchBrackets: true,
|
||||||
|
continueComments: "Enter",
|
||||||
|
extraKeys: {"Ctrl-Q": "toggleComment"}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var textareaVisible = false;
|
||||||
|
function toggleTextareaDisplay() {
|
||||||
|
|
||||||
|
if (!editor.display.input.getAttribute("backup-style")) {
|
||||||
|
editor.display.input.setAttribute("backup-style", editor.display.input.getAttribute("style"));
|
||||||
|
editor.display.input.parentNode.setAttribute("backup-style", editor.display.input.parentNode.getAttribute("style"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (textareaVisible) {
|
||||||
|
editor.display.input.setAttribute("style", editor.display.input.getAttribute("backup-style"));
|
||||||
|
editor.display.input.parentNode.setAttribute("style", editor.display.input.parentNode.getAttribute("backup-style"));
|
||||||
|
editor2.display.input.setAttribute("style", editor.display.input.getAttribute("backup-style"));
|
||||||
|
editor2.display.input.parentNode.setAttribute("style", editor.display.input.parentNode.getAttribute("backup-style"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
editor.display.input.setAttribute("style", "height: 100px; width: 95%; margin-left: 3%; ");
|
||||||
|
editor.display.input.parentNode.setAttribute("style", "");
|
||||||
|
editor2.display.input.setAttribute("style", "height: 100px; width: 95%; margin-left: 3%; ");
|
||||||
|
editor2.display.input.parentNode.setAttribute("style", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
textareaVisible = !textareaVisible;
|
||||||
|
|
||||||
|
if (window.localStorage) {
|
||||||
|
if (textareaVisible) {
|
||||||
|
window.localStorage["toggleTextareaDisplay"] = "1";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
window.localStorage.removeKey("toggleTextareaDisplay");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
button.onclick = toggleTextareaDisplay;
|
||||||
|
|
||||||
|
if (window.localStorage && window.localStorage["toggleTextareaDisplay"]) {
|
||||||
|
toggleTextareaDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
5828
public/js/lib/codemirror-accessible/codemirror-accessible.js
Executable file
5828
public/js/lib/codemirror-accessible/codemirror-accessible.js
Executable file
File diff suppressed because it is too large
Load Diff
5848
public/js/lib/codemirror-accessible/codemirror-accessible2.js
Executable file
5848
public/js/lib/codemirror-accessible/codemirror-accessible2.js
Executable file
File diff suppressed because it is too large
Load Diff
5799
public/js/lib/codemirror-accessible/codemirror-original.js
Executable file
5799
public/js/lib/codemirror-accessible/codemirror-original.js
Executable file
File diff suppressed because it is too large
Load Diff
258
public/js/lib/codemirror-accessible/codemirror.css
Executable file
258
public/js/lib/codemirror-accessible/codemirror.css
Executable file
@ -0,0 +1,258 @@
|
|||||||
|
/* BASICS */
|
||||||
|
|
||||||
|
.CodeMirror {
|
||||||
|
/* Set height, width, borders, and global font properties here */
|
||||||
|
font-family: monospace;
|
||||||
|
height: 300px;
|
||||||
|
}
|
||||||
|
.CodeMirror-scroll {
|
||||||
|
/* Set scrolling behaviour here */
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* PADDING */
|
||||||
|
|
||||||
|
.CodeMirror-lines {
|
||||||
|
padding: 4px 0; /* Vertical padding around content */
|
||||||
|
}
|
||||||
|
.CodeMirror pre {
|
||||||
|
padding: 0 4px; /* Horizontal padding of content */
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
||||||
|
background-color: white; /* The little square between H and V scrollbars */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* GUTTER */
|
||||||
|
|
||||||
|
.CodeMirror-gutters {
|
||||||
|
border-right: 1px solid #ddd;
|
||||||
|
background-color: #f7f7f7;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.CodeMirror-linenumbers {}
|
||||||
|
.CodeMirror-linenumber {
|
||||||
|
padding: 0 3px 0 5px;
|
||||||
|
min-width: 20px;
|
||||||
|
text-align: right;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* CURSOR */
|
||||||
|
|
||||||
|
.CodeMirror div.CodeMirror-cursor {
|
||||||
|
border-left: 1px solid black;
|
||||||
|
z-index: 3;
|
||||||
|
}
|
||||||
|
/* Shown when moving in bi-directional text */
|
||||||
|
.CodeMirror div.CodeMirror-secondarycursor {
|
||||||
|
border-left: 1px solid silver;
|
||||||
|
}
|
||||||
|
.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor {
|
||||||
|
width: auto;
|
||||||
|
border: 0;
|
||||||
|
background: #7e7;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
/* Can style cursor different in overwrite (non-insert) mode */
|
||||||
|
.CodeMirror div.CodeMirror-cursor.CodeMirror-overwrite {}
|
||||||
|
|
||||||
|
.cm-tab { display: inline-block; }
|
||||||
|
|
||||||
|
/* DEFAULT THEME */
|
||||||
|
|
||||||
|
.cm-s-default .cm-keyword {color: #708;}
|
||||||
|
.cm-s-default .cm-atom {color: #219;}
|
||||||
|
.cm-s-default .cm-number {color: #164;}
|
||||||
|
.cm-s-default .cm-def {color: #00f;}
|
||||||
|
.cm-s-default .cm-variable {color: black;}
|
||||||
|
.cm-s-default .cm-variable-2 {color: #05a;}
|
||||||
|
.cm-s-default .cm-variable-3 {color: #085;}
|
||||||
|
.cm-s-default .cm-property {color: black;}
|
||||||
|
.cm-s-default .cm-operator {color: black;}
|
||||||
|
.cm-s-default .cm-comment {color: #a50;}
|
||||||
|
.cm-s-default .cm-string {color: #a11;}
|
||||||
|
.cm-s-default .cm-string-2 {color: #f50;}
|
||||||
|
.cm-s-default .cm-meta {color: #555;}
|
||||||
|
.cm-s-default .cm-error {color: #f00;}
|
||||||
|
.cm-s-default .cm-qualifier {color: #555;}
|
||||||
|
.cm-s-default .cm-builtin {color: #30a;}
|
||||||
|
.cm-s-default .cm-bracket {color: #997;}
|
||||||
|
.cm-s-default .cm-tag {color: #170;}
|
||||||
|
.cm-s-default .cm-attribute {color: #00c;}
|
||||||
|
.cm-s-default .cm-header {color: blue;}
|
||||||
|
.cm-s-default .cm-quote {color: #090;}
|
||||||
|
.cm-s-default .cm-hr {color: #999;}
|
||||||
|
.cm-s-default .cm-link {color: #00c;}
|
||||||
|
|
||||||
|
.cm-negative {color: #d44;}
|
||||||
|
.cm-positive {color: #292;}
|
||||||
|
.cm-header, .cm-strong {font-weight: bold;}
|
||||||
|
.cm-em {font-style: italic;}
|
||||||
|
.cm-link {text-decoration: underline;}
|
||||||
|
|
||||||
|
.cm-invalidchar {color: #f00;}
|
||||||
|
|
||||||
|
div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
|
||||||
|
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
||||||
|
|
||||||
|
/* STOP */
|
||||||
|
|
||||||
|
/* The rest of this file contains styles related to the mechanics of
|
||||||
|
the editor. You probably shouldn't touch them. */
|
||||||
|
|
||||||
|
.CodeMirror {
|
||||||
|
line-height: 1;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
background: white;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-scroll {
|
||||||
|
/* 30px is the magic margin used to hide the element's real scrollbars */
|
||||||
|
/* See overflow: hidden in .CodeMirror */
|
||||||
|
margin-bottom: -30px; margin-right: -30px;
|
||||||
|
padding-bottom: 30px; padding-right: 30px;
|
||||||
|
height: 100%;
|
||||||
|
outline: none; /* Prevent dragging from highlighting the element */
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.CodeMirror-sizer {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
||||||
|
before actuall scrolling happens, thus preventing shaking and
|
||||||
|
flickering artifacts. */
|
||||||
|
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
||||||
|
position: absolute;
|
||||||
|
z-index: 6;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.CodeMirror-vscrollbar {
|
||||||
|
right: 0; top: 0;
|
||||||
|
overflow-x: hidden;
|
||||||
|
overflow-y: scroll;
|
||||||
|
}
|
||||||
|
.CodeMirror-hscrollbar {
|
||||||
|
bottom: 0; left: 0;
|
||||||
|
overflow-y: hidden;
|
||||||
|
overflow-x: scroll;
|
||||||
|
}
|
||||||
|
.CodeMirror-scrollbar-filler {
|
||||||
|
right: 0; bottom: 0;
|
||||||
|
}
|
||||||
|
.CodeMirror-gutter-filler {
|
||||||
|
left: 0; bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-gutters {
|
||||||
|
position: absolute; left: 0; top: 0;
|
||||||
|
padding-bottom: 30px;
|
||||||
|
z-index: 3;
|
||||||
|
}
|
||||||
|
.CodeMirror-gutter {
|
||||||
|
white-space: normal;
|
||||||
|
height: 100%;
|
||||||
|
padding-bottom: 30px;
|
||||||
|
margin-bottom: -32px;
|
||||||
|
display: inline-block;
|
||||||
|
/* Hack to make IE7 behave */
|
||||||
|
*zoom:1;
|
||||||
|
*display:inline;
|
||||||
|
}
|
||||||
|
.CodeMirror-gutter-elt {
|
||||||
|
position: absolute;
|
||||||
|
cursor: default;
|
||||||
|
z-index: 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-lines {
|
||||||
|
cursor: text;
|
||||||
|
}
|
||||||
|
.CodeMirror pre {
|
||||||
|
/* Reset some styles that the rest of the page might have set */
|
||||||
|
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
|
||||||
|
border-width: 0;
|
||||||
|
background: transparent;
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: inherit;
|
||||||
|
margin: 0;
|
||||||
|
white-space: pre;
|
||||||
|
word-wrap: normal;
|
||||||
|
line-height: inherit;
|
||||||
|
color: inherit;
|
||||||
|
z-index: 2;
|
||||||
|
position: relative;
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
|
.CodeMirror-wrap pre {
|
||||||
|
word-wrap: break-word;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-break: normal;
|
||||||
|
}
|
||||||
|
.CodeMirror-code pre {
|
||||||
|
border-right: 30px solid transparent;
|
||||||
|
width: -webkit-fit-content;
|
||||||
|
width: -moz-fit-content;
|
||||||
|
width: fit-content;
|
||||||
|
}
|
||||||
|
.CodeMirror-wrap .CodeMirror-code pre {
|
||||||
|
border-right: none;
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
.CodeMirror-linebackground {
|
||||||
|
position: absolute;
|
||||||
|
left: 0; right: 0; top: 0; bottom: 0;
|
||||||
|
z-index: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-linewidget {
|
||||||
|
position: relative;
|
||||||
|
z-index: 2;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-widget {
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-wrap .CodeMirror-scroll {
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-measure {
|
||||||
|
position: absolute;
|
||||||
|
width: 100%; height: 0px;
|
||||||
|
overflow: hidden;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
.CodeMirror-measure pre { position: static; }
|
||||||
|
|
||||||
|
.CodeMirror div.CodeMirror-cursor {
|
||||||
|
position: absolute;
|
||||||
|
visibility: hidden;
|
||||||
|
border-right: none;
|
||||||
|
width: 0;
|
||||||
|
}
|
||||||
|
.CodeMirror-focused div.CodeMirror-cursor {
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-selected { background: #d9d9d9; }
|
||||||
|
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
|
||||||
|
|
||||||
|
.cm-searching {
|
||||||
|
background: #ffa;
|
||||||
|
background: rgba(255, 255, 0, .4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* IE7 hack to prevent it from returning funny offsetTops on the spans */
|
||||||
|
.CodeMirror span { *vertical-align: text-bottom; }
|
||||||
|
|
||||||
|
@media print {
|
||||||
|
/* Hide the cursor when printing */
|
||||||
|
.CodeMirror div.CodeMirror-cursor {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
}
|
9941
public/js/lib/codemirror-accessible/index.html
Executable file
9941
public/js/lib/codemirror-accessible/index.html
Executable file
File diff suppressed because it is too large
Load Diff
482
public/js/lib/codemirror-accessible/javascript.js
Executable file
482
public/js/lib/codemirror-accessible/javascript.js
Executable file
@ -0,0 +1,482 @@
|
|||||||
|
// TODO actually recognize syntax of TypeScript constructs
|
||||||
|
|
||||||
|
|
||||||
|
var opts= function(config, parserConfig) {
|
||||||
|
var indentUnit = config.indentUnit;
|
||||||
|
var statementIndent = parserConfig.statementIndent;
|
||||||
|
var jsonMode = parserConfig.json;
|
||||||
|
var isTS = parserConfig.typescript;
|
||||||
|
|
||||||
|
// Tokenizer
|
||||||
|
|
||||||
|
var keywords = function(){
|
||||||
|
function kw(type) {return {type: type, style: "keyword"};}
|
||||||
|
var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
|
||||||
|
var operator = kw("operator"), atom = {type: "atom", style: "atom"};
|
||||||
|
|
||||||
|
var jsKeywords = {
|
||||||
|
"if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
|
||||||
|
"return": C, "break": C, "continue": C, "new": C, "delete": C, "throw": C,
|
||||||
|
"var": kw("var"), "const": kw("var"), "let": kw("var"),
|
||||||
|
"function": kw("function"), "catch": kw("catch"),
|
||||||
|
"for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
|
||||||
|
"in": operator, "typeof": operator, "instanceof": operator,
|
||||||
|
"true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
|
||||||
|
"this": kw("this")
|
||||||
|
};
|
||||||
|
|
||||||
|
// Extend the 'normal' keywords with the TypeScript language extensions
|
||||||
|
if (isTS) {
|
||||||
|
var type = {type: "variable", style: "variable-3"};
|
||||||
|
var tsKeywords = {
|
||||||
|
// object-like things
|
||||||
|
"interface": kw("interface"),
|
||||||
|
"class": kw("class"),
|
||||||
|
"extends": kw("extends"),
|
||||||
|
"constructor": kw("constructor"),
|
||||||
|
|
||||||
|
// scope modifiers
|
||||||
|
"public": kw("public"),
|
||||||
|
"private": kw("private"),
|
||||||
|
"protected": kw("protected"),
|
||||||
|
"static": kw("static"),
|
||||||
|
|
||||||
|
"super": kw("super"),
|
||||||
|
|
||||||
|
// types
|
||||||
|
"string": type, "number": type, "bool": type, "any": type
|
||||||
|
};
|
||||||
|
|
||||||
|
for (var attr in tsKeywords) {
|
||||||
|
jsKeywords[attr] = tsKeywords[attr];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return jsKeywords;
|
||||||
|
}();
|
||||||
|
|
||||||
|
var isOperatorChar = /[+\-*&%=<>!?|~^]/;
|
||||||
|
|
||||||
|
function chain(stream, state, f) {
|
||||||
|
state.tokenize = f;
|
||||||
|
return f(stream, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
function nextUntilUnescaped(stream, end) {
|
||||||
|
var escaped = false, next;
|
||||||
|
while ((next = stream.next()) != null) {
|
||||||
|
if (next == end && !escaped)
|
||||||
|
return false;
|
||||||
|
escaped = !escaped && next == "\\";
|
||||||
|
}
|
||||||
|
return escaped;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Used as scratch variables to communicate multiple values without
|
||||||
|
// consing up tons of objects.
|
||||||
|
var type, content;
|
||||||
|
function ret(tp, style, cont) {
|
||||||
|
type = tp; content = cont;
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
|
||||||
|
function jsTokenBase(stream, state) {
|
||||||
|
var ch = stream.next();
|
||||||
|
if (ch == '"' || ch == "'")
|
||||||
|
return chain(stream, state, jsTokenString(ch));
|
||||||
|
else if (/[\[\]{}\(\),;\:\.]/.test(ch))
|
||||||
|
return ret(ch);
|
||||||
|
else if (ch == "0" && stream.eat(/x/i)) {
|
||||||
|
stream.eatWhile(/[\da-f]/i);
|
||||||
|
return ret("number", "number");
|
||||||
|
}
|
||||||
|
else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) {
|
||||||
|
stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
|
||||||
|
return ret("number", "number");
|
||||||
|
}
|
||||||
|
else if (ch == "/") {
|
||||||
|
if (stream.eat("*")) {
|
||||||
|
return chain(stream, state, jsTokenComment);
|
||||||
|
}
|
||||||
|
else if (stream.eat("/")) {
|
||||||
|
stream.skipToEnd();
|
||||||
|
return ret("comment", "comment");
|
||||||
|
}
|
||||||
|
else if (state.lastType == "operator" || state.lastType == "keyword c" ||
|
||||||
|
/^[\[{}\(,;:]$/.test(state.lastType)) {
|
||||||
|
nextUntilUnescaped(stream, "/");
|
||||||
|
stream.eatWhile(/[gimy]/); // 'y' is "sticky" option in Mozilla
|
||||||
|
return ret("regexp", "string-2");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stream.eatWhile(isOperatorChar);
|
||||||
|
return ret("operator", null, stream.current());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (ch == "#") {
|
||||||
|
stream.skipToEnd();
|
||||||
|
return ret("error", "error");
|
||||||
|
}
|
||||||
|
else if (isOperatorChar.test(ch)) {
|
||||||
|
stream.eatWhile(isOperatorChar);
|
||||||
|
return ret("operator", null, stream.current());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stream.eatWhile(/[\w\$_]/);
|
||||||
|
var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
|
||||||
|
return (known && state.lastType != ".") ? ret(known.type, known.style, word) :
|
||||||
|
ret("variable", "variable", word);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function jsTokenString(quote) {
|
||||||
|
return function(stream, state) {
|
||||||
|
if (!nextUntilUnescaped(stream, quote))
|
||||||
|
state.tokenize = jsTokenBase;
|
||||||
|
return ret("string", "string");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function jsTokenComment(stream, state) {
|
||||||
|
var maybeEnd = false, ch;
|
||||||
|
while (ch = stream.next()) {
|
||||||
|
if (ch == "/" && maybeEnd) {
|
||||||
|
state.tokenize = jsTokenBase;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
maybeEnd = (ch == "*");
|
||||||
|
}
|
||||||
|
return ret("comment", "comment");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parser
|
||||||
|
|
||||||
|
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true};
|
||||||
|
|
||||||
|
function JSLexical(indented, column, type, align, prev, info) {
|
||||||
|
this.indented = indented;
|
||||||
|
this.column = column;
|
||||||
|
this.type = type;
|
||||||
|
this.prev = prev;
|
||||||
|
this.info = info;
|
||||||
|
if (align != null) this.align = align;
|
||||||
|
}
|
||||||
|
|
||||||
|
function inScope(state, varname) {
|
||||||
|
for (var v = state.localVars; v; v = v.next)
|
||||||
|
if (v.name == varname) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseJS(state, style, type, content, stream) {
|
||||||
|
var cc = state.cc;
|
||||||
|
// Communicate our context to the combinators.
|
||||||
|
// (Less wasteful than consing up a hundred closures on every call.)
|
||||||
|
cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc;
|
||||||
|
|
||||||
|
if (!state.lexical.hasOwnProperty("align"))
|
||||||
|
state.lexical.align = true;
|
||||||
|
|
||||||
|
while(true) {
|
||||||
|
var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
|
||||||
|
if (combinator(type, content)) {
|
||||||
|
while(cc.length && cc[cc.length - 1].lex)
|
||||||
|
cc.pop()();
|
||||||
|
if (cx.marked) return cx.marked;
|
||||||
|
if (type == "variable" && inScope(state, content)) return "variable-2";
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Combinator utils
|
||||||
|
|
||||||
|
var cx = {state: null, column: null, marked: null, cc: null};
|
||||||
|
function pass() {
|
||||||
|
for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
|
||||||
|
}
|
||||||
|
function cont() {
|
||||||
|
pass.apply(null, arguments);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
function register(varname) {
|
||||||
|
function inList(list) {
|
||||||
|
for (var v = list; v; v = v.next)
|
||||||
|
if (v.name == varname) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var state = cx.state;
|
||||||
|
if (state.context) {
|
||||||
|
cx.marked = "def";
|
||||||
|
if (inList(state.localVars)) return;
|
||||||
|
state.localVars = {name: varname, next: state.localVars};
|
||||||
|
} else {
|
||||||
|
if (inList(state.globalVars)) return;
|
||||||
|
state.globalVars = {name: varname, next: state.globalVars};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Combinators
|
||||||
|
|
||||||
|
var defaultVars = {name: "this", next: {name: "arguments"}};
|
||||||
|
function pushcontext() {
|
||||||
|
cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};
|
||||||
|
cx.state.localVars = defaultVars;
|
||||||
|
}
|
||||||
|
function popcontext() {
|
||||||
|
cx.state.localVars = cx.state.context.vars;
|
||||||
|
cx.state.context = cx.state.context.prev;
|
||||||
|
}
|
||||||
|
function pushlex(type, info) {
|
||||||
|
var result = function() {
|
||||||
|
var state = cx.state, indent = state.indented;
|
||||||
|
if (state.lexical.type == "stat") indent = state.lexical.indented;
|
||||||
|
state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
|
||||||
|
};
|
||||||
|
result.lex = true;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
function poplex() {
|
||||||
|
var state = cx.state;
|
||||||
|
if (state.lexical.prev) {
|
||||||
|
if (state.lexical.type == ")")
|
||||||
|
state.indented = state.lexical.indented;
|
||||||
|
state.lexical = state.lexical.prev;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
poplex.lex = true;
|
||||||
|
|
||||||
|
function expect(wanted) {
|
||||||
|
return function(type) {
|
||||||
|
if (type == wanted) return cont();
|
||||||
|
else if (wanted == ";") return pass();
|
||||||
|
else return cont(arguments.callee);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function statement(type) {
|
||||||
|
if (type == "var") return cont(pushlex("vardef"), vardef1, expect(";"), poplex);
|
||||||
|
if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex);
|
||||||
|
if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
|
||||||
|
if (type == "{") return cont(pushlex("}"), block, poplex);
|
||||||
|
if (type == ";") return cont();
|
||||||
|
if (type == "if") return cont(pushlex("form"), expression, statement, poplex, maybeelse);
|
||||||
|
if (type == "function") return cont(functiondef);
|
||||||
|
if (type == "for") return cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"),
|
||||||
|
poplex, statement, poplex);
|
||||||
|
if (type == "variable") return cont(pushlex("stat"), maybelabel);
|
||||||
|
if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
|
||||||
|
block, poplex, poplex);
|
||||||
|
if (type == "case") return cont(expression, expect(":"));
|
||||||
|
if (type == "default") return cont(expect(":"));
|
||||||
|
if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
|
||||||
|
statement, poplex, popcontext);
|
||||||
|
return pass(pushlex("stat"), expression, expect(";"), poplex);
|
||||||
|
}
|
||||||
|
function expression(type) {
|
||||||
|
return expressionInner(type, false);
|
||||||
|
}
|
||||||
|
function expressionNoComma(type) {
|
||||||
|
return expressionInner(type, true);
|
||||||
|
}
|
||||||
|
function expressionInner(type, noComma) {
|
||||||
|
var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
|
||||||
|
if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
|
||||||
|
if (type == "function") return cont(functiondef);
|
||||||
|
if (type == "keyword c") return cont(noComma ? maybeexpressionNoComma : maybeexpression);
|
||||||
|
if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop);
|
||||||
|
if (type == "operator") return cont(noComma ? expressionNoComma : expression);
|
||||||
|
if (type == "[") return cont(pushlex("]"), commasep(expressionNoComma, "]"), poplex, maybeop);
|
||||||
|
if (type == "{") return cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeop);
|
||||||
|
return cont();
|
||||||
|
}
|
||||||
|
function maybeexpression(type) {
|
||||||
|
if (type.match(/[;\}\)\],]/)) return pass();
|
||||||
|
return pass(expression);
|
||||||
|
}
|
||||||
|
function maybeexpressionNoComma(type) {
|
||||||
|
if (type.match(/[;\}\)\],]/)) return pass();
|
||||||
|
return pass(expressionNoComma);
|
||||||
|
}
|
||||||
|
|
||||||
|
function maybeoperatorComma(type, value) {
|
||||||
|
if (type == ",") return cont(expression);
|
||||||
|
return maybeoperatorNoComma(type, value, false);
|
||||||
|
}
|
||||||
|
function maybeoperatorNoComma(type, value, noComma) {
|
||||||
|
var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
|
||||||
|
var expr = noComma == false ? expression : expressionNoComma;
|
||||||
|
if (type == "operator") {
|
||||||
|
if (/\+\+|--/.test(value)) return cont(me);
|
||||||
|
if (value == "?") return cont(expression, expect(":"), expr);
|
||||||
|
return cont(expr);
|
||||||
|
}
|
||||||
|
if (type == ";") return;
|
||||||
|
if (type == "(") return cont(pushlex(")", "call"), commasep(expressionNoComma, ")"), poplex, me);
|
||||||
|
if (type == ".") return cont(property, me);
|
||||||
|
if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
|
||||||
|
}
|
||||||
|
function maybelabel(type) {
|
||||||
|
if (type == ":") return cont(poplex, statement);
|
||||||
|
return pass(maybeoperatorComma, expect(";"), poplex);
|
||||||
|
}
|
||||||
|
function property(type) {
|
||||||
|
if (type == "variable") {cx.marked = "property"; return cont();}
|
||||||
|
}
|
||||||
|
function objprop(type, value) {
|
||||||
|
if (type == "variable") {
|
||||||
|
cx.marked = "property";
|
||||||
|
if (value == "get" || value == "set") return cont(getterSetter);
|
||||||
|
} else if (type == "number" || type == "string") {
|
||||||
|
cx.marked = type + " property";
|
||||||
|
}
|
||||||
|
if (atomicTypes.hasOwnProperty(type)) return cont(expect(":"), expressionNoComma);
|
||||||
|
}
|
||||||
|
function getterSetter(type) {
|
||||||
|
if (type == ":") return cont(expression);
|
||||||
|
if (type != "variable") return cont(expect(":"), expression);
|
||||||
|
cx.marked = "property";
|
||||||
|
return cont(functiondef);
|
||||||
|
}
|
||||||
|
function commasep(what, end) {
|
||||||
|
function proceed(type) {
|
||||||
|
if (type == ",") {
|
||||||
|
var lex = cx.state.lexical;
|
||||||
|
if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
|
||||||
|
return cont(what, proceed);
|
||||||
|
}
|
||||||
|
if (type == end) return cont();
|
||||||
|
return cont(expect(end));
|
||||||
|
}
|
||||||
|
return function(type) {
|
||||||
|
if (type == end) return cont();
|
||||||
|
else return pass(what, proceed);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function block(type) {
|
||||||
|
if (type == "}") return cont();
|
||||||
|
return pass(statement, block);
|
||||||
|
}
|
||||||
|
function maybetype(type) {
|
||||||
|
if (type == ":") return cont(typedef);
|
||||||
|
return pass();
|
||||||
|
}
|
||||||
|
function typedef(type) {
|
||||||
|
if (type == "variable"){cx.marked = "variable-3"; return cont();}
|
||||||
|
return pass();
|
||||||
|
}
|
||||||
|
function vardef1(type, value) {
|
||||||
|
if (type == "variable") {
|
||||||
|
register(value);
|
||||||
|
return isTS ? cont(maybetype, vardef2) : cont(vardef2);
|
||||||
|
}
|
||||||
|
return pass();
|
||||||
|
}
|
||||||
|
function vardef2(type, value) {
|
||||||
|
if (value == "=") return cont(expressionNoComma, vardef2);
|
||||||
|
if (type == ",") return cont(vardef1);
|
||||||
|
}
|
||||||
|
function maybeelse(type, value) {
|
||||||
|
if (type == "keyword b" && value == "else") return cont(pushlex("form"), statement, poplex);
|
||||||
|
}
|
||||||
|
function forspec1(type) {
|
||||||
|
if (type == "var") return cont(vardef1, expect(";"), forspec2);
|
||||||
|
if (type == ";") return cont(forspec2);
|
||||||
|
if (type == "variable") return cont(formaybein);
|
||||||
|
return pass(expression, expect(";"), forspec2);
|
||||||
|
}
|
||||||
|
function formaybein(_type, value) {
|
||||||
|
if (value == "in") return cont(expression);
|
||||||
|
return cont(maybeoperatorComma, forspec2);
|
||||||
|
}
|
||||||
|
function forspec2(type, value) {
|
||||||
|
if (type == ";") return cont(forspec3);
|
||||||
|
if (value == "in") return cont(expression);
|
||||||
|
return pass(expression, expect(";"), forspec3);
|
||||||
|
}
|
||||||
|
function forspec3(type) {
|
||||||
|
if (type != ")") cont(expression);
|
||||||
|
}
|
||||||
|
function functiondef(type, value) {
|
||||||
|
if (type == "variable") {register(value); return cont(functiondef);}
|
||||||
|
if (type == "(") return cont(pushlex(")"), pushcontext, commasep(funarg, ")"), poplex, statement, popcontext);
|
||||||
|
}
|
||||||
|
function funarg(type, value) {
|
||||||
|
if (type == "variable") {register(value); return isTS ? cont(maybetype) : cont();}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Interface
|
||||||
|
|
||||||
|
return {
|
||||||
|
startState: function(basecolumn) {
|
||||||
|
return {
|
||||||
|
tokenize: jsTokenBase,
|
||||||
|
lastType: null,
|
||||||
|
cc: [],
|
||||||
|
lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
|
||||||
|
localVars: parserConfig.localVars,
|
||||||
|
globalVars: parserConfig.globalVars,
|
||||||
|
context: parserConfig.localVars && {vars: parserConfig.localVars},
|
||||||
|
indented: 0
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
token: function(stream, state) {
|
||||||
|
if (stream.sol()) {
|
||||||
|
if (!state.lexical.hasOwnProperty("align"))
|
||||||
|
state.lexical.align = false;
|
||||||
|
state.indented = stream.indentation();
|
||||||
|
}
|
||||||
|
if (state.tokenize != jsTokenComment && stream.eatSpace()) return null;
|
||||||
|
var style = state.tokenize(stream, state);
|
||||||
|
if (type == "comment") return style;
|
||||||
|
state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type;
|
||||||
|
return parseJS(state, style, type, content, stream);
|
||||||
|
},
|
||||||
|
|
||||||
|
indent: function(state, textAfter) {
|
||||||
|
if (state.tokenize == jsTokenComment) return CodeMirror.Pass;
|
||||||
|
if (state.tokenize != jsTokenBase) return 0;
|
||||||
|
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
|
||||||
|
// Kludge to prevent 'maybelse' from blocking lexical scope pops
|
||||||
|
for (var i = state.cc.length - 1; i >= 0; --i) {
|
||||||
|
var c = state.cc[i];
|
||||||
|
if (c == poplex) lexical = lexical.prev;
|
||||||
|
else if (c != maybeelse || /^else\b/.test(textAfter)) break;
|
||||||
|
}
|
||||||
|
if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
|
||||||
|
if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
|
||||||
|
lexical = lexical.prev;
|
||||||
|
var type = lexical.type, closing = firstChar == type;
|
||||||
|
|
||||||
|
if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? 4 : 0);
|
||||||
|
else if (type == "form" && firstChar == "{") return lexical.indented;
|
||||||
|
else if (type == "form") return lexical.indented + indentUnit;
|
||||||
|
else if (type == "stat")
|
||||||
|
return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? statementIndent || indentUnit : 0);
|
||||||
|
else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
|
||||||
|
return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
|
||||||
|
else if (lexical.align) return lexical.column + (closing ? 0 : 1);
|
||||||
|
else return lexical.indented + (closing ? 0 : indentUnit);
|
||||||
|
},
|
||||||
|
|
||||||
|
electricChars: ":{}",
|
||||||
|
blockCommentStart: jsonMode ? null : "/*",
|
||||||
|
blockCommentEnd: jsonMode ? null : "*/",
|
||||||
|
lineComment: jsonMode ? null : "//",
|
||||||
|
fold: "brace",
|
||||||
|
|
||||||
|
helperType: jsonMode ? "json" : "javascript",
|
||||||
|
jsonMode: jsonMode
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
CodeMirror.defineMode("javascript", opts );
|
||||||
|
CodeMirrorOriginal.defineMode("javascript", opts );
|
||||||
|
CodeMirror.defineMIME("text/javascript", "javascript");
|
||||||
|
CodeMirror.defineMIME("text/ecmascript", "javascript");
|
||||||
|
CodeMirror.defineMIME("application/javascript", "javascript");
|
||||||
|
CodeMirror.defineMIME("application/ecmascript", "javascript");
|
||||||
|
CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
|
||||||
|
CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true});
|
||||||
|
CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
|
||||||
|
CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
|
749
public/js/lib/codemirror-accessible/stress.html
Executable file
749
public/js/lib/codemirror-accessible/stress.html
Executable file
File diff suppressed because one or more lines are too long
@ -7,7 +7,7 @@ html(ng-app='profileValidation', lang='en')
|
|||||||
link(rel='shortcut icon', href='//s3.amazonaws.com/freecodecamp/favicon.ico')
|
link(rel='shortcut icon', href='//s3.amazonaws.com/freecodecamp/favicon.ico')
|
||||||
link(rel='stylesheet', href='//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css')
|
link(rel='stylesheet', href='//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css')
|
||||||
link(rel='stylesheet', href='//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css')
|
link(rel='stylesheet', href='//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css')
|
||||||
link(rel='stylesheet', href='//code.ionicframework.com/ionicons/2.0.0/css/ionicons.min.css')
|
link(rel='stylesheet', href='/css/lib/ionicons/ionicons.min.css')
|
||||||
include partials/meta
|
include partials/meta
|
||||||
title #{title} | Free Code Camp
|
title #{title} | Free Code Camp
|
||||||
meta(charset='utf-8')
|
meta(charset='utf-8')
|
||||||
|
Reference in New Issue
Block a user