Compare commits
150 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e4fd3927fa | ||
|
|
a5e7452673 | ||
|
|
6a1796a284 | ||
|
|
aaac445d84 | ||
|
|
fd9021190a | ||
|
|
5c35c18e49 | ||
|
|
89777eebcf | ||
|
|
18b2a1a65f | ||
|
|
edc5a9ea0a | ||
|
|
72edcc692b | ||
|
|
6e6a0dae96 | ||
|
|
c6224c4a4a | ||
|
|
76f9c9dd7c | ||
|
|
d75c7f9f50 | ||
|
|
cc7887d452 | ||
|
|
29f431cd78 | ||
|
|
1a97623dee | ||
|
|
79bd665b92 | ||
|
|
0de026fc2b | ||
|
|
cb3f87d4d9 | ||
|
|
f9ec7b7138 | ||
|
|
77e0e1d51f | ||
|
|
c28cd3506e | ||
|
|
7dd3c36867 | ||
|
|
4dd36c5130 | ||
|
|
f00628539a | ||
|
|
fcc5896926 | ||
|
|
75881d1c9f | ||
|
|
9597b057a6 | ||
|
|
7d209a1c58 | ||
|
|
490ca1c1c3 | ||
|
|
95c0aa1812 | ||
|
|
9cbb9f7529 | ||
|
|
c8a73fa56e | ||
|
|
29dff39bf1 | ||
|
|
ef8190612f | ||
|
|
55d547d947 | ||
|
|
e80825ac3a | ||
|
|
8d8edc171c | ||
|
|
c1f4740b68 | ||
|
|
d6a5f486d7 | ||
|
|
807cc53fa8 | ||
|
|
2237c91067 | ||
|
|
98a08fddf8 | ||
|
|
21cdcb20b4 | ||
|
|
47547b2ae8 | ||
|
|
6e9af92471 | ||
|
|
cc7df4222a | ||
|
|
25b5af50c2 | ||
|
|
7c8c728ad4 | ||
|
|
655fef4baa | ||
|
|
a27db58031 | ||
|
|
7c0cb2d1c3 | ||
|
|
229a089d45 | ||
|
|
49ca9d75f9 | ||
|
|
745903d133 | ||
|
|
54bf805548 | ||
|
|
2ac674f5c6 | ||
|
|
2b5a16be70 | ||
|
|
1fbe9df342 | ||
|
|
1217d2d05e | ||
|
|
432795026c | ||
|
|
ab23eaa6ff | ||
|
|
4583c0c713 | ||
|
|
d3a961f13f | ||
|
|
7a97af2c1d | ||
|
|
750cc59fd5 | ||
|
|
dfcf54d412 | ||
|
|
5fd1c35d85 | ||
|
|
21b61bd027 | ||
|
|
7fa28c6d8b | ||
|
|
97e396794a | ||
|
|
b096ef3606 | ||
|
|
74b0d86c36 | ||
|
|
319c509318 | ||
|
|
5703a040be | ||
|
|
6752b8ef50 | ||
|
|
7062560eaa | ||
|
|
3be433c910 | ||
|
|
bd0969e870 | ||
|
|
ffbac321a4 | ||
|
|
222f6589a9 | ||
|
|
a2245775a9 | ||
|
|
d594050166 | ||
|
|
2665055558 | ||
|
|
3e41afb0a6 | ||
|
|
f1ec4a2453 | ||
|
|
98f1ace910 | ||
|
|
401a3a7abb | ||
|
|
6a0cc816a9 | ||
|
|
4bafb3aaa1 | ||
|
|
782aac54e4 | ||
|
|
06dd46c24f | ||
|
|
bc50886250 | ||
|
|
4264c479ad | ||
|
|
b3afe9458e | ||
|
|
1382277c74 | ||
|
|
d1df67338d | ||
|
|
ccc5b9d30a | ||
|
|
86142ca5f1 | ||
|
|
b55fe4856c | ||
|
|
d5df587cc3 | ||
|
|
0665d10a7c | ||
|
|
43f7089106 | ||
|
|
fcb7722a55 | ||
|
|
7c5a005784 | ||
|
|
abd61689f1 | ||
|
|
acbe46b013 | ||
|
|
bbf169907a | ||
|
|
1d3af5c62d | ||
|
|
d095e6a5fe | ||
|
|
96df3ac91b | ||
|
|
38fe4fd85e | ||
|
|
95ac9b50e0 | ||
|
|
1f26ddaf3d | ||
|
|
64231d7f01 | ||
|
|
656c10e5cf | ||
|
|
f0d4ef75d3 | ||
|
|
ec27eb53bc | ||
|
|
6512d4895b | ||
|
|
de81341452 | ||
|
|
97e6906f17 | ||
|
|
feeb3907bf | ||
|
|
955d7714a2 | ||
|
|
e506d5a535 | ||
|
|
09ff2f279d | ||
|
|
e17a240661 | ||
|
|
a6e244a82f | ||
|
|
491fb4c243 | ||
|
|
ca46e36e5a | ||
|
|
09e3ece5a7 | ||
|
|
57e820501a | ||
|
|
1577118643 | ||
|
|
856a0c9f31 | ||
|
|
c621479709 | ||
|
|
b7769e6203 | ||
|
|
b1e27282a9 | ||
|
|
c19df45ec1 | ||
|
|
0ca29f9201 | ||
|
|
e208b45a88 | ||
|
|
b8f7be6376 | ||
|
|
5ae958e349 | ||
|
|
7237ef8c69 | ||
|
|
215a4ab362 | ||
|
|
8c83378b8b | ||
|
|
9d14ca1eb2 | ||
|
|
78067a8dec | ||
|
|
d12ea02c42 | ||
|
|
3ceb519b8a | ||
|
|
5508cd1074 |
@@ -1,29 +0,0 @@
|
||||
// TODO number prefixes
|
||||
(function() {
|
||||
// Really primitive kill-ring implementation.
|
||||
var killRing = [];
|
||||
function addToRing(str) {
|
||||
killRing.push(str);
|
||||
if (killRing.length > 50) killRing.shift();
|
||||
}
|
||||
function getFromRing() { return killRing[killRing.length - 1] || ""; }
|
||||
function popFromRing() { if (killRing.length > 1) killRing.pop(); return getFromRing(); }
|
||||
|
||||
CodeMirror.keyMap.emacs = {
|
||||
"Ctrl-X": function(cm) {cm.setOption("keyMap", "emacs-Ctrl-X");},
|
||||
"Ctrl-W": function(cm) {addToRing(cm.getSelection()); cm.replaceSelection("");},
|
||||
"Ctrl-Alt-W": function(cm) {addToRing(cm.getSelection()); cm.replaceSelection("");},
|
||||
"Alt-W": function(cm) {addToRing(cm.getSelection());},
|
||||
"Ctrl-Y": function(cm) {cm.replaceSelection(getFromRing());},
|
||||
"Alt-Y": function(cm) {cm.replaceSelection(popFromRing());},
|
||||
"Ctrl-/": "undo", "Shift-Ctrl--": "undo", "Shift-Alt-,": "goDocStart", "Shift-Alt-.": "goDocEnd",
|
||||
"Ctrl-S": "findNext", "Ctrl-R": "findPrev", "Ctrl-G": "clearSearch", "Shift-Alt-5": "replace",
|
||||
"Ctrl-Z": "undo", "Cmd-Z": "undo",
|
||||
fallthrough: ["basic", "emacsy"]
|
||||
};
|
||||
|
||||
CodeMirror.keyMap["emacs-Ctrl-X"] = {
|
||||
"Ctrl-S": "save", "Ctrl-W": "save", "S": "saveAll", "F": "open", "U": "undo", "K": "close",
|
||||
auto: "emacs", nofallthrough: true
|
||||
};
|
||||
})();
|
||||
@@ -1,230 +0,0 @@
|
||||
(function() {
|
||||
var count = "";
|
||||
var sdir = "f";
|
||||
var buf = "";
|
||||
var yank = 0;
|
||||
var mark = [];
|
||||
function emptyBuffer() { buf = ""; }
|
||||
function pushInBuffer(str) { buf += str; };
|
||||
function pushCountDigit(digit) { return function(cm) {count += digit;} }
|
||||
function popCount() { var i = parseInt(count); count = ""; return i || 1; }
|
||||
function countTimes(func) {
|
||||
if (typeof func == "string") func = CodeMirror.commands[func];
|
||||
return function(cm) { for (var i = 0, c = popCount(); i < c; ++i) func(cm); }
|
||||
}
|
||||
|
||||
function iterObj(o, f) {
|
||||
for (var prop in o) if (o.hasOwnProperty(prop)) f(prop, o[prop]);
|
||||
}
|
||||
|
||||
var word = [/\w/, /[^\w\s]/], bigWord = [/\S/];
|
||||
function findWord(line, pos, dir, regexps) {
|
||||
var stop = 0, next = -1;
|
||||
if (dir > 0) { stop = line.length; next = 0; }
|
||||
var start = stop, end = stop;
|
||||
// Find bounds of next one.
|
||||
outer: for (; pos != stop; pos += dir) {
|
||||
for (var i = 0; i < regexps.length; ++i) {
|
||||
if (regexps[i].test(line.charAt(pos + next))) {
|
||||
start = pos;
|
||||
for (; pos != stop; pos += dir) {
|
||||
if (!regexps[i].test(line.charAt(pos + next))) break;
|
||||
}
|
||||
end = pos;
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
return {from: Math.min(start, end), to: Math.max(start, end)};
|
||||
}
|
||||
function moveToWord(cm, regexps, dir, where) {
|
||||
var cur = cm.getCursor(), ch = cur.ch, line = cm.getLine(cur.line), word;
|
||||
while (true) {
|
||||
word = findWord(line, ch, dir, regexps);
|
||||
ch = word[where == "end" ? "to" : "from"];
|
||||
if (ch == cur.ch && word.from != word.to) ch = word[dir < 0 ? "from" : "to"];
|
||||
else break;
|
||||
}
|
||||
cm.setCursor(cur.line, word[where == "end" ? "to" : "from"], true);
|
||||
}
|
||||
function joinLineNext(cm) {
|
||||
var cur = cm.getCursor(), ch = cur.ch, line = cm.getLine(cur.line);
|
||||
CodeMirror.commands.goLineEnd(cm);
|
||||
if (cur.line != cm.lineCount()) {
|
||||
CodeMirror.commands.goLineEnd(cm);
|
||||
cm.replaceSelection(" ", "end");
|
||||
CodeMirror.commands.delCharRight(cm);
|
||||
}
|
||||
}
|
||||
function editCursor(mode) {
|
||||
if (mode == "vim-insert") {
|
||||
// put in your cursor css changing code
|
||||
} else if (mode == "vim") {
|
||||
// put in your cursor css changing code
|
||||
}
|
||||
}
|
||||
function delTillMark(cm, cHar) {
|
||||
var i = mark[cHar], l = cm.getCursor().line, start = i > l ? l : i, end = i > l ? i : l;
|
||||
cm.setCursor(start);
|
||||
for (var c = start; c <= end; c++) {
|
||||
pushInBuffer("\n"+cm.getLine(start));
|
||||
cm.removeLine(start);
|
||||
}
|
||||
}
|
||||
function yankTillMark(cm, cHar) {
|
||||
var i = mark[cHar], l = cm.getCursor().line, start = i > l ? l : i, end = i > l ? i : l;
|
||||
for (var c = start; c <= end; c++) {
|
||||
pushInBuffer("\n"+cm.getLine(c));
|
||||
}
|
||||
cm.setCursor(start);
|
||||
}
|
||||
function goLineStartText(cm) {
|
||||
// Go to the start of the line where the text begins, or the end for whitespace-only lines
|
||||
var cur = cm.getCursor(), firstNonWS = cm.getLine(cur.line).search(/\S/);
|
||||
cm.setCursor(cur.line, firstNonWS == -1 ? line.length : firstNonWS, true);
|
||||
}
|
||||
|
||||
var map = CodeMirror.keyMap.vim = {
|
||||
"0": function(cm) {count.length > 0 ? pushCountDigit("0")(cm) : CodeMirror.commands.goLineStart(cm);},
|
||||
// Pipe (|); TODO: should be *screen* chars, so need a util function to turn tabs into spaces?
|
||||
"'|'": function(cm) {cm.setCursor(cm.getCursor().line, popCount() - 1, true);},
|
||||
"'^'": function(cm) {popCount(); goLineStartText(cm);},
|
||||
"A": function(cm) {popCount(); cm.setCursor(cm.getCursor().line, cm.getCursor().ch+1, true); cm.setOption("keyMap", "vim-insert"); editCursor("vim-insert");},
|
||||
"Shift-A": function(cm) {popCount(); CodeMirror.commands.goLineEnd(cm); cm.setOption("keyMap", "vim-insert"); editCursor("vim-insert");},
|
||||
"I": function(cm) {popCount(); cm.setOption("keyMap", "vim-insert"); editCursor("vim-insert");},
|
||||
"Shift-I": function(cm) {popCount(); goLineStartText(cm); cm.setOption("keyMap", "vim-insert"); editCursor("vim-insert");},
|
||||
"O": function(cm) {popCount(); CodeMirror.commands.goLineEnd(cm); CodeMirror.commands.newlineAndIndent(cm); cm.setOption("keyMap", "vim-insert"); editCursor("vim-insert");},
|
||||
"Shift-O": function(cm) {popCount(); CodeMirror.commands.goLineStart(cm); cm.replaceSelection("\n", "start"); cm.indentLine(cm.getCursor().line); cm.setOption("keyMap", "vim-insert"); editCursor("vim-insert");},
|
||||
"G": function(cm) {cm.setOption("keyMap", "vim-prefix-g");},
|
||||
"D": function(cm) {cm.setOption("keyMap", "vim-prefix-d"); emptyBuffer();},
|
||||
"Shift-D": function(cm) {
|
||||
emptyBuffer();
|
||||
mark["Shift-D"] = cm.getCursor(false).line;
|
||||
cm.setCursor(cm.getCursor(true).line);
|
||||
delTillMark(cm,"Shift-D"); mark = [];
|
||||
},
|
||||
"M": function(cm) {cm.setOption("keyMap", "vim-prefix-m"); mark = [];},
|
||||
"Y": function(cm) {cm.setOption("keyMap", "vim-prefix-y"); emptyBuffer(); yank = 0;},
|
||||
"Shift-Y": function(cm) {
|
||||
emptyBuffer();
|
||||
mark["Shift-D"] = cm.getCursor(false).line;
|
||||
cm.setCursor(cm.getCursor(true).line);
|
||||
yankTillMark(cm,"Shift-D"); mark = [];
|
||||
},
|
||||
"/": function(cm) {var f = CodeMirror.commands.find; f && f(cm); sdir = "f"},
|
||||
"'?'": function(cm) {
|
||||
var f = CodeMirror.commands.find;
|
||||
if (f) { f(cm); CodeMirror.commands.findPrev(cm); sdir = "r"; }
|
||||
},
|
||||
"N": function(cm) {
|
||||
var fn = CodeMirror.commands.findNext;
|
||||
if (fn) sdir != "r" ? fn(cm) : CodeMirror.commands.findPrev(cm);
|
||||
},
|
||||
"Shift-N": function(cm) {
|
||||
var fn = CodeMirror.commands.findNext;
|
||||
if (fn) sdir != "r" ? CodeMirror.commands.findPrev(cm) : fn.findNext(cm);
|
||||
},
|
||||
"Shift-G": function(cm) {count == "" ? cm.setCursor(cm.lineCount()) : cm.setCursor(parseInt(count)-1); popCount(); CodeMirror.commands.goLineStart(cm);},
|
||||
nofallthrough: true
|
||||
};
|
||||
// Add bindings for number keys
|
||||
for (var i = 1; i < 10; ++i) map[i] = pushCountDigit(i);
|
||||
// Add bindings that are influenced by number keys
|
||||
iterObj({
|
||||
"H": "goColumnLeft", "L": "goColumnRight", "J": "goLineDown",
|
||||
"K": "goLineUp", "Left": "goColumnLeft", "Right": "goColumnRight",
|
||||
"Down": "goLineDown", "Up": "goLineUp", "Backspace": "goCharLeft",
|
||||
"Space": "goCharRight",
|
||||
"B": function(cm) {moveToWord(cm, word, -1, "end");},
|
||||
"E": function(cm) {moveToWord(cm, word, 1, "end");},
|
||||
"W": function(cm) {moveToWord(cm, word, 1, "start");},
|
||||
"Shift-B": function(cm) {moveToWord(cm, bigWord, -1, "end");},
|
||||
"Shift-E": function(cm) {moveToWord(cm, bigWord, 1, "end");},
|
||||
"Shift-W": function(cm) {moveToWord(cm, bigWord, 1, "start");},
|
||||
"X": function(cm) {CodeMirror.commands.delCharRight(cm)},
|
||||
"P": function(cm) {
|
||||
var cur = cm.getCursor().line;
|
||||
if (buf!= "") {
|
||||
CodeMirror.commands.goLineEnd(cm);
|
||||
cm.replaceSelection(buf, "end");
|
||||
}
|
||||
cm.setCursor(cur+1);
|
||||
},
|
||||
"Shift-X": function(cm) {CodeMirror.commands.delCharLeft(cm)},
|
||||
"Shift-J": function(cm) {joinLineNext(cm)},
|
||||
"'~'": function(cm) {
|
||||
var cur = cm.getCursor(), cHar = cm.getRange({line: cur.line, ch: cur.ch}, {line: cur.line, ch: cur.ch+1});
|
||||
cHar = cHar != cHar.toLowerCase() ? cHar.toLowerCase() : cHar.toUpperCase();
|
||||
cm.replaceRange(cHar, {line: cur.line, ch: cur.ch}, {line: cur.line, ch: cur.ch+1});
|
||||
cm.setCursor(cur.line, cur.ch+1);
|
||||
},
|
||||
"Ctrl-B": function(cm) {CodeMirror.commands.goPageUp(cm)},
|
||||
"Ctrl-F": function(cm) {CodeMirror.commands.goPageDown(cm)},
|
||||
"Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
|
||||
"U": "undo", "Ctrl-R": "redo", "'$'": "goLineEnd"
|
||||
}, function(key, cmd) { map[key] = countTimes(cmd); });
|
||||
|
||||
CodeMirror.keyMap["vim-prefix-g"] = {
|
||||
"E": countTimes(function(cm) { moveToWord(cm, word, -1, "start");}),
|
||||
"Shift-E": countTimes(function(cm) { moveToWord(cm, bigWord, -1, "start");}),
|
||||
auto: "vim",
|
||||
nofallthrough: true
|
||||
};
|
||||
|
||||
CodeMirror.keyMap["vim-prefix-m"] = {
|
||||
auto: "vim",
|
||||
nofallthrough: true
|
||||
};
|
||||
|
||||
CodeMirror.keyMap["vim-prefix-d"] = {
|
||||
"D": countTimes(function(cm) { pushInBuffer("\n"+cm.getLine(cm.getCursor().line)); cm.removeLine(cm.getCursor().line); }),
|
||||
"'": function(cm) {cm.setOption("keyMap", "vim-prefix-d'"); emptyBuffer();},
|
||||
auto: "vim",
|
||||
nofallthrough: true
|
||||
};
|
||||
|
||||
CodeMirror.keyMap["vim-prefix-d'"] = {
|
||||
auto: "vim",
|
||||
nofallthrough: true
|
||||
};
|
||||
|
||||
CodeMirror.keyMap["vim-prefix-y'"] = {
|
||||
auto: "vim",
|
||||
nofallthrough: true
|
||||
};
|
||||
|
||||
// iterate through uppercase alphabet char codes
|
||||
for (var i = 65; i < 65 + 26; i++) {
|
||||
// apply for `letter` and 'Shift-' + `letter`
|
||||
for (var m = String.fromCharCode(i); m.length < 8; m = "Shift-" + m) {
|
||||
CodeMirror.keyMap["vim-prefix-m"][m] = function(cm) {
|
||||
mark[m] = cm.getCursor().line;
|
||||
};
|
||||
CodeMirror.keyMap["vim-prefix-d'"][m] = function(cm) {
|
||||
delTillMark(cm,m);
|
||||
};
|
||||
CodeMirror.keyMap["vim-prefix-y'"][m] = function(cm) {
|
||||
yankTillMark(cm,m);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
CodeMirror.keyMap["vim-prefix-y"] = {
|
||||
"Y": countTimes(function(cm) { pushInBuffer("\n"+cm.getLine(cm.getCursor().line+yank)); yank++; }),
|
||||
"'": function(cm) {cm.setOption("keyMap", "vim-prefix-y'"); emptyBuffer();},
|
||||
auto: "vim",
|
||||
nofallthrough: true
|
||||
};
|
||||
|
||||
CodeMirror.keyMap["vim-insert"] = {
|
||||
// TODO: override navigation keys so that Esc will cancel automatic indentation from o, O, i_<CR>
|
||||
"Esc": function(cm) {
|
||||
cm.setCursor(cm.getCursor().line, cm.getCursor().ch-1, true);
|
||||
cm.setOption("keyMap", "vim");
|
||||
editCursor("vim");
|
||||
},
|
||||
"Ctrl-N": function(cm) {/* Code to bring up autocomplete hint */},
|
||||
"Ctrl-P": function(cm) {/* Code to bring up autocomplete hint */},
|
||||
fallthrough: ["default"]
|
||||
};
|
||||
})();
|
||||
@@ -1,174 +0,0 @@
|
||||
/**
|
||||
* Tag-closer extension for CodeMirror.
|
||||
*
|
||||
* This extension adds a "closeTag" utility function that can be used with key bindings to
|
||||
* insert a matching end tag after the ">" character of a start tag has been typed. It can
|
||||
* also complete "</" if a matching start tag is found. It will correctly ignore signal
|
||||
* characters for empty tags, comments, CDATA, etc.
|
||||
*
|
||||
* The function depends on internal parser state to identify tags. It is compatible with the
|
||||
* following CodeMirror modes and will ignore all others:
|
||||
* - htmlmixed
|
||||
* - xml
|
||||
* - xmlpure
|
||||
*
|
||||
* See demos/closetag.html for a usage example.
|
||||
*
|
||||
* @author Nathan Williams <nathan@nlwillia.net>
|
||||
* Contributed under the same license terms as CodeMirror.
|
||||
*/
|
||||
(function() {
|
||||
/** Option that allows tag closing behavior to be toggled. Default is true. */
|
||||
CodeMirror.defaults['closeTagEnabled'] = true;
|
||||
|
||||
/** Array of tag names to add indentation after the start tag for. Default is the list of block-level html tags. */
|
||||
CodeMirror.defaults['closeTagIndent'] = ['applet', 'blockquote', 'body', 'button', 'div', 'dl', 'fieldset', 'form', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'html', 'iframe', 'layer', 'legend', 'object', 'ol', 'p', 'select', 'table', 'ul'];
|
||||
|
||||
/**
|
||||
* Call during key processing to close tags. Handles the key event if the tag is closed, otherwise throws CodeMirror.Pass.
|
||||
* - cm: The editor instance.
|
||||
* - ch: The character being processed.
|
||||
* - indent: Optional. Omit or pass true to use the default indentation tag list defined in the 'closeTagIndent' option.
|
||||
* Pass false to disable indentation. Pass an array to override the default list of tag names.
|
||||
*/
|
||||
CodeMirror.defineExtension("closeTag", function(cm, ch, indent) {
|
||||
if (!cm.getOption('closeTagEnabled')) {
|
||||
throw CodeMirror.Pass;
|
||||
}
|
||||
|
||||
var mode = cm.getOption('mode');
|
||||
|
||||
if (mode == 'text/html') {
|
||||
|
||||
/*
|
||||
* Relevant structure of token:
|
||||
*
|
||||
* htmlmixed
|
||||
* className
|
||||
* state
|
||||
* htmlState
|
||||
* type
|
||||
* context
|
||||
* tagName
|
||||
* mode
|
||||
*
|
||||
* xml
|
||||
* className
|
||||
* state
|
||||
* tagName
|
||||
* type
|
||||
*/
|
||||
|
||||
var pos = cm.getCursor();
|
||||
var tok = cm.getTokenAt(pos);
|
||||
var state = tok.state;
|
||||
|
||||
if (state.mode && state.mode != 'html') {
|
||||
throw CodeMirror.Pass; // With htmlmixed, we only care about the html sub-mode.
|
||||
}
|
||||
|
||||
if (ch == '>') {
|
||||
var type = state.htmlState ? state.htmlState.type : state.type; // htmlmixed : xml
|
||||
|
||||
if (tok.className == 'tag' && type == 'closeTag') {
|
||||
throw CodeMirror.Pass; // Don't process the '>' at the end of an end-tag.
|
||||
}
|
||||
|
||||
cm.replaceSelection('>'); // Mode state won't update until we finish the tag.
|
||||
pos = {line: pos.line, ch: pos.ch + 1};
|
||||
cm.setCursor(pos);
|
||||
|
||||
tok = cm.getTokenAt(cm.getCursor());
|
||||
state = tok.state;
|
||||
type = state.htmlState ? state.htmlState.type : state.type; // htmlmixed : xml
|
||||
|
||||
if (tok.className == 'tag' && type != 'selfcloseTag') {
|
||||
var tagName = state.htmlState ? state.htmlState.context.tagName : state.tagName; // htmlmixed : xml
|
||||
if (tagName.length > 0) {
|
||||
insertEndTag(cm, indent, pos, tagName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Undo the '>' insert and allow cm to handle the key instead.
|
||||
cm.setSelection({line: pos.line, ch: pos.ch - 1}, pos);
|
||||
cm.replaceSelection("");
|
||||
|
||||
} else if (ch == '/') {
|
||||
if (tok.className == 'tag' && tok.string == '<') {
|
||||
var tagName = state.htmlState ? (state.htmlState.context ? state.htmlState.context.tagName : '') : state.context.tagName; // htmlmixed : xml # extra htmlmized check is for '</' edge case
|
||||
if (tagName.length > 0) {
|
||||
completeEndTag(cm, pos, tagName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (mode == 'xmlpure') {
|
||||
|
||||
var pos = cm.getCursor();
|
||||
var tok = cm.getTokenAt(pos);
|
||||
var tagName = tok.state.context.tagName;
|
||||
|
||||
if (ch == '>') {
|
||||
// <foo> tagName=foo, string=foo
|
||||
// <foo /> tagName=foo, string=/ # ignore
|
||||
// <foo></foo> tagName=foo, string=/foo # ignore
|
||||
if (tok.string == tagName) {
|
||||
cm.replaceSelection('>'); // parity w/html modes
|
||||
pos = {line: pos.line, ch: pos.ch + 1};
|
||||
cm.setCursor(pos);
|
||||
|
||||
insertEndTag(cm, indent, pos, tagName);
|
||||
return;
|
||||
}
|
||||
|
||||
} else if (ch == '/') {
|
||||
// <foo / tagName=foo, string= # ignore
|
||||
// <foo></ tagName=foo, string=<
|
||||
if (tok.string == '<') {
|
||||
completeEndTag(cm, pos, tagName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw CodeMirror.Pass; // Bubble if not handled
|
||||
});
|
||||
|
||||
function insertEndTag(cm, indent, pos, tagName) {
|
||||
if (shouldIndent(cm, indent, tagName)) {
|
||||
cm.replaceSelection('\n\n</' + tagName + '>', 'end');
|
||||
cm.indentLine(pos.line + 1);
|
||||
cm.indentLine(pos.line + 2);
|
||||
cm.setCursor({line: pos.line + 1, ch: cm.getLine(pos.line + 1).length});
|
||||
} else {
|
||||
cm.replaceSelection('</' + tagName + '>');
|
||||
cm.setCursor(pos);
|
||||
}
|
||||
}
|
||||
|
||||
function shouldIndent(cm, indent, tagName) {
|
||||
if (typeof indent == 'undefined' || indent == null || indent == true) {
|
||||
indent = cm.getOption('closeTagIndent');
|
||||
}
|
||||
if (!indent) {
|
||||
indent = [];
|
||||
}
|
||||
return indexOf(indent, tagName.toLowerCase()) != -1;
|
||||
}
|
||||
|
||||
// C&P from codemirror.js...would be nice if this were visible to utilities.
|
||||
function indexOf(collection, elt) {
|
||||
if (collection.indexOf) return collection.indexOf(elt);
|
||||
for (var i = 0, e = collection.length; i < e; ++i)
|
||||
if (collection[i] == elt) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
function completeEndTag(cm, pos, tagName) {
|
||||
cm.replaceSelection('/' + tagName + '>');
|
||||
cm.setCursor({line: pos.line, ch: pos.ch + tagName.length + 2 });
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -1,23 +0,0 @@
|
||||
.CodeMirror-dialog {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.CodeMirror-dialog > div {
|
||||
position: absolute;
|
||||
top: 0; left: 0; right: 0;
|
||||
background: white;
|
||||
border-bottom: 1px solid #eee;
|
||||
z-index: 15;
|
||||
padding: .1em .8em;
|
||||
overflow: hidden;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.CodeMirror-dialog input {
|
||||
border: none;
|
||||
outline: none;
|
||||
background: transparent;
|
||||
width: 20em;
|
||||
color: inherit;
|
||||
font-family: monospace;
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
// Open simple dialogs on top of an editor. Relies on dialog.css.
|
||||
|
||||
(function() {
|
||||
function dialogDiv(cm, template) {
|
||||
var wrap = cm.getWrapperElement();
|
||||
var dialog = wrap.insertBefore(document.createElement("div"), wrap.firstChild);
|
||||
dialog.className = "CodeMirror-dialog";
|
||||
dialog.innerHTML = '<div>' + template + '</div>';
|
||||
return dialog;
|
||||
}
|
||||
|
||||
CodeMirror.defineExtension("openDialog", function(template, callback) {
|
||||
var dialog = dialogDiv(this, template);
|
||||
var closed = false, me = this;
|
||||
function close() {
|
||||
if (closed) return;
|
||||
closed = true;
|
||||
dialog.parentNode.removeChild(dialog);
|
||||
}
|
||||
var inp = dialog.getElementsByTagName("input")[0];
|
||||
if (inp) {
|
||||
CodeMirror.connect(inp, "keydown", function(e) {
|
||||
if (e.keyCode == 13 || e.keyCode == 27) {
|
||||
CodeMirror.e_stop(e);
|
||||
close();
|
||||
me.focus();
|
||||
if (e.keyCode == 13) callback(inp.value);
|
||||
}
|
||||
});
|
||||
inp.focus();
|
||||
CodeMirror.connect(inp, "blur", close);
|
||||
}
|
||||
return close;
|
||||
});
|
||||
|
||||
CodeMirror.defineExtension("openConfirm", function(template, callbacks) {
|
||||
var dialog = dialogDiv(this, template);
|
||||
var buttons = dialog.getElementsByTagName("button");
|
||||
var closed = false, me = this, blurring = 1;
|
||||
function close() {
|
||||
if (closed) return;
|
||||
closed = true;
|
||||
dialog.parentNode.removeChild(dialog);
|
||||
me.focus();
|
||||
}
|
||||
buttons[0].focus();
|
||||
for (var i = 0; i < buttons.length; ++i) {
|
||||
var b = buttons[i];
|
||||
(function(callback) {
|
||||
CodeMirror.connect(b, "click", function(e) {
|
||||
CodeMirror.e_preventDefault(e);
|
||||
close();
|
||||
if (callback) callback(me);
|
||||
});
|
||||
})(callbacks[i]);
|
||||
CodeMirror.connect(b, "blur", function() {
|
||||
--blurring;
|
||||
setTimeout(function() { if (blurring <= 0) close(); }, 200);
|
||||
});
|
||||
CodeMirror.connect(b, "focus", function() { ++blurring; });
|
||||
}
|
||||
});
|
||||
})();
|
||||
@@ -1,294 +0,0 @@
|
||||
// ============== Formatting extensions ============================
|
||||
// A common storage for all mode-specific formatting features
|
||||
if (!CodeMirror.modeExtensions) CodeMirror.modeExtensions = {};
|
||||
|
||||
// Returns the extension of the editor's current mode
|
||||
CodeMirror.defineExtension("getModeExt", function () {
|
||||
var mname = CodeMirror.resolveMode(this.getOption("mode")).name;
|
||||
var ext = CodeMirror.modeExtensions[mname];
|
||||
if (!ext) throw new Error("No extensions found for mode " + mname);
|
||||
return ext;
|
||||
});
|
||||
|
||||
// If the current mode is 'htmlmixed', returns the extension of a mode located at
|
||||
// the specified position (can be htmlmixed, css or javascript). Otherwise, simply
|
||||
// returns the extension of the editor's current mode.
|
||||
CodeMirror.defineExtension("getModeExtAtPos", function (pos) {
|
||||
var token = this.getTokenAt(pos);
|
||||
if (token && token.state && token.state.mode)
|
||||
return CodeMirror.modeExtensions[token.state.mode == "html" ? "htmlmixed" : token.state.mode];
|
||||
else
|
||||
return this.getModeExt();
|
||||
});
|
||||
|
||||
// Comment/uncomment the specified range
|
||||
CodeMirror.defineExtension("commentRange", function (isComment, from, to) {
|
||||
var curMode = this.getModeExtAtPos(this.getCursor());
|
||||
if (isComment) { // Comment range
|
||||
var commentedText = this.getRange(from, to);
|
||||
this.replaceRange(curMode.commentStart + this.getRange(from, to) + curMode.commentEnd
|
||||
, from, to);
|
||||
if (from.line == to.line && from.ch == to.ch) { // An empty comment inserted - put cursor inside
|
||||
this.setCursor(from.line, from.ch + curMode.commentStart.length);
|
||||
}
|
||||
}
|
||||
else { // Uncomment range
|
||||
var selText = this.getRange(from, to);
|
||||
var startIndex = selText.indexOf(curMode.commentStart);
|
||||
var endIndex = selText.lastIndexOf(curMode.commentEnd);
|
||||
if (startIndex > -1 && endIndex > -1 && endIndex > startIndex) {
|
||||
// Take string till comment start
|
||||
selText = selText.substr(0, startIndex)
|
||||
// From comment start till comment end
|
||||
+ selText.substring(startIndex + curMode.commentStart.length, endIndex)
|
||||
// From comment end till string end
|
||||
+ selText.substr(endIndex + curMode.commentEnd.length);
|
||||
}
|
||||
this.replaceRange(selText, from, to);
|
||||
}
|
||||
});
|
||||
|
||||
// Applies automatic mode-aware indentation to the specified range
|
||||
CodeMirror.defineExtension("autoIndentRange", function (from, to) {
|
||||
var cmInstance = this;
|
||||
this.operation(function () {
|
||||
for (var i = from.line; i <= to.line; i++) {
|
||||
cmInstance.indentLine(i, "smart");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Applies automatic formatting to the specified range
|
||||
CodeMirror.defineExtension("autoFormatRange", function (from, to) {
|
||||
var absStart = this.indexFromPos(from);
|
||||
var absEnd = this.indexFromPos(to);
|
||||
// Insert additional line breaks where necessary according to the
|
||||
// mode's syntax
|
||||
var res = this.getModeExt().autoFormatLineBreaks(this.getValue(), absStart, absEnd);
|
||||
var cmInstance = this;
|
||||
|
||||
// Replace and auto-indent the range
|
||||
this.operation(function () {
|
||||
cmInstance.replaceRange(res, from, to);
|
||||
var startLine = cmInstance.posFromIndex(absStart).line;
|
||||
var endLine = cmInstance.posFromIndex(absStart + res.length).line;
|
||||
for (var i = startLine; i <= endLine; i++) {
|
||||
cmInstance.indentLine(i, "smart");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Define extensions for a few modes
|
||||
|
||||
CodeMirror.modeExtensions["css"] = {
|
||||
commentStart: "/*",
|
||||
commentEnd: "*/",
|
||||
wordWrapChars: [";", "\\{", "\\}"],
|
||||
autoFormatLineBreaks: function (text) {
|
||||
return text.replace(new RegExp("(;|\\{|\\})([^\r\n])", "g"), "$1\n$2");
|
||||
}
|
||||
};
|
||||
|
||||
CodeMirror.modeExtensions["javascript"] = {
|
||||
commentStart: "/*",
|
||||
commentEnd: "*/",
|
||||
wordWrapChars: [";", "\\{", "\\}"],
|
||||
|
||||
getNonBreakableBlocks: function (text) {
|
||||
var nonBreakableRegexes = [
|
||||
new RegExp("for\\s*?\\(([\\s\\S]*?)\\)"),
|
||||
new RegExp("'([\\s\\S]*?)('|$)"),
|
||||
new RegExp("\"([\\s\\S]*?)(\"|$)"),
|
||||
new RegExp("//.*([\r\n]|$)")
|
||||
];
|
||||
var nonBreakableBlocks = new Array();
|
||||
for (var i = 0; i < nonBreakableRegexes.length; i++) {
|
||||
var curPos = 0;
|
||||
while (curPos < text.length) {
|
||||
var m = text.substr(curPos).match(nonBreakableRegexes[i]);
|
||||
if (m != null) {
|
||||
nonBreakableBlocks.push({
|
||||
start: curPos + m.index,
|
||||
end: curPos + m.index + m[0].length
|
||||
});
|
||||
curPos += m.index + Math.max(1, m[0].length);
|
||||
}
|
||||
else { // No more matches
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
nonBreakableBlocks.sort(function (a, b) {
|
||||
return a.start - b.start;
|
||||
});
|
||||
|
||||
return nonBreakableBlocks;
|
||||
},
|
||||
|
||||
autoFormatLineBreaks: function (text) {
|
||||
var curPos = 0;
|
||||
var reLinesSplitter = new RegExp("(;|\\{|\\})([^\r\n])", "g");
|
||||
var nonBreakableBlocks = this.getNonBreakableBlocks(text);
|
||||
if (nonBreakableBlocks != null) {
|
||||
var res = "";
|
||||
for (var i = 0; i < nonBreakableBlocks.length; i++) {
|
||||
if (nonBreakableBlocks[i].start > curPos) { // Break lines till the block
|
||||
res += text.substring(curPos, nonBreakableBlocks[i].start).replace(reLinesSplitter, "$1\n$2");
|
||||
curPos = nonBreakableBlocks[i].start;
|
||||
}
|
||||
if (nonBreakableBlocks[i].start <= curPos
|
||||
&& nonBreakableBlocks[i].end >= curPos) { // Skip non-breakable block
|
||||
res += text.substring(curPos, nonBreakableBlocks[i].end);
|
||||
curPos = nonBreakableBlocks[i].end;
|
||||
}
|
||||
}
|
||||
if (curPos < text.length - 1) {
|
||||
res += text.substr(curPos).replace(reLinesSplitter, "$1\n$2");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
else {
|
||||
return text.replace(reLinesSplitter, "$1\n$2");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CodeMirror.modeExtensions["xml"] = {
|
||||
commentStart: "<!--",
|
||||
commentEnd: "-->",
|
||||
wordWrapChars: [">"],
|
||||
|
||||
autoFormatLineBreaks: function (text) {
|
||||
var lines = text.split("\n");
|
||||
var reProcessedPortion = new RegExp("(^\\s*?<|^[^<]*?)(.+)(>\\s*?$|[^>]*?$)");
|
||||
var reOpenBrackets = new RegExp("<", "g");
|
||||
var reCloseBrackets = new RegExp("(>)([^\r\n])", "g");
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var mToProcess = lines[i].match(reProcessedPortion);
|
||||
if (mToProcess != null && mToProcess.length > 3) { // The line starts with whitespaces and ends with whitespaces
|
||||
lines[i] = mToProcess[1]
|
||||
+ mToProcess[2].replace(reOpenBrackets, "\n$&").replace(reCloseBrackets, "$1\n$2")
|
||||
+ mToProcess[3];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return lines.join("\n");
|
||||
}
|
||||
};
|
||||
|
||||
CodeMirror.modeExtensions["htmlmixed"] = {
|
||||
commentStart: "<!--",
|
||||
commentEnd: "-->",
|
||||
wordWrapChars: [">", ";", "\\{", "\\}"],
|
||||
|
||||
getModeInfos: function (text, absPos) {
|
||||
var modeInfos = new Array();
|
||||
modeInfos[0] =
|
||||
{
|
||||
pos: 0,
|
||||
modeExt: CodeMirror.modeExtensions["xml"],
|
||||
modeName: "xml"
|
||||
};
|
||||
|
||||
var modeMatchers = new Array();
|
||||
modeMatchers[0] =
|
||||
{
|
||||
regex: new RegExp("<style[^>]*>([\\s\\S]*?)(</style[^>]*>|$)", "i"),
|
||||
modeExt: CodeMirror.modeExtensions["css"],
|
||||
modeName: "css"
|
||||
};
|
||||
modeMatchers[1] =
|
||||
{
|
||||
regex: new RegExp("<script[^>]*>([\\s\\S]*?)(</script[^>]*>|$)", "i"),
|
||||
modeExt: CodeMirror.modeExtensions["javascript"],
|
||||
modeName: "javascript"
|
||||
};
|
||||
|
||||
var lastCharPos = (typeof (absPos) !== "undefined" ? absPos : text.length - 1);
|
||||
// Detect modes for the entire text
|
||||
for (var i = 0; i < modeMatchers.length; i++) {
|
||||
var curPos = 0;
|
||||
while (curPos <= lastCharPos) {
|
||||
var m = text.substr(curPos).match(modeMatchers[i].regex);
|
||||
if (m != null) {
|
||||
if (m.length > 1 && m[1].length > 0) {
|
||||
// Push block begin pos
|
||||
var blockBegin = curPos + m.index + m[0].indexOf(m[1]);
|
||||
modeInfos.push(
|
||||
{
|
||||
pos: blockBegin,
|
||||
modeExt: modeMatchers[i].modeExt,
|
||||
modeName: modeMatchers[i].modeName
|
||||
});
|
||||
// Push block end pos
|
||||
modeInfos.push(
|
||||
{
|
||||
pos: blockBegin + m[1].length,
|
||||
modeExt: modeInfos[0].modeExt,
|
||||
modeName: modeInfos[0].modeName
|
||||
});
|
||||
curPos += m.index + m[0].length;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
curPos += m.index + Math.max(m[0].length, 1);
|
||||
}
|
||||
}
|
||||
else { // No more matches
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Sort mode infos
|
||||
modeInfos.sort(function sortModeInfo(a, b) {
|
||||
return a.pos - b.pos;
|
||||
});
|
||||
|
||||
return modeInfos;
|
||||
},
|
||||
|
||||
autoFormatLineBreaks: function (text, startPos, endPos) {
|
||||
var modeInfos = this.getModeInfos(text);
|
||||
var reBlockStartsWithNewline = new RegExp("^\\s*?\n");
|
||||
var reBlockEndsWithNewline = new RegExp("\n\\s*?$");
|
||||
var res = "";
|
||||
// Use modes info to break lines correspondingly
|
||||
if (modeInfos.length > 1) { // Deal with multi-mode text
|
||||
for (var i = 1; i <= modeInfos.length; i++) {
|
||||
var selStart = modeInfos[i - 1].pos;
|
||||
var selEnd = (i < modeInfos.length ? modeInfos[i].pos : endPos);
|
||||
|
||||
if (selStart >= endPos) { // The block starts later than the needed fragment
|
||||
break;
|
||||
}
|
||||
if (selStart < startPos) {
|
||||
if (selEnd <= startPos) { // The block starts earlier than the needed fragment
|
||||
continue;
|
||||
}
|
||||
selStart = startPos;
|
||||
}
|
||||
if (selEnd > endPos) {
|
||||
selEnd = endPos;
|
||||
}
|
||||
var textPortion = text.substring(selStart, selEnd);
|
||||
if (modeInfos[i - 1].modeName != "xml") { // Starting a CSS or JavaScript block
|
||||
if (!reBlockStartsWithNewline.test(textPortion)
|
||||
&& selStart > 0) { // The block does not start with a line break
|
||||
textPortion = "\n" + textPortion;
|
||||
}
|
||||
if (!reBlockEndsWithNewline.test(textPortion)
|
||||
&& selEnd < text.length - 1) { // The block does not end with a line break
|
||||
textPortion += "\n";
|
||||
}
|
||||
}
|
||||
res += modeInfos[i - 1].modeExt.autoFormatLineBreaks(textPortion);
|
||||
}
|
||||
}
|
||||
else { // Single-mode text
|
||||
res = modeInfos[0].modeExt.autoFormatLineBreaks(text.substring(startPos, endPos));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
@@ -1,134 +0,0 @@
|
||||
(function () {
|
||||
function forEach(arr, f) {
|
||||
for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
|
||||
}
|
||||
|
||||
function arrayContains(arr, item) {
|
||||
if (!Array.prototype.indexOf) {
|
||||
var i = arr.length;
|
||||
while (i--) {
|
||||
if (arr[i] === item) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return arr.indexOf(item) != -1;
|
||||
}
|
||||
|
||||
function scriptHint(editor, keywords, getToken) {
|
||||
// Find the token at the cursor
|
||||
var cur = editor.getCursor(), token = getToken(editor, cur), tprop = token;
|
||||
// If it's not a 'word-style' token, ignore the token.
|
||||
if (!/^[\w$_]*$/.test(token.string)) {
|
||||
token = tprop = {start: cur.ch, end: cur.ch, string: "", state: token.state,
|
||||
className: token.string == "." ? "property" : null};
|
||||
}
|
||||
// If it is a property, find out what it is a property of.
|
||||
while (tprop.className == "property") {
|
||||
tprop = getToken(editor, {line: cur.line, ch: tprop.start});
|
||||
if (tprop.string != ".") return;
|
||||
tprop = getToken(editor, {line: cur.line, ch: tprop.start});
|
||||
if (tprop.string == ')') {
|
||||
var level = 1;
|
||||
do {
|
||||
tprop = getToken(editor, {line: cur.line, ch: tprop.start});
|
||||
switch (tprop.string) {
|
||||
case ')': level++; break;
|
||||
case '(': level--; break;
|
||||
default: break;
|
||||
}
|
||||
} while (level > 0)
|
||||
tprop = getToken(editor, {line: cur.line, ch: tprop.start});
|
||||
if (tprop.className == 'variable')
|
||||
tprop.className = 'function';
|
||||
else return; // no clue
|
||||
}
|
||||
if (!context) var context = [];
|
||||
context.push(tprop);
|
||||
}
|
||||
return {list: getCompletions(token, context, keywords),
|
||||
from: {line: cur.line, ch: token.start},
|
||||
to: {line: cur.line, ch: token.end}};
|
||||
}
|
||||
|
||||
CodeMirror.javascriptHint = function(editor) {
|
||||
return scriptHint(editor, javascriptKeywords,
|
||||
function (e, cur) {return e.getTokenAt(cur);});
|
||||
}
|
||||
|
||||
function getCoffeeScriptToken(editor, cur) {
|
||||
// This getToken, it is for coffeescript, imitates the behavior of
|
||||
// getTokenAt method in javascript.js, that is, returning "property"
|
||||
// type and treat "." as indepenent token.
|
||||
var token = editor.getTokenAt(cur);
|
||||
if (cur.ch == token.start + 1 && token.string.charAt(0) == '.') {
|
||||
token.end = token.start;
|
||||
token.string = '.';
|
||||
token.className = "property";
|
||||
}
|
||||
else if (/^\.[\w$_]*$/.test(token.string)) {
|
||||
token.className = "property";
|
||||
token.start++;
|
||||
token.string = token.string.replace(/\./, '');
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
CodeMirror.coffeescriptHint = function(editor) {
|
||||
return scriptHint(editor, coffeescriptKeywords, getCoffeeScriptToken);
|
||||
}
|
||||
|
||||
var stringProps = ("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight " +
|
||||
"toUpperCase toLowerCase split concat match replace search").split(" ");
|
||||
var arrayProps = ("length concat join splice push pop shift unshift slice reverse sort indexOf " +
|
||||
"lastIndexOf every some filter forEach map reduce reduceRight ").split(" ");
|
||||
var funcProps = "prototype apply call bind".split(" ");
|
||||
var javascriptKeywords = ("break case catch continue debugger default delete do else false finally for function " +
|
||||
"if in instanceof new null return switch throw true try typeof var void while with").split(" ");
|
||||
var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
|
||||
"if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");
|
||||
|
||||
function getCompletions(token, context, keywords) {
|
||||
var found = [], start = token.string;
|
||||
function maybeAdd(str) {
|
||||
if (str.indexOf(start) == 0 && !arrayContains(found, str)) found.push(str);
|
||||
}
|
||||
function gatherCompletions(obj) {
|
||||
if (typeof obj == "string") forEach(stringProps, maybeAdd);
|
||||
else if (obj instanceof Array) forEach(arrayProps, maybeAdd);
|
||||
else if (obj instanceof Function) forEach(funcProps, maybeAdd);
|
||||
for (var name in obj) maybeAdd(name);
|
||||
}
|
||||
|
||||
if (context) {
|
||||
// If this is a property, see if it belongs to some object we can
|
||||
// find in the current environment.
|
||||
var obj = context.pop(), base;
|
||||
if (obj.className == "variable")
|
||||
base = window[obj.string];
|
||||
else if (obj.className == "string")
|
||||
base = "";
|
||||
else if (obj.className == "atom")
|
||||
base = 1;
|
||||
else if (obj.className == "function") {
|
||||
if (window.jQuery != null && (obj.string == '$' || obj.string == 'jQuery') &&
|
||||
(typeof window.jQuery == 'function'))
|
||||
base = window.jQuery();
|
||||
else if (window._ != null && (obj.string == '_') && (typeof window._ == 'function'))
|
||||
base = window._();
|
||||
}
|
||||
while (base != null && context.length)
|
||||
base = base[context.pop().string];
|
||||
if (base != null) gatherCompletions(base);
|
||||
}
|
||||
else {
|
||||
// If not, just look in the window object and any local scope
|
||||
// (reading into JS mode internals to get at the local variables)
|
||||
for (var v = token.state.localVars; v; v = v.next) maybeAdd(v.name);
|
||||
gatherCompletions(window);
|
||||
forEach(keywords, maybeAdd);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
})();
|
||||
@@ -1,50 +0,0 @@
|
||||
(function() {
|
||||
if (!CodeMirror.modeURL) CodeMirror.modeURL = "../mode/%N/%N.js";
|
||||
|
||||
var loading = {};
|
||||
function splitCallback(cont, n) {
|
||||
var countDown = n;
|
||||
return function() { if (--countDown == 0) cont(); }
|
||||
}
|
||||
function ensureDeps(mode, cont) {
|
||||
var deps = CodeMirror.modes[mode].dependencies;
|
||||
if (!deps) return cont();
|
||||
var missing = [];
|
||||
for (var i = 0; i < deps.length; ++i) {
|
||||
if (!CodeMirror.modes.hasOwnProperty(deps[i]))
|
||||
missing.push(deps[i]);
|
||||
}
|
||||
if (!missing.length) return cont();
|
||||
var split = splitCallback(cont, missing.length);
|
||||
for (var i = 0; i < missing.length; ++i)
|
||||
CodeMirror.requireMode(missing[i], split);
|
||||
}
|
||||
|
||||
CodeMirror.requireMode = function(mode, cont) {
|
||||
if (CodeMirror.modes.hasOwnProperty(mode)) return ensureDeps(mode, cont());
|
||||
if (loading.hasOwnProperty(mode)) return loading[mode].push(cont);
|
||||
|
||||
var script = document.createElement("script");
|
||||
script.src = CodeMirror.modeURL.replace(/%N/g, mode);
|
||||
var others = document.getElementsByTagName("script")[0];
|
||||
others.parentNode.insertBefore(script, others);
|
||||
var list = loading[mode] = [cont];
|
||||
var count = 0, poll = setInterval(function() {
|
||||
if (++count > 100) return clearInterval(poll);
|
||||
if (CodeMirror.modes.hasOwnProperty(mode)) {
|
||||
clearInterval(poll);
|
||||
loading[mode] = null;
|
||||
ensureDeps(mode, function() {
|
||||
for (var i = 0; i < list.length; ++i) list[i]();
|
||||
});
|
||||
}
|
||||
}, 200);
|
||||
};
|
||||
|
||||
CodeMirror.autoLoadMode = function(instance, mode) {
|
||||
if (!CodeMirror.modes.hasOwnProperty(mode))
|
||||
CodeMirror.requireMode(mode, function() {
|
||||
instance.setOption("mode", instance.getOption("mode"));
|
||||
});
|
||||
};
|
||||
}());
|
||||
@@ -1,51 +0,0 @@
|
||||
// Utility function that allows modes to be combined. The mode given
|
||||
// as the base argument takes care of most of the normal mode
|
||||
// functionality, but a second (typically simple) mode is used, which
|
||||
// can override the style of text. Both modes get to parse all of the
|
||||
// text, but when both assign a non-null style to a piece of code, the
|
||||
// overlay wins, unless the combine argument was true, in which case
|
||||
// the styles are combined.
|
||||
|
||||
CodeMirror.overlayParser = function(base, overlay, combine) {
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
base: CodeMirror.startState(base),
|
||||
overlay: CodeMirror.startState(overlay),
|
||||
basePos: 0, baseCur: null,
|
||||
overlayPos: 0, overlayCur: null
|
||||
};
|
||||
},
|
||||
copyState: function(state) {
|
||||
return {
|
||||
base: CodeMirror.copyState(base, state.base),
|
||||
overlay: CodeMirror.copyState(overlay, state.overlay),
|
||||
basePos: state.basePos, baseCur: null,
|
||||
overlayPos: state.overlayPos, overlayCur: null
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (stream.start == state.basePos) {
|
||||
state.baseCur = base.token(stream, state.base);
|
||||
state.basePos = stream.pos;
|
||||
}
|
||||
if (stream.start == state.overlayPos) {
|
||||
stream.pos = stream.start;
|
||||
state.overlayCur = overlay.token(stream, state.overlay);
|
||||
state.overlayPos = stream.pos;
|
||||
}
|
||||
stream.pos = Math.min(state.basePos, state.overlayPos);
|
||||
if (stream.eol()) state.basePos = state.overlayPos = 0;
|
||||
|
||||
if (state.overlayCur == null) return state.baseCur;
|
||||
if (state.baseCur != null && combine) return state.baseCur + " " + state.overlayCur;
|
||||
else return state.overlayCur;
|
||||
},
|
||||
|
||||
indent: base.indent && function(state, textAfter) {
|
||||
return base.indent(state.base, textAfter);
|
||||
},
|
||||
electricChars: base.electricChars
|
||||
};
|
||||
};
|
||||
@@ -1,49 +0,0 @@
|
||||
CodeMirror.runMode = function(string, modespec, callback, options) {
|
||||
var mode = CodeMirror.getMode(CodeMirror.defaults, modespec);
|
||||
var isNode = callback.nodeType == 1;
|
||||
var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize;
|
||||
if (isNode) {
|
||||
var node = callback, accum = [], col = 0;
|
||||
callback = function(text, style) {
|
||||
if (text == "\n") {
|
||||
accum.push("<br>");
|
||||
col = 0;
|
||||
return;
|
||||
}
|
||||
var escaped = "";
|
||||
// HTML-escape and replace tabs
|
||||
for (var pos = 0;;) {
|
||||
var idx = text.indexOf("\t", pos);
|
||||
if (idx == -1) {
|
||||
escaped += CodeMirror.htmlEscape(text.slice(pos));
|
||||
col += text.length - pos;
|
||||
break;
|
||||
} else {
|
||||
col += idx - pos;
|
||||
escaped += CodeMirror.htmlEscape(text.slice(pos, idx));
|
||||
var size = tabSize - col % tabSize;
|
||||
col += size;
|
||||
for (var i = 0; i < size; ++i) escaped += " ";
|
||||
pos = idx + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (style)
|
||||
accum.push("<span class=\"cm-" + CodeMirror.htmlEscape(style) + "\">" + escaped + "</span>");
|
||||
else
|
||||
accum.push(escaped);
|
||||
}
|
||||
}
|
||||
var lines = CodeMirror.splitLines(string), state = CodeMirror.startState(mode);
|
||||
for (var i = 0, e = lines.length; i < e; ++i) {
|
||||
if (i) callback("\n");
|
||||
var stream = new CodeMirror.StringStream(lines[i]);
|
||||
while (!stream.eol()) {
|
||||
var style = mode.token(stream, state);
|
||||
callback(stream.current(), style, i, stream.start);
|
||||
stream.start = stream.pos;
|
||||
}
|
||||
}
|
||||
if (isNode)
|
||||
node.innerHTML = accum.join("");
|
||||
};
|
||||
@@ -1,114 +0,0 @@
|
||||
// Define search commands. Depends on dialog.js or another
|
||||
// implementation of the openDialog method.
|
||||
|
||||
// Replace works a little oddly -- it will do the replace on the next
|
||||
// Ctrl-G (or whatever is bound to findNext) press. You prevent a
|
||||
// replace by making sure the match is no longer selected when hitting
|
||||
// Ctrl-G.
|
||||
|
||||
(function() {
|
||||
function SearchState() {
|
||||
this.posFrom = this.posTo = this.query = null;
|
||||
this.marked = [];
|
||||
}
|
||||
function getSearchState(cm) {
|
||||
return cm._searchState || (cm._searchState = new SearchState());
|
||||
}
|
||||
function dialog(cm, text, shortText, f) {
|
||||
if (cm.openDialog) cm.openDialog(text, f);
|
||||
else f(prompt(shortText, ""));
|
||||
}
|
||||
function confirmDialog(cm, text, shortText, fs) {
|
||||
if (cm.openConfirm) cm.openConfirm(text, fs);
|
||||
else if (confirm(shortText)) fs[0]();
|
||||
}
|
||||
function parseQuery(query) {
|
||||
var isRE = query.match(/^\/(.*)\/$/);
|
||||
return isRE ? new RegExp(isRE[1]) : query;
|
||||
}
|
||||
var queryDialog =
|
||||
'Search: <input type="text" style="width: 10em"> <span style="color: #888">(Use /re/ syntax for regexp search)</span>';
|
||||
function doSearch(cm, rev) {
|
||||
var state = getSearchState(cm);
|
||||
if (state.query) return findNext(cm, rev);
|
||||
dialog(cm, queryDialog, "Search for:", function(query) {
|
||||
cm.operation(function() {
|
||||
if (!query || state.query) return;
|
||||
state.query = parseQuery(query);
|
||||
if (cm.lineCount() < 2000) { // This is too expensive on big documents.
|
||||
for (var cursor = cm.getSearchCursor(query); cursor.findNext();)
|
||||
state.marked.push(cm.markText(cursor.from(), cursor.to(), "CodeMirror-searching"));
|
||||
}
|
||||
state.posFrom = state.posTo = cm.getCursor();
|
||||
findNext(cm, rev);
|
||||
});
|
||||
});
|
||||
}
|
||||
function findNext(cm, rev) {cm.operation(function() {
|
||||
var state = getSearchState(cm);
|
||||
var cursor = cm.getSearchCursor(state.query, rev ? state.posFrom : state.posTo);
|
||||
if (!cursor.find(rev)) {
|
||||
cursor = cm.getSearchCursor(state.query, rev ? {line: cm.lineCount() - 1} : {line: 0, ch: 0});
|
||||
if (!cursor.find(rev)) return;
|
||||
}
|
||||
cm.setSelection(cursor.from(), cursor.to());
|
||||
state.posFrom = cursor.from(); state.posTo = cursor.to();
|
||||
})}
|
||||
function clearSearch(cm) {cm.operation(function() {
|
||||
var state = getSearchState(cm);
|
||||
if (!state.query) return;
|
||||
state.query = null;
|
||||
for (var i = 0; i < state.marked.length; ++i) state.marked[i].clear();
|
||||
state.marked.length = 0;
|
||||
})}
|
||||
|
||||
var replaceQueryDialog =
|
||||
'Replace: <input type="text" style="width: 10em"> <span style="color: #888">(Use /re/ syntax for regexp search)</span>';
|
||||
var replacementQueryDialog = 'With: <input type="text" style="width: 10em">';
|
||||
var doReplaceConfirm = "Replace? <button>Yes</button> <button>No</button> <button>Stop</button>";
|
||||
function replace(cm, all) {
|
||||
dialog(cm, replaceQueryDialog, "Replace:", function(query) {
|
||||
if (!query) return;
|
||||
query = parseQuery(query);
|
||||
dialog(cm, replacementQueryDialog, "Replace with:", function(text) {
|
||||
if (all) {
|
||||
cm.compoundChange(function() { cm.operation(function() {
|
||||
for (var cursor = cm.getSearchCursor(query); cursor.findNext();) {
|
||||
if (typeof query != "string") {
|
||||
var match = cm.getRange(cursor.from(), cursor.to()).match(query);
|
||||
cursor.replace(text.replace(/\$(\d)/, function(w, i) {return match[i];}));
|
||||
} else cursor.replace(text);
|
||||
}
|
||||
})});
|
||||
} else {
|
||||
clearSearch(cm);
|
||||
var cursor = cm.getSearchCursor(query, cm.getCursor());
|
||||
function advance() {
|
||||
var start = cursor.from(), match;
|
||||
if (!(match = cursor.findNext())) {
|
||||
cursor = cm.getSearchCursor(query);
|
||||
if (!(match = cursor.findNext()) ||
|
||||
(cursor.from().line == start.line && cursor.from().ch == start.ch)) return;
|
||||
}
|
||||
cm.setSelection(cursor.from(), cursor.to());
|
||||
confirmDialog(cm, doReplaceConfirm, "Replace?",
|
||||
[function() {doReplace(match);}, advance]);
|
||||
}
|
||||
function doReplace(match) {
|
||||
cursor.replace(typeof query == "string" ? text :
|
||||
text.replace(/\$(\d)/, function(w, i) {return match[i];}));
|
||||
advance();
|
||||
}
|
||||
advance();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
CodeMirror.commands.find = function(cm) {clearSearch(cm); doSearch(cm);};
|
||||
CodeMirror.commands.findNext = doSearch;
|
||||
CodeMirror.commands.findPrev = function(cm) {doSearch(cm, true);};
|
||||
CodeMirror.commands.clearSearch = clearSearch;
|
||||
CodeMirror.commands.replace = replace;
|
||||
CodeMirror.commands.replaceAll = function(cm) {replace(cm, true);};
|
||||
})();
|
||||
@@ -1,16 +0,0 @@
|
||||
.CodeMirror-completions {
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
overflow: hidden;
|
||||
-webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
||||
-moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
||||
box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
||||
}
|
||||
.CodeMirror-completions select {
|
||||
background: #fafafa;
|
||||
outline: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-family: monospace;
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
(function() {
|
||||
CodeMirror.simpleHint = function(editor, getHints) {
|
||||
// We want a single cursor position.
|
||||
if (editor.somethingSelected()) return;
|
||||
var result = getHints(editor);
|
||||
if (!result || !result.list.length) return;
|
||||
var completions = result.list;
|
||||
function insert(str) {
|
||||
editor.replaceRange(str, result.from, result.to);
|
||||
}
|
||||
// When there is only one completion, use it directly.
|
||||
if (completions.length == 1) {insert(completions[0]); return true;}
|
||||
|
||||
// Build the select widget
|
||||
var complete = document.createElement("div");
|
||||
complete.className = "CodeMirror-completions";
|
||||
var sel = complete.appendChild(document.createElement("select"));
|
||||
// Opera doesn't move the selection when pressing up/down in a
|
||||
// multi-select, but it does properly support the size property on
|
||||
// single-selects, so no multi-select is necessary.
|
||||
if (!window.opera) sel.multiple = true;
|
||||
for (var i = 0; i < completions.length; ++i) {
|
||||
var opt = sel.appendChild(document.createElement("option"));
|
||||
opt.appendChild(document.createTextNode(completions[i]));
|
||||
}
|
||||
sel.firstChild.selected = true;
|
||||
sel.size = Math.min(10, completions.length);
|
||||
var pos = editor.cursorCoords();
|
||||
complete.style.left = pos.x + "px";
|
||||
complete.style.top = pos.yBot + "px";
|
||||
document.body.appendChild(complete);
|
||||
// If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
|
||||
var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
|
||||
if(winW - pos.x < sel.clientWidth)
|
||||
complete.style.left = (pos.x - sel.clientWidth) + "px";
|
||||
// Hack to hide the scrollbar.
|
||||
if (completions.length <= 10)
|
||||
complete.style.width = (sel.clientWidth - 1) + "px";
|
||||
|
||||
var done = false;
|
||||
function close() {
|
||||
if (done) return;
|
||||
done = true;
|
||||
complete.parentNode.removeChild(complete);
|
||||
}
|
||||
function pick() {
|
||||
insert(completions[sel.selectedIndex]);
|
||||
close();
|
||||
setTimeout(function(){editor.focus();}, 50);
|
||||
}
|
||||
CodeMirror.connect(sel, "blur", close);
|
||||
CodeMirror.connect(sel, "keydown", function(event) {
|
||||
var code = event.keyCode;
|
||||
// Enter
|
||||
if (code == 13) {CodeMirror.e_stop(event); pick();}
|
||||
// Escape
|
||||
else if (code == 27) {CodeMirror.e_stop(event); close(); editor.focus();}
|
||||
else if (code != 38 && code != 40) {
|
||||
close(); editor.focus();
|
||||
// Pass the event to the CodeMirror instance so that it can handle things like backspace properly.
|
||||
editor.triggerOnKeyDown(event);
|
||||
setTimeout(function(){CodeMirror.simpleHint(editor, getHints);}, 50);
|
||||
}
|
||||
});
|
||||
CodeMirror.connect(sel, "dblclick", pick);
|
||||
|
||||
sel.focus();
|
||||
// Opera sometimes ignores focusing a freshly created node
|
||||
if (window.opera) setTimeout(function(){if (!done) sel.focus();}, 100);
|
||||
return true;
|
||||
};
|
||||
})();
|
||||
@@ -1,234 +0,0 @@
|
||||
CodeMirror.defineMode("clike", function(config, parserConfig) {
|
||||
var indentUnit = config.indentUnit,
|
||||
keywords = parserConfig.keywords || {},
|
||||
blockKeywords = parserConfig.blockKeywords || {},
|
||||
atoms = parserConfig.atoms || {},
|
||||
hooks = parserConfig.hooks || {},
|
||||
multiLineStrings = parserConfig.multiLineStrings;
|
||||
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
|
||||
|
||||
var curPunc;
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (hooks[ch]) {
|
||||
var result = hooks[ch](stream, state);
|
||||
if (result !== false) return result;
|
||||
}
|
||||
if (ch == '"' || ch == "'") {
|
||||
state.tokenize = tokenString(ch);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
||||
curPunc = ch;
|
||||
return null;
|
||||
}
|
||||
if (/\d/.test(ch)) {
|
||||
stream.eatWhile(/[\w\.]/);
|
||||
return "number";
|
||||
}
|
||||
if (ch == "/") {
|
||||
if (stream.eat("*")) {
|
||||
state.tokenize = tokenComment;
|
||||
return tokenComment(stream, state);
|
||||
}
|
||||
if (stream.eat("/")) {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
}
|
||||
if (isOperatorChar.test(ch)) {
|
||||
stream.eatWhile(isOperatorChar);
|
||||
return "operator";
|
||||
}
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
var cur = stream.current();
|
||||
if (keywords.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "keyword";
|
||||
}
|
||||
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
||||
return "word";
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var escaped = false, next, end = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == quote && !escaped) {end = true; break;}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
if (end || !(escaped || multiLineStrings))
|
||||
state.tokenize = null;
|
||||
return "string";
|
||||
};
|
||||
}
|
||||
|
||||
function tokenComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "/" && maybeEnd) {
|
||||
state.tokenize = null;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
|
||||
function Context(indented, column, type, align, prev) {
|
||||
this.indented = indented;
|
||||
this.column = column;
|
||||
this.type = type;
|
||||
this.align = align;
|
||||
this.prev = prev;
|
||||
}
|
||||
function pushContext(state, col, type) {
|
||||
return state.context = new Context(state.indented, col, type, null, state.context);
|
||||
}
|
||||
function popContext(state) {
|
||||
var t = state.context.type;
|
||||
if (t == ")" || t == "]" || t == "}")
|
||||
state.indented = state.context.indented;
|
||||
return state.context = state.context.prev;
|
||||
}
|
||||
|
||||
// Interface
|
||||
|
||||
return {
|
||||
startState: function(basecolumn) {
|
||||
return {
|
||||
tokenize: null,
|
||||
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
||||
indented: 0,
|
||||
startOfLine: true
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
var ctx = state.context;
|
||||
if (stream.sol()) {
|
||||
if (ctx.align == null) ctx.align = false;
|
||||
state.indented = stream.indentation();
|
||||
state.startOfLine = true;
|
||||
}
|
||||
if (stream.eatSpace()) return null;
|
||||
curPunc = null;
|
||||
var style = (state.tokenize || tokenBase)(stream, state);
|
||||
if (style == "comment" || style == "meta") return style;
|
||||
if (ctx.align == null) ctx.align = true;
|
||||
|
||||
if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
|
||||
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
||||
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
||||
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
||||
else if (curPunc == "}") {
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
if (ctx.type == "}") ctx = popContext(state);
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
}
|
||||
else if (curPunc == ctx.type) popContext(state);
|
||||
else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
|
||||
pushContext(state, stream.column(), "statement");
|
||||
state.startOfLine = false;
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize != tokenBase && state.tokenize != null) return 0;
|
||||
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
||||
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
|
||||
var closing = firstChar == ctx.type;
|
||||
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
|
||||
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
|
||||
else return ctx.indented + (closing ? 0 : indentUnit);
|
||||
},
|
||||
|
||||
electricChars: "{}"
|
||||
};
|
||||
});
|
||||
|
||||
(function() {
|
||||
function words(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
var cKeywords = "auto if break int case long char register continue return default short do sizeof " +
|
||||
"double static else struct entry switch extern typedef float union for unsigned " +
|
||||
"goto while enum void const signed volatile";
|
||||
|
||||
function cppHook(stream, state) {
|
||||
if (!state.startOfLine) return false;
|
||||
stream.skipToEnd();
|
||||
return "meta";
|
||||
}
|
||||
|
||||
// C#-style strings where "" escapes a quote.
|
||||
function tokenAtString(stream, state) {
|
||||
var next;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == '"' && !stream.eat('"')) {
|
||||
state.tokenize = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "string";
|
||||
}
|
||||
|
||||
CodeMirror.defineMIME("text/x-csrc", {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords),
|
||||
blockKeywords: words("case do else for if switch while struct"),
|
||||
atoms: words("null"),
|
||||
hooks: {"#": cppHook}
|
||||
});
|
||||
CodeMirror.defineMIME("text/x-c++src", {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try bool explicit new " +
|
||||
"static_cast typeid catch operator template typename class friend private " +
|
||||
"this using const_cast inline public throw virtual delete mutable protected " +
|
||||
"wchar_t"),
|
||||
blockKeywords: words("catch class do else finally for if struct switch try while"),
|
||||
atoms: words("true false null"),
|
||||
hooks: {"#": cppHook}
|
||||
});
|
||||
CodeMirror.defineMIME("text/x-java", {
|
||||
name: "clike",
|
||||
keywords: words("abstract assert boolean break byte case catch char class const continue default " +
|
||||
"do double else enum extends final finally float for goto if implements import " +
|
||||
"instanceof int interface long native new package private protected public " +
|
||||
"return short static strictfp super switch synchronized this throw throws transient " +
|
||||
"try void volatile while"),
|
||||
blockKeywords: words("catch class do else finally for if switch try while"),
|
||||
atoms: words("true false null"),
|
||||
hooks: {
|
||||
"@": function(stream, state) {
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
return "meta";
|
||||
}
|
||||
}
|
||||
});
|
||||
CodeMirror.defineMIME("text/x-csharp", {
|
||||
name: "clike",
|
||||
keywords: words("abstract as base bool break byte case catch char checked class const continue decimal" +
|
||||
" default delegate do double else enum event explicit extern finally fixed float for" +
|
||||
" foreach goto if implicit in int interface internal is lock long namespace new object" +
|
||||
" operator out override params private protected public readonly ref return sbyte sealed short" +
|
||||
" sizeof stackalloc static string struct switch this throw try typeof uint ulong unchecked" +
|
||||
" unsafe ushort using virtual void volatile while add alias ascending descending dynamic from get" +
|
||||
" global group into join let orderby partial remove select set value var yield"),
|
||||
blockKeywords: words("catch class do else finally for foreach if struct switch try while"),
|
||||
atoms: words("true false null"),
|
||||
hooks: {
|
||||
"@": function(stream, state) {
|
||||
if (stream.eat('"')) {
|
||||
state.tokenize = tokenAtString;
|
||||
return tokenAtString(stream, state);
|
||||
}
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
return "meta";
|
||||
}
|
||||
}
|
||||
});
|
||||
}());
|
||||
@@ -1,101 +0,0 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CodeMirror: C-like mode</title>
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="clike.js"></script>
|
||||
<link rel="stylesheet" href="../../doc/docs.css">
|
||||
<style>.CodeMirror {border: 2px inset #dee;}</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>CodeMirror: C-like mode</h1>
|
||||
|
||||
<form><textarea id="code" name="code">
|
||||
/* C demo code */
|
||||
|
||||
#include <zmq.h>
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <malloc.h>
|
||||
|
||||
typedef struct {
|
||||
void* arg_socket;
|
||||
zmq_msg_t* arg_msg;
|
||||
char* arg_string;
|
||||
unsigned long arg_len;
|
||||
int arg_int, arg_command;
|
||||
|
||||
int signal_fd;
|
||||
int pad;
|
||||
void* context;
|
||||
sem_t sem;
|
||||
} acl_zmq_context;
|
||||
|
||||
#define p(X) (context->arg_##X)
|
||||
|
||||
void* zmq_thread(void* context_pointer) {
|
||||
acl_zmq_context* context = (acl_zmq_context*)context_pointer;
|
||||
char ok = 'K', err = 'X';
|
||||
int res;
|
||||
|
||||
while (1) {
|
||||
while ((res = sem_wait(&context->sem)) == EINTR);
|
||||
if (res) {write(context->signal_fd, &err, 1); goto cleanup;}
|
||||
switch(p(command)) {
|
||||
case 0: goto cleanup;
|
||||
case 1: p(socket) = zmq_socket(context->context, p(int)); break;
|
||||
case 2: p(int) = zmq_close(p(socket)); break;
|
||||
case 3: p(int) = zmq_bind(p(socket), p(string)); break;
|
||||
case 4: p(int) = zmq_connect(p(socket), p(string)); break;
|
||||
case 5: p(int) = zmq_getsockopt(p(socket), p(int), (void*)p(string), &p(len)); break;
|
||||
case 6: p(int) = zmq_setsockopt(p(socket), p(int), (void*)p(string), p(len)); break;
|
||||
case 7: p(int) = zmq_send(p(socket), p(msg), p(int)); break;
|
||||
case 8: p(int) = zmq_recv(p(socket), p(msg), p(int)); break;
|
||||
case 9: p(int) = zmq_poll(p(socket), p(int), p(len)); break;
|
||||
}
|
||||
p(command) = errno;
|
||||
write(context->signal_fd, &ok, 1);
|
||||
}
|
||||
cleanup:
|
||||
close(context->signal_fd);
|
||||
free(context_pointer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* zmq_thread_init(void* zmq_context, int signal_fd) {
|
||||
acl_zmq_context* context = malloc(sizeof(acl_zmq_context));
|
||||
pthread_t thread;
|
||||
|
||||
context->context = zmq_context;
|
||||
context->signal_fd = signal_fd;
|
||||
sem_init(&context->sem, 1, 0);
|
||||
pthread_create(&thread, 0, &zmq_thread, context);
|
||||
pthread_detach(thread);
|
||||
return context;
|
||||
}
|
||||
</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-csrc"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>Simple mode that tries to handle C-like languages as well as it
|
||||
can. Takes two configuration parameters: <code>keywords</code>, an
|
||||
object whose property names are the keywords in the language,
|
||||
and <code>useCPP</code>, which determines whether C preprocessor
|
||||
directives are recognized.</p>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-csrc</code>
|
||||
(C code), <code>text/x-c++src</code> (C++
|
||||
code), <code>text/x-java</code> (Java
|
||||
code), <code>text/x-csharp</code> (C#).</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,124 +0,0 @@
|
||||
CodeMirror.defineMode("css", function(config) {
|
||||
var indentUnit = config.indentUnit, type;
|
||||
function ret(style, tp) {type = tp; return style;}
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (ch == "@") {stream.eatWhile(/[\w\\\-]/); return ret("meta", stream.current());}
|
||||
else if (ch == "/" && stream.eat("*")) {
|
||||
state.tokenize = tokenCComment;
|
||||
return tokenCComment(stream, state);
|
||||
}
|
||||
else if (ch == "<" && stream.eat("!")) {
|
||||
state.tokenize = tokenSGMLComment;
|
||||
return tokenSGMLComment(stream, state);
|
||||
}
|
||||
else if (ch == "=") ret(null, "compare");
|
||||
else if ((ch == "~" || ch == "|") && stream.eat("=")) return ret(null, "compare");
|
||||
else if (ch == "\"" || ch == "'") {
|
||||
state.tokenize = tokenString(ch);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
else if (ch == "#") {
|
||||
stream.eatWhile(/[\w\\\-]/);
|
||||
return ret("atom", "hash");
|
||||
}
|
||||
else if (ch == "!") {
|
||||
stream.match(/^\s*\w*/);
|
||||
return ret("keyword", "important");
|
||||
}
|
||||
else if (/\d/.test(ch)) {
|
||||
stream.eatWhile(/[\w.%]/);
|
||||
return ret("number", "unit");
|
||||
}
|
||||
else if (/[,.+>*\/]/.test(ch)) {
|
||||
return ret(null, "select-op");
|
||||
}
|
||||
else if (/[;{}:\[\]]/.test(ch)) {
|
||||
return ret(null, ch);
|
||||
}
|
||||
else {
|
||||
stream.eatWhile(/[\w\\\-]/);
|
||||
return ret("variable", "variable");
|
||||
}
|
||||
}
|
||||
|
||||
function tokenCComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (maybeEnd && ch == "/") {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return ret("comment", "comment");
|
||||
}
|
||||
|
||||
function tokenSGMLComment(stream, state) {
|
||||
var dashes = 0, ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (dashes >= 2 && ch == ">") {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
dashes = (ch == "-") ? dashes + 1 : 0;
|
||||
}
|
||||
return ret("comment", "comment");
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var escaped = false, ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (ch == quote && !escaped)
|
||||
break;
|
||||
escaped = !escaped && ch == "\\";
|
||||
}
|
||||
if (!escaped) state.tokenize = tokenBase;
|
||||
return ret("string", "string");
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function(base) {
|
||||
return {tokenize: tokenBase,
|
||||
baseIndent: base || 0,
|
||||
stack: []};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (stream.eatSpace()) return null;
|
||||
var style = state.tokenize(stream, state);
|
||||
|
||||
var context = state.stack[state.stack.length-1];
|
||||
if (type == "hash" && context != "rule") style = "string-2";
|
||||
else if (style == "variable") {
|
||||
if (context == "rule") style = "number";
|
||||
else if (!context || context == "@media{") style = "tag";
|
||||
}
|
||||
|
||||
if (context == "rule" && /^[\{\};]$/.test(type))
|
||||
state.stack.pop();
|
||||
if (type == "{") {
|
||||
if (context == "@media") state.stack[state.stack.length-1] = "@media{";
|
||||
else state.stack.push("{");
|
||||
}
|
||||
else if (type == "}") state.stack.pop();
|
||||
else if (type == "@media") state.stack.push("@media");
|
||||
else if (context == "{" && type != "comment") state.stack.push("rule");
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
var n = state.stack.length;
|
||||
if (/^\}/.test(textAfter))
|
||||
n -= state.stack[state.stack.length-1] == "rule" ? 2 : 1;
|
||||
return state.baseIndent + n * indentUnit;
|
||||
},
|
||||
|
||||
electricChars: "}"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/css", "css");
|
||||
@@ -1,55 +0,0 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CodeMirror: CSS mode</title>
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="css.js"></script>
|
||||
<style>.CodeMirror {background: #f8f8f8;}</style>
|
||||
<link rel="stylesheet" href="../../doc/docs.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>CodeMirror: CSS mode</h1>
|
||||
<form><textarea id="code" name="code">
|
||||
/* Some example CSS */
|
||||
|
||||
@import url("something.css");
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 3em 6em;
|
||||
font-family: tahoma, arial, sans-serif;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#navigation a {
|
||||
font-weight: bold;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2.5em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.7em;
|
||||
}
|
||||
|
||||
h1:before, h2:before {
|
||||
content: "::";
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: courier, monospace;
|
||||
font-size: 80%;
|
||||
color: #418A8A;
|
||||
}
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/css</code>.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,77 +0,0 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CodeMirror: JavaScript mode</title>
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="javascript.js"></script>
|
||||
<link rel="stylesheet" href="../../doc/docs.css">
|
||||
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>CodeMirror: JavaScript mode</h1>
|
||||
|
||||
<div><textarea id="code" name="code">
|
||||
// Demo code (the actual new parser character stream implementation)
|
||||
|
||||
function StringStream(string) {
|
||||
this.pos = 0;
|
||||
this.string = string;
|
||||
}
|
||||
|
||||
StringStream.prototype = {
|
||||
done: function() {return this.pos >= this.string.length;},
|
||||
peek: function() {return this.string.charAt(this.pos);},
|
||||
next: function() {
|
||||
if (this.pos < this.string.length)
|
||||
return this.string.charAt(this.pos++);
|
||||
},
|
||||
eat: function(match) {
|
||||
var ch = this.string.charAt(this.pos);
|
||||
if (typeof match == "string") var ok = ch == match;
|
||||
else var ok = ch && match.test ? match.test(ch) : match(ch);
|
||||
if (ok) {this.pos++; return ch;}
|
||||
},
|
||||
eatWhile: function(match) {
|
||||
var start = this.pos;
|
||||
while (this.eat(match));
|
||||
if (this.pos > start) return this.string.slice(start, this.pos);
|
||||
},
|
||||
backUp: function(n) {this.pos -= n;},
|
||||
column: function() {return this.pos;},
|
||||
eatSpace: function() {
|
||||
var start = this.pos;
|
||||
while (/\s/.test(this.string.charAt(this.pos))) this.pos++;
|
||||
return this.pos - start;
|
||||
},
|
||||
match: function(pattern, consume, caseInsensitive) {
|
||||
if (typeof pattern == "string") {
|
||||
function cased(str) {return caseInsensitive ? str.toLowerCase() : str;}
|
||||
if (cased(this.string).indexOf(cased(pattern), this.pos) == this.pos) {
|
||||
if (consume !== false) this.pos += str.length;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
var match = this.string.slice(this.pos).match(pattern);
|
||||
if (match && consume !== false) this.pos += match[0].length;
|
||||
return match;
|
||||
}
|
||||
}
|
||||
};
|
||||
</textarea></div>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>JavaScript mode supports a single configuration
|
||||
option, <code>json</code>, which will set the mode to expect JSON
|
||||
data rather than a JavaScript program.</p>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/javascript</code>, <code>application/json</code>.</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,361 +0,0 @@
|
||||
CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
var indentUnit = config.indentUnit;
|
||||
var jsonMode = parserConfig.json;
|
||||
|
||||
// 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"};
|
||||
return {
|
||||
"if": A, "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
|
||||
};
|
||||
}();
|
||||
|
||||
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)) {
|
||||
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.reAllowed) {
|
||||
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.kwAllowed) ? 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};
|
||||
|
||||
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) {
|
||||
var state = cx.state;
|
||||
if (state.context) {
|
||||
cx.marked = "def";
|
||||
for (var v = state.localVars; v; v = v.next)
|
||||
if (v.name == varname) return;
|
||||
state.localVars = {name: varname, next: state.localVars};
|
||||
}
|
||||
}
|
||||
|
||||
// Combinators
|
||||
|
||||
var defaultVars = {name: "this", next: {name: "arguments"}};
|
||||
function pushcontext() {
|
||||
if (!cx.state.context) cx.state.localVars = defaultVars;
|
||||
cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};
|
||||
}
|
||||
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;
|
||||
state.lexical = new JSLexical(state.indented, 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 expecting(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 == "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) {
|
||||
if (atomicTypes.hasOwnProperty(type)) return cont(maybeoperator);
|
||||
if (type == "function") return cont(functiondef);
|
||||
if (type == "keyword c") return cont(maybeexpression);
|
||||
if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeoperator);
|
||||
if (type == "operator") return cont(expression);
|
||||
if (type == "[") return cont(pushlex("]"), commasep(expression, "]"), poplex, maybeoperator);
|
||||
if (type == "{") return cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator);
|
||||
return cont();
|
||||
}
|
||||
function maybeexpression(type) {
|
||||
if (type.match(/[;\}\)\],]/)) return pass();
|
||||
return pass(expression);
|
||||
}
|
||||
|
||||
function maybeoperator(type, value) {
|
||||
if (type == "operator" && /\+\+|--/.test(value)) return cont(maybeoperator);
|
||||
if (type == "operator" || type == ":") return cont(expression);
|
||||
if (type == ";") return;
|
||||
if (type == "(") return cont(pushlex(")"), commasep(expression, ")"), poplex, maybeoperator);
|
||||
if (type == ".") return cont(property, maybeoperator);
|
||||
if (type == "[") return cont(pushlex("]"), expression, expect("]"), poplex, maybeoperator);
|
||||
}
|
||||
function maybelabel(type) {
|
||||
if (type == ":") return cont(poplex, statement);
|
||||
return pass(maybeoperator, expect(";"), poplex);
|
||||
}
|
||||
function property(type) {
|
||||
if (type == "variable") {cx.marked = "property"; return cont();}
|
||||
}
|
||||
function objprop(type) {
|
||||
if (type == "variable") cx.marked = "property";
|
||||
if (atomicTypes.hasOwnProperty(type)) return cont(expect(":"), expression);
|
||||
}
|
||||
function commasep(what, end) {
|
||||
function proceed(type) {
|
||||
if (type == ",") return cont(what, proceed);
|
||||
if (type == end) return cont();
|
||||
return cont(expect(end));
|
||||
}
|
||||
return function commaSeparated(type) {
|
||||
if (type == end) return cont();
|
||||
else return pass(what, proceed);
|
||||
};
|
||||
}
|
||||
function block(type) {
|
||||
if (type == "}") return cont();
|
||||
return pass(statement, block);
|
||||
}
|
||||
function vardef1(type, value) {
|
||||
if (type == "variable"){register(value); return cont(vardef2);}
|
||||
return cont();
|
||||
}
|
||||
function vardef2(type, value) {
|
||||
if (value == "=") return cont(expression, vardef2);
|
||||
if (type == ",") return cont(vardef1);
|
||||
}
|
||||
function forspec1(type) {
|
||||
if (type == "var") return cont(vardef1, forspec2);
|
||||
if (type == ";") return pass(forspec2);
|
||||
if (type == "variable") return cont(formaybein);
|
||||
return pass(forspec2);
|
||||
}
|
||||
function formaybein(type, value) {
|
||||
if (value == "in") return cont(expression);
|
||||
return cont(maybeoperator, forspec2);
|
||||
}
|
||||
function forspec2(type, value) {
|
||||
if (type == ";") return cont(forspec3);
|
||||
if (value == "in") return cont(expression);
|
||||
return cont(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 cont();}
|
||||
}
|
||||
|
||||
// Interface
|
||||
|
||||
return {
|
||||
startState: function(basecolumn) {
|
||||
return {
|
||||
tokenize: jsTokenBase,
|
||||
reAllowed: true,
|
||||
kwAllowed: true,
|
||||
cc: [],
|
||||
lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
|
||||
localVars: parserConfig.localVars,
|
||||
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 (stream.eatSpace()) return null;
|
||||
var style = state.tokenize(stream, state);
|
||||
if (type == "comment") return style;
|
||||
state.reAllowed = !!(type == "operator" || type == "keyword c" || type.match(/^[\[{}\(,;:]$/));
|
||||
state.kwAllowed = type != '.';
|
||||
return parseJS(state, style, type, content, stream);
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize != jsTokenBase) return 0;
|
||||
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
|
||||
if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
|
||||
var type = lexical.type, closing = firstChar == type;
|
||||
if (type == "vardef") return lexical.indented + 4;
|
||||
else if (type == "form" && firstChar == "{") return lexical.indented;
|
||||
else if (type == "stat" || type == "form") return lexical.indented + indentUnit;
|
||||
else if (lexical.info == "switch" && !closing)
|
||||
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: ":{}"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/javascript", "javascript");
|
||||
CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
|
||||
@@ -1,48 +0,0 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CodeMirror: PHP mode</title>
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../xml/xml.js"></script>
|
||||
<script src="../javascript/javascript.js"></script>
|
||||
<script src="../css/css.js"></script>
|
||||
<script src="../clike/clike.js"></script>
|
||||
<script src="php.js"></script>
|
||||
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
<link rel="stylesheet" href="../../doc/docs.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>CodeMirror: PHP mode</h1>
|
||||
|
||||
<form><textarea id="code" name="code">
|
||||
<?php
|
||||
function hello($who) {
|
||||
return "Hello " . $who;
|
||||
}
|
||||
?>
|
||||
<p>The program says <?= hello("World") ?>.</p>
|
||||
<script>
|
||||
alert("And here is some JS code"); // also colored
|
||||
</script>
|
||||
</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "application/x-httpd-php",
|
||||
indentUnit: 4,
|
||||
indentWithTabs: true,
|
||||
enterMode: "keep",
|
||||
tabMode: "shift"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>Simple HTML/PHP mode based on
|
||||
the <a href="../clike/">C-like</a> mode. Depends on XML,
|
||||
JavaScript, CSS, and C-like modes.</p>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>application/x-httpd-php</code> (HTML with PHP code), <code>text/x-php</code> (plain, non-wrapped PHP code).</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,150 +0,0 @@
|
||||
(function() {
|
||||
function keywords(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
function heredoc(delim) {
|
||||
return function(stream, state) {
|
||||
if (stream.match(delim)) state.tokenize = null;
|
||||
else stream.skipToEnd();
|
||||
return "string";
|
||||
}
|
||||
}
|
||||
var phpConfig = {
|
||||
name: "clike",
|
||||
keywords: keywords("abstract and array as break case catch class clone const continue declare default " +
|
||||
"do else elseif enddeclare endfor endforeach endif endswitch endwhile extends final " +
|
||||
"for foreach function global goto if implements interface instanceof namespace " +
|
||||
"new or private protected public static switch throw trait try use var while xor " +
|
||||
"die echo empty exit eval include include_once isset list require require_once return " +
|
||||
"print unset __halt_compiler self static parent"),
|
||||
blockKeywords: keywords("catch do else elseif for foreach if switch try while"),
|
||||
atoms: keywords("true false null TRUE FALSE NULL"),
|
||||
multiLineStrings: true,
|
||||
hooks: {
|
||||
"$": function(stream, state) {
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
return "variable-2";
|
||||
},
|
||||
"<": function(stream, state) {
|
||||
if (stream.match(/<</)) {
|
||||
stream.eatWhile(/[\w\.]/);
|
||||
state.tokenize = heredoc(stream.current().slice(3));
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
"#": function(stream, state) {
|
||||
while (!stream.eol() && !stream.match("?>", false)) stream.next();
|
||||
return "comment";
|
||||
},
|
||||
"/": function(stream, state) {
|
||||
if (stream.eat("/")) {
|
||||
while (!stream.eol() && !stream.match("?>", false)) stream.next();
|
||||
return "comment";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CodeMirror.defineMode("php", function(config, parserConfig) {
|
||||
var htmlMode = CodeMirror.getMode(config, {name: "xml", htmlMode: true});
|
||||
var jsMode = CodeMirror.getMode(config, "javascript");
|
||||
var cssMode = CodeMirror.getMode(config, "css");
|
||||
var phpMode = CodeMirror.getMode(config, phpConfig);
|
||||
|
||||
function dispatch(stream, state) { // TODO open PHP inside text/css
|
||||
var isPHP = state.mode == "php";
|
||||
if (stream.sol() && state.pending != '"') state.pending = null;
|
||||
if (state.curMode == htmlMode) {
|
||||
if (stream.match(/^<\?\w*/)) {
|
||||
state.curMode = phpMode;
|
||||
state.curState = state.php;
|
||||
state.curClose = "?>";
|
||||
state.mode = "php";
|
||||
return "meta";
|
||||
}
|
||||
if (state.pending == '"') {
|
||||
while (!stream.eol() && stream.next() != '"') {}
|
||||
var style = "string";
|
||||
} else if (state.pending && stream.pos < state.pending.end) {
|
||||
stream.pos = state.pending.end;
|
||||
var style = state.pending.style;
|
||||
} else {
|
||||
var style = htmlMode.token(stream, state.curState);
|
||||
}
|
||||
state.pending = null;
|
||||
var cur = stream.current(), openPHP = cur.search(/<\?/);
|
||||
if (openPHP != -1) {
|
||||
if (style == "string" && /\"$/.test(cur) && !/\?>/.test(cur)) state.pending = '"';
|
||||
else state.pending = {end: stream.pos, style: style};
|
||||
stream.backUp(cur.length - openPHP);
|
||||
} else if (style == "tag" && stream.current() == ">" && state.curState.context) {
|
||||
if (/^script$/i.test(state.curState.context.tagName)) {
|
||||
state.curMode = jsMode;
|
||||
state.curState = jsMode.startState(htmlMode.indent(state.curState, ""));
|
||||
state.curClose = /^<\/\s*script\s*>/i;
|
||||
state.mode = "javascript";
|
||||
}
|
||||
else if (/^style$/i.test(state.curState.context.tagName)) {
|
||||
state.curMode = cssMode;
|
||||
state.curState = cssMode.startState(htmlMode.indent(state.curState, ""));
|
||||
state.curClose = /^<\/\s*style\s*>/i;
|
||||
state.mode = "css";
|
||||
}
|
||||
}
|
||||
return style;
|
||||
} else if ((!isPHP || state.php.tokenize == null) &&
|
||||
stream.match(state.curClose, isPHP)) {
|
||||
state.curMode = htmlMode;
|
||||
state.curState = state.html;
|
||||
state.curClose = null;
|
||||
state.mode = "html";
|
||||
if (isPHP) return "meta";
|
||||
else return dispatch(stream, state);
|
||||
} else {
|
||||
return state.curMode.token(stream, state.curState);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
var html = htmlMode.startState();
|
||||
return {html: html,
|
||||
php: phpMode.startState(),
|
||||
curMode: parserConfig.startOpen ? phpMode : htmlMode,
|
||||
curState: parserConfig.startOpen ? phpMode.startState() : html,
|
||||
curClose: parserConfig.startOpen ? /^\?>/ : null,
|
||||
mode: parserConfig.startOpen ? "php" : "html",
|
||||
pending: null}
|
||||
},
|
||||
|
||||
copyState: function(state) {
|
||||
var html = state.html, htmlNew = CodeMirror.copyState(htmlMode, html),
|
||||
php = state.php, phpNew = CodeMirror.copyState(phpMode, php), cur;
|
||||
if (state.curState == html) cur = htmlNew;
|
||||
else if (state.curState == php) cur = phpNew;
|
||||
else cur = CodeMirror.copyState(state.curMode, state.curState);
|
||||
return {html: htmlNew, php: phpNew, curMode: state.curMode, curState: cur,
|
||||
curClose: state.curClose, mode: state.mode,
|
||||
pending: state.pending};
|
||||
},
|
||||
|
||||
token: dispatch,
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if ((state.curMode != phpMode && /^\s*<\//.test(textAfter)) ||
|
||||
(state.curMode == phpMode && /^\?>/.test(textAfter)))
|
||||
return htmlMode.indent(state.html, textAfter);
|
||||
return state.curMode.indent(state.curState, textAfter);
|
||||
},
|
||||
|
||||
electricChars: "/{}:"
|
||||
}
|
||||
}, "xml", "clike", "javascript", "css");
|
||||
CodeMirror.defineMIME("application/x-httpd-php", "php");
|
||||
CodeMirror.defineMIME("application/x-httpd-php-open", {name: "php", startOpen: true});
|
||||
CodeMirror.defineMIME("text/x-php", phpConfig);
|
||||
})();
|
||||
@@ -1,24 +0,0 @@
|
||||
Copyright (c) 2011, Ubalo, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Ubalo, Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL UBALO, INC BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -1,171 +0,0 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CodeMirror: Ruby mode</title>
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="ruby.js"></script>
|
||||
<style>
|
||||
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
|
||||
.cm-s-default span.cm-arrow { color: red; }
|
||||
</style>
|
||||
<link rel="stylesheet" href="../../doc/docs.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>CodeMirror: Ruby mode</h1>
|
||||
<form><textarea id="code" name="code">
|
||||
# Code from http://sandbox.mc.edu/~bennet/ruby/code/poly_rb.html
|
||||
#
|
||||
# This program evaluates polynomials. It first asks for the coefficients
|
||||
# of a polynomial, which must be entered on one line, highest-order first.
|
||||
# It then requests values of x and will compute the value of the poly for
|
||||
# each x. It will repeatly ask for x values, unless you the user enters
|
||||
# a blank line. It that case, it will ask for another polynomial. If the
|
||||
# user types quit for either input, the program immediately exits.
|
||||
#
|
||||
|
||||
#
|
||||
# Function to evaluate a polynomial at x. The polynomial is given
|
||||
# as a list of coefficients, from the greatest to the least.
|
||||
def polyval(x, coef)
|
||||
sum = 0
|
||||
coef = coef.clone # Don't want to destroy the original
|
||||
while true
|
||||
sum += coef.shift # Add and remove the next coef
|
||||
break if coef.empty? # If no more, done entirely.
|
||||
sum *= x # This happens the right number of times.
|
||||
end
|
||||
return sum
|
||||
end
|
||||
|
||||
#
|
||||
# Function to read a line containing a list of integers and return
|
||||
# them as an array of integers. If the string conversion fails, it
|
||||
# throws TypeError. If the input line is the word 'quit', then it
|
||||
# converts it to an end-of-file exception
|
||||
def readints(prompt)
|
||||
# Read a line
|
||||
print prompt
|
||||
line = readline.chomp
|
||||
raise EOFError.new if line == 'quit' # You can also use a real EOF.
|
||||
|
||||
# Go through each item on the line, converting each one and adding it
|
||||
# to retval.
|
||||
retval = [ ]
|
||||
for str in line.split(/\s+/)
|
||||
if str =~ /^\-?\d+$/
|
||||
retval.push(str.to_i)
|
||||
else
|
||||
raise TypeError.new
|
||||
end
|
||||
end
|
||||
|
||||
return retval
|
||||
end
|
||||
|
||||
#
|
||||
# Take a coeff and an exponent and return the string representation, ignoring
|
||||
# the sign of the coefficient.
|
||||
def term_to_str(coef, exp)
|
||||
ret = ""
|
||||
|
||||
# Show coeff, unless it's 1 or at the right
|
||||
coef = coef.abs
|
||||
ret = coef.to_s unless coef == 1 && exp > 0
|
||||
ret += "x" if exp > 0 # x if exponent not 0
|
||||
ret += "^" + exp.to_s if exp > 1 # ^exponent, if > 1.
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
#
|
||||
# Create a string of the polynomial in sort-of-readable form.
|
||||
def polystr(p)
|
||||
# Get the exponent of first coefficient, plus 1.
|
||||
exp = p.length
|
||||
|
||||
# Assign exponents to each term, making pairs of coeff and exponent,
|
||||
# Then get rid of the zero terms.
|
||||
p = (p.map { |c| exp -= 1; [ c, exp ] }).select { |p| p[0] != 0 }
|
||||
|
||||
# If there's nothing left, it's a zero
|
||||
return "0" if p.empty?
|
||||
|
||||
# *** Now p is a non-empty list of [ coef, exponent ] pairs. ***
|
||||
|
||||
# Convert the first term, preceded by a "-" if it's negative.
|
||||
result = (if p[0][0] < 0 then "-" else "" end) + term_to_str(*p[0])
|
||||
|
||||
# Convert the rest of the terms, in each case adding the appropriate
|
||||
# + or - separating them.
|
||||
for term in p[1...p.length]
|
||||
# Add the separator then the rep. of the term.
|
||||
result += (if term[0] < 0 then " - " else " + " end) +
|
||||
term_to_str(*term)
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
#
|
||||
# Run until some kind of endfile.
|
||||
begin
|
||||
# Repeat until an exception or quit gets us out.
|
||||
while true
|
||||
# Read a poly until it works. An EOF will except out of the
|
||||
# program.
|
||||
print "\n"
|
||||
begin
|
||||
poly = readints("Enter a polynomial coefficients: ")
|
||||
rescue TypeError
|
||||
print "Try again.\n"
|
||||
retry
|
||||
end
|
||||
break if poly.empty?
|
||||
|
||||
# Read and evaluate x values until the user types a blank line.
|
||||
# Again, an EOF will except out of the pgm.
|
||||
while true
|
||||
# Request an integer.
|
||||
print "Enter x value or blank line: "
|
||||
x = readline.chomp
|
||||
break if x == ''
|
||||
raise EOFError.new if x == 'quit'
|
||||
|
||||
# If it looks bad, let's try again.
|
||||
if x !~ /^\-?\d+$/
|
||||
print "That doesn't look like an integer. Please try again.\n"
|
||||
next
|
||||
end
|
||||
|
||||
# Convert to an integer and print the result.
|
||||
x = x.to_i
|
||||
print "p(x) = ", polystr(poly), "\n"
|
||||
print "p(", x, ") = ", polyval(x, poly), "\n"
|
||||
end
|
||||
end
|
||||
rescue EOFError
|
||||
print "\n=== EOF ===\n"
|
||||
rescue Interrupt, SignalException
|
||||
print "\n=== Interrupted ===\n"
|
||||
else
|
||||
print "--- Bye ---\n"
|
||||
end
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
mode: "text/x-ruby",
|
||||
tabMode: "indent",
|
||||
matchBrackets: true,
|
||||
indentUnit: 4
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-ruby</code>.</p>
|
||||
|
||||
<p>Development of the CodeMirror Ruby mode was kindly sponsored
|
||||
by <a href="http://ubalo.com/">Ubalo</a>, who hold
|
||||
the <a href="LICENSE">license</a>.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,200 +0,0 @@
|
||||
CodeMirror.defineMode("ruby", function(config, parserConfig) {
|
||||
function wordObj(words) {
|
||||
var o = {};
|
||||
for (var i = 0, e = words.length; i < e; ++i) o[words[i]] = true;
|
||||
return o;
|
||||
}
|
||||
var keywords = wordObj([
|
||||
"alias", "and", "BEGIN", "begin", "break", "case", "class", "def", "defined?", "do", "else",
|
||||
"elsif", "END", "end", "ensure", "false", "for", "if", "in", "module", "next", "not", "or",
|
||||
"redo", "rescue", "retry", "return", "self", "super", "then", "true", "undef", "unless",
|
||||
"until", "when", "while", "yield", "nil", "raise", "throw", "catch", "fail", "loop", "callcc",
|
||||
"caller", "lambda", "proc", "public", "protected", "private", "require", "load",
|
||||
"require_relative", "extend", "autoload"
|
||||
]);
|
||||
var indentWords = wordObj(["def", "class", "case", "for", "while", "do", "module", "then",
|
||||
"catch", "loop", "proc", "begin"]);
|
||||
var dedentWords = wordObj(["end", "until"]);
|
||||
var matching = {"[": "]", "{": "}", "(": ")"};
|
||||
var curPunc;
|
||||
|
||||
function chain(newtok, stream, state) {
|
||||
state.tokenize.push(newtok);
|
||||
return newtok(stream, state);
|
||||
}
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
curPunc = null;
|
||||
if (stream.sol() && stream.match("=begin") && stream.eol()) {
|
||||
state.tokenize.push(readBlockComment);
|
||||
return "comment";
|
||||
}
|
||||
if (stream.eatSpace()) return null;
|
||||
var ch = stream.next();
|
||||
if (ch == "`" || ch == "'" || ch == '"' ||
|
||||
(ch == "/" && !stream.eol() && stream.peek() != " ")) {
|
||||
return chain(readQuoted(ch, "string", ch == '"' || ch == "`"), stream, state);
|
||||
} else if (ch == "%") {
|
||||
var style, embed = false;
|
||||
if (stream.eat("s")) style = "atom";
|
||||
else if (stream.eat(/[WQ]/)) { style = "string"; embed = true; }
|
||||
else if (stream.eat(/[wxqr]/)) style = "string";
|
||||
var delim = stream.eat(/[^\w\s]/);
|
||||
if (!delim) return "operator";
|
||||
if (matching.propertyIsEnumerable(delim)) delim = matching[delim];
|
||||
return chain(readQuoted(delim, style, embed, true), stream, state);
|
||||
} else if (ch == "#") {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
} else if (ch == "<" && stream.eat("<")) {
|
||||
stream.eat("-");
|
||||
stream.eat(/[\'\"\`]/);
|
||||
var match = stream.match(/^\w+/);
|
||||
stream.eat(/[\'\"\`]/);
|
||||
if (match) return chain(readHereDoc(match[0]), stream, state);
|
||||
return null;
|
||||
} else if (ch == "0") {
|
||||
if (stream.eat("x")) stream.eatWhile(/[\da-fA-F]/);
|
||||
else if (stream.eat("b")) stream.eatWhile(/[01]/);
|
||||
else stream.eatWhile(/[0-7]/);
|
||||
return "number";
|
||||
} else if (/\d/.test(ch)) {
|
||||
stream.match(/^[\d_]*(?:\.[\d_]+)?(?:[eE][+\-]?[\d_]+)?/);
|
||||
return "number";
|
||||
} else if (ch == "?") {
|
||||
while (stream.match(/^\\[CM]-/)) {}
|
||||
if (stream.eat("\\")) stream.eatWhile(/\w/);
|
||||
else stream.next();
|
||||
return "string";
|
||||
} else if (ch == ":") {
|
||||
if (stream.eat("'")) return chain(readQuoted("'", "atom", false), stream, state);
|
||||
if (stream.eat('"')) return chain(readQuoted('"', "atom", true), stream, state);
|
||||
stream.eatWhile(/[\w\?]/);
|
||||
return "atom";
|
||||
} else if (ch == "@") {
|
||||
stream.eat("@");
|
||||
stream.eatWhile(/[\w\?]/);
|
||||
return "variable-2";
|
||||
} else if (ch == "$") {
|
||||
stream.next();
|
||||
stream.eatWhile(/[\w\?]/);
|
||||
return "variable-3";
|
||||
} else if (/\w/.test(ch)) {
|
||||
stream.eatWhile(/[\w\?]/);
|
||||
if (stream.eat(":")) return "atom";
|
||||
return "ident";
|
||||
} else if (ch == "|" && (state.varList || state.lastTok == "{" || state.lastTok == "do")) {
|
||||
curPunc = "|";
|
||||
return null;
|
||||
} else if (/[\(\)\[\]{}\\;]/.test(ch)) {
|
||||
curPunc = ch;
|
||||
return null;
|
||||
} else if (ch == "-" && stream.eat(">")) {
|
||||
return "arrow";
|
||||
} else if (/[=+\-\/*:\.^%<>~|]/.test(ch)) {
|
||||
stream.eatWhile(/[=+\-\/*:\.^%<>~|]/);
|
||||
return "operator";
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function tokenBaseUntilBrace() {
|
||||
var depth = 1;
|
||||
return function(stream, state) {
|
||||
if (stream.peek() == "}") {
|
||||
depth--;
|
||||
if (depth == 0) {
|
||||
state.tokenize.pop();
|
||||
return state.tokenize[state.tokenize.length-1](stream, state);
|
||||
}
|
||||
} else if (stream.peek() == "{") {
|
||||
depth++;
|
||||
}
|
||||
return tokenBase(stream, state);
|
||||
};
|
||||
}
|
||||
function readQuoted(quote, style, embed, unescaped) {
|
||||
return function(stream, state) {
|
||||
var escaped = false, ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (ch == quote && (unescaped || !escaped)) {
|
||||
state.tokenize.pop();
|
||||
break;
|
||||
}
|
||||
if (embed && ch == "#" && !escaped && stream.eat("{")) {
|
||||
state.tokenize.push(tokenBaseUntilBrace(arguments.callee));
|
||||
break;
|
||||
}
|
||||
escaped = !escaped && ch == "\\";
|
||||
}
|
||||
return style;
|
||||
};
|
||||
}
|
||||
function readHereDoc(phrase) {
|
||||
return function(stream, state) {
|
||||
if (stream.match(phrase)) state.tokenize.pop();
|
||||
else stream.skipToEnd();
|
||||
return "string";
|
||||
};
|
||||
}
|
||||
function readBlockComment(stream, state) {
|
||||
if (stream.sol() && stream.match("=end") && stream.eol())
|
||||
state.tokenize.pop();
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
return {tokenize: [tokenBase],
|
||||
indented: 0,
|
||||
context: {type: "top", indented: -config.indentUnit},
|
||||
continuedLine: false,
|
||||
lastTok: null,
|
||||
varList: false};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (stream.sol()) state.indented = stream.indentation();
|
||||
var style = state.tokenize[state.tokenize.length-1](stream, state), kwtype;
|
||||
if (style == "ident") {
|
||||
var word = stream.current();
|
||||
style = keywords.propertyIsEnumerable(stream.current()) ? "keyword"
|
||||
: /^[A-Z]/.test(word) ? "tag"
|
||||
: (state.lastTok == "def" || state.lastTok == "class" || state.varList) ? "def"
|
||||
: "variable";
|
||||
if (indentWords.propertyIsEnumerable(word)) kwtype = "indent";
|
||||
else if (dedentWords.propertyIsEnumerable(word)) kwtype = "dedent";
|
||||
else if ((word == "if" || word == "unless") && stream.column() == stream.indentation())
|
||||
kwtype = "indent";
|
||||
}
|
||||
if (curPunc || (style && style != "comment")) state.lastTok = word || curPunc || style;
|
||||
if (curPunc == "|") state.varList = !state.varList;
|
||||
|
||||
if (kwtype == "indent" || /[\(\[\{]/.test(curPunc))
|
||||
state.context = {prev: state.context, type: curPunc || style, indented: state.indented};
|
||||
else if ((kwtype == "dedent" || /[\)\]\}]/.test(curPunc)) && state.context.prev)
|
||||
state.context = state.context.prev;
|
||||
|
||||
if (stream.eol())
|
||||
state.continuedLine = (curPunc == "\\" || style == "operator");
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize[state.tokenize.length-1] != tokenBase) return 0;
|
||||
var firstChar = textAfter && textAfter.charAt(0);
|
||||
var ct = state.context;
|
||||
var closing = ct.type == matching[firstChar] ||
|
||||
ct.type == "keyword" && /^(?:end|until|else|elsif|when|rescue)\b/.test(textAfter);
|
||||
return ct.indented + (closing ? 0 : config.indentUnit) +
|
||||
(state.continuedLine ? config.indentUnit : 0);
|
||||
},
|
||||
electricChars: "}de" // enD and rescuE
|
||||
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-ruby", "ruby");
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CodeMirror: XML mode</title>
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="xml.js"></script>
|
||||
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
<link rel="stylesheet" href="../../doc/docs.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>CodeMirror: XML mode</h1>
|
||||
<form><textarea id="code" name="code">
|
||||
<html style="color: green">
|
||||
<!-- this is a comment -->
|
||||
<head>
|
||||
<title>HTML Example</title>
|
||||
</head>
|
||||
<body>
|
||||
The indentation tries to be <em>somewhat &quot;do what
|
||||
I mean&quot;</em>... but might not match your style.
|
||||
</body>
|
||||
</html>
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
mode: {name: "xml", alignCDATA: true},
|
||||
lineNumbers: true
|
||||
});
|
||||
</script>
|
||||
<p>The XML mode supports two configuration parameters:</p>
|
||||
<dl>
|
||||
<dt><code>htmlMode (boolean)</code></dt>
|
||||
<dd>This switches the mode to parse HTML instead of XML. This
|
||||
means attributes do not have to be quoted, and some elements
|
||||
(such as <code>br</code>) do not require a closing tag.</dd>
|
||||
<dt><code>alignCDATA (boolean)</code></dt>
|
||||
<dd>Setting this to true will force the opening tag of CDATA
|
||||
blocks to not be indented.</dd>
|
||||
</dl>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>application/xml</code>, <code>text/html</code>.</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,325 +0,0 @@
|
||||
CodeMirror.defineMode("xml", function(config, parserConfig) {
|
||||
var indentUnit = config.indentUnit;
|
||||
var Kludges = parserConfig.htmlMode ? {
|
||||
autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
|
||||
'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
|
||||
'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
|
||||
'track': true, 'wbr': true},
|
||||
implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
|
||||
'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
|
||||
'th': true, 'tr': true},
|
||||
contextGrabbers: {
|
||||
'dd': {'dd': true, 'dt': true},
|
||||
'dt': {'dd': true, 'dt': true},
|
||||
'li': {'li': true},
|
||||
'option': {'option': true, 'optgroup': true},
|
||||
'optgroup': {'optgroup': true},
|
||||
'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
|
||||
'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
|
||||
'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
|
||||
'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
|
||||
'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
|
||||
'rp': {'rp': true, 'rt': true},
|
||||
'rt': {'rp': true, 'rt': true},
|
||||
'tbody': {'tbody': true, 'tfoot': true},
|
||||
'td': {'td': true, 'th': true},
|
||||
'tfoot': {'tbody': true},
|
||||
'th': {'td': true, 'th': true},
|
||||
'thead': {'tbody': true, 'tfoot': true},
|
||||
'tr': {'tr': true}
|
||||
},
|
||||
doNotIndent: {"pre": true},
|
||||
allowUnquoted: true,
|
||||
allowMissing: false
|
||||
} : {
|
||||
autoSelfClosers: {},
|
||||
implicitlyClosed: {},
|
||||
contextGrabbers: {},
|
||||
doNotIndent: {},
|
||||
allowUnquoted: false,
|
||||
allowMissing: false
|
||||
};
|
||||
var alignCDATA = parserConfig.alignCDATA;
|
||||
|
||||
// Return variables for tokenizers
|
||||
var tagName, type;
|
||||
|
||||
function inText(stream, state) {
|
||||
function chain(parser) {
|
||||
state.tokenize = parser;
|
||||
return parser(stream, state);
|
||||
}
|
||||
|
||||
var ch = stream.next();
|
||||
if (ch == "<") {
|
||||
if (stream.eat("!")) {
|
||||
if (stream.eat("[")) {
|
||||
if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
|
||||
else return null;
|
||||
}
|
||||
else if (stream.match("--")) return chain(inBlock("comment", "-->"));
|
||||
else if (stream.match("DOCTYPE", true, true)) {
|
||||
stream.eatWhile(/[\w\._\-]/);
|
||||
return chain(doctype(1));
|
||||
}
|
||||
else return null;
|
||||
}
|
||||
else if (stream.eat("?")) {
|
||||
stream.eatWhile(/[\w\._\-]/);
|
||||
state.tokenize = inBlock("meta", "?>");
|
||||
return "meta";
|
||||
}
|
||||
else {
|
||||
type = stream.eat("/") ? "closeTag" : "openTag";
|
||||
stream.eatSpace();
|
||||
tagName = "";
|
||||
var c;
|
||||
while ((c = stream.eat(/[^\s\u00a0=<>\"\'\/?]/))) tagName += c;
|
||||
state.tokenize = inTag;
|
||||
return "tag";
|
||||
}
|
||||
}
|
||||
else if (ch == "&") {
|
||||
var ok;
|
||||
if (stream.eat("#")) {
|
||||
if (stream.eat("x")) {
|
||||
ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
|
||||
} else {
|
||||
ok = stream.eatWhile(/[\d]/) && stream.eat(";");
|
||||
}
|
||||
} else {
|
||||
ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
|
||||
}
|
||||
return ok ? "atom" : "error";
|
||||
}
|
||||
else {
|
||||
stream.eatWhile(/[^&<]/);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function inTag(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (ch == ">" || (ch == "/" && stream.eat(">"))) {
|
||||
state.tokenize = inText;
|
||||
type = ch == ">" ? "endTag" : "selfcloseTag";
|
||||
return "tag";
|
||||
}
|
||||
else if (ch == "=") {
|
||||
type = "equals";
|
||||
return null;
|
||||
}
|
||||
else if (/[\'\"]/.test(ch)) {
|
||||
state.tokenize = inAttribute(ch);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
else {
|
||||
stream.eatWhile(/[^\s\u00a0=<>\"\'\/?]/);
|
||||
return "word";
|
||||
}
|
||||
}
|
||||
|
||||
function inAttribute(quote) {
|
||||
return function(stream, state) {
|
||||
while (!stream.eol()) {
|
||||
if (stream.next() == quote) {
|
||||
state.tokenize = inTag;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "string";
|
||||
};
|
||||
}
|
||||
|
||||
function inBlock(style, terminator) {
|
||||
return function(stream, state) {
|
||||
while (!stream.eol()) {
|
||||
if (stream.match(terminator)) {
|
||||
state.tokenize = inText;
|
||||
break;
|
||||
}
|
||||
stream.next();
|
||||
}
|
||||
return style;
|
||||
};
|
||||
}
|
||||
function doctype(depth) {
|
||||
return function(stream, state) {
|
||||
var ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (ch == "<") {
|
||||
state.tokenize = doctype(depth + 1);
|
||||
return state.tokenize(stream, state);
|
||||
} else if (ch == ">") {
|
||||
if (depth == 1) {
|
||||
state.tokenize = inText;
|
||||
break;
|
||||
} else {
|
||||
state.tokenize = doctype(depth - 1);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
return "meta";
|
||||
};
|
||||
}
|
||||
|
||||
var curState, setStyle;
|
||||
function pass() {
|
||||
for (var i = arguments.length - 1; i >= 0; i--) curState.cc.push(arguments[i]);
|
||||
}
|
||||
function cont() {
|
||||
pass.apply(null, arguments);
|
||||
return true;
|
||||
}
|
||||
|
||||
function pushContext(tagName, startOfLine) {
|
||||
var noIndent = Kludges.doNotIndent.hasOwnProperty(tagName) || (curState.context && curState.context.noIndent);
|
||||
curState.context = {
|
||||
prev: curState.context,
|
||||
tagName: tagName,
|
||||
indent: curState.indented,
|
||||
startOfLine: startOfLine,
|
||||
noIndent: noIndent
|
||||
};
|
||||
}
|
||||
function popContext() {
|
||||
if (curState.context) curState.context = curState.context.prev;
|
||||
}
|
||||
|
||||
function element(type) {
|
||||
if (type == "openTag") {
|
||||
curState.tagName = tagName;
|
||||
return cont(attributes, endtag(curState.startOfLine));
|
||||
} else if (type == "closeTag") {
|
||||
var err = false;
|
||||
if (curState.context) {
|
||||
if (curState.context.tagName != tagName) {
|
||||
if (Kludges.implicitlyClosed.hasOwnProperty(curState.context.tagName.toLowerCase())) {
|
||||
popContext();
|
||||
}
|
||||
err = !curState.context || curState.context.tagName != tagName;
|
||||
}
|
||||
} else {
|
||||
err = true;
|
||||
}
|
||||
if (err) setStyle = "error";
|
||||
return cont(endclosetag(err));
|
||||
}
|
||||
return cont();
|
||||
}
|
||||
function endtag(startOfLine) {
|
||||
return function(type) {
|
||||
if (type == "selfcloseTag" ||
|
||||
(type == "endTag" && Kludges.autoSelfClosers.hasOwnProperty(curState.tagName.toLowerCase()))) {
|
||||
maybePopContext(curState.tagName.toLowerCase());
|
||||
return cont();
|
||||
}
|
||||
if (type == "endTag") {
|
||||
maybePopContext(curState.tagName.toLowerCase());
|
||||
pushContext(curState.tagName, startOfLine);
|
||||
return cont();
|
||||
}
|
||||
return cont();
|
||||
};
|
||||
}
|
||||
function endclosetag(err) {
|
||||
return function(type) {
|
||||
if (err) setStyle = "error";
|
||||
if (type == "endTag") { popContext(); return cont(); }
|
||||
setStyle = "error";
|
||||
return cont(arguments.callee);
|
||||
}
|
||||
}
|
||||
function maybePopContext(nextTagName) {
|
||||
var parentTagName;
|
||||
while (true) {
|
||||
if (!curState.context) {
|
||||
return;
|
||||
}
|
||||
parentTagName = curState.context.tagName.toLowerCase();
|
||||
if (!Kludges.contextGrabbers.hasOwnProperty(parentTagName) ||
|
||||
!Kludges.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
|
||||
return;
|
||||
}
|
||||
popContext();
|
||||
}
|
||||
}
|
||||
|
||||
function attributes(type) {
|
||||
if (type == "word") {setStyle = "attribute"; return cont(attribute, attributes);}
|
||||
if (type == "endTag" || type == "selfcloseTag") return pass();
|
||||
setStyle = "error";
|
||||
return cont(attributes);
|
||||
}
|
||||
function attribute(type) {
|
||||
if (type == "equals") return cont(attvalue, attributes);
|
||||
if (!Kludges.allowMissing) setStyle = "error";
|
||||
return (type == "endTag" || type == "selfcloseTag") ? pass() : cont();
|
||||
}
|
||||
function attvalue(type) {
|
||||
if (type == "string") return cont(attvaluemaybe);
|
||||
if (type == "word" && Kludges.allowUnquoted) {setStyle = "string"; return cont();}
|
||||
setStyle = "error";
|
||||
return (type == "endTag" || type == "selfCloseTag") ? pass() : cont();
|
||||
}
|
||||
function attvaluemaybe(type) {
|
||||
if (type == "string") return cont(attvaluemaybe);
|
||||
else return pass();
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
return {tokenize: inText, cc: [], indented: 0, startOfLine: true, tagName: null, context: null};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (stream.sol()) {
|
||||
state.startOfLine = true;
|
||||
state.indented = stream.indentation();
|
||||
}
|
||||
if (stream.eatSpace()) return null;
|
||||
|
||||
setStyle = type = tagName = null;
|
||||
var style = state.tokenize(stream, state);
|
||||
state.type = type;
|
||||
if ((style || type) && style != "comment") {
|
||||
curState = state;
|
||||
while (true) {
|
||||
var comb = state.cc.pop() || element;
|
||||
if (comb(type || style)) break;
|
||||
}
|
||||
}
|
||||
state.startOfLine = false;
|
||||
return setStyle || style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter, fullLine) {
|
||||
var context = state.context;
|
||||
if ((state.tokenize != inTag && state.tokenize != inText) ||
|
||||
context && context.noIndent)
|
||||
return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
|
||||
if (alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
|
||||
if (context && /^<\//.test(textAfter))
|
||||
context = context.prev;
|
||||
while (context && !context.startOfLine)
|
||||
context = context.prev;
|
||||
if (context) return context.indent + indentUnit;
|
||||
else return 0;
|
||||
},
|
||||
|
||||
compareStates: function(a, b) {
|
||||
if (a.indented != b.indented || a.tokenize != b.tokenize) return false;
|
||||
for (var ca = a.context, cb = b.context; ; ca = ca.prev, cb = cb.prev) {
|
||||
if (!ca || !cb) return ca == cb;
|
||||
if (ca.tagName != cb.tagName) return false;
|
||||
}
|
||||
},
|
||||
|
||||
electricChars: "/"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("application/xml", "xml");
|
||||
if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
|
||||
CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
|
||||
1
CodeMirror-2.25/lib/codemirror-compressed.js
Normal file
@@ -43,6 +43,7 @@
|
||||
white-space: pre;
|
||||
word-wrap: normal;
|
||||
line-height: inherit;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.CodeMirror-wrap pre {
|
||||
@@ -63,8 +64,19 @@
|
||||
position: absolute;
|
||||
visibility: hidden;
|
||||
border-left: 1px solid black;
|
||||
border-right:none;
|
||||
width:0;
|
||||
border-right: none;
|
||||
width: 0;
|
||||
}
|
||||
.cm-keymap-fat-cursor pre.CodeMirror-cursor {
|
||||
width: auto;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
background: rgba(0, 200, 0, .4);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#6600c800, endColorstr=#4c00c800);
|
||||
}
|
||||
/* Kludge to turn off filter in ie9+, which also accepts rgba */
|
||||
.cm-keymap-fat-cursor pre.CodeMirror-cursor:not(#nonsense_id) {
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
|
||||
}
|
||||
.CodeMirror pre.CodeMirror-cursor.CodeMirror-overwrite {}
|
||||
.CodeMirror-focused pre.CodeMirror-cursor {
|
||||
@@ -100,7 +112,7 @@ div.CodeMirror-selected { background: #d9d9d9; }
|
||||
.cm-s-default span.cm-bracket {color: #cc7;}
|
||||
.cm-s-default span.cm-tag {color: #170;}
|
||||
.cm-s-default span.cm-attribute {color: #00c;}
|
||||
.cm-s-default span.cm-header {color: #a0a;}
|
||||
.cm-s-default span.cm-header {color: blue;}
|
||||
.cm-s-default span.cm-quote {color: #090;}
|
||||
.cm-s-default span.cm-hr {color: #999;}
|
||||
.cm-s-default span.cm-link {color: #00c;}
|
||||
@@ -1,7 +1,7 @@
|
||||
(function(){
|
||||
function SearchCursor(cm, query, pos, caseFold) {
|
||||
this.atOccurrence = false; this.cm = cm;
|
||||
if (caseFold == null) caseFold = typeof query == "string" && query == query.toLowerCase();
|
||||
if (caseFold == null && typeof query == "string") caseFold = false;
|
||||
|
||||
pos = pos ? cm.clipPos(pos) : {line: 0, ch: 0};
|
||||
this.pos = {from: pos, to: pos};
|
||||
21
CodeMirror-2.25/theme/erlang-dark.css
Normal file
@@ -0,0 +1,21 @@
|
||||
.cm-s-erlang-dark { background: #002240; color: white; }
|
||||
.cm-s-erlang-dark div.CodeMirror-selected { background: #b36539 !important; }
|
||||
.cm-s-erlang-dark .CodeMirror-gutter { background: #002240; border-right: 1px solid #aaa; }
|
||||
.cm-s-erlang-dark .CodeMirror-gutter-text { color: #d0d0d0; }
|
||||
.cm-s-erlang-dark .CodeMirror-cursor { border-left: 1px solid white !important; }
|
||||
|
||||
.cm-s-erlang-dark span.cm-atom { color: #845dc4; }
|
||||
.cm-s-erlang-dark span.cm-attribute { color: #ff80e1; }
|
||||
.cm-s-erlang-dark span.cm-bracket { color: #ff9d00; }
|
||||
.cm-s-erlang-dark span.cm-builtin { color: #eeaaaa; }
|
||||
.cm-s-erlang-dark span.cm-comment { color: #7777ff; }
|
||||
.cm-s-erlang-dark span.cm-def { color: #ee77aa; }
|
||||
.cm-s-erlang-dark span.cm-error { color: #9d1e15; }
|
||||
.cm-s-erlang-dark span.cm-keyword { color: #ffee80; }
|
||||
.cm-s-erlang-dark span.cm-meta { color: #50fefe; }
|
||||
.cm-s-erlang-dark span.cm-number { color: #ffd0d0; }
|
||||
.cm-s-erlang-dark span.cm-operator { color: #dd1111; }
|
||||
.cm-s-erlang-dark span.cm-string { color: #3ad900; }
|
||||
.cm-s-erlang-dark span.cm-tag { color: #9effff; }
|
||||
.cm-s-erlang-dark span.cm-variable { color: #50fe50; }
|
||||
.cm-s-erlang-dark span.cm-variable-2 { color: #ee00ee; }
|
||||
30
LICENSE.md
Normal file
@@ -0,0 +1,30 @@
|
||||
Copyright (C) 2012 Matt Pass
|
||||
Website: mattpass.com
|
||||
Email: matt@mattpass.com
|
||||
Twitter: @mattpass
|
||||
|
||||
#ICEcoder License
|
||||
##Standard Open Source Initiative MIT License
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
```
|
||||
Please note that this LICENSE file covers the ICEcoder shell IDE only and 3rd
|
||||
party code, in subfolders such as CodeMirror and plugins, may contain their
|
||||
own LICENSE files, and may not also be an MIT licence.
|
||||
```
|
||||
76
README.md
@@ -1,27 +1,65 @@
|
||||
ICE coder :: Matt Pass
|
||||
#ICEcoder
|
||||
##Web based IDE for smart web development
|
||||
|
||||
Demo: http://www.mattpass.com/_coder
|
||||
Early version of the web based IDE which allows for creation of websites in the web browser. Uses the brilliant CodeMirror for code highlighting & editing, with a slick IDE wrapped around it to make the whole thing work.
|
||||
|
||||
Early version of the web based IDE which allows for creation of websites in the web browser.
|
||||
###Features you'd expect
|
||||
* Context aware code highlighting
|
||||
* Supports HTML, CSS, LESS, JavaScript, CoffeeScript, PHP & Ruby
|
||||
* Smart tab key system (selected text indents line)
|
||||
* File manager
|
||||
* Find & replace/replace all
|
||||
* Document tabs indicate current doc & changes made
|
||||
* Code folding
|
||||
* Open last files on load
|
||||
* Web based, access from anywhere
|
||||
* Free, open source & customisable
|
||||
|
||||
Uses the brilliant CodeMirror plus some other PHP & JS code to deal with file handling and make the whole thing work. Also has the extra plugin 'Adminer' for DB management.
|
||||
###Cool features you wouldn't expect
|
||||
* Find & replace in current doc, open docs, files & filenames
|
||||
* Found match & current position counter
|
||||
* Indicates content type cursor is on
|
||||
* Account login to keep certain files secure
|
||||
* Restrict files, ban files and restrict by IP
|
||||
* Settings to change functionality & editor theme
|
||||
* Code Assist system
|
||||
* Displays nest position of text cursor, hover to select, click to set cursor
|
||||
* Nest structure OK/broken indicator
|
||||
* Highlight word and press CTRL+I to Google search that
|
||||
* Adds end tags as you type and in a context aware way
|
||||
* Can rename open files (whoaah!)
|
||||
* CTRL+Enter open current webpage in new tab
|
||||
* CTRL+S+Enter opens a sticky tab to show live edits
|
||||
* ESC = Comment/Uncomment line, incl partial lines
|
||||
* Image viewer
|
||||
* Colour preview block on CSS colours, ie red, #ff0000 or RGBA(255,0,0,0.5)
|
||||
* MySQL Database management via Adminer plugin
|
||||
* Backs up files every 10 mins or on click of backup plugin icon
|
||||
|
||||
###Installation
|
||||
|
||||
####Step 1: Clone the repo
|
||||
|
||||
```
|
||||
$ git clone git@github:mattpass/ICEcoder
|
||||
```
|
||||
|
||||
####Step 2: Upload the files (Linux or Windows hosting OK)
|
||||
```
|
||||
Upload to a new sub-dir URL such as yourdomain.com/_coder
|
||||
Set public write permissions on the lib/config.php file
|
||||
```
|
||||
|
||||
####Step 3: Start coding
|
||||
```
|
||||
Visit the sub-dir URL in your browser and enter a password
|
||||
Now you're setup, auto-logged in and ready to code!
|
||||
```
|
||||
|
||||
Suitable for commercial & non-commercial projects, just let me know if it's useful to you and any cool customisations you make to it. I take no responsibility for anything, your usage is all down to you.
|
||||
|
||||
Is fully open source and I'd encourage you to take it, make it your own and customise to your hearts content! :)
|
||||
|
||||
Suitable for commercial & non-commercial projects, just let me know if it's useful to you and any cool customisations you make to it.
|
||||
|
||||
Please feel free to assist with the development of this and maybe in time we can produce a fantastic web based IDE for web devs.
|
||||
|
||||
INSTALLATION
|
||||
|
||||
1.Open /lib/settings.php and adjust variables to suit
|
||||
|
||||
2.Upload all the files to a Linux or Windows host under a new sub-dir URL such as yourdomain.com/_coder. Set public write permissions on the settings.php file
|
||||
|
||||
3.Visit this URL in your browser and set a password
|
||||
|
||||
4.Now you have top level access and can save (CTRL+S), delete (DEL) etc
|
||||
|
||||
Plenty of comments included in the code to assist with understanding.
|
||||
Plenty of comments included in the code to assist with understanding, customising etc.
|
||||
|
||||
Comments, improvements & feedback welcomed!
|
||||
106
editor.php
@@ -1,17 +1,13 @@
|
||||
<?php include("lib/config.php");?>
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html style="margin: 0px">
|
||||
<html style="margin: 0">
|
||||
<head>
|
||||
<title>CodeMirror 2: ICE Coders Editor of Choice</title>
|
||||
<?php include("lib/settings.php");?>
|
||||
<link rel="stylesheet" href="<?php echo $codeMirrorDir; ?>/lib/codemirror.css">
|
||||
<script src="<?php echo $codeMirrorDir; ?>/lib/codemirror.js"></script>
|
||||
<script src="<?php echo $codeMirrorDir; ?>/mode/xml/xml.js"></script>
|
||||
<script src="<?php echo $codeMirrorDir; ?>/mode/javascript/javascript.js"></script>
|
||||
<script src="<?php echo $codeMirrorDir; ?>/mode/css/css.js"></script>
|
||||
<script src="<?php echo $codeMirrorDir; ?>/mode/clike/clike.js"></script>
|
||||
<script src="<?php echo $codeMirrorDir; ?>/mode/php/php.js"></script>
|
||||
<script src="<?php echo $codeMirrorDir; ?>/mode/ruby/ruby.js"></script>
|
||||
<!--codemirror-compressed.js includes codemirror.js plus the mode files for clike, coffeescript, css, javascript, less, php, ruby & xml //-->
|
||||
<script src="<?php echo $codeMirrorDir; ?>/lib/codemirror-compressed.js"></script>
|
||||
<script src="<?php echo $codeMirrorDir; ?>/lib/util/searchcursor.js"></script>
|
||||
<script src="<?php echo $codeMirrorDir; ?>/lib/util/match-highlighter.js"></script>
|
||||
<script src="<?php echo $codeMirrorDir; ?>/lib/util/foldcode.js"></script>
|
||||
@@ -23,40 +19,96 @@ if ($theme=="default") {
|
||||
}
|
||||
?>
|
||||
<style type="text/css">
|
||||
.CodeMirror {position: absolute; width: 0px; background-color: #ffffff}
|
||||
.CodeMirror {position: absolute; width: 0; background-color: #fff; top: 0px; z-index: 1}
|
||||
.CodeMirror-scroll {width: 100px; height: 100px;}
|
||||
.cm-s-visible {display: block; top: 0px}
|
||||
.cm-s-visible {display: block; top: 0}
|
||||
.cm-s-hidden {display: none; top: 4000px}
|
||||
.cm-s-activeLine {background: #002 !important;}
|
||||
// Make sure this next one remains the 5th item, updated with JS
|
||||
.cm-tab:after {position: relative; display: inline-block; width: 0px; left: -1.4em; overflow: visible; color: #aaa; content: "<?php if ($visibleTabs) {?>\21e5<?;};?>";}
|
||||
span.CodeMirror-matchhighlight {background: #555555}
|
||||
.CodeMirror-focused span.CodeMirror-matchhighlight {color: #000000; background: #555555; !important}
|
||||
.cm-s-activeLine {background: #000 !important;}
|
||||
/* Make sure this next one remains the 5th item, updated with JS */
|
||||
.cm-tab:after {position: relative; display: inline-block; width: 0; left: -1.4em; overflow: visible; color: #aaa; content: "<?php if($visibleTabs) {echo '\\21e5';};?>";}
|
||||
span.CodeMirror-matchhighlight {background: #555}
|
||||
.CodeMirror-focused span.CodeMirror-matchhighlight {color: #000; background: #555; !important}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body style="margin: 0px" onKeyDown="return top.ICEcoder.interceptKeys('content', event);" onKeyUp="top.ICEcoder.resetKeys(event);">
|
||||
<body onLoad="top.ICEcoder.updateFileFolderCount()" style="color: #fff; margin: 0" onKeyDown="return top.ICEcoder.interceptKeys('content', event);" onKeyUp="top.ICEcoder.resetKeys(event);">
|
||||
|
||||
<div style="margin: 32px 43px; font-family: arial; font-size: 10px; color: #dddddd">
|
||||
<?php if($_SESSION['userLevel'] == 10) {
|
||||
echo '<div style="float: left; margin-right: 50px">'.PHP_EOL;
|
||||
echo '<h2 style="color: rgba(0,198,255,0.7)">server</h2>'.PHP_EOL;
|
||||
echo '<span style="color:#888">Server name, OS & IP:</span><br>'.PHP_EOL;
|
||||
echo $_SERVER['SERVER_NAME'].' '.$_SERVER['SERVER_SOFTWARE'].' '.$_SERVER['SERVER_ADDR'].'<br><br>'.PHP_EOL;
|
||||
echo '<span style="color:#888">Root:</span><br>'.PHP_EOL;
|
||||
echo $_SERVER['DOCUMENT_ROOT'].'<br><br>'.PHP_EOL;
|
||||
echo '<span style="color:#888">PHP version:</span><br>'.PHP_EOL;
|
||||
echo phpversion().'<br><br>'.PHP_EOL;
|
||||
echo '<span style="color:#888">Date & time:</span><br>'.PHP_EOL;
|
||||
echo '<span id="serverDT"></span><br><br><br>'.PHP_EOL;
|
||||
echo '</div>'.PHP_EOL;
|
||||
|
||||
echo '<div style="float: left">'.PHP_EOL;
|
||||
echo '<h2 style="color: rgba(0,198,255,0.7)">files</h2>'.PHP_EOL;
|
||||
echo '<span style="color:#888">Last 10 files opened:</span><br>'.PHP_EOL;
|
||||
$last10FilesArray = explode(",",$last10Files);
|
||||
for ($i=0;$i<count($last10FilesArray);$i++) {
|
||||
if ($last10Files=="") {
|
||||
echo '[none]<br><br>';
|
||||
} else {
|
||||
echo '<a style="cursor:pointer" onClick="top.ICEcoder.openFile(top.fullPath+\''.str_replace("|","/",$last10FilesArray[$i]).'\')">';
|
||||
echo str_replace("|","/",$last10FilesArray[$i]);
|
||||
echo '</a><br>'.PHP_EOL;
|
||||
if ($i==count($last10FilesArray)-1) {echo '<br>'.PHP_EOL;};
|
||||
}
|
||||
}
|
||||
echo '<span style="color:#888">File & folder count:</span><br>'.PHP_EOL;
|
||||
echo '<div id="fileFolderCounts"></div><br><br><br>'.PHP_EOL;
|
||||
echo '</div>'.PHP_EOL;
|
||||
|
||||
echo '<div style="clear: both">'.PHP_EOL;
|
||||
echo '<h2 style="color: rgba(0,198,255,0.7)">your device</h2>'.PHP_EOL;
|
||||
echo '<span style="color:#888">Browser:</span><br>'.PHP_EOL;
|
||||
echo $_SERVER['HTTP_USER_AGENT'].'<br><br>'.PHP_EOL;
|
||||
echo '<span style="color:#888">Your IP:</span><br>'.PHP_EOL;
|
||||
echo $_SERVER['REMOTE_ADDR'].PHP_EOL;
|
||||
echo '</div>'.PHP_EOL;
|
||||
}; ?>
|
||||
<script>
|
||||
var nDT=<?php echo time()*1000;?>;
|
||||
setInterval(function(){
|
||||
var s=(new Date(nDT+=1e3)+'').split(' '),
|
||||
d=s[2]*1,
|
||||
t=s[4].split(':'),
|
||||
p=t[0]>11?'pm':'am',
|
||||
e=d%20==1|d>30?'st':d%20==2?'nd':d%20==3?'rd':'th';
|
||||
t[0]=--t[0]%12+1;
|
||||
if (document.getElementById('serverDT')) {
|
||||
document.getElementById('serverDT').innerHTML=[s[0],d+e,s[1],s[3],t.join(':')+p].join(' ');
|
||||
}
|
||||
},1000);
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function createNewCMInstance(num) {
|
||||
var fileName = top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1];
|
||||
var codeFold = CodeMirror.newFoldFunction(CodeMirror.tagRangeFinder,'<span style=\"display: inline-block; width: 13px; height: 13px; background-color: #bb0000; color: #ffffff; text-align: center; cursor: pointer\"><span style="position: relative; top: -1px">+</span></span> %N%');
|
||||
var codeFold_JS_PHP_Ruby = CodeMirror.newFoldFunction(CodeMirror.braceRangeFinder,'<span style=\"display: inline-block; width: 13px; height: 13px; background-color: #bb0000; color: #ffffff; text-align: center; cursor: pointer\"><span style="position: relative; top: -1px">+</span></span> %N%');
|
||||
var codeFold = CodeMirror.newFoldFunction(CodeMirror.tagRangeFinder,'<span style=\"display: inline-block; width: 13px; height: 13px; background-color: #b00; color: #fff; text-align: center; cursor: pointer\"><span style="position: relative; top: -1px">+</span></span> %N%');
|
||||
var codeFold_JS_Coffee_PHP_Ruby = CodeMirror.newFoldFunction(CodeMirror.braceRangeFinder,'<span style=\"display: inline-block; width: 13px; height: 13px; background-color: #b00; color: #fff; text-align: center; cursor: pointer\"><span style="position: relative; top: -1px">+</span></span> %N%');
|
||||
|
||||
window['cM'+num] = CodeMirror(document.body, {
|
||||
mode: "application/x-httpd-php",
|
||||
lineNumbers: true,
|
||||
lineWrapping: true,
|
||||
indentUnit: 4,
|
||||
tabSize: 4,
|
||||
indentUnit: top.tabWidth,
|
||||
tabSize: top.tabWidth,
|
||||
indentWithTabs: true,
|
||||
electricChars: false,
|
||||
onCursorActivity: function() {
|
||||
top.ICEcoder.getCaretPosition();
|
||||
top.ICEcoder.updateCharDisplay();
|
||||
window['cM'+top.ICEcoder.cMInstances[top.ICEcoder.selectedTab-1]].setLineClass(top.ICEcoder['cMActiveLine'+top.ICEcoder.selectedTab], null);
|
||||
if(!window['cM'+top.ICEcoder.cMInstances[top.ICEcoder.selectedTab-1]].somethingSelected()) {
|
||||
top.ICEcoder['cMActiveLine'+top.ICEcoder.selectedTab] = window['cM'+top.ICEcoder.cMInstances[top.ICEcoder.selectedTab-1]].setLineClass(window['cM'+top.ICEcoder.cMInstances[top.ICEcoder.selectedTab-1]].getCursor().line, "cm-s-activeLine");
|
||||
window['cM'+num].setLineClass(top.ICEcoder['cMActiveLine'+num], null);
|
||||
if(!window['cM'+num].somethingSelected()) {
|
||||
top.ICEcoder['cMActiveLine'+num] = window['cM'+num].setLineClass(window['cM'+num].getCursor().line, "cm-s-activeLine");
|
||||
}
|
||||
window['cM'+top.ICEcoder.cMInstances[top.ICEcoder.selectedTab-1]].matchHighlight("CodeMirror-matchhighlight");
|
||||
top.ICEcoder.cssColorPreview();
|
||||
@@ -78,7 +130,7 @@ function createNewCMInstance(num) {
|
||||
}
|
||||
},
|
||||
onKeyEvent: function(instance, e) {
|
||||
top.ICEcoder.redoChangedContent(event);
|
||||
top.ICEcoder.redoChangedContent(e);
|
||||
top.ICEcoder.findReplace('find',true,false);
|
||||
top.ICEcoder.getCaretPosition();
|
||||
top.ICEcoder.updateCharDisplay();
|
||||
@@ -94,7 +146,7 @@ function createNewCMInstance(num) {
|
||||
if(top.ICEcoder.tagString.slice(0,1)=="/"||top.ICEcoder.tagString.slice(0,1)=="?") {
|
||||
canDoEndTag=false;
|
||||
}
|
||||
if (!top.ICEcoder.codeAssist||fileName.indexOf(".js")>0||fileName.indexOf(".css")>0) {
|
||||
if (!top.ICEcoder.codeAssist||fileName && (fileName.indexOf(".js")>0||fileName.indexOf(".css")>0||fileName.indexOf(".less")>0)) {
|
||||
canDoEndTag=false;
|
||||
}
|
||||
contentType = top.ICEcoder.caretLocType;
|
||||
@@ -122,7 +174,7 @@ function createNewCMInstance(num) {
|
||||
};
|
||||
lastKeyCode = e.keyCode;
|
||||
},
|
||||
onGutterClick: !fileName || (fileName && fileName.indexOf(".js") == -1 && fileName.indexOf(".php") && fileName.indexOf(".rb") == -1) ? codeFold : codeFold_JS_PHP_Ruby,
|
||||
onGutterClick: !fileName || (fileName && fileName.indexOf(".js") == -1 && fileName.indexOf(".coffee") == -1 && fileName.indexOf(".php") && fileName.indexOf(".rb") == -1) ? codeFold : codeFold_JS_Coffee_PHP_Ruby,
|
||||
extraKeys: {
|
||||
"Tab": function(cm) {CodeMirror.commands[top.tabsIndent ? "defaultTab" : "insertTab"](cm);},
|
||||
"Shift-Tab": "indentLess"
|
||||
@@ -130,7 +182,7 @@ function createNewCMInstance(num) {
|
||||
});
|
||||
|
||||
// Now create the active line for this CodeMirror object
|
||||
top.ICEcoder['cMActiveLine'+top.ICEcoder.selectedTab] = window['cM'+top.ICEcoder.cMInstances[top.ICEcoder.selectedTab-1]].setLineClass(0, "cm-s-activeLine");
|
||||
top.ICEcoder['cMActiveLine'+num] = window['cM'+num].setLineClass(0, "cm-s-activeLine");
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
37
files.php
@@ -53,8 +53,8 @@ function fileManager_dir($directory, $return_link, $first_call=true) {
|
||||
$fileAtts = "";
|
||||
|
||||
if ($serverType=="Linux") {
|
||||
$chmodInfo = substr(sprintf('%o', fileperms($link)), -4);
|
||||
$fileAtts = '<span style="color: #888888; font-size: 8px">'.$chmodInfo.'</span>';
|
||||
$chmodInfo = substr(sprintf('%o', fileperms($link)), -3);
|
||||
$fileAtts = '<span style="color: #888; font-size: 8px" id="|_perms">'.$chmodInfo.'</span>';
|
||||
}
|
||||
$fileManager = "<ul class=\"fileManager\">";
|
||||
$fileManager .= "<li class=\"pft-directory\"><a href=\"#\" onMouseOver=\"top.ICEcoder.overFileFolder('folder','$link')\" onMouseOut=\"top.ICEcoder.overFileFolder('folder','')\" style=\"position: relative; left:-22px\"> <span id=\"|\">/ [ROOT]</span> ".$fileAtts."</a>";
|
||||
@@ -74,6 +74,7 @@ function fileManager_dir($directory, $return_link, $first_call=true) {
|
||||
if( $this_file != "." && $this_file != ".." && $bannedFile == false) {
|
||||
if( is_dir("$directory/$this_file") ) {
|
||||
// Directory
|
||||
$dirCount++;
|
||||
$dirRep = str_replace("\\","/",$directory);
|
||||
$link = str_replace("[link]", "$dirRep/" . urlencode($this_file), $return_link);
|
||||
$link = str_replace("//","/",$link);
|
||||
@@ -87,18 +88,20 @@ function fileManager_dir($directory, $return_link, $first_call=true) {
|
||||
|
||||
$fileAtts = "";
|
||||
if ($serverType=="Linux") {
|
||||
$chmodInfo = substr(sprintf('%o', fileperms($link)), -4);
|
||||
$fileAtts = '<span style="color: #888888; font-size: 8px">'.$chmodInfo.'</span>';
|
||||
$chmodInfo = substr(sprintf('%o', fileperms($link)), -3);
|
||||
$fileAtts = '<span style="color: #888; font-size: 8px" id="'.str_replace("/","|",str_replace($docRoot,"",$link)).'_perms">'.$chmodInfo.'</span>';
|
||||
}
|
||||
if ($_SESSION['userLevel'] == 10 || ($_SESSION['userLevel'] < 10 && $restrictedFile==false)) {
|
||||
$fileManager .= "<li class=\"pft-directory\"><a href=\"#\" onMouseOver=\"top.ICEcoder.overFileFolder('folder','$link')\" onMouseOut=\"top.ICEcoder.overFileFolder('folder','')\" style=\"position: relative; left:-22px\"> <span id=\"".str_replace("/","|",str_replace($docRoot,"",$link))."\">" . htmlspecialchars($this_file) . "</span> ".$fileAtts."</a>";
|
||||
$fileManager .= fileManager_dir("$directory/$this_file", $return_link , false);
|
||||
$fileManager .= "</li>";
|
||||
} else {
|
||||
$fileManager .= "<li class=\"pft-directory\" style=\"cursor: pointer\"><span style=\"position: relative; left:-22px; color: #888888\"> [HIDDEN] ".$fileAtts."</span></li>";
|
||||
$fileManager .= "<li class=\"pft-directory\" style=\"cursor: pointer\"><span style=\"position: relative; left:-22px; color: #888\"> [HIDDEN] ".$fileAtts."</span></li>";
|
||||
}
|
||||
} else {
|
||||
// File
|
||||
$fileCount++;
|
||||
$fileBytes+=filesize($link);
|
||||
// Get extension (prefix 'ext-' to prevent invalid classes from extensions that begin with numbers)
|
||||
$ext = "ext-" . substr($this_file, strrpos($this_file, ".") + 1);
|
||||
$dirRep = str_replace("\\","/",$directory);
|
||||
@@ -114,20 +117,25 @@ function fileManager_dir($directory, $return_link, $first_call=true) {
|
||||
if ($_SESSION['userLevel'] == 10 || ($_SESSION['userLevel'] < 10 && $restrictedFile==false)) {
|
||||
$fileAtts = "";
|
||||
if ($serverType=="Linux") {
|
||||
$chmodInfo = substr(sprintf('%o', fileperms($link)), -4);
|
||||
$fileAtts = '<span style="color: #888888; font-size: 8px">'.$chmodInfo.'</span>';
|
||||
$chmodInfo = substr(sprintf('%o', fileperms($link)), -3);
|
||||
$fileAtts = '<span style="color: #888; font-size: 8px" id="'.str_replace("/","|",str_replace($docRoot,"",$link)).'_perms">'.$chmodInfo.'</span>';
|
||||
}
|
||||
$fileManager .= "<li class=\"pft-file " . strtolower($ext) . "\"><a nohref onMouseOver=\"top.ICEcoder.overFileFolder('file','$link')\" onMouseOut=\"top.ICEcoder.overFileFolder('file','')\" style=\"position: relative; left:-22px; cursor: pointer\"> <span id=\"".str_replace("/","|",str_replace($docRoot,"",$link))."\">" . htmlspecialchars($this_file) . "</span> ".$fileAtts."</a></li>";
|
||||
} else {
|
||||
$fileAtts = "<img src=\"images/file-manager-icons/padlock.png\" style=\"cursor: pointer\" onClick=\"alert('Sorry, you need higher admin level rights to view.')\">";
|
||||
$fileManager .= "<li class=\"pft-file " . strtolower($ext) . "\" style=\"cursor: default\"><span style=\"position: relative; left:-22px; color: #888888\"> [HIDDEN] ".$fileAtts."</span></li>";
|
||||
$fileAtts = "<img src=\"images/padlock.png\" style=\"cursor: pointer\" onClick=\"top.ICEcoder.message('Sorry, you need higher admin level rights to view.')\">";
|
||||
$fileManager .= "<li class=\"pft-file " . strtolower($ext) . "\" style=\"cursor: default\"><span style=\"position: relative; left:-22px; color: #888\"> [HIDDEN] ".$fileAtts."</span></li>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$fileManager .= "</ul>";
|
||||
}
|
||||
return $fileManager;
|
||||
$varOutput = "";
|
||||
if ($dirCount) {$varOutput .= "top.ICEcoder.dirCount+=".$dirCount.";".PHP_EOL;};
|
||||
if ($fileCount) {$varOutput .= "top.ICEcoder.fileCount+=".$fileCount.";".PHP_EOL;};
|
||||
if ($fileBytes) {$varOutput .= "top.ICEcoder.fileBytes+=".$fileBytes.";".PHP_EOL;};
|
||||
// After outputting the fileManager, output the JS vars, but only the first time
|
||||
return $fileManager."<script>if (top.ICEcoder.dirCount==0) {".PHP_EOL.$varOutput."}</script>";
|
||||
}
|
||||
|
||||
// For PHP4 compatibility
|
||||
@@ -146,12 +154,19 @@ function php4_scandir($dir) {
|
||||
<head>
|
||||
<title>ICE Coder File Manager</title>
|
||||
<link rel="stylesheet" type="text/css" href="lib/files.css">
|
||||
|
||||
<script src="lib/coder.js" type="text/javascript"></script>
|
||||
</head>
|
||||
|
||||
<body onLoad="top.ICEcoder.fileManager()" onDblClick="top.ICEcoder.openFile()" onKeyDown="return top.ICEcoder.interceptKeys('files', event);" onKeyUp="top.ICEcoder.resetKeys(event);">
|
||||
<div onClick="top.ICEcoder.refreshFileManager()" class="refresh"><img src="images/file-manager-icons/refresh.png"></div>
|
||||
<div onClick="top.ICEcoder.refreshFileManager()" class="refresh"><img src="images/refresh.png"></div>
|
||||
<script>
|
||||
top.ICEcoder.dirCount = 0;
|
||||
top.ICEcoder.fileCount = 0;
|
||||
top.ICEcoder.fileBytes = 0;
|
||||
</script>
|
||||
<?php
|
||||
|
||||
echo fileManager($_SERVER['DOCUMENT_ROOT'], "[link]");
|
||||
?>
|
||||
|
||||
|
||||
BIN
images/Thumbs.db
BIN
images/blank.gif
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
images/file-manager-icons.png
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 464 B |
|
Before Width: | Height: | Size: 603 B |
|
Before Width: | Height: | Size: 618 B |
|
Before Width: | Height: | Size: 579 B |
|
Before Width: | Height: | Size: 537 B |
|
Before Width: | Height: | Size: 651 B |
|
Before Width: | Height: | Size: 294 B |
|
Before Width: | Height: | Size: 653 B |
|
Before Width: | Height: | Size: 582 B |
|
Before Width: | Height: | Size: 734 B |
|
Before Width: | Height: | Size: 633 B |
|
Before Width: | Height: | Size: 668 B |
|
Before Width: | Height: | Size: 385 B |
|
Before Width: | Height: | Size: 447 B |
|
Before Width: | Height: | Size: 591 B |
|
Before Width: | Height: | Size: 538 B |
|
Before Width: | Height: | Size: 606 B |
|
Before Width: | Height: | Size: 588 B |
|
Before Width: | Height: | Size: 856 B |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 626 B |
|
Before Width: | Height: | Size: 859 B |
|
Before Width: | Height: | Size: 342 B |
|
Before Width: | Height: | Size: 663 B |
|
Before Width: | Height: | Size: 386 B |
BIN
images/full-screen.gif
Normal file
|
After Width: | Height: | Size: 73 B |
BIN
images/ice-coder.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 56 B After Width: | Height: | Size: 56 B |
|
Before Width: | Height: | Size: 377 B After Width: | Height: | Size: 1.2 KiB |
BIN
images/padlock-disabled.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 752 B After Width: | Height: | Size: 752 B |
BIN
images/refresh.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
images/restored-screen.gif
Normal file
|
After Width: | Height: | Size: 65 B |
|
Before Width: | Height: | Size: 551 B After Width: | Height: | Size: 551 B |
51
index.php
@@ -10,12 +10,18 @@ if (!$allowedIP) {
|
||||
header('Location: /');
|
||||
};
|
||||
|
||||
// Test for latest CodeMirror version
|
||||
if ($testcMVersion) {
|
||||
$cMLatestVer = json_encode(file_get_contents("http://codemirror.net/latest-version.txt"));
|
||||
$cMLatestVer = rtrim(ltrim($cMLatestVer,"\""),"\"\\n");
|
||||
if ($cMThisVer<$cMLatestVer) {
|
||||
echo '<script>alert(\'Code Mirror '.$cMLatestVer.' now released\n\nPlease upgrade\');</script>';
|
||||
// Check for updates of ICEcoder & CodeMirror
|
||||
if ($checkUpdates) {
|
||||
$ICEcoderLatestVer = json_encode(file_get_contents("http://icecoder.net/latest-version.txt"));
|
||||
$ICEcoderLatestVer = rtrim(ltrim($ICEcoderLatestVer,"\""),"\"\\n");
|
||||
if (ltrim($versionNo,"v ")<ltrim($ICEcoderLatestVer,"v ")) {
|
||||
echo '<script>top.ICEcoder.message(\'ICEcoder '.$ICEcoderLatestVer.' now released\n\nPlease upgrade\');</script>';
|
||||
} else {
|
||||
$cMLatestVer = json_encode(file_get_contents("http://codemirror.net/latest-version.txt"));
|
||||
$cMLatestVer = rtrim(ltrim($cMLatestVer,"\""),"\"\\n");
|
||||
if ($cMThisVer<$cMLatestVer) {
|
||||
echo '<script>top.ICEcoder.message(\'Code Mirror '.$cMLatestVer.' now released\n\nPlease upgrade\');</script>';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -24,14 +30,14 @@ if ($testcMVersion) {
|
||||
<html>
|
||||
<head>
|
||||
<title>ICE Coder - <?php echo $versionNo;?></title>
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
<link rel="stylesheet" type="text/css" href="lib/coder.css">
|
||||
<script>
|
||||
shortURLStarts = "<?php echo $shortURLStarts;?>";
|
||||
theme = "<?php if ($theme=="default") {echo 'icecoder';} else {echo $theme;};?>";
|
||||
tabsIndent = <?php if ($tabsIndent) {echo 'true';} else {echo 'false';};?>;
|
||||
tabWidth = <?php echo $tabWidth; ?>;
|
||||
<?
|
||||
$docRoot = str_replace("\\","/",$_SERVER['DOCUMENT_ROOT']);
|
||||
if (strrpos($docRoot,"/")==strlen($docRoot)-1) {$docRoot = substr($docRoot,0,strlen($docRoot)-1);};
|
||||
echo 'fullPath = "'.$docRoot.'";'.PHP_EOL;
|
||||
?>
|
||||
window.onbeforeunload = function() {
|
||||
@@ -42,9 +48,9 @@ window.onbeforeunload = function() {
|
||||
}
|
||||
}
|
||||
|
||||
lastOpenFiles = [<?php
|
||||
if ($lastOpenedFiles!="" && $_SESSION['userLevel'] == 10) {
|
||||
$openFilesArray = explode(",",$lastOpenedFiles);
|
||||
previousFiles = [<?php
|
||||
if ($previousFiles!="" && $_SESSION['userLevel'] == 10) {
|
||||
$openFilesArray = explode(",",$previousFiles);
|
||||
for ($i=0;$i<count($openFilesArray);$i++) {
|
||||
echo "'".$openFilesArray[$i]."'";
|
||||
if ($i<count($openFilesArray)-1) {echo ",";};
|
||||
@@ -75,7 +81,7 @@ lastOpenFiles = [<?php
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="fileMenu" class="fileMenu" onMouseOver="ICEcoder.changeFilesW('expand')" onMouseOut="ICEcoder.changeFilesW('contract')">
|
||||
<div id="fileMenu" class="fileMenu" onMouseOver="ICEcoder.changeFilesW('expand')" onMouseOut="ICEcoder.changeFilesW('contract');this.style.display='none'">
|
||||
<span id="folderMenuItems">
|
||||
<a href="javascript:top.ICEcoder.newFile()" onMouseOver="document.getElementById('fileMenu').style.display='inline-block'">New File</a>
|
||||
<a href="javascript:top.ICEcoder.newFolder()" onMouseOver="document.getElementById('fileMenu').style.display='inline-block'">New Folder</a>
|
||||
@@ -85,14 +91,16 @@ lastOpenFiles = [<?php
|
||||
<a href="javascript:top.ICEcoder.renameFile(top.ICEcoder.rightClickedFile)" onMouseOver="document.getElementById('fileMenu').style.display='inline-block'">Rename</a>
|
||||
<a href="javascript:window.open(top.ICEcoder.rightClickedFile.substr((top.ICEcoder.rightClickedFile.indexOf(shortURLStarts)+top.shortURLStarts.length),top.ICEcoder.rightClickedFile.length))" onMouseOver="document.getElementById('fileMenu').style.display='inline-block'">View Webpage</a>
|
||||
</span>
|
||||
<a href="javascript:top.ICEcoder.zipIt(top.ICEcoder.rightClickedFile)" onMouseOver="document.getElementById('fileMenu').style.display='inline-block'">Zip It!</a>
|
||||
<a href="javascript:top.ICEcoder.propertiesScreen(top.ICEcoder.rightClickedFile)" onMouseOver="document.getElementById('fileMenu').style.display='inline-block'">Properties</a>
|
||||
</div>
|
||||
|
||||
<div id="header" class="header" onContextMenu="return false">
|
||||
<div class="plugins" id="pluginsContainer">
|
||||
<?php echo $pluginsDisplay; ?>
|
||||
</div>
|
||||
<div class="version"><?php echo $versionNo;?></div>
|
||||
<img src="images/ice-coder.gif" class="logo" onContextMenu="ICEcoder.settingsScreen('show')">
|
||||
<div class="version"><?php echo $versionNo;?></div><img src="images/full-screen.gif" id="screenMode" class="screenModeIcon" onClick="top.ICEcoder.fullScreenSwitcher()">
|
||||
<img src="images/ice-coder.png" class="logo" onClick="ICEcoder.helpScreen()" onContextMenu="ICEcoder.settingsScreen()">
|
||||
</div>
|
||||
|
||||
<div id="files" class="files" onMouseOver="ICEcoder.changeFilesW('expand')" onMouseOut="ICEcoder.changeFilesW('contract'); top.document.getElementById('fileMenu').style.display='none';">
|
||||
@@ -108,13 +116,13 @@ lastOpenFiles = [<?php
|
||||
<div class="accountOptions">
|
||||
<a nohref title="Save" onClick="ICEcoder.fMIcon('save')"><img src="images/save.png" alt="Save" id="fMSave" style="opacity: 0.3"></a>
|
||||
<a nohref title="Open" onClick="ICEcoder.fMIcon('open')"><img src="images/open.png" alt="Open" id="fMOpen" style="margin-left: 7px; opacity: 0.3"></a>
|
||||
<a nohref title="New File" onClick="ICEcoder.fMIcon('newFile')"><img src="images/new-file.png" alt="New File" id="fMNewFile" style="margin: 8px 0px 0px 10px; opacity: 0.3"></a>
|
||||
<a nohref title="New Folder" onClick="ICEcoder.fMIcon('newFolder')"><img src="images/new-folder.png" alt="New Folder" id="fMNewFolder" style="margin: 9px 0px 0px 5px; opacity: 0.3"></a>
|
||||
<a nohref title="Delete" onClick="ICEcoder.fMIcon('delete')"><img src="images/delete.png" alt="Delete" id="fMDelete" style="margin: 9px 0px 0px 5px; opacity: 0.3"></a>
|
||||
<a nohref title="Rename" onClick="ICEcoder.fMIcon('rename')"><img src="images/rename.png" alt="Rename" id="fMRename" style="margin: 9px 0px 0px 5px; opacity: 0.3"></a>
|
||||
<a nohref title="View" onClick="ICEcoder.fMIcon('view')"><img src="images/view.png" alt="View" id="fMView" style="margin: 9px 0px 0px 5px; opacity: 0.3"></a>
|
||||
<a nohref title="New File" onClick="ICEcoder.fMIcon('newFile')"><img src="images/new-file.png" alt="New File" id="fMNewFile" style="margin: 8px 0 0 10px; opacity: 0.3"></a>
|
||||
<a nohref title="New Folder" onClick="ICEcoder.fMIcon('newFolder')"><img src="images/new-folder.png" alt="New Folder" id="fMNewFolder" style="margin: 9px 0 0 5px; opacity: 0.3"></a>
|
||||
<a nohref title="Delete" onClick="ICEcoder.fMIcon('delete')"><img src="images/delete.png" alt="Delete" id="fMDelete" style="margin: 9px 0 0 5px; opacity: 0.3"></a>
|
||||
<a nohref title="Rename" onClick="ICEcoder.fMIcon('rename')"><img src="images/rename.png" alt="Rename" id="fMRename" style="margin: 9px 0 0 5px; opacity: 0.3"></a>
|
||||
<a nohref title="View" onClick="ICEcoder.fMIcon('view')"><img src="images/view.png" alt="View" id="fMView" style="margin: 9px 0 0 5px; opacity: 0.3"></a>
|
||||
</div>
|
||||
<a nohref style="cursor: pointer" onClick="ICEcoder.lockUnlockNav()"><img src="images/file-manager-icons/padlock.png" id="fmLock" class="lock"></a>
|
||||
<a nohref style="cursor: pointer" onClick="ICEcoder.lockUnlockNav()"><img src="images/padlock.png" id="fmLock" class="lock"></a>
|
||||
</div>
|
||||
<iframe id="filesFrame" class="frame" name="ff" src="files.php" style="opacity: 0" onLoad="this.style.opacity='1'"></iframe>
|
||||
<div class="serverMessage" id="serverMessage"></div>
|
||||
@@ -124,7 +132,7 @@ lastOpenFiles = [<?php
|
||||
<div id="tabsBar" class="tabsBar" onContextMenu="return false">
|
||||
<?php
|
||||
for ($i=1;$i<=10;$i++) {
|
||||
echo '<div id="tab'.$i.'" class="tab" onClick="if(ICEcoder.canSwitchTabs) {ICEcoder.switchTab('.$i.')} else {ICEcoder.canSwitchTabs=true}"></div>';
|
||||
echo '<div id="tab'.$i.'" class="tab" draggable="true" onClick="if(ICEcoder.canSwitchTabs) {ICEcoder.switchTab('.$i.')} else {ICEcoder.canSwitchTabs=true}"></div>';
|
||||
}
|
||||
?><div class="newTab" onClick="ICEcoder.newTab()"><img src="images/nav-new.png"></div>
|
||||
</div>
|
||||
@@ -174,6 +182,7 @@ lastOpenFiles = [<?php
|
||||
</div>
|
||||
|
||||
<script>
|
||||
ICEcoder.initAliases();
|
||||
ICEcoder.setLayout('dontSetEditor');
|
||||
</script>
|
||||
|
||||
|
||||
138
lib/coder.css
@@ -9,31 +9,32 @@ dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td {
|
||||
font-family: arial, verdana, helvetica, sans-serif;
|
||||
border: 0px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
outline: 0px;
|
||||
border: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
outline: 0;
|
||||
font-size: 12px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
body {overflow: hidden;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-o-user-select:none;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-o-user-select:none;
|
||||
user-select: none;
|
||||
background-color: #222;
|
||||
}
|
||||
|
||||
h1 {font-size: 36px; font-weight: normal; color: #888888; margin-bottom: 20px}
|
||||
h2 {font-size: 18px; font-weight: normal; color: #ffffff}
|
||||
h1 {font-size: 36px; font-weight: normal; color: #888; margin-bottom: 20px}
|
||||
h2 {font-size: 18px; font-weight: normal; color: #fff}
|
||||
|
||||
.blackMask {position: fixed; display: table; width: 100%; height: 100%; top: 0px; left: 0px; visibility: hidden; background-color: rgba(0,0,0,0.8); text-align: center; z-index: 100}
|
||||
.blackMask {position: fixed; display: table; width: 100%; height: 100%; top: 0; left: 0; visibility: hidden; background-color: rgba(0,0,0,0.8); text-align: center; z-index: 100}
|
||||
.blackMask .popupVCenter {#position: absolute; display: table-cell; #top: 50%; vertical-align: middle; text-align: center}
|
||||
.popupVCenter .popup {#position: relative; #top: -50%; text-align: center; color: #ffffff; font-size: 10px}
|
||||
.popupVCenter .popup {#position: relative; #top: -50%; text-align: center; color: #fff; font-size: 10px}
|
||||
.whiteGlow {
|
||||
-webkit-box-shadow: 0px 0px 8px 2px rgba(255,255,255,0.6);
|
||||
-moz-box-shadow: 0px 0px 8px 2px rgba(255,255,255,0.6);
|
||||
box-shadow: 0px 0px 8px 2px rgba(255,255,255,0.6);
|
||||
-webkit-box-shadow: 0 0 8px 2px rgba(255,255,255,0.6);
|
||||
-moz-box-shadow: 0 0 8px 2px rgba(255,255,255,0.6);
|
||||
box-shadow: 0 0 8px 2px rgba(255,255,255,0.6);
|
||||
}
|
||||
|
||||
.circleOutside {background-color: rgba(0,0,0,0); border:5px solid rgba(0,183,229,0.9); opacity:.9; border-top:5px solid rgba(0,0,0,0); border-left:5px solid rgba(0,0,0,0); border-radius:50px; box-shadow: 0 0 35px #2187e7;
|
||||
@@ -59,32 +60,33 @@ h2 {font-size: 18px; font-weight: normal; color: #ffffff}
|
||||
100% { -webkit-transform:rotate(-360deg);}
|
||||
}
|
||||
|
||||
.progressBar {top: 0px; left: 0px; width:100%; height:1px; margin:2px 0; background:#2187e7; position:absolute; box-shadow:0px 0px 10px 1px rgba(0,198,255,0.7);
|
||||
.progressBar {top: 0; left: 0; width:100%; height:1px; margin:2px 0; background:#2187e7; position:absolute; box-shadow:0 0 10px 1px rgba(0,198,255,0.7);
|
||||
-moz-animation:fullexpand 10s ease-out; -webkit-animation:fullexpand 10s ease-out;
|
||||
}
|
||||
@-moz-keyframes fullexpand {
|
||||
0% { width:0px;}
|
||||
0% { width:0;}
|
||||
100%{ width:100%;}
|
||||
}
|
||||
@-webkit-keyframes fullexpand {
|
||||
0% { width:0px;}
|
||||
0% { width:0;}
|
||||
100%{ width:100%;}
|
||||
}
|
||||
|
||||
.header {position: absolute; display: inline-block; width: 100%; height: 40px; background-color: #ffffff; text-align: right; z-index: 2}
|
||||
.header {position: absolute; display: inline-block; top: 0; left: 0; width: 100%; height: 40px; background-color: #fff; text-align: right; z-index: 2}
|
||||
.header .plugins {position: absolute; display: inline-block; left: 15px; top: 3px}
|
||||
.header .plugins img {position: relative; display: inline-block; margin-right: 15px}
|
||||
.header .version {position: relative; display: inline-block; margin-top: 25px; font-size: 10px; color: #bbbbbb}
|
||||
.header .logo {position: relative; margin: 5px 10px 0px 5px; cursor: pointer}
|
||||
.header .screenModeIcon {position: absolute; top: 5px; right: 178px; cursor: pointer}
|
||||
.header .version {position: relative; display: inline-block; margin-top: 25px; font-size: 10px; color: #bbb}
|
||||
.header .logo {position: relative; margin: 5px 10px 0 5px; cursor: pointer}
|
||||
|
||||
.files {position: absolute; display: inline-block; height: 100%; width: 250px; background-color: #e0e0e0; background-image: url('../images/files-arrow.gif'); background-repeat: no-repeat; background-position: 100% 50%; overflow: hidden; z-index: 1;
|
||||
-webkit-box-shadow: 0px 0px 10px 4px rgba(0,0,0,0.4);
|
||||
-moz-box-shadow: 0px 0px 10px 4px rgba(0,0,0,0.4);
|
||||
box-shadow: 0px 0px 10px 4px rgba(0,0,0,0.4);
|
||||
.files {position: absolute; display: inline-block; top: 0; left: 0; height: 100%; width: 250px; background-color: #444; background-image: url('../images/files-arrow.gif'); background-repeat: no-repeat; background-position: 100% 50%; overflow: hidden; z-index: 1;
|
||||
-webkit-box-shadow: 0 0 10px 4px rgba(0,0,0,0.4);
|
||||
-moz-box-shadow: 0 0 10px 4px rgba(0,0,0,0.4);
|
||||
box-shadow: 0 0 10px 4px rgba(0,0,0,0.4);
|
||||
}
|
||||
.files .account {display: inline-block; height: 50px; width: 250px; margin-top: 40px; background-color: #888888}
|
||||
.files .account {display: inline-block; height: 50px; width: 250px; margin-top: 40px; background-color: #888}
|
||||
.files .accountLoginContainer {position: absolute; width: 250px; height: 50px; z-index: 1}
|
||||
.files .accountLoginContainer .accountLogin {position: absolute; width: 250px; height: 50px; top: 0px; background-color: #666666;
|
||||
.files .accountLoginContainer .accountLogin {position: absolute; width: 250px; height: 50px; top: 0; background-color: #666;
|
||||
-webkit-transition: top 0.3s;
|
||||
-moz-transition: top 0.3s;
|
||||
-o-transition: top 0.3s;
|
||||
@@ -92,18 +94,18 @@ h2 {font-size: 18px; font-weight: normal; color: #ffffff}
|
||||
}
|
||||
.files .accountOptions {position: relative; height: 31px; width: 200px; margin-left: 15px; margin-top: 8px}
|
||||
.files .accountOptions img {cursor: pointer}
|
||||
.files .accountPassword {position: relative; border: 1px solid #888888; background-color: #999999; height: 18px; width: 140px; margin-left: 14px; margin-top: 15px}
|
||||
.files .accountPassword {position: relative; border: 1px solid #888; background-color: #999; height: 18px; width: 140px; margin-left: 14px; margin-top: 15px}
|
||||
.files input:focus, .findReplace input:focus, .findReplace select:focus, .accountPassword:focus {
|
||||
outline: none;
|
||||
-webkit-box-shadow: 0px 0px 10px 1px rgba(0,198,255,0.7);
|
||||
-moz-box-shadow: 0px 0px 10px 1px rgba(0,198,255,0.7);
|
||||
box-shadow: 0px 0px 10px 1px rgba(0,198,255,0.7);
|
||||
-webkit-box-shadow: 0 0 10px 1px rgba(0,198,255,0.7);
|
||||
-moz-box-shadow: 0 0 10px 1px rgba(0,198,255,0.7);
|
||||
box-shadow: 0 0 10px 1px rgba(0,198,255,0.7);
|
||||
}
|
||||
.files .button {position: absolute; border: 0px; background: #999999; color: #555555; height:20px; margin-top: 16px; margin-left: 5px; font-size: 11px; cursor: pointer}
|
||||
.files .button:hover {background-color: #444444; color: #eeeeee}
|
||||
.files .button {position: absolute; border: 0; background: #999; color: #555; height:20px; margin-top: 16px; margin-left: 5px; font-size: 11px; cursor: pointer}
|
||||
.files .button:hover {background-color: #444; color: #eee}
|
||||
.files .lock {position: relative; margin-left: 225px; margin-top: -20px; z-index: 1}
|
||||
.files .frame {display: inline-block; width: 250px}
|
||||
.files .serverMessage {position: absolute; display: inline-block; width: 180px; bottom: 0px; margin-bottom: 30px; background-color: rgba(255,255,255,0.8); font-size: 10px; padding: 7px 12px; opacity: 0;
|
||||
.files .serverMessage {position: absolute; display: inline-block; width: 450px; bottom: 0; margin-bottom: 30px; background-color: rgba(255,255,255,0.8); font-size: 10px; padding: 7px 12px; opacity: 0;
|
||||
-webkit-transition: all 0.2s;
|
||||
-moz-transition: all 0.2s;
|
||||
-o-transition: all 0.2s;
|
||||
@@ -111,53 +113,53 @@ h2 {font-size: 18px; font-weight: normal; color: #ffffff}
|
||||
}
|
||||
.files .serverMessage b {font-size: 10px}
|
||||
|
||||
.editor {position: absolute; display: inline-block; top: 0px; left: 15px; width: 2400px; background-color: #fbfbfb;}
|
||||
.editor .tabsBar {display: inline-block; height: 21px; width: 2400px; margin-top: 40px; padding-left: 41px; border-bottom: solid 1px #888888; background-color: #eeeeee;}
|
||||
.tabsBar .tab {display: inline-block; display: none; background-image: url('../images/nav-bg.gif'); background-repeat: repeat-x; background-position: 0px 0px; padding: 4px 8px 2px 8px; font-size: 10px; border-left: solid 1px #ffffff; border-right: solid 1px #bbbbbb; color: #ffffff; cursor: pointer;
|
||||
-webkit-transition: all 0.2s;
|
||||
-moz-transition: all 0.2s;
|
||||
-o-transition: all 0.2s;
|
||||
transition: all 0.2s;
|
||||
.editor {position: absolute; display: inline-block; top: 0; left: 15px; width: 2400px}
|
||||
.editor .tabsBar {display: inline-block; height: 22px; width: 2400px; margin-top: 40px; padding-left: 41px; background-color: #888;}
|
||||
.tabsBar .tab {display: inline-block; display: none; background-image: url('../images/nav-bg.gif'); background-repeat: repeat-x; background-position: 0 0; padding: 5px 8px 2px 8px; font-size: 10px; border-left: solid 1px #fff; border-right: solid 1px #777; color: #fff; cursor: pointer;
|
||||
-webkit-transition: all 0.15s;
|
||||
-moz-transition: all 0.15s;
|
||||
-o-transition: all 0.15s;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
.tabsBar .tab img {margin: 1px 0px 0px 5px}
|
||||
.tabsBar .newTab {display: inline-block; background-image: url('../images/nav-bg.gif'); background-repeat: repeat-x; background-position: 0px 0px; padding: 5px 5px 1px 5px; border-left: solid 1px #ffffff; border-right: solid 1px #bbbbbb; cursor: pointer;}
|
||||
.editor .findBar {display: inline-block; height: 28px; width: 2400px; background-color: #eeeeee}
|
||||
.tabsBar .tab .closeTab {margin: 1px 0 0 5px; border-radius: 6px}
|
||||
.tabsBar .newTab {display: inline-block; background-image: url('../images/nav-bg.gif'); background-repeat: repeat-x; background-position: 0 0; padding: 6px 5px 1px 5px; border-left: solid 1px #fff; border-right: solid 1px #777; cursor: pointer;}
|
||||
.editor .findBar {display: inline-block; height: 28px; width: 2400px; color: #fff; background-color: #141414}
|
||||
.findBar .findReplace {position: absolute; z-index: 1}
|
||||
.findReplace select {position: relative; font-size: 10px; margin: 8px 2px 0px 2px; top: -2px;}
|
||||
.findReplace .findText {display: inline-block; height: 21px; font-size: 10px; margin: 8px 2px 0px 2px; margin-left: 43px}
|
||||
.findReplace select {position: relative; font-size: 10px; margin: 8px 2px 0 2px; top: -2px;}
|
||||
.findReplace .findText {display: inline-block; height: 21px; font-size: 10px; margin: 8px 2px 0 2px; margin-left: 43px}
|
||||
.findReplace .find {position: relative; width: 120px; height: 16px; border: 0; top: -2px; font-size: 10px; padding-left: 5px}
|
||||
.findReplace .findTextPlural {display: inline-block; height: 21px; font-size: 10px; margin: 8px 2px 0px 0px}
|
||||
.findReplace .replaceAction {margin: 0px 2px 0px 0px; top: -2px}
|
||||
.findReplace .replaceText {height: 21px; font-size: 10px; margin: 8px 2px 0px 2px}
|
||||
.findReplace .findTextPlural {display: inline-block; height: 21px; font-size: 10px; margin: 8px 2px 0 0}
|
||||
.findReplace .replaceAction {margin: 0 2px 0 0; top: -2px}
|
||||
.findReplace .replaceText {height: 21px; font-size: 10px; margin: 8px 2px 0 2px}
|
||||
.findReplace .replace {position: relative; width: 120px; height: 16px; border: 0; top: -2px; font-size: 10px; padding-left: 5px}
|
||||
.findReplace .targetText {height: 21px; font-size: 10px; margin: 8px 2px 0px 2px}
|
||||
.findReplace .submit {position: relative; top: -2px; height: 17px; border: 1px solid #bbbbbb; background-color: #f8f8f8; font-size: 10px; cursor: pointer}
|
||||
.findReplace .results {position: relative; display: inline-block; width: 200px; height: 20px; font-size: 10px; margin: 8px 0px 0px 20px}
|
||||
.findReplace .targetText {height: 21px; font-size: 10px; margin: 8px 2px 0 2px}
|
||||
.findReplace .submit {position: relative; top: -2px; height: 17px; border: 1px solid #bbb; background-color: #f8f8f8; font-size: 10px; cursor: pointer}
|
||||
.findReplace .results {position: relative; display: inline-block; width: 200px; height: 20px; font-size: 10px; margin: 8px 0 0 20px}
|
||||
.findBar .codeAssist {position: fixed; display: inline-block; width: 100px; right: 74px; top: 70px; height: 21px; font-size: 10px; z-index: 1}
|
||||
.findBar .codeAssist input {margin-top: -1px}
|
||||
.findBar .goLine {position: fixed; display: inline-block; width: 100px; right: -10px; top: 70px; height: 21px; font-size: 10px; z-index: 1}
|
||||
.goLine .goToLine {width: 25px; height: 16px; border: 0; font-size: 10px; margin: -3px 0px 0px 3px}
|
||||
.goLine .goToLine {width: 25px; height: 16px; border: 0; font-size: 10px; margin: -3px 0 0 3px}
|
||||
.editor .code {position: relative; display: inline-block; top: 28px; width: 600px; height: 600px; visibility: hidden}
|
||||
|
||||
.footer {position: fixed; display: inline-block; width: 100%; height: 30px; bottom: 0px; background-color: rgba(0,0,0,0.7); left: 0px; z-index: 2}
|
||||
.footer .nesting {display: inline-block; padding: 5px 8px; margin: 4px 0px 0px 15px; font-weight: bold; font-size: 10px; color: #ffffff; background-color: #00bb00}
|
||||
.footer .nestLoc {position: absolute; display: inline-block; width: 120px; padding: 5px 0px 0px 8px; margin-top: 3px; left: 112px; font-weight: bold; font-size: 12px; color: #ffffff; text-align: right}
|
||||
.footer .nestDisplay {position: absolute; display: inline-block; padding: 5px 0px 0px 8px; margin-top: 3px; left: 255px; font-size: 12px; color: #ffffff; text-align: right}
|
||||
.footer .charDisplay {position: absolute; display: inline-block; padding: 5px 0px 0px 8px; margin-top: 3px; left: 100%; font-weight: bold; font-size: 12px; color: #ffffff; text-align: right; width: 200px; text-align: right; margin-left: -220px}
|
||||
.footer {position: fixed; display: inline-block; width: 100%; height: 30px; bottom: 0; background-color: rgba(0,0,0,0.7); left: 0; z-index: 2}
|
||||
.footer .nesting {display: inline-block; padding: 5px 8px; margin: 4px 0 0 15px; font-weight: bold; font-size: 10px; color: #fff; background-color: #0b0}
|
||||
.footer .nestLoc {position: absolute; display: inline-block; width: 120px; padding: 5px 0 0 8px; margin-top: 3px; left: 112px; font-weight: bold; font-size: 12px; color: #fff; text-align: right}
|
||||
.footer .nestDisplay {position: absolute; display: inline-block; padding: 5px 0 0 8px; margin-top: 3px; left: 255px; font-size: 12px; color: #fff; text-align: right}
|
||||
.footer .charDisplay {position: absolute; display: inline-block; padding: 5px 0 0 8px; margin-top: 3px; left: 100%; font-weight: bold; font-size: 12px; color: #fff; text-align: right; width: 200px; text-align: right; margin-left: -220px}
|
||||
|
||||
.textbox {
|
||||
-webkit-box-shadow: inset 1px 1px 2px 0px rgba(0,0,0,0.4);
|
||||
-moz-box-shadow: inset 1px 1px 2px 0px rgba(0,0,0,0.4);
|
||||
box-shadow: inset 1px 1px 2px 0px rgba(0,0,0,0.4);
|
||||
-webkit-box-shadow: inset 1px 1px 2px 0 rgba(0,0,0,0.4);
|
||||
-moz-box-shadow: inset 1px 1px 2px 0 rgba(0,0,0,0.4);
|
||||
box-shadow: inset 1px 1px 2px 0 rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
.fileMenu {position: absolute; display: none; left: 0px; top: 0px; background-color: #333333; z-index: 10}
|
||||
.fileMenu a {display: block; padding: 2px 5px; background-color: #444444; color: #eeeeee; text-decoration: none}
|
||||
.fileMenu a:hover {background-color: #666666}
|
||||
.fileMenu {position: absolute; display: none; left: 0; top: 0; background-color: #333; z-index: 10}
|
||||
.fileMenu a {display: block; padding: 2px 5px; background-color: #333; color: #eee; text-decoration: none}
|
||||
.fileMenu a:hover {background-color: #666}
|
||||
|
||||
.screenContainer {position: absolute; display: table; width: 100%; height: 100%; top: 0px; left: 0px; text-align: center}
|
||||
.screenContainer {position: absolute; display: table; width: 100%; height: 100%; top: 0; left: 0; text-align: center}
|
||||
.screenContainer .screenVCenter {#position: absolute; display: table-cell; #top: 50%; vertical-align: middle; text-align: center}
|
||||
.screenVCenter .screenCenter {#position: relative; #top: -50%; text-align: center; display: inline}
|
||||
.screenCenter .version {position: relative; display: block; margin: 5px 0px 15px 0px; font-size: 10px; color: #bbbbbb}
|
||||
.screenCenter .accountPassword {border: 1px solid #888888; height: 18px}
|
||||
.screenCenter .button {border: 0px; background: #666666; color: #ffffff; height: 22px; cursor: pointer}
|
||||
.screenCenter .version {position: relative; display: block; margin: 5px 0 15px 0; font-size: 10px; color: #bbb}
|
||||
.screenCenter .accountPassword {border: 1px solid #888; height: 18px}
|
||||
.screenCenter .button {border: 0; background: #666; color: #fff; height: 22px; cursor: pointer}
|
||||
380
lib/coder.js
@@ -1,9 +1,3 @@
|
||||
// ICE coder by Matt Pass
|
||||
// Free to use it for your own purposes, commercial or not, just let me know of any cool uses or customisations. :)
|
||||
// No warranty or liability accepted for anything, all responsibility of use is your own.
|
||||
// Latest version: https://github.com/mattpass/ICEcoder
|
||||
// Twitter: @mattpass
|
||||
|
||||
var ICEcoder = {
|
||||
// Define settings
|
||||
filesW: 250, // Initial width of the files pane
|
||||
@@ -16,6 +10,7 @@ var ICEcoder = {
|
||||
delKeyDown: false, // Indicates if DEL keydown
|
||||
canSwitchTabs: true, // Stops switching of tabs when trying to close
|
||||
openFiles: [], // Array of open file URLs
|
||||
openFileMDTs: [], // Array of open file modification datetimes
|
||||
cMInstances: [], // List of CodeMirror instance no's
|
||||
nextcMInstance: 1, // Next available CodeMirror instance no
|
||||
selectedFiles: [], // Array of selected files
|
||||
@@ -28,19 +23,23 @@ var ICEcoder = {
|
||||
stickyTab: false, // If we have a sticky tab open or not
|
||||
stickyTabWindow: false, // Target variable for the sticky tab window
|
||||
pluginIntervalRefs: [], // Array of plugin interval refs
|
||||
dragSrcEl: null, // Tab element being dragged
|
||||
|
||||
// Don't consider these tags as part of nesting as they're singles, JS, PHP or Ruby code blocks
|
||||
tagNestExceptions: ["!DOCTYPE","meta","link","img","br","hr","input","script","?php","?","%"],
|
||||
|
||||
// On load, set aliases, set the layout and get the nest location
|
||||
init: function(login) {
|
||||
// Set our aliases
|
||||
initAliases: function() {
|
||||
var aliasArray = ["header","files","account","accountLogin","fmLock","filesFrame","editor","tabsBar","findBar","content","footer","nestValid","nestDisplay","charDisplay"];
|
||||
|
||||
// Create our ID aliases
|
||||
for (var i=0;i<aliasArray.length;i++) {
|
||||
ICEcoder[aliasArray[i]] = top.document.getElementById(aliasArray[i]);
|
||||
}
|
||||
},
|
||||
|
||||
// On load, set the layout and get the nest location
|
||||
init: function(login) {
|
||||
// Set layout & the nest location
|
||||
ICEcoder.setLayout();
|
||||
|
||||
@@ -52,6 +51,16 @@ var ICEcoder = {
|
||||
top.document.getElementById('accountLogin').style.top = "-50px";
|
||||
setTimeout(function() {top.document.getElementById('accountLoginContainer').style.display = "none";},300);
|
||||
}
|
||||
|
||||
// Add drag based events to our tabs
|
||||
var tabs = document.querySelectorAll('.tab');
|
||||
[].forEach.call(tabs, function(tab) {
|
||||
// not used: dragenter, dragleave
|
||||
tab.addEventListener('dragstart', ICEcoder.handleDragStart, false);
|
||||
tab.addEventListener('dragover', ICEcoder.handleDragOver, false);
|
||||
tab.addEventListener('drop', ICEcoder.handleDrop, false);
|
||||
tab.addEventListener('dragend', ICEcoder.handleDragEnd, false);
|
||||
});
|
||||
},
|
||||
|
||||
// Set our layout according to the browser size
|
||||
@@ -64,23 +73,29 @@ var ICEcoder = {
|
||||
|
||||
// Apply sizes to various elements of the page
|
||||
headerH = 40, footerH = 30, accountH = 50, tabsBarH = 21, findBarH = 28;
|
||||
header.style.width = tabsBar.style.width = findBar.style.width = winW + "px";
|
||||
files.style.width = accountLogin.style.width = editor.style.left = this.filesW + "px";
|
||||
account.style.height = accountH + "px";
|
||||
fmLock.style.marginLeft = (this.filesW-27) + "px";
|
||||
filesFrame.style.height = (winH-headerH-accountH-footerH) + "px";
|
||||
this.header.style.width = this.tabsBar.style.width = this.findBar.style.width = winW + "px";
|
||||
this.files.style.width = this.accountLogin.style.width = this.editor.style.left = this.filesW + "px";
|
||||
this.account.style.height = this.accountH + "px";
|
||||
this.fmLock.style.marginLeft = (this.filesW-27) + "px";
|
||||
this.filesFrame.style.height = (winH-headerH-accountH-footerH) + "px";
|
||||
|
||||
// If we need to set the editor sizes
|
||||
if (!dontSetEditor) {
|
||||
editor.style.width = ICEcoder.content.style.width = (winW-this.filesW) + "px";
|
||||
this.editor.style.width = ICEcoder.content.style.width = (winW-this.filesW) + "px";
|
||||
ICEcoder.content.style.height = (winH-headerH-footerH-tabsBarH-findBarH) + "px";
|
||||
|
||||
// Resize the CodeMirror instances to match the window size
|
||||
document.all ? strCSS = 'rules' : strCSS = 'cssRules';
|
||||
cMCSS = ICEcoder.content.contentWindow.document;
|
||||
cMCSS.styleSheets[2][strCSS][1].style['width'] = ICEcoder.content.style.width;
|
||||
cMCSS.styleSheets[2][strCSS][1].style['height'] = ICEcoder.content.style.height;
|
||||
cMCSS.styleSheets[2][strCSS][2].style['width'] = ICEcoder.content.style.width;
|
||||
cMCSS = ICEcoder.content.contentWindow.document.styleSheets[2];
|
||||
cMCSS.rules ? strCSS = 'rules' : strCSS = 'cssRules';
|
||||
for(var i=0;i<cMCSS[strCSS].length;i++) {
|
||||
if(cMCSS[strCSS][i].selectorText==".CodeMirror-scroll") {
|
||||
cMCSS[strCSS][i].style['width'] = ICEcoder.content.style.width;
|
||||
cMCSS[strCSS][i].style['height'] = ICEcoder.content.style.height;
|
||||
}
|
||||
if(cMCSS[strCSS][i].selectorText==".cm-s-visible") {
|
||||
cMCSS[strCSS][i].style['width'] = ICEcoder.content.style.width;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -88,9 +103,9 @@ var ICEcoder = {
|
||||
contentCleanUp: function() {
|
||||
var fileName, cM, content;
|
||||
|
||||
// If it's not a JS, Ruby or CSS file, replace & and our temp </textarea> value
|
||||
// If it's not a JS, CoffeeScript Ruby, CSS or LESS file, replace & and our temp </textarea> value
|
||||
fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1];
|
||||
if (fileName.indexOf(".js")<0&&fileName.indexOf(".rb")&&fileName.indexOf(".css")<0) {
|
||||
if (fileName.indexOf(".js")<0 && fileName.indexOf(".coffee")<0 && fileName.indexOf(".rb")<0 && fileName.indexOf(".css")<0 && fileName.indexOf(".less")<0) {
|
||||
cM = ICEcoder.getcMInstance();
|
||||
content = cM.getValue();
|
||||
content = content.replace(/<ICEcoder:\/:textarea>/g,'</textarea>');
|
||||
@@ -181,7 +196,7 @@ var ICEcoder = {
|
||||
ICEcoder.nestDisplay.innerHTML = "";
|
||||
if ("undefined" != typeof ICEcoder.openFiles[ICEcoder.selectedTab-1]) {
|
||||
fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1];
|
||||
if (fileName.indexOf(".js")<0&&fileName.indexOf(".rb")<0&&fileName.indexOf(".css")<0&&
|
||||
if (fileName.indexOf(".js")<0 && fileName.indexOf(".coffee")<0 && fileName.indexOf(".rb")<0 && fileName.indexOf(".css")<0 && fileName.indexOf(".less")<0 &&
|
||||
(nestCheck.indexOf("include(")==-1)&&(nestCheck.indexOf("include_once(")==-1)&&
|
||||
(nestCheck.indexOf("<html")>-1||nestCheck.indexOf("<body")>-1)) {
|
||||
|
||||
@@ -362,17 +377,30 @@ var ICEcoder = {
|
||||
// Redo our find display
|
||||
top.ICEcoder.findMode = false;
|
||||
ICEcoder.findReplace('find',true,false);
|
||||
|
||||
// Finally, update the cursor display
|
||||
top.ICEcoder.getCaretPosition();
|
||||
top.ICEcoder.updateCharDisplay();
|
||||
}
|
||||
},
|
||||
|
||||
// Reset all tabs to be without a highlight and then highlight the selected
|
||||
redoTabHighlight: function(selectedTab) {
|
||||
var bgVPos;
|
||||
var cM, bgVPos, tColor, fileLink;
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
for(var i=1;i<=ICEcoder.changedContent.length;i++) {
|
||||
ICEcoder.changedContent[i-1]==1 ? bgVPos = -44 : bgVPos = 0;
|
||||
i==selectedTab ? ICEcoder.changedContent[selectedTab-1]==1 ? bgVPos = -33 : bgVPos = -22 : bgVPos = bgVPos;
|
||||
document.getElementById('tab'+i).style.backgroundPosition = "0px "+bgVPos+"px";
|
||||
if (document.getElementById('closeTabButton'+i)) {
|
||||
ICEcoder.changedContent[i-1]==1 && cM.historySize().undo>0 ? document.getElementById('closeTabButton'+i).style.backgroundColor = "#b00" : document.getElementById('closeTabButton'+i).style.backgroundColor = "rgba(255,255,255,0.3)";
|
||||
}
|
||||
i==selectedTab ? tColor = "#000" : tColor = "#fff";
|
||||
if ("undefined" != typeof top.ICEcoder.openFiles[i-1] && top.ICEcoder.openFiles[i-1] != "/[NEW]") {
|
||||
fileLink = top.ICEcoder.filesFrame.contentWindow.document.getElementById(top.ICEcoder.openFiles[i-1].replace(/\//g,"|"));
|
||||
i==selectedTab ? fileLink.style.backgroundColor = "#4499dd" : fileLink.style.backgroundColor = "rgba(255,255,255,0.15)";
|
||||
}
|
||||
document.getElementById('tab'+i).style.color = tColor;
|
||||
i==selectedTab ? bgVPos = -22 : bgVPos = 0;
|
||||
document.getElementById('tab'+i).style.backgroundPosition = "0 "+bgVPos+"px";
|
||||
}
|
||||
ICEcoder.changedContent[selectedTab-1]==1 ? top.ICEcoder.fMIconVis('fMSave',1) : top.ICEcoder.fMIconVis('fMSave',0.3);
|
||||
},
|
||||
@@ -391,7 +419,6 @@ var ICEcoder = {
|
||||
|
||||
cM = ICEcoder.getcMInstance('new');
|
||||
ICEcoder.switchTab(ICEcoder.openFiles.length);
|
||||
ICEcoder.content.style.visibility='visible';
|
||||
|
||||
cM.setLineClass(ICEcoder['cMActiveLine'+ICEcoder.selectedTab], null);
|
||||
ICEcoder['cMActiveLine'+ICEcoder.selectedTab] = cM.setLineClass(0, "cm-s-activeLine");
|
||||
@@ -406,7 +433,7 @@ var ICEcoder = {
|
||||
top.ICEcoder.openFiles.push(top.ICEcoder.shortURL);
|
||||
|
||||
// Setup a new tab
|
||||
closeTabLink = '<a nohref onClick="parent.ICEcoder.closeTab('+(top.ICEcoder.openFiles.length)+')"><img src="images/nav-close.gif"></a>';
|
||||
closeTabLink = '<a nohref onClick="top.ICEcoder.closeTab('+(top.ICEcoder.openFiles.length)+')"><img src="images/nav-close.gif" id="closeTabButton'+(top.ICEcoder.openFiles.length)+'" class="closeTab"></a>';
|
||||
top.document.getElementById('tab'+(top.ICEcoder.openFiles.length)).style.display = "inline-block";
|
||||
top.document.getElementById('tab'+(top.ICEcoder.openFiles.length)).innerHTML = top.ICEcoder.openFiles[top.ICEcoder.openFiles.length-1] + " " + closeTabLink;
|
||||
|
||||
@@ -417,7 +444,7 @@ var ICEcoder = {
|
||||
// Add a new value ready to indicate if this content has been changed
|
||||
top.ICEcoder.changedContent.push(0);
|
||||
|
||||
top.ICEcoder.setLastOpenedFiles();
|
||||
top.ICEcoder.setPreviousFiles();
|
||||
},
|
||||
|
||||
// Create a new tab for a file
|
||||
@@ -428,7 +455,7 @@ var ICEcoder = {
|
||||
top.ICEcoder.openFiles[tabNum] = newName;
|
||||
|
||||
// Setup a new tab
|
||||
closeTabLink = '<a nohref onClick="parent.ICEcoder.closeTab('+tabNum+')"><img src="images/nav-close.gif"></a>';
|
||||
closeTabLink = '<a nohref onClick="parent.ICEcoder.closeTab('+tabNum+')"><img src="images/nav-close.gif" id="closeTabButton'+tabNum+'" class="closeTab"></a>';
|
||||
top.document.getElementById('tab'+tabNum).innerHTML = top.ICEcoder.openFiles[tabNum] + " " + closeTabLink;
|
||||
},
|
||||
|
||||
@@ -441,11 +468,11 @@ var ICEcoder = {
|
||||
ICEcoder.caretPos=cM.getValue().length;
|
||||
ICEcoder.getNestLocation();
|
||||
// Nesting is OK if at the end of the file we have no nests left, or it's a JS, Ruby or CSS file
|
||||
if (ICEcoder.htmlTagArray.length==0||fileName.indexOf(".js")>0||fileName.indexOf(".rb")>0||fileName.indexOf(".css")>0) {
|
||||
ICEcoder.nestValid.style.backgroundColor="#00bb00";
|
||||
if (ICEcoder.htmlTagArray.length==0||fileName.indexOf(".js")>0||fileName.indexOf(".coffee")>0||fileName.indexOf(".rb")>0||fileName.indexOf(".css")>0||fileName.indexOf(".less")>0) {
|
||||
ICEcoder.nestValid.style.backgroundColor="#0b0";
|
||||
ICEcoder.nestValid.innerHTML = "Nesting OK";
|
||||
} else {
|
||||
ICEcoder.nestValid.style.backgroundColor="#ff0000";
|
||||
ICEcoder.nestValid.style.backgroundColor="#f00";
|
||||
ICEcoder.nestValid.innerHTML = "Nesting Broken";
|
||||
}
|
||||
},
|
||||
@@ -491,13 +518,15 @@ var ICEcoder = {
|
||||
|
||||
fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1];
|
||||
if (fileName.indexOf(".js")>0) {caretLocType="JavaScript"};
|
||||
if (fileName.indexOf(".coffee")>0) {caretLocType="CoffeeScript"};
|
||||
if (fileName.indexOf(".rb")>0) {caretLocType="Ruby"};
|
||||
if (fileName.indexOf(".css")>0) {caretLocType="CSS"};
|
||||
if (fileName.indexOf(".less")>0) {caretLocType="LESS"};
|
||||
|
||||
ICEcoder.caretLocType = caretLocType;
|
||||
|
||||
// If we're in a JS, PHP or Ruby code block, add that to the nest display
|
||||
if (caretLocType=="JavaScript"||caretLocType=="PHP"||caretLocType=="Ruby") {
|
||||
// If we're in a JS, CoffeeScript PHP or Ruby code block, add that to the nest display
|
||||
if (caretLocType=="JavaScript"||caretLocType=="CoffeeScript"||caretLocType=="PHP"||caretLocType=="Ruby") {
|
||||
ICEcoder.nestDisplay.innerHTML += " > " + caretLocType;
|
||||
}
|
||||
},
|
||||
@@ -505,7 +534,7 @@ var ICEcoder = {
|
||||
// Alter array indicating which files have changed
|
||||
redoChangedContent: function(evt) {
|
||||
var key;
|
||||
|
||||
|
||||
key = evt.keyCode ? evt.keyCode : evt.which ? evt.which : evt.charCode;
|
||||
// Exclude a few keys such as Escape...
|
||||
if (top.ICEcoder.ctrlKeyDown==false && key!=27 && key!=20 && (key<16||key>19) && (key<37||key>40) && (key!=144||key!=145) && (key!=44||key!=45) && (key<33||key>36) && (key!=91||key!=92) && (key<112||key>123)) {
|
||||
@@ -521,7 +550,7 @@ var ICEcoder = {
|
||||
cM = ICEcoder.getcMInstance();
|
||||
okToRemove = true;
|
||||
if (ICEcoder.changedContent[closeTabNum-1]==1) {
|
||||
okToRemove = confirm('You have made changes.\n\nAre you sure you want to close without saving?');
|
||||
okToRemove = top.ICEcoder.ask('You have made changes.\n\nAre you sure you want to close without saving?');
|
||||
}
|
||||
|
||||
if (okToRemove) {
|
||||
@@ -531,38 +560,35 @@ var ICEcoder = {
|
||||
ICEcoder.openFiles[i-1] = ICEcoder.openFiles[i];
|
||||
|
||||
// reduce the tab reference number on the closeTab link by 1
|
||||
top.document.getElementById('tab'+i).innerHTML = top.document.getElementById('tab'+i).innerHTML.replace(("closeTab("+(i+1)+")"),"closeTab("+i+")");
|
||||
top.document.getElementById('tab'+i).innerHTML = top.document.getElementById('tab'+i).innerHTML.replace(("closeTab("+(i+1)+")"),"closeTab("+i+")").replace(("closeTabButton("+(i+1)+")"),"closeTabButton("+i+")");
|
||||
}
|
||||
|
||||
// hide the instance we're closing by setting the hide class, clear the value & remove from the array
|
||||
// hide the instance we're closing by setting the hide class and removing from the array
|
||||
ICEcoder.content.contentWindow['cM'+top.ICEcoder.cMInstances[closeTabNum-1]].setOption('theme',top.theme+' hidden');
|
||||
ICEcoder.content.contentWindow['cM'+top.ICEcoder.cMInstances[closeTabNum-1]].setValue('');
|
||||
top.ICEcoder.cMInstances.splice(closeTabNum-1,1);
|
||||
|
||||
// clear the rightmost tab (or only one left in a 1 tab scenario) & remove from the array
|
||||
top.document.getElementById('tab'+ICEcoder.openFiles.length).style.display = "none";
|
||||
top.document.getElementById('tab'+ICEcoder.openFiles.length).innerHTML = "";
|
||||
ICEcoder.openFiles.pop();
|
||||
|
||||
// Determin the new selectedTab number, reduced by 1 if we have some tabs, 0 for a reset state
|
||||
ICEcoder.openFiles.length>0 ? ICEcoder.selectedTab-=1 : ICEcoder.selectedTab = 0;
|
||||
ICEcoder.openFileMDTs.pop();
|
||||
// If we're closing the selected tab, determin the new selectedTab number, reduced by 1 if we have some tabs, 0 for a reset state
|
||||
if (ICEcoder.selectedTab==closeTabNum) {
|
||||
ICEcoder.openFiles.length>0 ? ICEcoder.selectedTab-=1 : ICEcoder.selectedTab = 0;
|
||||
}
|
||||
if (ICEcoder.openFiles.length>0 && ICEcoder.selectedTab==0) {ICEcoder.selectedTab=1};
|
||||
|
||||
// hide the content area if we have no tabs open
|
||||
if (ICEcoder.openFiles.length==0) {
|
||||
top.document.getElementById('content').style.visibility = "hidden";
|
||||
top.ICEcoder.fMIconVis('fMView',0.3);
|
||||
} else {
|
||||
// Switch the mode & the tab
|
||||
ICEcoder.switchMode();
|
||||
ICEcoder.switchTab(ICEcoder.selectedTab);
|
||||
}
|
||||
|
||||
// Highlight the selected tab after splicing the change state out of the array
|
||||
top.ICEcoder.changedContent.splice(closeTabNum-1,1);
|
||||
top.parent.ICEcoder.redoTabHighlight(ICEcoder.selectedTab);
|
||||
|
||||
top.ICEcoder.setLastOpenedFiles();
|
||||
top.ICEcoder.setPreviousFiles();
|
||||
}
|
||||
// Lastly, stop it from trying to also switch tab
|
||||
top.ICEcoder.canSwitchTabs=false;
|
||||
@@ -585,7 +611,7 @@ var ICEcoder = {
|
||||
while (1) {
|
||||
if (node != null) {
|
||||
if (node.tagName == "UL") {
|
||||
var d = (node.style.display == "none")
|
||||
var d = (node.style.display == "none");
|
||||
node.style.display = (d) ? "block" : "none";
|
||||
this.className = (d) ? "open" : "closed";
|
||||
return false;
|
||||
@@ -605,6 +631,8 @@ var ICEcoder = {
|
||||
}
|
||||
}
|
||||
}
|
||||
aMenus[0].childNodes[0].className = "open";
|
||||
aMenus[0].childNodes[1].style.display = "block";
|
||||
return false;
|
||||
},
|
||||
|
||||
@@ -688,8 +716,20 @@ var ICEcoder = {
|
||||
|
||||
// Select or deselect file
|
||||
selectDeselectFile: function(action,file) {
|
||||
action == "select" ? file.style.backgroundColor="#888888" : file.style.backgroundColor="#dddddd";
|
||||
action == "select" ? file.style.color="#f8f8f8" : file.style.color="#000000";
|
||||
var isOpen;
|
||||
|
||||
top.ICEcoder.openFiles.indexOf(file.id.replace(/\|/g,"/")) > -1 ? isOpen = true : isOpen = false;
|
||||
|
||||
if (top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1] == file.id.replace(/\|/g,"/")) {
|
||||
file.style.backgroundColor="#4499dd";
|
||||
} else {
|
||||
if (action=="select") {
|
||||
file.style.backgroundColor="#888";
|
||||
} else {
|
||||
isOpen ? file.style.backgroundColor = "rgba(255,255,255,0.15)" : file.style.backgroundColor="transparent";
|
||||
}
|
||||
}
|
||||
action == "select" ? file.style.color="#fff" : file.style.color="#eee";
|
||||
},
|
||||
|
||||
// Create a new file (start & instant save)
|
||||
@@ -703,7 +743,7 @@ var ICEcoder = {
|
||||
var newFolder, shortURL;
|
||||
|
||||
shortURL = top.ICEcoder.rightClickedFile.substr((top.ICEcoder.rightClickedFile.indexOf(shortURLStarts)+top.shortURLStarts.length),top.ICEcoder.rightClickedFile.length).replace(/\|/g,"/");
|
||||
newFolder = prompt('Enter New Folder Name at '+shortURL+'/','');
|
||||
newFolder = top.ICEcoder.getInput('Enter New Folder Name at '+shortURL+'/','');
|
||||
if (newFolder) {
|
||||
newFolder = shortURL + "/" + newFolder;
|
||||
top.ICEcoder.serverQueue("add","lib/file-control.php?action=newFolder&file="+newFolder.replace(/\//g,"|"));
|
||||
@@ -712,7 +752,11 @@ var ICEcoder = {
|
||||
},
|
||||
|
||||
// Open a file on demand
|
||||
openFile: function() {
|
||||
openFile: function(fileLink) {
|
||||
if (fileLink) {
|
||||
top.ICEcoder.thisFileFolderLink=fileLink;
|
||||
top.ICEcoder.thisFileFolderType="file";
|
||||
}
|
||||
if (top.ICEcoder.thisFileFolderLink!="" && top.ICEcoder.thisFileFolderType=="file") {
|
||||
var shortURL, canOpenFile;
|
||||
|
||||
@@ -736,7 +780,7 @@ var ICEcoder = {
|
||||
}
|
||||
} else {
|
||||
// show a message because we have 10 files open
|
||||
alert('Sorry, you can only have 10 files open at a time!');
|
||||
top.ICEcoder.message('Sorry, you can only have 10 files open at a time!');
|
||||
canOpenFile = false;
|
||||
}
|
||||
|
||||
@@ -761,8 +805,8 @@ var ICEcoder = {
|
||||
var saveType;
|
||||
|
||||
saveAs ? saveType = "saveAs" : saveType = "save";
|
||||
|
||||
top.ICEcoder.serverQueue("add","lib/file-control.php?action=save&file="+ICEcoder.openFiles[ICEcoder.selectedTab-1].replace(/\//g,"|")+"&saveType="+saveType);
|
||||
|
||||
top.ICEcoder.serverQueue("add","lib/file-control.php?action=save&file="+ICEcoder.openFiles[ICEcoder.selectedTab-1].replace(/\//g,"|")+"&fileMDT="+ICEcoder.openFileMDTs[ICEcoder.selectedTab-1]+"&saveType="+saveType);
|
||||
top.ICEcoder.serverMessage('<b>Saving</b><br>'+ICEcoder.openFiles[ICEcoder.selectedTab-1]);
|
||||
},
|
||||
|
||||
@@ -771,20 +815,20 @@ var ICEcoder = {
|
||||
var renamedFile, shortURL;
|
||||
|
||||
shortURL = top.ICEcoder.rightClickedFile.substr((top.ICEcoder.rightClickedFile.indexOf(shortURLStarts)+top.shortURLStarts.length),top.ICEcoder.rightClickedFile.length).replace(/\|/g,"/");
|
||||
renamedFile = prompt('Please enter the new name for',shortURL);
|
||||
renamedFile = top.ICEcoder.getInput('Please enter the new name for',shortURL);
|
||||
if (renamedFile) {
|
||||
for (var i=0;i<top.ICEcoder.openFiles.length;i++) {
|
||||
if(top.ICEcoder.openFiles[i]==shortURL.replace(/\|/g,"/")) {
|
||||
// rename array item and the tab
|
||||
top.ICEcoder.openFiles[i] = renamedFile;
|
||||
closeTabLink = '<a nohref onClick="top.ICEcoder.files.contentWindow.closeTab('+(i+1)+')"><img src="images/nav-close.gif"></a>';
|
||||
closeTabLink = '<a nohref onClick="top.ICEcoder.files.contentWindow.closeTab('+(i+1)+')"><img src="images/nav-close.gif" id="closeTabButton'+(i+1)+'" class="closeTab"></a>';
|
||||
top.document.getElementById('tab'+(i+1)).innerHTML = top.ICEcoder.openFiles[i] + " " + closeTabLink;
|
||||
}
|
||||
}
|
||||
top.ICEcoder.serverQueue("add","lib/file-control.php?action=rename&file="+renamedFile+"&oldFileName="+top.ICEcoder.rightClickedFile.replace(/\|/g,"/"));
|
||||
top.ICEcoder.serverMessage('<b>Renaming to</b><br>'+renamedFile);
|
||||
|
||||
top.ICEcoder.setLastOpenedFiles();
|
||||
top.ICEcoder.setPreviousFiles();
|
||||
}
|
||||
},
|
||||
|
||||
@@ -792,7 +836,7 @@ var ICEcoder = {
|
||||
deleteFile: function() {
|
||||
var delFiles, selectedFilesList;
|
||||
|
||||
delFiles = confirm('Delete:\n\n'+top.ICEcoder.selectedFiles.toString().replace(/\|/g,"/").replace(/,/g,"\n")+'?');
|
||||
delFiles = top.ICEcoder.ask('Delete:\n\n'+top.ICEcoder.selectedFiles.toString().replace(/\|/g,"/").replace(/,/g,"\n")+'?');
|
||||
// Upon supply a new name, rename tabs and update filename on server
|
||||
if (delFiles) {
|
||||
selectedFilesList = "";
|
||||
@@ -818,7 +862,7 @@ var ICEcoder = {
|
||||
if (!foundFile) {top.ICEcoder.selectFileFolder()};
|
||||
|
||||
if ("undefined" != typeof top.ICEcoder.thisFileFolderLink && top.ICEcoder.thisFileFolderLink!="") {
|
||||
top.ICEcoder.selectedFiles[0].indexOf(".")>0 ? menuType = "file" : menuType = "folder";
|
||||
top.ICEcoder.selectedFiles[0].indexOf(".")>-1 ? menuType = "file" : menuType = "folder";
|
||||
folderMenuItems = top.document.getElementById('folderMenuItems');
|
||||
menuType == "folder" && top.ICEcoder.selectedFiles.length == 1 ? folderMenuItems.style.display = "block" : folderMenuItems.style.display = "none";
|
||||
top.ICEcoder.selectedFiles.length > 1 ? singleFileMenuItems.style.display = "none" : singleFileMenuItems.style.display = "block";
|
||||
@@ -955,11 +999,11 @@ var ICEcoder = {
|
||||
},
|
||||
|
||||
// Go to a specific line number
|
||||
goToLine: function() {
|
||||
goToLine: function(lineNo) {
|
||||
var cM;
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
cM.setCursor(document.getElementById('goToLineNo').value-1);
|
||||
cM.setCursor(lineNo ? lineNo-1 : document.getElementById('goToLineNo').value-1);
|
||||
cM.focus();
|
||||
return false;
|
||||
},
|
||||
@@ -973,10 +1017,14 @@ var ICEcoder = {
|
||||
if (fileName) {
|
||||
if (fileName.indexOf('.js')>0) {
|
||||
cM.setOption("mode","javascript");
|
||||
} else if (fileName.indexOf('.coffee')>0) {
|
||||
cM.setOption("mode","coffeescript");
|
||||
} else if (fileName.indexOf('.rb')>0) {
|
||||
cM.setOption("mode","ruby");
|
||||
} else if (fileName.indexOf('.css')>0) {
|
||||
cM.setOption("mode","css");
|
||||
} else if (fileName.indexOf('.less')>0) {
|
||||
cM.setOption("mode","less");
|
||||
} else {
|
||||
cM.setOption("mode","application/x-httpd-php");
|
||||
}
|
||||
@@ -989,7 +1037,7 @@ var ICEcoder = {
|
||||
|
||||
lockIcon = top.document.getElementById('fmLock');
|
||||
ICEcoder.lockedNav ? ICEcoder.lockedNav = false : ICEcoder.lockedNav = true;
|
||||
ICEcoder.lockedNav ? lockIcon.src="images/file-manager-icons/padlock.png" : lockIcon.src="images/file-manager-icons/padlock-disabled.png";
|
||||
ICEcoder.lockedNav ? lockIcon.src="images/padlock.png" : lockIcon.src="images/padlock-disabled.png";
|
||||
},
|
||||
|
||||
// Determine the CodeMirror instance we're using on demand
|
||||
@@ -1034,7 +1082,7 @@ var ICEcoder = {
|
||||
lCLen = lineContent.length;
|
||||
adjustCursor = 3;
|
||||
|
||||
if (ICEcoder.caretLocType=="JavaScript"||ICEcoder.caretLocType=="PHP"||ICEcoder.caretLocType=="Ruby"||ICEcoder.caretLocType=="CSS") {
|
||||
if (ICEcoder.caretLocType=="JavaScript"||ICEcoder.caretLocType=="CoffeeScript"||ICEcoder.caretLocType=="PHP"||ICEcoder.caretLocType=="Ruby"||ICEcoder.caretLocType=="CSS") {
|
||||
if (cM.somethingSelected()) {
|
||||
if (ICEcoder.caretLocType=="Ruby") {
|
||||
startLine = cM.getCursor(true).line;
|
||||
@@ -1050,7 +1098,7 @@ var ICEcoder = {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (ICEcoder.caretLocType=="CSS") {
|
||||
if (ICEcoder.caretLocType=="CSS"||ICEcoder.caretLocType=="CoffeeScript") {
|
||||
lineContent.slice(0,3)!="/* " ? cM.setLine(linePos, "/* " + lineContent + " */") : cM.setLine(linePos, lineContent.slice(3,lCLen).slice(0,lCLen-5));
|
||||
if (lineContent.slice(0,3)=="/* ") {adjustCursor = -adjustCursor};
|
||||
} else if (ICEcoder.caretLocType=="Ruby") {
|
||||
@@ -1080,12 +1128,12 @@ var ICEcoder = {
|
||||
getMouseXY: function(e) {
|
||||
var tempX, tempY, scrollTop, IE;
|
||||
|
||||
IE = document.all ? true : false;
|
||||
if (!IE) {document.captureEvents(Event.MOUSEMOVE)};
|
||||
IE = !e.pageX ? true : false;
|
||||
if (IE) {
|
||||
top.ICEcoder.mouseX = event.clientX + document.body.scrollLeft;
|
||||
top.ICEcoder.mouseY = event.clientY + document.body.scrollTop;
|
||||
top.ICEcoder.mouseX = e.clientX + document.body.scrollLeft;
|
||||
top.ICEcoder.mouseY = e.clientY + document.body.scrollTop;
|
||||
} else {
|
||||
document.captureEvents(Event.MOUSEMOVE);
|
||||
top.ICEcoder.mouseX = e.pageX;
|
||||
top.ICEcoder.mouseY = e.pageY;
|
||||
}
|
||||
@@ -1107,14 +1155,14 @@ var ICEcoder = {
|
||||
},
|
||||
|
||||
// Update the file manager tree list on demand
|
||||
updateFileManagerList: function(action,location,file) {
|
||||
updateFileManagerList: function(action,location,file,perms) {
|
||||
var actionElemType, cssStyle, hrefLink, targetElem, locNest, newUL, newLI, nameLI, shortURL, newMouseOver;
|
||||
|
||||
// Adding files
|
||||
if (action=="add") {
|
||||
|
||||
// Determin if this is a file or folder and based on that, set the CSS styling & link
|
||||
file.indexOf(".")>0 ? actionElemType = "file" : actionElemType = "folder";
|
||||
file.indexOf(".")>-1 ? actionElemType = "file" : actionElemType = "folder";
|
||||
actionElemType=="file" ? cssStyle = "pft-file ext-" + file.substr(file.indexOf(".")+1,file.length) : cssStyle = "pft-directory";
|
||||
actionElemType=="file" ? hrefLink = "nohref" : hrefLink = "href=\"#\"";
|
||||
|
||||
@@ -1179,6 +1227,15 @@ var ICEcoder = {
|
||||
eval("targetElem.parentNode.onmouseover = function() { top.ICEcoder.overFileFolder('"+newMouseOver[1]+"','"+newMouseOver[3]+"');}");
|
||||
}
|
||||
|
||||
// Chmod on files
|
||||
if (action=="chmod") {
|
||||
// Identify a shortened URL for our file and get our target element based on this
|
||||
shortURL = top.ICEcoder.rightClickedFile.substr((top.ICEcoder.rightClickedFile.indexOf(shortURLStarts)+top.shortURLStarts.length),top.ICEcoder.rightClickedFile.length).replace(/\|/g,"/");
|
||||
targetElem = document.getElementById('filesFrame').contentWindow.document.getElementById(shortURL.replace(/\//g,"|")+"_perms");
|
||||
// Set the new perms
|
||||
targetElem.innerHTML = perms;
|
||||
}
|
||||
|
||||
// Deleting files
|
||||
if (action=="delete") {
|
||||
// Simply get our target and make it dissapear
|
||||
@@ -1286,7 +1343,7 @@ var ICEcoder = {
|
||||
if (ICEcoder.selectedFiles.length==1) {
|
||||
top.ICEcoder.rightClickedFile=top.ICEcoder.thisFileFolderLink=top.fullPath+top.ICEcoder.selectedFiles[0].replace('|','/');
|
||||
|
||||
if (action=="open" && ICEcoder.selectedFiles[0].indexOf(".")>0) {
|
||||
if (action=="open" && ICEcoder.selectedFiles[0].indexOf(".")>-1) {
|
||||
top.ICEcoder.thisFileFolderType='file';
|
||||
top.ICEcoder.openFile();
|
||||
}
|
||||
@@ -1319,7 +1376,7 @@ var ICEcoder = {
|
||||
ICEcoder.serverQueueItems.splice(1,ICEcoder.serverQueueItems.length);
|
||||
}
|
||||
top.document.getElementById('loadingMask').style.visibility = "hidden";
|
||||
top.ICEcoder.serverMessage('<b style="color: #dd0000">Cancelled tasks</b>');
|
||||
top.ICEcoder.serverMessage('<b style="color: #d00">Cancelled tasks</b>');
|
||||
setTimeout(function() {top.ICEcoder.serverMessage();},2000);
|
||||
},
|
||||
|
||||
@@ -1385,26 +1442,27 @@ var ICEcoder = {
|
||||
top.ICEcoder.dontSelect = true;
|
||||
},
|
||||
|
||||
// Set the current lastOpenedFiles in the settings file
|
||||
setLastOpenedFiles: function() {
|
||||
var lastOpenedFiles;
|
||||
// Set the current previousFiles in the settings file
|
||||
setPreviousFiles: function() {
|
||||
var previousFiles;
|
||||
|
||||
lastOpenedFiles = "";
|
||||
previousFiles = "";
|
||||
// Generate a comma seperated list
|
||||
for (var i=0;i<top.ICEcoder.openFiles.length;i++) {
|
||||
if (top.ICEcoder.openFiles[i]!="/[NEW]") {
|
||||
lastOpenedFiles += top.ICEcoder.openFiles[i].replace(/\//g,"|");
|
||||
if (i<top.ICEcoder.openFiles.length-1) {lastOpenedFiles += ","};
|
||||
if (top.ICEcoder.openFiles[i]!="" && top.ICEcoder.openFiles[i].indexOf("[NEW]")==-1) {
|
||||
if (i>0) {previousFiles += ","};
|
||||
previousFiles += top.ICEcoder.openFiles[i].replace(/\//g,"|");
|
||||
}
|
||||
}
|
||||
if (previousFiles=="") {previousFiles="CLEAR"};
|
||||
// Then send through to the settings page to update setting
|
||||
top.ICEcoder.serverQueue("add","lib/settings.php?saveFiles="+lastOpenedFiles);
|
||||
top.ICEcoder.serverQueue("add","lib/settings.php?saveFiles="+previousFiles);
|
||||
},
|
||||
|
||||
// Opens the last files we had open
|
||||
autoOpenFiles: function() {
|
||||
for (var i=0;i<=top.lastOpenFiles.length-1;i++) {
|
||||
top.ICEcoder.rightClickedFile=top.ICEcoder.thisFileFolderLink=top.fullPath+top.lastOpenFiles[i].replace('|','/');
|
||||
for (var i=0;i<=top.previousFiles.length-1;i++) {
|
||||
top.ICEcoder.rightClickedFile=top.ICEcoder.thisFileFolderLink=top.fullPath+top.previousFiles[i].replace('|','/');
|
||||
top.ICEcoder.thisFileFolderType='file';
|
||||
top.ICEcoder.openFile();
|
||||
}
|
||||
@@ -1420,25 +1478,41 @@ var ICEcoder = {
|
||||
top.document.getElementById('loadingMask').style.visibility = "hidden";
|
||||
if (loginAttempt) {
|
||||
if (loginAttempt == "loginOK") {
|
||||
if (top.ICEcoder.openFiles.length==0) {
|
||||
top.ICEcoder.content.style.visibility='visible';
|
||||
top.ICEcoder.content.src = "editor.php";
|
||||
}
|
||||
top.document.getElementById('accountLogin').style.top = "-50px";
|
||||
setTimeout(function() {top.document.getElementById('accountLoginContainer').style.display = "none";},300);
|
||||
} else {
|
||||
alert('Sorry, that\'s not correct.');
|
||||
top.ICEcoder.message('Sorry, that\'s not correct.');
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Show the settings screen
|
||||
settingsScreen: function(vis) {
|
||||
if (vis=="show") {
|
||||
settingsScreen: function(hide) {
|
||||
if (!hide) {
|
||||
top.document.getElementById('mediaContainer').innerHTML = '<iframe src="lib/settings-screen.php" class="whiteGlow" style="width: 970px; height: 600px"></iframe>';
|
||||
}
|
||||
top.ICEcoder.showHide(vis,top.document.getElementById('blackMask'));
|
||||
top.ICEcoder.showHide(hide?'hide':'show',top.document.getElementById('blackMask'));
|
||||
},
|
||||
|
||||
// Show the help screen
|
||||
helpScreen: function() {
|
||||
top.document.getElementById('mediaContainer').innerHTML = '<iframe src="lib/help.php" class="whiteGlow" style="width: 400px; height: 400px"></iframe>';
|
||||
top.ICEcoder.showHide('show',top.document.getElementById('blackMask'));
|
||||
},
|
||||
|
||||
// Show the properties screen
|
||||
propertiesScreen: function(fileName) {
|
||||
top.document.getElementById('mediaContainer').innerHTML = '<iframe src="lib/file-folder-properties.php?fileName='+fileName.replace(/\//g,"|")+'" class="whiteGlow" style="width: 660px; height: 330px"></iframe>';
|
||||
top.ICEcoder.showHide('show',top.document.getElementById('blackMask'));
|
||||
},
|
||||
|
||||
// Update the settings used when we make a change to them
|
||||
useNewSettings: function(themeURL,tabsIndent,codeAssist,lockedNav,visibleTabs,refreshFM) {
|
||||
useNewSettings: function(themeURL,tabsIndent,codeAssist,lockedNav,visibleTabs,tabWidth,refreshFM) {
|
||||
var styleNode, strCSS, cMCSS;
|
||||
|
||||
// Add new stylesheet for selected theme
|
||||
@@ -1464,10 +1538,15 @@ var ICEcoder = {
|
||||
top.document.getElementById('fileMenu').style.display='none';
|
||||
}
|
||||
|
||||
// Show visible tabs or not
|
||||
document.all ? strCSS = 'rules' : strCSS = 'cssRules';
|
||||
cMCSS = ICEcoder.content.contentWindow.document;
|
||||
visibleTabs ? cMCSS.styleSheets[2][strCSS][5].style['content'] = '"\\21e5"' : cMCSS.styleSheets[2][strCSS][5].style['content'] = '" "';
|
||||
cMCSS = ICEcoder.content.contentWindow.document.styleSheets[2];
|
||||
cMCSS.rules ? strCSS = 'rules' : strCSS = 'cssRules';
|
||||
visibleTabs ? cMCSS[strCSS][5].style['content'] = '"\\21e5"' : cMCSS[strCSS][5].style['content'] = '" "';
|
||||
|
||||
top.tabWidth = tabWidth;
|
||||
for (var i=0;i<ICEcoder.cMInstances.length;i++) {
|
||||
ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[i]].setOption("indentUnit", top.tabWidth);
|
||||
ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[i]].setOption("tabSize", top.tabWidth);
|
||||
}
|
||||
|
||||
// Finally, refresh the file manager if we need to
|
||||
if (refreshFM) {top.ICEcoder.refreshFileManager()};
|
||||
@@ -1477,5 +1556,120 @@ var ICEcoder = {
|
||||
updateResultsDisplay: function(showHide) {
|
||||
ICEcoder.findReplace('find',true,false);
|
||||
document.getElementById('results').style.display = showHide == "show" ? 'inline-block' : 'none';
|
||||
},
|
||||
|
||||
// Show file & folder count in server info screen
|
||||
updateFileFolderCount: function() {
|
||||
var fileText, dirText, unitSize, unitText, dContainer;
|
||||
|
||||
top.ICEcoder.dirCount > 1 ? dirText = "folders" : dirText = "folder";
|
||||
top.ICEcoder.fileCount > 1 ? fileText = "files" : fileText = "file";
|
||||
// Change into kilobytes
|
||||
unitSize = Math.ceil(top.ICEcoder.fileBytes/1024);
|
||||
unitText = "kb";
|
||||
// Maybe we should show in megabytes?
|
||||
if (unitSize >= 1024) {
|
||||
unitSize = unitSize / 1024;
|
||||
unitText = "mb";
|
||||
}
|
||||
// Update the display
|
||||
dContainer = top.ICEcoder.content.contentWindow.document.getElementById('fileFolderCounts');
|
||||
if (dContainer) {
|
||||
dContainer.innerHTML = top.ICEcoder.fileCount+" "+fileText+", "+top.ICEcoder.dirCount+" "+dirText+"<br>~ "+unitSize+" "+unitText;
|
||||
}
|
||||
},
|
||||
|
||||
// Toggle full screen on/off
|
||||
fullScreenSwitcher: function() {
|
||||
var screenIcon;
|
||||
|
||||
screenIcon = top.document.getElementById('screenMode');
|
||||
|
||||
// Future use
|
||||
if ("undefined" != typeof document.cancelFullScreen) {
|
||||
document.fullScreen ? document.cancelFullScreen() : document.body.requestFullScreen();
|
||||
// Moz specific
|
||||
} else if ("undefined" != typeof document.mozCancelFullScreen) {
|
||||
document.mozFullScreen ? document.mozCancelFullScreen() : document.body.mozRequestFullScreen();
|
||||
// Chrome specific
|
||||
} else if ("undefined" != typeof document.webkitCancelFullScreen) {
|
||||
document.webkitIsFullScreen ? document.webkitCancelFullScreen() : document.body.webkitRequestFullScreen();
|
||||
}
|
||||
|
||||
screenIcon.src.indexOf("images/full-screen.gif") > -1 ? screenIcon.src = "images/restored-screen.gif" : screenIcon.src = "images/full-screen.gif";
|
||||
|
||||
},
|
||||
|
||||
// Pass target file/folder to Zip It!
|
||||
zipIt: function(tgt) {
|
||||
tgt=tgt.replace(top.fullPath+"/","").replace(/\//g,"|");
|
||||
top.ICEcoder.filesFrame.contentWindow.frames['fileControl'].location.href="plugins/zip-it/index.php?zip="+tgt;
|
||||
},
|
||||
|
||||
// Tab dragging start
|
||||
handleDragStart: function(e) {
|
||||
this.style.opacity = '0.2';
|
||||
ICEcoder.dragSrcEl = this;
|
||||
e.dataTransfer.effectAllowed = 'move';
|
||||
e.dataTransfer.setData('text/html', this.innerHTML);
|
||||
},
|
||||
|
||||
// Tab dragging over tabs
|
||||
handleDragOver: function(e) {
|
||||
if (e.preventDefault) {e.preventDefault()}
|
||||
e.dataTransfer.dropEffect = 'move';
|
||||
return false;
|
||||
},
|
||||
|
||||
// Tab dropping on target
|
||||
handleDrop: function(e) {
|
||||
if (e.stopPropagation) {e.stopPropagation()}
|
||||
if (ICEcoder.dragSrcEl != this) {
|
||||
ICEcoder.dragSrcEl.innerHTML = this.innerHTML.split(" ")[0] + ICEcoder.dragSrcEl.innerHTML.substr(ICEcoder.dragSrcEl.innerHTML.indexOf(" "),ICEcoder.dragSrcEl.innerHTML.length);
|
||||
this.innerHTML = e.dataTransfer.getData('text/html').split(" ")[0] + this.innerHTML.substr(this.innerHTML.indexOf(" "),this.innerHTML.length);
|
||||
var dragID = ICEcoder.dragSrcEl.id.substr(3,ICEcoder.dragSrcEl.id.length)*1;
|
||||
var dropID = this.id.substr(3,this.id.length)*1;
|
||||
if(dragID==top.ICEcoder.selectedTab) {
|
||||
var a; // array value
|
||||
var b = dragID-1;
|
||||
var c = dropID-1;
|
||||
|
||||
// Swap values for switched tabs in these arrays
|
||||
a = [ICEcoder.changedContent, ICEcoder.openFiles, ICEcoder.openFileMDTs, ICEcoder.cMInstances];
|
||||
for (var i=0;i<a.length;i++) {
|
||||
a[i][b]=[a[i][c],a[i][c]=a[i][b]][0];
|
||||
}
|
||||
|
||||
top.ICEcoder.switchTab(dropID);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
// Tab drag ending
|
||||
handleDragEnd: function(e) {
|
||||
this.style.opacity = '1';
|
||||
},
|
||||
|
||||
// Change permissions on a file/folder
|
||||
chmod: function(file,perms) {
|
||||
top.ICEcoder.showHide('hide',top.document.getElementById('blackMask'));
|
||||
top.ICEcoder.serverQueue("add","lib/file-control.php?action=perms&file="+file+"&perms="+perms);
|
||||
top.ICEcoder.serverMessage('<b>chMod '+perms+' on </b><br>'+file);
|
||||
},
|
||||
|
||||
// Show a message
|
||||
message: function(msg) {
|
||||
alert(msg);
|
||||
},
|
||||
|
||||
// Ask for confirmation
|
||||
ask: function(question) {
|
||||
return confirm(question);
|
||||
},
|
||||
|
||||
// Get the users input
|
||||
getInput: function(question,defaultValue) {
|
||||
return prompt(question,defaultValue);
|
||||
}
|
||||
};
|
||||
25
lib/config.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
$versionNo = "v 0.7.6";
|
||||
$codeMirrorDir = "CodeMirror-2.25";
|
||||
$cMThisVer = 2.25;
|
||||
$tabsIndent = true;
|
||||
$checkUpdates = false;
|
||||
$openLastFiles = true;
|
||||
$findFilesExclude = array("_coder",".doc",".gif",".jpg",".jpeg",".pdf",".png",".swf",".xml",".zip");
|
||||
$codeAssist = true;
|
||||
$visibleTabs = false;
|
||||
$lockedNav = true;
|
||||
$accountPassword = "";
|
||||
$restrictedFiles = array("wp-",".php",".rb",".sql");
|
||||
$bannedFiles = array("_coder","wp-",".exe");
|
||||
$allowedIPs = array("*");
|
||||
$plugins = array(
|
||||
array("Database Admin","images/database.png","margin-top: 3px","plugins/adminer/adminer-3.3.3-mysql-en.php","_blank",""),
|
||||
array("Batch Image Processor","images/images.png","margin-top: 5px","http://birme.net","_blank",""),
|
||||
array("Zip It!","images/zip-it.png","margin-top: 3px","plugins/zip-it/?zip=|&exclude=.doc,.gif,.jpg,.jpeg,.pdf,.png,.swf,.xml,.zip","fileControl:<b>Zipping Open Files</b>","10")
|
||||
);
|
||||
$theme = "default";
|
||||
$tabWidth = 4;
|
||||
$previousFiles = "";
|
||||
$last10Files = "";
|
||||
?>
|
||||
@@ -2,12 +2,12 @@
|
||||
<?php
|
||||
|
||||
// Establish the full file path reference
|
||||
$file=$_GET['file'];
|
||||
if (isset($_GET['saveType'])) {$saveType = $_GET['saveType'];};
|
||||
$file=strClean($_GET['file']);
|
||||
if (isset($_GET['saveType'])) {$saveType = strClean($_GET['saveType']);};
|
||||
$docRoot = str_replace("\\","/",$_SERVER['DOCUMENT_ROOT']);
|
||||
|
||||
// Not done the first time we are on the save loop (ie, before the form posting reload)
|
||||
if ($_GET['action']=="load"||$_GET['action']=="newFolder"||$_GET['action']=="rename"||$_GET['action']=="delete"||isset($_POST['contents'])) {
|
||||
if ($_GET['action']=="load"||$_GET['action']=="newFolder"||$_GET['action']=="rename"||$_GET['action']=="delete"||$_GET['action']=="perms"||isset($_POST['contents'])) {
|
||||
$file= str_replace("|","/",$file);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ if ($_GET['action']=="load") {
|
||||
echo '<textarea name="loadedFile" id="loadedFile">'.str_replace("</textarea>","<ICEcoder:/:textarea>",$loadedFile).'</textarea>';
|
||||
} else {
|
||||
echo '<script>fileType="nothing";</script>';
|
||||
echo '<script>alert(\'Sorry, you need a higher admin level to view this file\');</script>';
|
||||
echo '<script>top.ICEcoder.message(\'Sorry, you need a higher admin level to view this file\');</script>';
|
||||
}
|
||||
};
|
||||
|
||||
@@ -55,9 +55,9 @@ if ($_GET['action']=="newFolder") {
|
||||
echo '<script>top.ICEcoder.selectedFiles=[];top.ICEcoder.updateFileManagerList(\'add\',\''.$fileLoc.'\',\''.$fileName.'\');top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);action="newFolder";</script>';
|
||||
} else {
|
||||
if (!is_writable($docRoot.$file)) {
|
||||
echo "<script>alert('Sorry, cannot create folder at\\n".substr($file,0,strrpos($file,"/"))."');</script>";
|
||||
echo "<script>top.ICEcoder.message('Sorry, cannot create folder at\\n".substr($file,0,strrpos($file,"/"))."');</script>";
|
||||
} else {
|
||||
echo '<script>alert(\'Sorry, you need to be logged in to add folders\');</script>';
|
||||
echo '<script>top.ICEcoder.message(\'Sorry, you need to be logged in to add folders\');</script>';
|
||||
}
|
||||
echo '<script>top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);action="nothing";</script>';
|
||||
}
|
||||
@@ -66,7 +66,7 @@ if ($_GET['action']=="newFolder") {
|
||||
// If we're due to rename a file...
|
||||
if ($_GET['action']=="rename") {
|
||||
if ($_SESSION['userLevel'] > 0 && is_writable($_GET['oldFileName'])) {
|
||||
rename($_GET['oldFileName'],$docRoot.$file);
|
||||
rename(strClean($_GET['oldFileName']),$docRoot.$file);
|
||||
// Reload file manager
|
||||
$fileName = substr($file,strrpos($file,"/")+1);
|
||||
$fileLoc = substr($file,0,strrpos($file,"/"));
|
||||
@@ -74,9 +74,28 @@ if ($_GET['action']=="rename") {
|
||||
echo '<script>top.ICEcoder.selectedFiles=[];top.ICEcoder.updateFileManagerList(\'rename\',\''.$fileLoc.'\',\''.$fileName.'\');top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);action="rename";</script>';
|
||||
} else {
|
||||
if (!is_writable($_GET['oldFileName'])) {
|
||||
echo "<script>alert('Sorry, cannot rename\\n".$_GET['oldFileName']."');</script>";
|
||||
echo "<script>top.ICEcoder.message('Sorry, cannot rename\\n".strClean($_GET['oldFileName'])."');</script>";
|
||||
} else {
|
||||
echo '<script>alert(\'Sorry, you need to be logged in to rename\');</script>';
|
||||
echo '<script>top.ICEcoder.message(\'Sorry, you need to be logged in to rename\');</script>';
|
||||
}
|
||||
echo '<script>top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);action="nothing";</script>';
|
||||
}
|
||||
}
|
||||
|
||||
// If we're due to change permissions on a file/folder...
|
||||
if ($_GET['action']=="perms") {
|
||||
if ($_SESSION['userLevel'] > 0 && is_writable($docRoot.$file)) {
|
||||
chmod($docRoot.$file,octdec(numClean($_GET['perms'])));
|
||||
// Reload file manager
|
||||
$fileName = substr($file,strrpos($file,"/")+1);
|
||||
$fileLoc = substr($file,0,strrpos($file,"/"));
|
||||
if ($fileLoc=="") {$fileLoc = "/";};
|
||||
echo '<script>top.ICEcoder.selectedFiles=[];top.ICEcoder.updateFileManagerList(\'chmod\',\''.$fileLoc.'\',\''.$fileName.'\',\''.numClean($_GET['perms']).'\');top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);action="perms";</script>';
|
||||
} else {
|
||||
if (!is_writable($docRoot.$file)) {
|
||||
echo "<script>top.ICEcoder.message('Sorry, cannot change permissions on \\n".strClean($docRoot.$file)."');</script>";
|
||||
} else {
|
||||
echo '<script>top.ICEcoder.message(\'Sorry, you need to be logged in to change permissions\');</script>';
|
||||
}
|
||||
echo '<script>top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);action="nothing";</script>';
|
||||
}
|
||||
@@ -99,15 +118,15 @@ if ($_GET['action']=="delete") {
|
||||
if ($fileLoc=="") {$fileLoc = "/";};
|
||||
echo '<script>top.ICEcoder.selectedFiles=[];top.ICEcoder.updateFileManagerList(\'delete\',\''.$fileLoc.'\',\''.$fileName.'\');top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);action="delete";</script>';
|
||||
} else {
|
||||
echo "<script>alert('Sorry can\\'t delete\\n".$filesArray[$i]."');</script>";
|
||||
echo "<script>top.ICEcoder.message('Sorry can\\'t delete\\n".$filesArray[$i]."');</script>";
|
||||
}
|
||||
echo '<script>top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);action="nothing";</script>';
|
||||
}
|
||||
} else {
|
||||
if (!is_writable($docRoot.$filesArray[$i])) {
|
||||
echo "<script>alert('Sorry, cannot delete\\n".$docRoot.$filesArray[$i]."');</script>";
|
||||
echo "<script>top.ICEcoder.message('Sorry, cannot delete\\n".$docRoot.$filesArray[$i]."');</script>";
|
||||
} else {
|
||||
echo '<script>alert(\'Sorry, you need to be logged in to delete\');</script>';
|
||||
echo '<script>top.ICEcoder.message(\'Sorry, you need to be logged in to delete\');</script>';
|
||||
}
|
||||
echo '<script>top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);action="nothing";</script>';
|
||||
}
|
||||
@@ -133,35 +152,66 @@ if ($_GET['action']=="save") {
|
||||
if (isset($_POST['contents'])) {
|
||||
if ($_SESSION['userLevel'] > 0) {
|
||||
if (isset($_POST['newFileName'])&&$_POST['newFileName']!="") {
|
||||
$file = $_POST['newFileName'];
|
||||
$file = strClean($_POST['newFileName']);
|
||||
}
|
||||
$saveFile = str_replace("\\","/",$_SERVER['DOCUMENT_ROOT']).$file;
|
||||
$saveFile = str_replace("//","/",$saveFile);
|
||||
if ((file_exists($saveFile) && is_writable($saveFile)) || $_POST['newFileName']!="") {
|
||||
$fh = fopen($saveFile, 'w') or die("can't open file");
|
||||
fwrite($fh, $_POST['contents']);
|
||||
fclose($fh);
|
||||
if (filemtime($saveFile)==$_GET['fileMDT']||!(isset($_GET['fileMDT']))) {
|
||||
$fh = fopen($saveFile, 'w') or die("Sorry, cannot save");
|
||||
fwrite($fh, $_POST['contents']);
|
||||
fclose($fh);
|
||||
clearstatcache();
|
||||
echo '<script>top.ICEcoder.openFileMDTs[top.ICEcoder.selectedTab-1]="'.filemtime($saveFile).'";</script>';
|
||||
|
||||
if (isset($_POST['newFileName'])&&$_POST['newFileName']!="") {
|
||||
// Reload file manager & stop CTRL+s being sticky
|
||||
$fileName = substr($file,strrpos($file,"/")+1);
|
||||
$fileLoc = substr($file,0,strrpos($file,"/"));
|
||||
if ($fileLoc=="") {$fileLoc = "/";};
|
||||
echo '<script>top.ICEcoder.selectedFiles=[];top.ICEcoder.updateFileManagerList(\'add\',\''.$fileLoc.'\',\''.$fileName.'\')</script>';
|
||||
if (isset($_POST['newFileName'])&&$_POST['newFileName']!="") {
|
||||
// Reload file manager & stop CTRL+s being sticky
|
||||
$fileName = substr($file,strrpos($file,"/")+1);
|
||||
$fileLoc = substr($file,0,strrpos($file,"/"));
|
||||
if ($fileLoc=="") {$fileLoc = "/";};
|
||||
echo '<script>top.ICEcoder.selectedFiles=[];top.ICEcoder.updateFileManagerList(\'add\',\''.$fileLoc.'\',\''.$fileName.'\')</script>';
|
||||
}
|
||||
if (isset($_POST['newFileName'])&&$_POST['newFileName']!="") {
|
||||
echo '<script>top.ICEcoder.renameTab(top.ICEcoder.selectedTab,\''.$file.'\');</script>';
|
||||
}
|
||||
echo '<script>top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);if (top.ICEcoder.stickyTabWindow.location) {top.ICEcoder.stickyTabWindow.location.reload()};action="doneSave";</script>';
|
||||
} else {
|
||||
$loadedFile = file_get_contents($saveFile);
|
||||
echo '<textarea name="loadedFile" id="loadedFile">'.str_replace("</textarea>","<ICEcoder:/:textarea>",$loadedFile).'</textarea>';
|
||||
echo '<textarea name="userVersionFile" id="userVersionFile"></textarea>';
|
||||
?>
|
||||
<script>
|
||||
var refreshFile = top.ICEcoder.ask('Sorry, this file has changed, cannot save\n<?php echo $file;?>\n\nReload this file and copy your version to a new document?');
|
||||
if (refreshFile) {
|
||||
var cM = top.ICEcoder.getcMInstance();
|
||||
var thisTab = top.ICEcoder.selectedTab;
|
||||
document.getElementById('userVersionFile').value = cM.getValue();
|
||||
// Revert back to original
|
||||
cM.setValue(document.getElementById('loadedFile').value);
|
||||
top.ICEcoder.changedContent[thisTab-1] = 0;
|
||||
top.ICEcoder.openFileMDTs[top.ICEcoder.selectedTab-1] = "<?php echo filemtime($saveFile); ?>";
|
||||
cM.clearHistory();
|
||||
// Now for the new file
|
||||
top.ICEcoder.newTab();
|
||||
cM = top.ICEcoder.getcMInstance();
|
||||
cM.setValue(document.getElementById('userVersionFile').value);
|
||||
cM.clearHistory();
|
||||
// Finally, switch back to original tab
|
||||
top.ICEcoder.switchTab(thisTab);
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
echo '<script>top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);action="nothing";</script>';
|
||||
}
|
||||
if (isset($_POST['newFileName'])&&$_POST['newFileName']!="") {
|
||||
echo '<script>top.ICEcoder.renameTab(top.ICEcoder.selectedTab,\''.$file.'\');</script>';
|
||||
}
|
||||
echo '<script>top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);if (top.ICEcoder.stickyTabWindow.location) {top.ICEcoder.stickyTabWindow.location.reload()};action="doneSave";</script>';
|
||||
} else {
|
||||
echo "<script>alert('Sorry, cannot write\\n".$file."');</script>";
|
||||
echo "<script>top.ICEcoder.message('Sorry, cannot write\\n".$file."');</script>";
|
||||
echo '<script>top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);action="nothing";</script>';
|
||||
}
|
||||
} else {
|
||||
if (!is_writable($saveFile)) {
|
||||
echo "<script>alert('Sorry, cannot write\\n".$file."');</script>";
|
||||
echo "<script>top.ICEcoder.message('Sorry, cannot write\\n".$file."');</script>";
|
||||
} else {
|
||||
echo '<script>alert(\'Sorry, you need to be logged in to save\');</script>';
|
||||
echo '<script>top.ICEcoder.message(\'Sorry, you need to be logged in to save\');</script>';
|
||||
}
|
||||
echo '<script>top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);action="nothing";</script>';
|
||||
}
|
||||
@@ -193,12 +243,13 @@ if (action=="load") {
|
||||
top.ICEcoder.content.contentWindow['cM'+top.ICEcoder.cMInstances[top.ICEcoder.selectedTab-1]].setLineClass(top.ICEcoder['cMActiveLine'+top.ICEcoder.selectedTab], null);
|
||||
top.ICEcoder['cMActiveLine'+top.ICEcoder.selectedTab] = top.ICEcoder.content.contentWindow['cM'+top.ICEcoder.cMInstances[top.ICEcoder.selectedTab-1]].setLineClass(0, "cm-s-activeLine");
|
||||
top.ICEcoder.nextcMInstance++;
|
||||
top.ICEcoder.openFileMDTs.push('<?php echo filemtime($file); ?>');
|
||||
top.ICEcoder.loadingFile = false;
|
||||
}
|
||||
|
||||
if (fileType=="image") {
|
||||
top.document.getElementById('blackMask').style.visibility = "visible";
|
||||
top.document.getElementById('mediaContainer').innerHTML = "<img src=\"<?php echo str_replace($docRoot,"",$file);?>\" class=\"whiteGlow\" style=\"border: solid 10px #ffffff; max-width: 700px; max-height: 500px\" onClick=\"return false\"><br><span class=\"whiteGlow\" style=\"border: solid 10px #ffffff; color: #000000; background-color: #ffffff\" onClick=\"return false\"><?php echo str_replace($docRoot,"",$file);?></span>";
|
||||
top.document.getElementById('mediaContainer').innerHTML = "<img src=\"<?php echo str_replace($docRoot,"",$file);?>\" class=\"whiteGlow\" style=\"border: solid 10px #fff; max-width: 700px; max-height: 500px\" onClick=\"return false\"><br><span class=\"whiteGlow\" style=\"border: solid 10px #fff; color: #000; background-color: #fff\" onClick=\"return false\"><?php echo str_replace($docRoot,"",$file);?></span>";
|
||||
}
|
||||
|
||||
top.ICEcoder.serverMessage();
|
||||
@@ -206,7 +257,7 @@ if (action=="load") {
|
||||
}
|
||||
</script>
|
||||
|
||||
<form name="saveFile" action="file-control.php?action=save&file=<?php if (isset($file)) {echo $file;};?>" method="POST">
|
||||
<form name="saveFile" action="file-control.php?action=save&file=<?php if (isset($file)) {echo $file;}; if (isset($_GET['fileMDT']) && $_GET['fileMDT']!="undefined") {echo "&fileMDT=".numClean($_GET['fileMDT']);};?>" method="POST">
|
||||
<textarea name="contents"></textarea>
|
||||
<input type="hidden" name="newFileName" value="">
|
||||
</form>
|
||||
@@ -218,12 +269,12 @@ if (action=="save") {
|
||||
?>
|
||||
if (top.ICEcoder.rightClickedFile) {
|
||||
shortURL = top.ICEcoder.rightClickedFile.substr((top.ICEcoder.rightClickedFile.indexOf(top.shortURLStarts)+top.shortURLStarts.length),top.ICEcoder.rightClickedFile.length).replace(/\|/g,"/")+"/";
|
||||
newFileName = prompt('Enter Filename',shortURL);
|
||||
newFileName = top.ICEcoder.getInput('Enter Filename',shortURL);
|
||||
} else {
|
||||
newFileName = prompt('Enter Filename','/');
|
||||
newFileName = top.ICEcoder.getInput('Enter Filename','/');
|
||||
}
|
||||
if (newFileName && top.document.getElementById('filesFrame').contentWindow.document.getElementById(newFileName.replace(/\//g,"|"))) {
|
||||
overwriteOK = confirm('That file exists already, overwrite?');
|
||||
overwriteOK = top.ICEcoder.ask('That file exists already, overwrite?');
|
||||
}
|
||||
document.saveFile.newFileName.value = newFileName;
|
||||
<?php ;};?>
|
||||
@@ -231,7 +282,7 @@ if (action=="save") {
|
||||
if ("undefined" != typeof newFileName) {
|
||||
top.ICEcoder.serverMessage('<b>Saving</b><br>'+newFileName);
|
||||
}
|
||||
document.saveFile.contents.innerHTML = top.document.getElementById('saveTemp1').value;
|
||||
document.saveFile.contents.value = top.document.getElementById('saveTemp1').value;
|
||||
document.saveFile.submit();
|
||||
} else {
|
||||
top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);
|
||||
|
||||
28
lib/file-folder-properties.css
Normal file
@@ -0,0 +1,28 @@
|
||||
/* First, reset everything to a standard */
|
||||
html, body, div, span, applet, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
a, abbr, acronym, address, big, cite, code,
|
||||
del, dfn, em, font, img, ins, kbd, q, s, samp,
|
||||
small, strike, strong, sub, sup, tt, var,
|
||||
b, u, i, center,
|
||||
dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td {
|
||||
border: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
outline: 0;
|
||||
font-size: 12px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
body {overflow: hidden;}
|
||||
|
||||
h1 {font-size: 36px; font-weight: normal; color: #888; margin-bottom: 20px}
|
||||
th {padding-left: 23px; padding-bottom: 5px}
|
||||
th, td {text-align: left; font-size: 10px}
|
||||
|
||||
.properties {font-family: arial, verdana, helvetica, sans-serif; background-color: #1c1c19; color: #fff; padding: 20px}
|
||||
.properties .column {display: inline-block; width: 210px; font-size: 10px; float: left}
|
||||
|
||||
.properties .update {position: absolute; bottom: 0; right: 20px; padding: 5px 10px; font-size: 18px; background-color: rgba(0,198,255,0.7); opacity: 0.1; cursor: pointer}
|
||||
159
lib/file-folder-properties.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php include("settings.php");?>
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html onContextMenu="return false">
|
||||
<head>
|
||||
<title>ICE Coder - <?php echo $versionNo;?> :: File/Folder Properties</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" type="text/css" href="file-folder-properties.css">
|
||||
</head>
|
||||
|
||||
<body class="properties">
|
||||
|
||||
<h1 id="title">properties</h1>
|
||||
|
||||
<?php
|
||||
$fileName=str_replace("|","/",strClean($_GET['fileName']));
|
||||
?>
|
||||
<h2><?php echo basename($fileName); ?></h2><br>
|
||||
<span class="column" style="width: 180px">Size: <?php
|
||||
$bytes = filesize($fileName);
|
||||
// If it's a dir, get the dir size
|
||||
if (is_dir($fileName)) {
|
||||
$io = popen('/usr/bin/du -sb '.$fileName, 'r');
|
||||
$bytes = intval(fgets($io,80));
|
||||
pclose($io);
|
||||
}
|
||||
// Change into kilobytes
|
||||
$outputSize = ($bytes/1024);
|
||||
$outputUnit = "kb";
|
||||
// Maybe we should show in megabytes?
|
||||
if ($outputSize >= 1024) {
|
||||
$outputSize = ($outputSize/1024);
|
||||
$outputUnit = "mb";
|
||||
}
|
||||
echo number_format($outputSize, 2, '.', '').$outputUnit." (".number_format($bytes)." bytes)";
|
||||
?></span>
|
||||
<span class="column" style="margin: 0 10px">Modified: <?php echo date( "D d M Y g:i:sa", filemtime($fileName)); ?></span>
|
||||
<span class="column">Last access: <?php echo date( "D d M Y g:i:sa", fileatime($fileName)); ?></span>
|
||||
<br><br>
|
||||
<span class="column" style="width: 180px">Type: <?php echo is_dir($fileName) ? "Folder" : "File"; ?></span>
|
||||
<span class="column" style="margin: 0 10px">Readable / Writeable: <?php
|
||||
if ($_SESSION['userLevel'] == 10) {
|
||||
echo is_readable($fileName) ? "Yes" : "No"; ?> / <?php echo is_writeable($fileName) ? "Yes" : "No";
|
||||
} else {
|
||||
echo '[HIDDEN]';
|
||||
}
|
||||
?></span>
|
||||
<span class="column">Relative path: <?php echo str_replace($docRoot,"",$fileName);?></span>
|
||||
<span style="font-size:10px">
|
||||
<br><br>
|
||||
Absolute path:<br><?php
|
||||
if ($_SESSION['userLevel'] == 10) {echo $fileName;} else {echo '[HIDDEN]';}
|
||||
?>
|
||||
<br><br>
|
||||
</span>
|
||||
<span class="column" style="width: 180px">
|
||||
Permissions:
|
||||
<?
|
||||
$chmodInfo = substr(sprintf('%o', fileperms($fileName)), -4);
|
||||
echo $chmodInfo;
|
||||
?>
|
||||
</span>
|
||||
<span class="column" style="margin: 0 10px">
|
||||
<?php
|
||||
$perms = str_split(substr($chmodInfo,1,3)); // reduces 0705 down to 705
|
||||
$readVars = array(4,5,6,7);
|
||||
$writeVars = array(2,3,6,7);
|
||||
$execVars = array(1,3,5,7);
|
||||
?>
|
||||
<table>
|
||||
<tr><th>Owner</th><th>Group</th><th>Public</th></tr>
|
||||
<tr>
|
||||
<td><input type="checkbox" name="ownerR" id="owner4"<?php if(in_array($perms[0],$readVars)!="") {echo ' checked';};?> onClick="changePerms();showButton()"> Read</td>
|
||||
<td><input type="checkbox" name="groupR" id="group4"<?php if(in_array($perms[1],$readVars)!="") {echo ' checked';};?> onClick="changePerms();showButton()"> Read</td>
|
||||
<td><input type="checkbox" name="publicR" id="public4"<?php if(in_array($perms[2],$readVars)!="") {echo ' checked';};?> onClick="changePerms();showButton()"> Read</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="checkbox" name="ownerW" id="owner2"<?php if(in_array($perms[0],$writeVars)!="") {echo ' checked';};?> onClick="changePerms();showButton()"> Write</td>
|
||||
<td><input type="checkbox" name="groupW" id="group2"<?php if(in_array($perms[1],$writeVars)!="") {echo ' checked';};?> onClick="changePerms();showButton()"> Write</td>
|
||||
<td><input type="checkbox" name="publicW" id="public2"<?php if(in_array($perms[2],$writeVars)!="") {echo ' checked';};?> onClick="changePerms();showButton()"> Write</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="checkbox" name="ownerE" id="owner1"<?php if(in_array($perms[0],$execVars)!="") {echo ' checked';};?> onClick="changePerms();showButton()"> Execute</td>
|
||||
<td><input type="checkbox" name="groupE" id="group1"<?php if(in_array($perms[1],$execVars)!="") {echo ' checked';};?> onClick="changePerms();showButton()"> Execute</td>
|
||||
<td><input type="checkbox" name="publicE" id="public1"<?php if(in_array($perms[2],$execVars)!="") {echo ' checked';};?> onClick="changePerms();showButton()"> Execute</td>
|
||||
</tr>
|
||||
</table>
|
||||
</span>
|
||||
<span class="column">
|
||||
Change to:<br>
|
||||
<form name="chmod" action="#" method="GET">
|
||||
<input type="text" name="chmod" id="permText" style="width: 30px; border: 0; background-color: #444; font-size: 10px; color: #fff" maxlength="3" value="<?php echo substr($chmodInfo,1,3); ?>" onKeyUp="changePerms(this.value);showButton()" onChange="changePerms(this.value);showButton()">
|
||||
</form>
|
||||
</span>
|
||||
|
||||
<div class="update" id="updateButton" onClick="validatePerms()">update</div>
|
||||
|
||||
<script>
|
||||
readVars = [4,5,6,7];
|
||||
writeVars = [2,3,6,7];
|
||||
execVars = [1,3,5,7];
|
||||
permGroups = ['owner','group','public'];
|
||||
permValues = [4,2,1];
|
||||
permTypes = ['read','write','exec'];
|
||||
|
||||
function changePerms(val) {
|
||||
var permText = document.getElementById('permText').value;
|
||||
// change checkboxes
|
||||
if (val) {
|
||||
// set values
|
||||
if (permText.length==3) {
|
||||
for (var i=0;i<=2;i++) {
|
||||
for (var j=0;j<=2;j++) {
|
||||
document.getElementById(permGroups[i]+permValues[j]).checked = window[permTypes[j]+'Vars'].indexOf(permText.split("")[i]*1)>-1;
|
||||
}
|
||||
}
|
||||
// clear values
|
||||
} else {
|
||||
for (var i=0;i<=2;i++) {
|
||||
for (var j=0;j<=2;j++) {
|
||||
document.getElementById(permGroups[i]+permValues[j]).checked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// change text value
|
||||
} else {
|
||||
ownerPerms = (document.getElementById('owner4').checked*4)+(document.getElementById('owner2').checked*2)+(document.getElementById('owner1').checked*1);
|
||||
groupPerms = (document.getElementById('group4').checked*4)+(document.getElementById('group2').checked*2)+(document.getElementById('group1').checked*1);
|
||||
publicPerms = (document.getElementById('public4').checked*4)+(document.getElementById('public2').checked*2)+(document.getElementById('public1').checked*1);
|
||||
document.getElementById('permText').value = ownerPerms.toString() + groupPerms.toString() + publicPerms.toString();
|
||||
}
|
||||
}
|
||||
|
||||
var showButton = function() {
|
||||
document.getElementById('updateButton').style.opacity = 1;
|
||||
}
|
||||
|
||||
var validatePerms = function() {
|
||||
var permText = document.getElementById('permText').value;
|
||||
canUpdate = true;
|
||||
if (permText.length!=3 || isNaN(permText)) {canUpdate = false};
|
||||
if ( permText.split("")[0]*1 <0 || permText.split("")[0]*1 >7 ||
|
||||
permText.split("")[1]*1 <0 || permText.split("")[1]*1 >7 ||
|
||||
permText.split("")[2]*1 <0 || permText.split("")[2]*1 >7) {
|
||||
canUpdate = false;
|
||||
}
|
||||
<?php
|
||||
if ($_SESSION['userLevel'] == 10) {
|
||||
?>
|
||||
if (canUpdate) {top.ICEcoder.chmod('<?php echo str_replace($docRoot,"",$fileName);?>',permText)};
|
||||
<?php
|
||||
;};
|
||||
?>
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
113
lib/files.css
@@ -9,92 +9,63 @@ dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td {
|
||||
font-family: arial, verdana, helvetica, sans-serif;
|
||||
border: 0px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
outline: 0px;
|
||||
border: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
outline: 0;
|
||||
font-size: 12px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
body {margin: 0px; overflow: auto}
|
||||
body {margin: 0; overflow: auto}
|
||||
|
||||
.refresh {float: right; margin-right: 15px; cursor: pointer}
|
||||
|
||||
.fileManager {
|
||||
margin: 15px 0px 15px 22px;
|
||||
margin: 15px 0 15px 22px;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-o-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.fileManager span {font-family: helvetica, arial, swiss, verdana;}
|
||||
.fileManager a {color: #000000; text-decoration: none;}
|
||||
.fileManager .open {font-style: italic;}
|
||||
.fileManager .closed {font-style: normal;}
|
||||
.fileManager .pft-directory {list-style-image: url(../images/file-manager-icons/directory.png);}
|
||||
.fileManager li {margin-left: 15px;}
|
||||
.fileManager span {font-family: helvetica, arial, swiss, verdana}
|
||||
.fileManager a {color: #eee; text-decoration: none}
|
||||
.fileManager .open {font-style: italic}
|
||||
.fileManager .closed {font-style: normal}
|
||||
.fileManager .pft-directory, .fileManager .pft-file {list-style-image: url(../images/blank.gif)}
|
||||
.fileManager li {margin-left: 15px}
|
||||
|
||||
/* Default file */
|
||||
.fileManager LI.pft-file { list-style-image: url(../images/file-manager-icons/file.png); }
|
||||
.fileManager LI.pft-directory:before, .fileManager LI.pft-file:before {
|
||||
position: absolute; display: block; width: 16px; height: 16px; content: ""; margin-top: -2px; margin-left: -23px; background:url(../images/file-manager-icons.png) no-repeat 0 0;
|
||||
}
|
||||
@media screen and (-webkit-min-device-pixel-ratio:0) { /* hacked for chrome and safari */
|
||||
.fileManager LI.pft-directory:before, .fileManager LI.pft-file:before {
|
||||
margin-top: -19px;
|
||||
}
|
||||
}
|
||||
.fileManager LI.pft-file:before {background-position: -16px 0}
|
||||
|
||||
/* Additional file types */
|
||||
.fileManager LI.ext-3gp { list-style-image: url(../images/file-manager-icons/film.png); }
|
||||
.fileManager LI.ext-afp { list-style-image: url(../images/file-manager-icons/code.png); }
|
||||
.fileManager LI.ext-afpa { list-style-image: url(../images/file-manager-icons/code.png); }
|
||||
.fileManager LI.ext-asp { list-style-image: url(../images/file-manager-icons/code.png); }
|
||||
.fileManager LI.ext-aspx { list-style-image: url(../images/file-manager-icons/code.png); }
|
||||
.fileManager LI.ext-avi { list-style-image: url(../images/file-manager-icons/film.png); }
|
||||
.fileManager LI.ext-bat { list-style-image: url(../images/file-manager-icons/application.png); }
|
||||
.fileManager LI.ext-bmp { list-style-image: url(../images/file-manager-icons/picture.png); }
|
||||
.fileManager LI.ext-c { list-style-image: url(../images/file-manager-icons/code.png); }
|
||||
.fileManager LI.ext-cfm { list-style-image: url(../images/file-manager-icons/code.png); }
|
||||
.fileManager LI.ext-cgi { list-style-image: url(../images/file-manager-icons/code.png); }
|
||||
.fileManager LI.ext-com { list-style-image: url(../images/file-manager-icons/application.png); }
|
||||
.fileManager LI.ext-cpp { list-style-image: url(../images/file-manager-icons/code.png); }
|
||||
.fileManager LI.ext-css { list-style-image: url(../images/file-manager-icons/css.png); }
|
||||
.fileManager LI.ext-doc { list-style-image: url(../images/file-manager-icons/doc.png); }
|
||||
.fileManager LI.ext-exe { list-style-image: url(../images/file-manager-icons/application.png); }
|
||||
.fileManager LI.ext-gif { list-style-image: url(../images/file-manager-icons/picture.png); }
|
||||
.fileManager LI.ext-fla { list-style-image: url(../images/file-manager-icons/flash.png); }
|
||||
.fileManager LI.ext-h { list-style-image: url(../images/file-manager-icons/code.png); }
|
||||
.fileManager LI.ext-htm { list-style-image: url(../images/file-manager-icons/html.png); }
|
||||
.fileManager LI.ext-html { list-style-image: url(../images/file-manager-icons/html.png); }
|
||||
.fileManager LI.ext-jar { list-style-image: url(../images/file-manager-icons/java.png); }
|
||||
.fileManager LI.ext-jpg { list-style-image: url(../images/file-manager-icons/picture.png); }
|
||||
.fileManager LI.ext-jpeg { list-style-image: url(../images/file-manager-icons/picture.png); }
|
||||
.fileManager LI.ext-js { list-style-image: url(../images/file-manager-icons/script.png); }
|
||||
.fileManager LI.ext-lasso { list-style-image: url(../images/file-manager-icons/code.png); }
|
||||
.fileManager LI.ext-log { list-style-image: url(../images/file-manager-icons/txt.png); }
|
||||
.fileManager LI.ext-m4p { list-style-image: url(../images/file-manager-icons/music.png); }
|
||||
.fileManager LI.ext-mov { list-style-image: url(../images/file-manager-icons/film.png); }
|
||||
.fileManager LI.ext-mp3 { list-style-image: url(../images/file-manager-icons/music.png); }
|
||||
.fileManager LI.ext-mp4 { list-style-image: url(../images/file-manager-icons/film.png); }
|
||||
.fileManager LI.ext-mpg { list-style-image: url(../images/file-manager-icons/film.png); }
|
||||
.fileManager LI.ext-mpeg { list-style-image: url(../images/file-manager-icons/film.png); }
|
||||
.fileManager LI.ext-ogg { list-style-image: url(../images/file-manager-icons/music.png); }
|
||||
.fileManager LI.ext-pcx { list-style-image: url(../images/file-manager-icons/picture.png); }
|
||||
.fileManager LI.ext-pdf { list-style-image: url(../images/file-manager-icons/pdf.png); }
|
||||
.fileManager LI.ext-php { list-style-image: url(../images/file-manager-icons/php.png); }
|
||||
.fileManager LI.ext-png { list-style-image: url(../images/file-manager-icons/picture.png); }
|
||||
.fileManager LI.ext-ppt { list-style-image: url(../images/file-manager-icons/ppt.png); }
|
||||
.fileManager LI.ext-psd { list-style-image: url(../images/file-manager-icons/psd.png); }
|
||||
.fileManager LI.ext-pl { list-style-image: url(../images/file-manager-icons/script.png); }
|
||||
.fileManager LI.ext-py { list-style-image: url(../images/file-manager-icons/script.png); }
|
||||
.fileManager LI.ext-rb { list-style-image: url(../images/file-manager-icons/ruby.png); }
|
||||
.fileManager LI.ext-rbx { list-style-image: url(../images/file-manager-icons/ruby.png); }
|
||||
.fileManager LI.ext-rhtml { list-style-image: url(../images/file-manager-icons/ruby.png); }
|
||||
.fileManager LI.ext-rpm { list-style-image: url(../images/file-manager-icons/linux.png); }
|
||||
.fileManager LI.ext-ruby { list-style-image: url(../images/file-manager-icons/ruby.png); }
|
||||
.fileManager LI.ext-sql { list-style-image: url(../images/file-manager-icons/db.png); }
|
||||
.fileManager LI.ext-swf { list-style-image: url(../images/file-manager-icons/flash.png); }
|
||||
.fileManager LI.ext-tif { list-style-image: url(../images/file-manager-icons/picture.png); }
|
||||
.fileManager LI.ext-tiff { list-style-image: url(../images/file-manager-icons/picture.png); }
|
||||
.fileManager LI.ext-txt { list-style-image: url(../images/file-manager-icons/txt.png); }
|
||||
.fileManager LI.ext-vb { list-style-image: url(../images/file-manager-icons/code.png); }
|
||||
.fileManager LI.ext-wav { list-style-image: url(../images/file-manager-icons/music.png); }
|
||||
.fileManager LI.ext-wmv { list-style-image: url(../images/file-manager-icons/film.png); }
|
||||
.fileManager LI.ext-xls { list-style-image: url(../images/file-manager-icons/xls.png); }
|
||||
.fileManager LI.ext-xml { list-style-image: url(../images/file-manager-icons/code.png); }
|
||||
.fileManager LI.ext-zip { list-style-image: url(../images/file-manager-icons/zip.png); }
|
||||
.fileManager LI.ext-coffee:before {background-position: -32px 0}
|
||||
.fileManager LI.ext-css:before {background-position: -48px 0}
|
||||
.fileManager LI.ext-gif:before {background-position: -64px 0}
|
||||
.fileManager LI.ext-htm:before {background-position: -80px 0}
|
||||
.fileManager LI.ext-html:before {background-position: -80px 0}
|
||||
.fileManager LI.ext-jpg:before {background-position: -96px 0}
|
||||
.fileManager LI.ext-jpeg:before {background-position: -96px 0}
|
||||
.fileManager LI.ext-js:before {background-position: -112px 0}
|
||||
/*.fileManager LI.ext-pdf:before {background-position: -???px 0} */
|
||||
.fileManager LI.ext-less:before {background-position: -128px 0}
|
||||
.fileManager LI.ext-php:before {background-position: -144px 0}
|
||||
.fileManager LI.ext-png:before {background-position: -160px 0}
|
||||
.fileManager LI.ext-rb:before {background-position: -176px 0}
|
||||
.fileManager LI.ext-rbx:before {background-position: -176px 0}
|
||||
.fileManager LI.ext-rhtml:before {background-position: -176px 0}
|
||||
.fileManager LI.ext-ruby:before {background-position: -176px 0}
|
||||
/*.fileManager LI.ext-sql:before {background-position: -???px 0} */
|
||||
/*.fileManager LI.ext-swf:before {background-position: -???px 0} */
|
||||
.fileManager LI.ext-txt:before {background-position: -192px 0}
|
||||
/*.fileManager LI.ext-xml:before {background-position: -???px 0} */
|
||||
.fileManager LI.ext-zip:before {background-position: -208px 0}
|
||||
31
lib/help.css
Normal file
@@ -0,0 +1,31 @@
|
||||
/* First, reset everything to a standard */
|
||||
html, body, div, span, applet, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
a, abbr, acronym, address, big, cite, code,
|
||||
del, dfn, em, font, img, ins, kbd, q, s, samp,
|
||||
small, strike, strong, sub, sup, tt, var,
|
||||
b, u, i, center,
|
||||
dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td {
|
||||
border: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
outline: 0;
|
||||
font-size: 12px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
body {overflow: hidden;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-o-user-select:none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
h1 {font-size: 36px; font-weight: normal; color: #888; margin-bottom: 20px}
|
||||
|
||||
.help {font-family: arial, verdana, helvetica, sans-serif; background-color: #1c1c19; color: #fff; padding: 20px}
|
||||
.help .key {display: inline-block; width: 175px; text-align: right; margin-right: 5px; float: left}
|
||||
.help .key .plus {color: #888}
|
||||
.help .shortcut {display: inline-block; width: 175px; color: #888; margin-left: 5px; float: left}
|
||||
38
lib/help.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php include("settings.php");?>
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>ICE Coder - <?php echo $versionNo;?> :: Help & Shortcuts</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" type="text/css" href="help.css">
|
||||
</head>
|
||||
|
||||
<body class="help">
|
||||
|
||||
<h1 id="title">help</h1>
|
||||
|
||||
<h2>In file manager</h2>
|
||||
<span class="key">Delete</span> <span class="shortcut">Delete file</span><br><br>
|
||||
|
||||
<h2>Within document</h2>
|
||||
<span class="key">CTRL <span class="plus">+</span> I</span> <span class="shortcut">Search selected text</span><br>
|
||||
<span class="key">Esc</span> <span class="shortcut">Comment / uncomment text</span><br>
|
||||
<span class="key">Tab</span> <span class="shortcut">Insert tab / indent selected text</span><br><br>
|
||||
|
||||
<h2>Anywhere</h2>
|
||||
<span class="key">CTRL <span class="plus">+</span> F</span> <span class="shortcut">Find</span><br>
|
||||
<span class="key">CTRL <span class="plus">+</span> G</span> <span class="shortcut">Go to line</span><br>
|
||||
<span class="key">CTRL <span class="plus">+</span> S</span> <span class="shortcut">Save</span><br>
|
||||
<span class="key">CTRL <span class="plus">+</span> Shift <span class="plus">+</span> S</span> <span class="shortcut">Save as...</span><br>
|
||||
<span class="key">CTRL <span class="plus">+</span> Enter</span> <span class="shortcut">View webpage</span><br>
|
||||
<span class="key">CTRL <span class="plus">+</span> S <span class="plus">+</span> Enter</span> <span class="shortcut">Save & create sticky tab</span><br>
|
||||
<span class="key">Esc</span> <span class="shortcut">Cancel tasks</span><br><br>
|
||||
|
||||
<h2>Clicking logo</h2>
|
||||
<span class="key">Left click</span> <span class="shortcut">Help</span><br>
|
||||
<span class="key">Right click</span> <span class="shortcut">Settings</span><br>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -8,10 +8,10 @@ b, u, i, center,
|
||||
dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td {
|
||||
border: 0px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
outline: 0px;
|
||||
border: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
outline: 0;
|
||||
font-size: 12px;
|
||||
vertical-align: top;
|
||||
}
|
||||
@@ -23,13 +23,13 @@ body {overflow: hidden;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
h1 {font-size: 36px; font-weight: normal; color: #888888; margin-bottom: 20px}
|
||||
h2 {font-size: 18px; font-weight: normal; color: #ffffff}
|
||||
hr {border: 0; height: 1px; background-color: #888888}
|
||||
h1 {font-size: 36px; font-weight: normal; color: #888; margin-bottom: 20px}
|
||||
h2 {font-size: 18px; font-weight: normal; color: #fff}
|
||||
hr {border: 0; height: 1px; background-color: #888}
|
||||
|
||||
.results {font-family: arial, verdana, helvetica, sans-serif; background-color: #1c1c19; color: #ffffff}
|
||||
.results {font-family: arial, verdana, helvetica, sans-serif; background-color: #1c1c19; color: #fff}
|
||||
.results .resultsPane {position: relative; width: 660px; height: 560px; font-size: 10px; padding: 20px; float: left}
|
||||
.results .resultsPane a {color: rgba(0,198,255,0.7); text-decoration: none}
|
||||
.results .resultsPane a:hover {text-decoration: underline}
|
||||
.replace {position: absolute; margin-top: -28px; right: 20px; padding: 5px 10px; font-size: 14px; background-color: rgba(0,198,255,0.7); cursor: pointer}
|
||||
.replaceAll {position: absolute; bottom: 0px; right: 20px; padding: 5px 10px; font-size: 18px; background-color: rgba(0,198,255,0.7); cursor: pointer}
|
||||
.replaceAll {position: absolute; bottom: 0; right: 20px; padding: 5px 10px; font-size: 18px; background-color: rgba(0,198,255,0.7); cursor: pointer}
|
||||