Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
579dc7d5d0 | ||
|
|
bdb7433c4a | ||
|
|
2a2a631c99 | ||
|
|
a28213983b | ||
|
|
0bcbc1a222 | ||
|
|
978e2145e6 | ||
|
|
e4e75ccbef | ||
|
|
4a804e71df | ||
|
|
c758a2ff37 | ||
|
|
77aaa16be4 | ||
|
|
215229d051 | ||
|
|
dbf7e4e834 | ||
|
|
cafd79b03d | ||
|
|
0b1073fdbe | ||
|
|
d23171b8f1 | ||
|
|
64b026ca6e | ||
|
|
422b013330 |
@@ -1,368 +0,0 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CodeMirror</title>
|
||||
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Droid+Sans|Droid+Sans:bold"/>
|
||||
<link rel="stylesheet" type="text/css" href="doc/docs.css"/>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<link rel="alternate" href="http://twitter.com/statuses/user_timeline/242283288.rss" type="application/rss+xml"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMirror</a></h1>
|
||||
|
||||
<pre class="grey">
|
||||
<img src="doc/baboon.png" class="logo" alt="logo"/>/* In-browser code editing
|
||||
made bearable */
|
||||
</pre>
|
||||
|
||||
<div class="clear"><div class="left blk">
|
||||
|
||||
<p style="margin-top: 0">CodeMirror is a JavaScript library that can
|
||||
be used to create a relatively pleasant editor interface for
|
||||
code-like content ― computer programs, HTML markup, and
|
||||
similar. If a mode has been written for the language you are
|
||||
editing, the code will be coloured, and the editor will optionally
|
||||
help you with indentation.</p>
|
||||
|
||||
<p>This is the project page for CodeMirror 2, the currently more
|
||||
actively developed, and recommended
|
||||
version. <a href="1/index.html">CodeMirror 1</a> is still available
|
||||
from here.</p>
|
||||
|
||||
<div class="clear"><div class="left1 blk">
|
||||
|
||||
<h2 style="margin-top: 0">Supported modes:</h2>
|
||||
|
||||
<ul>
|
||||
<li><a href="mode/clike/index.html">C, C++, Java, and similar</a></li>
|
||||
<li><a href="mode/clojure/index.html">Clojure</a></li>
|
||||
<li><a href="mode/coffeescript/index.html">CoffeeScript</a></li>
|
||||
<li><a href="mode/css/index.html">CSS</a></li>
|
||||
<li><a href="mode/diff/index.html">diff</a></li>
|
||||
<li><a href="mode/ecl/index.html">ECL</a></li>
|
||||
<li><a href="mode/go/index.html">Go</a></li>
|
||||
<li><a href="mode/groovy/index.html">Groovy</a></li>
|
||||
<li><a href="mode/haskell/index.html">Haskell</a></li>
|
||||
<li><a href="mode/htmlembedded/index.html">HTML embedded scripts</a></li>
|
||||
<li><a href="mode/htmlmixed/index.html">HTML mixed-mode</a></li>
|
||||
<li><a href="mode/javascript/index.html">JavaScript</a></li>
|
||||
<li><a href="mode/jinja2/index.html">Jinja2</a></li>
|
||||
<li><a href="mode/less/index.html">LESS</a></li>
|
||||
<li><a href="mode/lua/index.html">Lua</a></li>
|
||||
<li><a href="mode/markdown/index.html">Markdown</a> (<a href="mode/gfm/index.html">Github-flavour</a>)</li>
|
||||
<li><a href="mode/mysql/index.html">MySQL</a></li>
|
||||
<li><a href="mode/ntriples/index.html">NTriples</a></li>
|
||||
<li><a href="mode/pascal/index.html">Pascal</a></li>
|
||||
<li><a href="mode/perl/index.html">Perl</a></li>
|
||||
<li><a href="mode/php/index.html">PHP</a></li>
|
||||
<li><a href="mode/plsql/index.html">PL/SQL</a></li>
|
||||
<li><a href="mode/properties/index.html">Properties files</a></li>
|
||||
<li><a href="mode/python/index.html">Python</a></li>
|
||||
<li><a href="mode/r/index.html">R</a></li>
|
||||
<li>RPM <a href="mode/rpm/spec/index.html">spec</a> and <a href="mode/rpm/changes/index.html">changelog</a></li>
|
||||
<li><a href="mode/rst/index.html">reStructuredText</a></li>
|
||||
<li><a href="mode/ruby/index.html">Ruby</a></li>
|
||||
<li><a href="mode/rust/index.html">Rust</a></li>
|
||||
<li><a href="mode/scheme/index.html">Scheme</a></li>
|
||||
<li><a href="mode/smalltalk/index.html">Smalltalk</a></li>
|
||||
<li><a href="mode/sparql/index.html">SPARQL</a></li>
|
||||
<li><a href="mode/stex/index.html">sTeX, LaTeX</a></li>
|
||||
<li><a href="mode/tiddlywiki/index.html">Tiddlywiki</a></li>
|
||||
<li><a href="mode/velocity/index.html">Velocity</a></li>
|
||||
<li><a href="mode/verilog/index.html">Verilog</a></li>
|
||||
<li><a href="mode/xml/index.html">XML/HTML</a> (<a href="mode/xmlpure/index.html">alternative XML</a>)</li>
|
||||
<li><a href="mode/yaml/index.html">YAML</a></li>
|
||||
</ul>
|
||||
|
||||
</div><div class="left2 blk">
|
||||
|
||||
<h2 style="margin-top: 0">Usage demos:</h2>
|
||||
|
||||
<ul>
|
||||
<li><a href="demo/complete.html">Autocompletion</a></li>
|
||||
<li><a href="demo/mustache.html">Mode overlays</a></li>
|
||||
<li><a href="demo/search.html">Search/replace</a></li>
|
||||
<li><a href="demo/folding.html">Code folding</a></li>
|
||||
<li><a href="demo/preview.html">HTML editor with preview</a></li>
|
||||
<li><a href="demo/resize.html">Auto-resizing editor</a></li>
|
||||
<li><a href="demo/marker.html">Setting breakpoints</a></li>
|
||||
<li><a href="demo/activeline.html">Highlighting the current line</a></li>
|
||||
<li><a href="demo/matchhighlighter.html">Highlighting selection matches</a></li>
|
||||
<li><a href="demo/theme.html">Theming</a></li>
|
||||
<li><a href="demo/runmode.html">Stand-alone highlighting</a></li>
|
||||
<li><a href="demo/fullscreen.html">Full-screen editing</a></li>
|
||||
<li><a href="demo/changemode.html">Mode auto-changing</a></li>
|
||||
<li><a href="demo/visibletabs.html">Visible tabs</a></li>
|
||||
<li><a href="demo/formatting.html">Autoformatting of code</a></li>
|
||||
<li><a href="demo/emacs.html">Emacs keybindings</a></li>
|
||||
<li><a href="demo/vim.html">Vim keybindings</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Real-world uses:</h2>
|
||||
|
||||
<ul>
|
||||
<li><a href="http://jsbin.com">jsbin.com</a> (JS playground)</li>
|
||||
<li><a href="http://buzzard.ups.edu/">Sage demo</a> (math system)</li>
|
||||
<li><a href="http://www.sourcelair.com/">sourceLair</a> (online IDE)</li>
|
||||
<li><a href="http://eloquentjavascript.net/chapter1.html">Eloquent JavaScript</a> (book)</a></li>
|
||||
<li><a href="http://www.mergely.com/">Mergely</a> (interactive diffing)</li>
|
||||
<li><a href="http://paperjs.org/">Paper.js</a> (graphics scripting)</li>
|
||||
<li><a href="http://www.wescheme.org/">WeScheme</a> (learning tool)</li>
|
||||
<li><a href="http://webglplayground.net/">WebGL playground</a></li>
|
||||
<li><a href="http://ql.io/">ql.io</a> (http API query helper)</li>
|
||||
<li><a href="http://elm-lang.org/Examples.elm">Elm language examples</a></li>
|
||||
<li><a href="http://bluegriffon.org/">BlueGriffon</a> (HTML editor)</li>
|
||||
<li><a href="http://www.jshint.com/">JSHint</a> (JS linter)</li>
|
||||
<li><a href="http://kl1p.com/cmtest/1">kl1p</a> (paste service)</li>
|
||||
</ul>
|
||||
|
||||
</div></div>
|
||||
|
||||
<h2 id="code">Getting the code</h2>
|
||||
|
||||
<p>All of CodeMirror is released under a <a
|
||||
href="LICENSE">MIT-style</a> license. To get it, you can download
|
||||
the <a href="http://codemirror.net/codemirror.zip">latest
|
||||
release</a> or the current <a
|
||||
href="http://codemirror.net/codemirror2-latest.zip">development
|
||||
snapshot</a> as zip files. To create a custom minified script file,
|
||||
you can use the <a href="doc/compress.html">compression API</a>.</p>
|
||||
|
||||
<p>We use <a href="http://git-scm.com/">git</a> for version control.
|
||||
The main repository can be fetched in this way:</p>
|
||||
|
||||
<pre class="code">git clone http://marijnhaverbeke.nl/git/codemirror2</pre>
|
||||
|
||||
<p>CodeMirror can also be found on GitHub at <a
|
||||
href="http://github.com/marijnh/CodeMirror2">marijnh/CodeMirror2</a>.
|
||||
If you plan to hack on the code and contribute patches, the best way
|
||||
to do it is to create a GitHub fork, and send pull requests.</p>
|
||||
|
||||
<h2 id="documention">Documentation</h2>
|
||||
|
||||
<p>The <a href="doc/manual.html">manual</a> is your first stop for
|
||||
learning how to use this library. It starts with a quick explanation
|
||||
of how to use the editor, and then describes the API in detail.</p>
|
||||
|
||||
<p>For those who want to learn more about the code, there is
|
||||
an <a href="doc/internals.html">overview of the internals</a> available.
|
||||
The <a href="http://github.com/marijnh/CodeMirror2">source code</a>
|
||||
itself is, for the most part, also well commented.</p>
|
||||
|
||||
<h2 id="support">Support and bug reports</h2>
|
||||
|
||||
<p>There is
|
||||
a <a href="http://groups.google.com/group/codemirror">Google
|
||||
group</a> (a sort of mailing list/newsgroup thing) for discussion
|
||||
and news related to CodeMirror. When reporting a bug,
|
||||
<a href="doc/reporting.html">read this first</a>. If you have
|
||||
a <a href="http://github.com">github</a> account,
|
||||
simply <a href="http://github.com/marijnh/CodeMirror2/issues">open
|
||||
an issue there</a>. Otherwise, post something to
|
||||
the <a href="http://groups.google.com/group/codemirror">group</a>,
|
||||
or e-mail me directly: <a href="mailto:marijnh@gmail.com">Marijn
|
||||
Haverbeke</a>.</p>
|
||||
|
||||
<h2 id="supported">Supported browsers</h2>
|
||||
|
||||
<p>The following browsers are able to run CodeMirror:</p>
|
||||
|
||||
<ul>
|
||||
<li>Firefox 2 or higher</li>
|
||||
<li>Chrome, any version</li>
|
||||
<li>Safari 3 or higher</li>
|
||||
<li>Internet Explorer 6 or higher in standards (<strong>non-quirks</strong>) mode</li>
|
||||
<li>Opera 9 or higher (with some key-handling problems on OS X)</li>
|
||||
</ul>
|
||||
|
||||
<p>I am not actively testing against every new browser release, and
|
||||
vendors have a habit of introducing bugs all the time, so I am
|
||||
relying on the community to tell me when something breaks.
|
||||
See <a href="#support">here</a> for information on how to contact
|
||||
me.</p>
|
||||
|
||||
<h2 id="commercial">Commercial support</h2>
|
||||
|
||||
<p>CodeMirror is developed and maintained by me, Marijn Haverbeke,
|
||||
in my own time. If your company is getting value out of CodeMirror,
|
||||
please consider purchasing a support contract.</p>
|
||||
|
||||
<ul>
|
||||
<li>You'll be funding further work on CodeMirror.</li>
|
||||
<li>You ensure that you get a quick response when you have a
|
||||
problem, even when I am otherwise busy.</li>
|
||||
</ul>
|
||||
|
||||
<p>CodeMirror support contracts exist in two
|
||||
forms—<strong>basic</strong> at €100 per month,
|
||||
and <strong>premium</strong> at €500 per
|
||||
month. <a href="mailto:marijnh@gmail.com">Contact me</a> for further
|
||||
information.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="right blk">
|
||||
|
||||
<a href="http://codemirror.net/codemirror.zip" class="download">Download the latest release</a>
|
||||
|
||||
<h2>Support CodeMirror</h2>
|
||||
|
||||
<ul>
|
||||
<li>Donate
|
||||
(<span onclick="document.getElementById('paypal').submit();"
|
||||
class="quasilink">Paypal</span>
|
||||
or <span onclick="document.getElementById('bankinfo').style.display = 'block';"
|
||||
class="quasilink">bank</span>)</li>
|
||||
<li>Purchase <a href="#commercial">commercial support</a></li>
|
||||
</ul>
|
||||
|
||||
<p id="bankinfo" style="display: none;">
|
||||
Bank: <i>Rabobank</i><br/>
|
||||
Country: <i>Netherlands</i><br/>
|
||||
SWIFT: <i>RABONL2U</i><br/>
|
||||
Account: <i>147850770</i><br/>
|
||||
Name: <i>Marijn Haverbeke</i><br/>
|
||||
IBAN: <i>NL26 RABO 0147 8507 70</i>
|
||||
</p>
|
||||
|
||||
<h2>Releases:</h2>
|
||||
|
||||
<p class="rel">27-02-2012: <a href="http://codemirror.net/codemirror-2.22.zip">Version 2.22</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>Allow <a href="doc/manual.html#keymaps">key handlers</a> to pass up events, allow binding characters.</li>
|
||||
<li>Add <a href="doc/manual.html#option_autoClearEmptyLines"><code>autoClearEmptyLines</code></a> option.</li>
|
||||
<li>Properly use tab stops when rendering tabs.</li>
|
||||
<li>Make PHP mode more robust.</li>
|
||||
<li>Support indentation blocks in <a href="doc/manual.html#util_foldcode">code folder</a>.</li>
|
||||
<li>Add a script for <a href="doc/manual.html#util_match-highlighter">highlighting instances of the selection</a>.</li>
|
||||
<li>New <a href="mode/properties/index.html">.properties</a> mode.</li>
|
||||
<li>Fix many bugs.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">27-01-2012: <a href="http://codemirror.net/codemirror-2.21.zip">Version 2.21</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>Added <a href="mode/less/index.html">LESS</a>, <a href="mode/mysql/index.html">MySQL</a>,
|
||||
<a href="mode/go/index.html">Go</a>, and <a href="mode/verilog/index.html">Verilog</a> modes.</li>
|
||||
<li>Add <a href="doc/manual.html#option_smartIndent"><code>smartIndent</code></a>
|
||||
option.</li>
|
||||
<li>Support a cursor in <a href="doc/manual.html#option_readOnly"><code>readOnly</code></a>-mode.</li>
|
||||
<li>Support assigning multiple styles to a token.</li>
|
||||
<li>Use a new approach to drawing the selection.</li>
|
||||
<li>Add <a href="doc/manual.html#scrollTo"><code>scrollTo</code></a> method.</li>
|
||||
<li>Allow undo/redo events to span non-adjacent lines.</li>
|
||||
<li>Lots and lots of bugfixes.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">20-12-2011: <a href="http://codemirror.net/codemirror-2.2.zip">Version 2.2</a>:</p>
|
||||
|
||||
<ul class="rel-note">
|
||||
<li>Slightly incompatible API changes. Read <a href="doc/upgrade_v2.2.html">this</a>.</li>
|
||||
<li>New approach
|
||||
to <a href="doc/manual.html#option_extraKeys">binding</a> keys,
|
||||
support for <a href="doc/manual.html#option_keyMap">custom
|
||||
bindings</a>.</li>
|
||||
<li>Support for overwrite (insert).</li>
|
||||
<li><a href="doc/manual.html#option_tabSize">Custom-width</a>
|
||||
and <a href="demo/visibletabs.html">stylable</a> tabs.</li>
|
||||
<li>Moved more code into <a href="doc/manual.html#addons">add-on scripts</a>.</li>
|
||||
<li>Support for sane vertical cursor movement in wrapped lines.</li>
|
||||
<li>More reliable handling of
|
||||
editing <a href="doc/manual.html#markText">marked text</a>.</li>
|
||||
<li>Add minimal <a href="demo/emacs.html">emacs</a>
|
||||
and <a href="demo/vim.html">vim</a> bindings.</li>
|
||||
<li>Rename <code>coordsFromIndex</code>
|
||||
to <a href="doc/manual.html#posFromIndex"><code>posFromIndex</code></a>,
|
||||
add <a href="doc/manual.html#indexFromPos"><code>indexFromPos</code></a>
|
||||
method.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">21-11-2011: <a href="http://codemirror.net/codemirror-2.18.zip">Version 2.18</a>:</p>
|
||||
<p class="rel-note">Fixes <code>TextMarker.clear</code>, which is broken in 2.17.</p>
|
||||
|
||||
<p class="rel">21-11-2011: <a href="http://codemirror.net/codemirror-2.17.zip">Version 2.17</a>:</p>
|
||||
<ul class="rel-note">
|
||||
<li>Add support for <a href="doc/manual.html#option_lineWrapping">line
|
||||
wrapping</a> and <a href="doc/manual.html#hideLine">code
|
||||
folding</a>.</li>
|
||||
<li>Add <a href="mode/gfm/index.html">Github-style Markdown</a> mode.</li>
|
||||
<li>Add <a href="theme/monokai.css">Monokai</a>
|
||||
and <a href="theme/rubyblue.css">Rubyblue</a> themes.</li>
|
||||
<li>Add <a href="doc/manual.html#setBookmark"><code>setBookmark</code></a> method.</li>
|
||||
<li>Move some of the demo code into reusable components
|
||||
under <a href="lib/util/"><code>lib/util</code></a>.</li>
|
||||
<li>Make screen-coord-finding code faster and more reliable.</li>
|
||||
<li>Fix drag-and-drop in Firefox.</li>
|
||||
<li>Improve support for IME.</li>
|
||||
<li>Speed up content rendering.</li>
|
||||
<li>Fix browser's built-in search in Webkit.</li>
|
||||
<li>Make double- and triple-click work in IE.</li>
|
||||
<li>Various fixes to modes.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">27-10-2011: <a href="http://codemirror.net/codemirror-2.16.zip">Version 2.16</a>:</p>
|
||||
<ul class="rel-note">
|
||||
<li>Add <a href="mode/perl/index.html">Perl</a>, <a href="mode/rust/index.html">Rust</a>, <a href="mode/tiddlywiki/index.html">TiddlyWiki</a>, and <a href="mode/groovy/index.html">Groovy</a> modes.</li>
|
||||
<li>Dragging text inside the editor now moves, rather than copies.</li>
|
||||
<li>Add a <a href="doc/manual.html#coordsFromIndex"><code>coordsFromIndex</code></a> method.</li>
|
||||
<li><strong>API change</strong>: <code>setValue</code> now no longer clears history. Use <a href="doc/manual.html#clearHistory"><code>clearHistory</code></a> for that.</li>
|
||||
<li><strong>API change</strong>: <a href="doc/manual.html#markText"><code>markText</code></a> now
|
||||
returns an object with <code>clear</code> and <code>find</code>
|
||||
methods. Marked text is now more robust when edited.</li>
|
||||
<li>Fix editing code with tabs in Internet Explorer.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">26-09-2011: <a href="http://codemirror.net/codemirror-2.15.zip">Version 2.15</a>:</p>
|
||||
<p class="rel-note">Fix bug that snuck into 2.14: Clicking the
|
||||
character that currently has the cursor didn't re-focus the
|
||||
editor.</p>
|
||||
|
||||
<p class="rel">26-09-2011: <a href="http://codemirror.net/codemirror-2.14.zip">Version 2.14</a>:</p>
|
||||
<ul class="rel-note">
|
||||
<li>Add <a href="mode/clojure/index.html">Clojure</a>, <a href="mode/pascal/index.html">Pascal</a>, <a href="mode/ntriples/index.html">NTriples</a>, <a href="mode/jinja2/index.html">Jinja2</a>, and <a href="mode/markdown/index.html">Markdown</a> modes.</li>
|
||||
<li>Add <a href="theme/cobalt.css">Cobalt</a> and <a href="theme/eclipse.css">Eclipse</a> themes.</li>
|
||||
<li>Add a <a href="doc/manual.html#option_fixedGutter"><code>fixedGutter</code></a> option.</li>
|
||||
<li>Fix bug with <code>setValue</code> breaking cursor movement.</li>
|
||||
<li>Make gutter updates much more efficient.</li>
|
||||
<li>Allow dragging of text out of the editor (on modern browsers).</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">23-08-2011: <a href="http://codemirror.net/codemirror-2.13.zip">Version 2.13</a>:</p>
|
||||
<ul class="rel-note">
|
||||
<li>Add <a href="mode/ruby/index.html">Ruby</a>, <a href="mode/r/index.html">R</a>, <a href="mode/coffeescript/index.html">CoffeeScript</a>, and <a href="mode/velocity/index.html">Velocity</a> modes.</li>
|
||||
<li>Add <a href="doc/manual.html#getGutterElement"><code>getGutterElement</code></a> to API.</li>
|
||||
<li>Several fixes to scrolling and positioning.</li>
|
||||
<li>Add <a href="doc/manual.html#option_smartHome"><code>smartHome</code></a> option.</li>
|
||||
<li>Add an experimental <a href="mode/xmlpure/index.html">pure XML</a> mode.</li>
|
||||
</ul>
|
||||
|
||||
<p class="rel">25-07-2011: <a href="http://codemirror.net/codemirror-2.12.zip">Version 2.12</a>:</p>
|
||||
<ul class="rel-note">
|
||||
<li>Add a <a href="mode/sparql/index.html">SPARQL</a> mode.</li>
|
||||
<li>Fix bug with cursor jumping around in an unfocused editor in IE.</li>
|
||||
<li>Allow key and mouse events to bubble out of the editor. Ignore widget clicks.</li>
|
||||
<li>Solve cursor flakiness after undo/redo.</li>
|
||||
<li>Fix block-reindent ignoring the last few lines.</li>
|
||||
<li>Fix parsing of multi-line attrs in XML mode.</li>
|
||||
<li>Use <code>innerHTML</code> for HTML-escaping.</li>
|
||||
<li>Some fixes to indentation in C-like mode.</li>
|
||||
<li>Shrink horiz scrollbars when long lines removed.</li>
|
||||
<li>Fix width feedback loop bug that caused the width of an inner DIV to shrink.</li>
|
||||
</ul>
|
||||
|
||||
<p><a href="doc/oldrelease.html">Older releases...</a></p>
|
||||
|
||||
</div></div>
|
||||
|
||||
<div style="height: 2em"> </div>
|
||||
|
||||
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="paypal">
|
||||
<input type="hidden" name="cmd" value="_s-xclick"/>
|
||||
<input type="hidden" name="hosted_button_id" value="3FVHS5FGUY7CC"/>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
/* This is needed to prevent an IE[67] bug where the scrolled content
|
||||
is visible outside of the scrolling box. */
|
||||
position: relative;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.CodeMirror-gutter {
|
||||
@@ -27,6 +28,7 @@
|
||||
}
|
||||
.CodeMirror-lines {
|
||||
padding: .4em;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.CodeMirror pre {
|
||||
@@ -1,4 +1,4 @@
|
||||
// CodeMirror version 2.22
|
||||
// CodeMirror version 2.23
|
||||
//
|
||||
// All functions that need access to the editor's state live inside
|
||||
// the CodeMirror function. Below that, at the bottom of the file,
|
||||
@@ -15,9 +15,8 @@ var CodeMirror = (function() {
|
||||
if (defaults.hasOwnProperty(opt))
|
||||
options[opt] = (givenOptions && givenOptions.hasOwnProperty(opt) ? givenOptions : defaults)[opt];
|
||||
|
||||
var targetDocument = options["document"];
|
||||
// The element in which the editor lives.
|
||||
var wrapper = targetDocument.createElement("div");
|
||||
var wrapper = document.createElement("div");
|
||||
wrapper.className = "CodeMirror" + (options.lineWrapping ? " CodeMirror-wrap" : "");
|
||||
// This mess creates the base DOM structure for the editor.
|
||||
wrapper.innerHTML =
|
||||
@@ -48,7 +47,10 @@ var CodeMirror = (function() {
|
||||
if (!webkit) lineSpace.draggable = true;
|
||||
lineSpace.style.outline = "none";
|
||||
if (options.tabindex != null) input.tabIndex = options.tabindex;
|
||||
if (options.autofocus) focusInput();
|
||||
if (!options.gutter && !options.lineNumbers) gutter.style.display = "none";
|
||||
// Needed to handle Tab key in KHTML
|
||||
if (khtml) inputDiv.style.height = "1px", inputDiv.style.position = "absolute";
|
||||
|
||||
// Check for problem with IE innerHTML not working when we have a
|
||||
// P (or similar) parent node.
|
||||
@@ -81,12 +83,13 @@ var CodeMirror = (function() {
|
||||
gutterDirty, callbacks;
|
||||
// Current visible range (may be bigger than the view window).
|
||||
var displayOffset = 0, showingFrom = 0, showingTo = 0, lastSizeC = 0;
|
||||
// bracketHighlighted is used to remember that a backet has been
|
||||
// bracketHighlighted is used to remember that a bracket has been
|
||||
// marked.
|
||||
var bracketHighlighted;
|
||||
// Tracks the maximum line length so that the horizontal scrollbar
|
||||
// can be kept static when scrolling.
|
||||
var maxLine = "", maxWidth;
|
||||
var tabCache = {};
|
||||
|
||||
// Initialize the content.
|
||||
operation(function(){setValue(options.value || ""); updateInput = false;})();
|
||||
@@ -124,10 +127,16 @@ var CodeMirror = (function() {
|
||||
if (!options.readOnly) replaceSelection("");
|
||||
}));
|
||||
|
||||
// Needed to handle Tab key in KHTML
|
||||
if (khtml) connect(code, "mouseup", function() {
|
||||
if (document.activeElement == input) input.blur();
|
||||
focusInput();
|
||||
});
|
||||
|
||||
// IE throws unspecified error in certain cases, when
|
||||
// trying to access activeElement before onload
|
||||
var hasFocus; try { hasFocus = (targetDocument.activeElement == input); } catch(e) { }
|
||||
if (hasFocus) setTimeout(onFocus, 20);
|
||||
var hasFocus; try { hasFocus = (document.activeElement == input); } catch(e) { }
|
||||
if (hasFocus || options.autofocus) setTimeout(onFocus, 20);
|
||||
else onBlur();
|
||||
|
||||
function isLine(l) {return l >= 0 && l < doc.size;}
|
||||
@@ -178,17 +187,23 @@ var CodeMirror = (function() {
|
||||
line = clipLine(line == null ? doc.size - 1: line);
|
||||
return getStateBefore(line + 1);
|
||||
},
|
||||
cursorCoords: function(start){
|
||||
cursorCoords: function(start, mode) {
|
||||
if (start == null) start = sel.inverted;
|
||||
return pageCoords(start ? sel.from : sel.to);
|
||||
return this.charCoords(start ? sel.from : sel.to, mode);
|
||||
},
|
||||
charCoords: function(pos, mode) {
|
||||
pos = clipPos(pos);
|
||||
if (mode == "local") return localCoords(pos, false);
|
||||
if (mode == "div") return localCoords(pos, true);
|
||||
return pageCoords(pos);
|
||||
},
|
||||
charCoords: function(pos){return pageCoords(clipPos(pos));},
|
||||
coordsChar: function(coords) {
|
||||
var off = eltOffset(lineSpace);
|
||||
return coordsChar(coords.x - off.left, coords.y - off.top);
|
||||
},
|
||||
markText: operation(markText),
|
||||
setBookmark: setBookmark,
|
||||
findMarksAt: findMarksAt,
|
||||
setMarker: operation(addGutterMarker),
|
||||
clearMarker: operation(removeGutterMarker),
|
||||
setLineClass: operation(setLineClass),
|
||||
@@ -256,6 +271,7 @@ var CodeMirror = (function() {
|
||||
replaceRange: operation(replaceRange),
|
||||
getRange: function(from, to) {return getRange(clipPos(from), clipPos(to));},
|
||||
|
||||
triggerOnKeyDown: operation(onKeyDown),
|
||||
execCommand: function(cmd) {return commands[cmd](instance);},
|
||||
// Stuff used by commands, probably not much use to outside code.
|
||||
moveH: operation(moveH),
|
||||
@@ -373,7 +389,7 @@ var CodeMirror = (function() {
|
||||
!posLess(start, sel.from) && !posLess(sel.to, start)) {
|
||||
// Let the drag handler handle this.
|
||||
if (webkit) lineSpace.draggable = true;
|
||||
var up = connect(targetDocument, "mouseup", operation(function(e2) {
|
||||
var up = connect(document, "mouseup", operation(function(e2) {
|
||||
if (webkit) lineSpace.draggable = false;
|
||||
draggingText = false;
|
||||
up();
|
||||
@@ -384,6 +400,8 @@ var CodeMirror = (function() {
|
||||
}
|
||||
}), true);
|
||||
draggingText = true;
|
||||
// IE's approach to draggable
|
||||
if (lineSpace.dragDrop) lineSpace.dragDrop();
|
||||
return;
|
||||
}
|
||||
e_preventDefault(e);
|
||||
@@ -402,12 +420,7 @@ var CodeMirror = (function() {
|
||||
}
|
||||
}
|
||||
|
||||
var move = connect(targetDocument, "mousemove", operation(function(e) {
|
||||
clearTimeout(going);
|
||||
e_preventDefault(e);
|
||||
extend(e);
|
||||
}), true);
|
||||
var up = connect(targetDocument, "mouseup", operation(function(e) {
|
||||
function done(e) {
|
||||
clearTimeout(going);
|
||||
var cur = posFromMouse(e);
|
||||
if (cur) setSelectionUser(start, cur);
|
||||
@@ -415,7 +428,14 @@ var CodeMirror = (function() {
|
||||
focusInput();
|
||||
updateInput = true;
|
||||
move(); up();
|
||||
}
|
||||
var move = connect(document, "mousemove", operation(function(e) {
|
||||
clearTimeout(going);
|
||||
e_preventDefault(e);
|
||||
if (!ie && !e_button(e)) done(e);
|
||||
else extend(e);
|
||||
}), true);
|
||||
var up = connect(document, "mouseup", operation(done), true);
|
||||
}
|
||||
function onDoubleClick(e) {
|
||||
for (var n = e_target(e); n != wrapper; n = n.parentNode)
|
||||
@@ -464,11 +484,14 @@ var CodeMirror = (function() {
|
||||
}
|
||||
function onDragStart(e) {
|
||||
var txt = getSelection();
|
||||
// Disabled until further notice. Doesn't work on most browsers,
|
||||
// and crashes Safari (issue #332).
|
||||
//htmlEscape(txt);
|
||||
//e.dataTransfer.setDragImage(escapeElement, 0, 0);
|
||||
e.dataTransfer.setData("Text", txt);
|
||||
|
||||
// Use dummy image instead of default browsers image.
|
||||
if (gecko || chrome) {
|
||||
var img = document.createElement('img');
|
||||
img.scr = 'data:image/gif;base64,R0lGODdhAgACAIAAAAAAAP///ywAAAAAAgACAAACAoRRADs='; //1x1 image
|
||||
e.dataTransfer.setDragImage(img, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
function doHandleBinding(bound, dropShift) {
|
||||
@@ -506,13 +529,19 @@ var CodeMirror = (function() {
|
||||
if (e_prop(e, "ctrlKey")) name = "Ctrl-" + name;
|
||||
if (e_prop(e, "metaKey")) name = "Cmd-" + name;
|
||||
|
||||
if (e_prop(e, "shiftKey"))
|
||||
if (e_prop(e, "shiftKey")) {
|
||||
handled = lookupKey("Shift-" + name, options.extraKeys, options.keyMap,
|
||||
function(b) {return doHandleBinding(b, true);});
|
||||
if (!handled)
|
||||
function(b) {return doHandleBinding(b, true);})
|
||||
|| lookupKey(name, options.extraKeys, options.keyMap, function(b) {
|
||||
if (typeof b == "string" && /^go[A-Z]/.test(b)) return doHandleBinding(b);
|
||||
});
|
||||
} else {
|
||||
handled = lookupKey(name, options.extraKeys, options.keyMap, doHandleBinding);
|
||||
|
||||
if (handled) e_preventDefault(e);
|
||||
}
|
||||
if (handled) {
|
||||
e_preventDefault(e);
|
||||
if (ie) { e.oldKeyCode = e.keyCode; e.keyCode = 0; }
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
function handleCharBinding(e, ch) {
|
||||
@@ -545,7 +574,7 @@ var CodeMirror = (function() {
|
||||
if (options.onKeyEvent && options.onKeyEvent(instance, addStop(e))) return;
|
||||
var keyCode = e_prop(e, "keyCode"), charCode = e_prop(e, "charCode");
|
||||
if (window.opera && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;}
|
||||
if (window.opera && !e.which && handleKeyBinding(e)) return;
|
||||
if (((window.opera && !e.which) || khtml) && handleKeyBinding(e)) return;
|
||||
var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
|
||||
if (options.electricChars && mode.electricChars && options.smartIndent && !options.readOnly) {
|
||||
if (mode.electricChars.indexOf(ch) > -1)
|
||||
@@ -837,11 +866,11 @@ var CodeMirror = (function() {
|
||||
return scrollIntoView(x, cursor.y, x, cursor.yBot);
|
||||
}
|
||||
function scrollIntoView(x1, y1, x2, y2) {
|
||||
var pl = paddingLeft(), pt = paddingTop(), lh = textHeight();
|
||||
var pl = paddingLeft(), pt = paddingTop();
|
||||
y1 += pt; y2 += pt; x1 += pl; x2 += pl;
|
||||
var screen = scroller.clientHeight, screentop = scroller.scrollTop, scrolled = false, result = true;
|
||||
if (y1 < screentop) {scroller.scrollTop = Math.max(0, y1 - 2*lh); scrolled = true;}
|
||||
else if (y2 > screentop + screen) {scroller.scrollTop = y2 + lh - screen; scrolled = true;}
|
||||
if (y1 < screentop) {scroller.scrollTop = Math.max(0, y1); scrolled = true;}
|
||||
else if (y2 > screentop + screen) {scroller.scrollTop = y2 - screen; scrolled = true;}
|
||||
|
||||
var screenw = scroller.clientWidth, screenleft = scroller.scrollLeft;
|
||||
var gutterw = options.fixedGutter ? gutter.clientWidth : 0;
|
||||
@@ -921,7 +950,7 @@ var CodeMirror = (function() {
|
||||
throw new Error("BAD PATCH! " + JSON.stringify(intact) + " size=" + (showingTo - showingFrom) +
|
||||
" nodes=" + lineDiv.childNodes.length);
|
||||
|
||||
if (options.lineWrapping) {
|
||||
function checkHeights() {
|
||||
maxWidth = scroller.clientWidth;
|
||||
var curNode = lineDiv.firstChild, heightChanged = false;
|
||||
doc.iter(showingFrom, showingTo, function(line) {
|
||||
@@ -936,6 +965,11 @@ var CodeMirror = (function() {
|
||||
});
|
||||
if (heightChanged)
|
||||
code.style.height = (doc.height * th + 2 * paddingTop()) + "px";
|
||||
return heightChanged;
|
||||
}
|
||||
|
||||
if (options.lineWrapping) {
|
||||
checkHeights();
|
||||
} else {
|
||||
if (maxWidth == null) maxWidth = stringWidth(maxLine);
|
||||
if (maxWidth > scroller.clientWidth) {
|
||||
@@ -947,8 +981,12 @@ var CodeMirror = (function() {
|
||||
lineSpace.style.width = code.style.width = "";
|
||||
}
|
||||
}
|
||||
|
||||
gutter.style.display = gutterDisplay;
|
||||
if (different || gutterDirty) updateGutter();
|
||||
if (different || gutterDirty) {
|
||||
// If the gutter grew in size, re-check heights. If those changed, re-draw gutter.
|
||||
updateGutter() && options.lineWrapping && checkHeights() && updateGutter();
|
||||
}
|
||||
updateSelection();
|
||||
if (!suppressCallback && options.onUpdate) options.onUpdate(instance);
|
||||
return true;
|
||||
@@ -996,16 +1034,17 @@ var CodeMirror = (function() {
|
||||
}
|
||||
// This pass fills in the lines that actually changed.
|
||||
var nextIntact = intact.shift(), curNode = lineDiv.firstChild, j = from;
|
||||
var scratch = targetDocument.createElement("div"), newElt;
|
||||
var scratch = document.createElement("div");
|
||||
doc.iter(from, to, function(line) {
|
||||
if (nextIntact && nextIntact.to == j) nextIntact = intact.shift();
|
||||
if (!nextIntact || nextIntact.from > j) {
|
||||
if (line.hidden) var html = scratch.innerHTML = "<pre></pre>";
|
||||
else {
|
||||
var html = '<pre>' + line.getHTML(makeTab) + '</pre>';
|
||||
var html = '<pre' + (line.className ? ' class="' + line.className + '"' : '') + '>'
|
||||
+ line.getHTML(makeTab) + '</pre>';
|
||||
// Kludge to make sure the styled element lies behind the selection (by z-index)
|
||||
if (line.className)
|
||||
html = '<div style="position: relative"><pre class="' + line.className +
|
||||
if (line.bgClassName)
|
||||
html = '<div style="position: relative"><pre class="' + line.bgClassName +
|
||||
'" style="position: absolute; left: 0; right: 0; top: 0; bottom: 0; z-index: -2"> </pre>' + html + "</div>";
|
||||
}
|
||||
scratch.innerHTML = html;
|
||||
@@ -1021,7 +1060,7 @@ var CodeMirror = (function() {
|
||||
if (!options.gutter && !options.lineNumbers) return;
|
||||
var hText = mover.offsetHeight, hEditor = scroller.clientHeight;
|
||||
gutter.style.height = (hText - hEditor < 2 ? hEditor : hText) + "px";
|
||||
var html = [], i = showingFrom;
|
||||
var html = [], i = showingFrom, normalNode;
|
||||
doc.iter(showingFrom, Math.max(showingTo, showingFrom + 1), function(line) {
|
||||
if (line.hidden) {
|
||||
html.push("<pre></pre>");
|
||||
@@ -1035,17 +1074,24 @@ var CodeMirror = (function() {
|
||||
html.push((marker && marker.style ? '<pre class="' + marker.style + '">' : "<pre>"), text);
|
||||
for (var j = 1; j < line.height; ++j) html.push("<br/> ");
|
||||
html.push("</pre>");
|
||||
if (!marker) normalNode = i;
|
||||
}
|
||||
++i;
|
||||
});
|
||||
gutter.style.display = "none";
|
||||
gutterText.innerHTML = html.join("");
|
||||
var minwidth = String(doc.size).length, firstNode = gutterText.firstChild, val = eltText(firstNode), pad = "";
|
||||
while (val.length + pad.length < minwidth) pad += "\u00a0";
|
||||
if (pad) firstNode.insertBefore(targetDocument.createTextNode(pad), firstNode.firstChild);
|
||||
// Make sure scrolling doesn't cause number gutter size to pop
|
||||
if (normalNode != null) {
|
||||
var node = gutterText.childNodes[normalNode - showingFrom];
|
||||
var minwidth = String(doc.size).length, val = eltText(node), pad = "";
|
||||
while (val.length + pad.length < minwidth) pad += "\u00a0";
|
||||
if (pad) node.insertBefore(document.createTextNode(pad), node.firstChild);
|
||||
}
|
||||
gutter.style.display = "";
|
||||
var resized = Math.abs((parseInt(lineSpace.style.marginLeft) || 0) - gutter.offsetWidth) > 2;
|
||||
lineSpace.style.marginLeft = gutter.offsetWidth + "px";
|
||||
gutterDirty = false;
|
||||
return resized;
|
||||
}
|
||||
function updateSelection() {
|
||||
var collapsed = posEq(sel.from, sel.to);
|
||||
@@ -1066,16 +1112,18 @@ var CodeMirror = (function() {
|
||||
html += '<div class="CodeMirror-selected" style="position: absolute; left: ' + left +
|
||||
'px; top: ' + top + 'px; right: ' + right + 'px; height: ' + height + 'px"></div>';
|
||||
}
|
||||
var clientWidth = lineSpace.clientWidth || lineSpace.offsetWidth;
|
||||
var clientHeight = lineSpace.clientHeight || lineSpace.offsetHeight;
|
||||
if (sel.from.ch && fromPos.y >= 0) {
|
||||
var right = sameLine ? lineSpace.clientWidth - toPos.x : 0;
|
||||
var right = sameLine ? clientWidth - toPos.x : 0;
|
||||
add(fromPos.x, fromPos.y, right, th);
|
||||
}
|
||||
var middleStart = Math.max(0, fromPos.y + (sel.from.ch ? th : 0));
|
||||
var middleHeight = Math.min(toPos.y, lineSpace.clientHeight) - middleStart;
|
||||
var middleHeight = Math.min(toPos.y, clientHeight) - middleStart;
|
||||
if (middleHeight > 0.2 * th)
|
||||
add(0, middleStart, 0, middleHeight);
|
||||
if ((!sameLine || !sel.from.ch) && toPos.y < lineSpace.clientHeight - .5 * th)
|
||||
add(0, toPos.y, lineSpace.clientWidth - toPos.x, th);
|
||||
if ((!sameLine || !sel.from.ch) && toPos.y < clientHeight - .5 * th)
|
||||
add(0, toPos.y, clientWidth - toPos.x, th);
|
||||
selectionDiv.innerHTML = html;
|
||||
cursor.style.display = "none";
|
||||
selectionDiv.style.display = "";
|
||||
@@ -1105,7 +1153,12 @@ var CodeMirror = (function() {
|
||||
if (posLess(to, from)) {var tmp = to; to = from; from = tmp;}
|
||||
|
||||
// Skip over hidden lines.
|
||||
if (from.line != oldFrom) from = skipHidden(from, oldFrom, sel.from.ch);
|
||||
if (from.line != oldFrom) {
|
||||
var from1 = skipHidden(from, oldFrom, sel.from.ch);
|
||||
// If there is no non-hidden line left, force visibility on current line
|
||||
if (!from1) setLineHidden(from.line, false);
|
||||
else from = from1;
|
||||
}
|
||||
if (to.line != oldTo) to = skipHidden(to, oldTo, sel.to.ch);
|
||||
|
||||
if (posEq(from, to)) sel.inverted = false;
|
||||
@@ -1114,7 +1167,7 @@ var CodeMirror = (function() {
|
||||
|
||||
if (options.autoClearEmptyLines && posEq(sel.from, sel.to)) {
|
||||
var head = sel.inverted ? from : to;
|
||||
if (head.line != sel.from.line) {
|
||||
if (head.line != sel.from.line && sel.from.line < doc.size) {
|
||||
var oldLine = getLine(sel.from.line);
|
||||
if (/^\s+$/.test(oldLine.text))
|
||||
setTimeout(operation(function() {
|
||||
@@ -1209,6 +1262,7 @@ var CodeMirror = (function() {
|
||||
if (unit == "page") dist = Math.min(scroller.clientHeight, window.innerHeight || document.documentElement.clientHeight);
|
||||
else if (unit == "line") dist = textHeight();
|
||||
var target = coordsChar(pos.x, pos.y + dist * dir + 2);
|
||||
if (unit == "page") scroller.scrollTop += localCoords(target, true).y - pos.y;
|
||||
setCursor(target.line, target.ch, true);
|
||||
goalColumn = pos.x;
|
||||
}
|
||||
@@ -1295,9 +1349,10 @@ var CodeMirror = (function() {
|
||||
changes.push({from: 0, to: doc.size});
|
||||
}
|
||||
function makeTab(col) {
|
||||
var w = options.tabSize - col % options.tabSize;
|
||||
var w = options.tabSize - col % options.tabSize, cached = tabCache[w];
|
||||
if (cached) return cached;
|
||||
for (var str = '<span class="cm-tab">', i = 0; i < w; ++i) str += " ";
|
||||
return {html: str + "</span>", width: w};
|
||||
return (tabCache[w] = {html: str + "</span>", width: w});
|
||||
}
|
||||
function themeChanged() {
|
||||
scroller.className = scroller.className.replace(/\s*cm-s-\w+/g, "") +
|
||||
@@ -1313,7 +1368,7 @@ var CodeMirror = (function() {
|
||||
var lineN = lineNo(line);
|
||||
min = Math.min(min, lineN); max = Math.max(max, lineN);
|
||||
for (var j = 0; j < mk.length; ++j)
|
||||
if (mk[j].set == this.set) mk.splice(j--, 1);
|
||||
if (mk[j].marker == this) mk.splice(j--, 1);
|
||||
}
|
||||
if (min != Infinity)
|
||||
changes.push({from: min, to: max + 1});
|
||||
@@ -1324,7 +1379,7 @@ var CodeMirror = (function() {
|
||||
var line = this.set[i], mk = line.marked;
|
||||
for (var j = 0; j < mk.length; ++j) {
|
||||
var mark = mk[j];
|
||||
if (mark.set == this.set) {
|
||||
if (mark.marker == this) {
|
||||
if (mark.from != null || mark.to != null) {
|
||||
var found = lineNo(line);
|
||||
if (found != null) {
|
||||
@@ -1341,8 +1396,9 @@ var CodeMirror = (function() {
|
||||
function markText(from, to, className) {
|
||||
from = clipPos(from); to = clipPos(to);
|
||||
var tm = new TextMarker();
|
||||
if (!posLess(from, to)) return tm;
|
||||
function add(line, from, to, className) {
|
||||
getLine(line).addMark(new MarkedText(from, to, className, tm.set));
|
||||
getLine(line).addMark(new MarkedText(from, to, className, tm));
|
||||
}
|
||||
if (from.line == to.line) add(from.line, from.ch, to.ch, className);
|
||||
else {
|
||||
@@ -1362,6 +1418,19 @@ var CodeMirror = (function() {
|
||||
return bm;
|
||||
}
|
||||
|
||||
function findMarksAt(pos) {
|
||||
pos = clipPos(pos);
|
||||
var markers = [], marked = getLine(pos.line).marked;
|
||||
if (!marked) return markers;
|
||||
for (var i = 0, e = marked.length; i < e; ++i) {
|
||||
var m = marked[i];
|
||||
if ((m.from == null || m.from <= pos.ch) &&
|
||||
(m.to == null || m.to >= pos.ch))
|
||||
markers.push(m.marker || m);
|
||||
}
|
||||
return markers;
|
||||
}
|
||||
|
||||
function addGutterMarker(line, text, className) {
|
||||
if (typeof line == "number") line = getLine(clipLine(line));
|
||||
line.gutterMarker = {text: text, style: className};
|
||||
@@ -1383,10 +1452,11 @@ var CodeMirror = (function() {
|
||||
else return null;
|
||||
return line;
|
||||
}
|
||||
function setLineClass(handle, className) {
|
||||
function setLineClass(handle, className, bgClassName) {
|
||||
return changeLine(handle, function(line) {
|
||||
if (line.className != className) {
|
||||
if (line.className != className || line.bgClassName != bgClassName) {
|
||||
line.className = className;
|
||||
line.bgClassName = bgClassName;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@@ -1400,6 +1470,8 @@ var CodeMirror = (function() {
|
||||
if (hidden && (fline == no || tline == no)) {
|
||||
var from = fline == no ? skipHidden({line: fline, ch: 0}, fline, 0) : sel.from;
|
||||
var to = tline == no ? skipHidden({line: tline, ch: 0}, tline, 0) : sel.to;
|
||||
// Can't hide the last visible line, we'd have no place to put the cursor
|
||||
if (!to) return;
|
||||
setSelection(from, to);
|
||||
}
|
||||
return (gutterDirty = true);
|
||||
@@ -1420,7 +1492,7 @@ var CodeMirror = (function() {
|
||||
}
|
||||
var marker = line.gutterMarker;
|
||||
return {line: n, handle: line, text: line.text, markerText: marker && marker.text,
|
||||
markerClass: marker && marker.style, lineClass: line.className};
|
||||
markerClass: marker && marker.style, lineClass: line.className, bgClass: line.bgClassName};
|
||||
}
|
||||
|
||||
function stringWidth(str) {
|
||||
@@ -1464,7 +1536,7 @@ var CodeMirror = (function() {
|
||||
var extra = "";
|
||||
// Include extra text at the end to make sure the measured line is wrapped in the right way.
|
||||
if (options.lineWrapping) {
|
||||
var end = line.text.indexOf(" ", ch + 2);
|
||||
var end = line.text.indexOf(" ", ch + 6);
|
||||
extra = htmlEscape(line.text.slice(ch + 1, end < 0 ? line.text.length : end + (ie ? 5 : 0)));
|
||||
}
|
||||
measure.innerHTML = "<pre>" + line.getHTML(makeTab, ch) +
|
||||
@@ -1823,7 +1895,7 @@ var CodeMirror = (function() {
|
||||
pollInterval: 100,
|
||||
undoDepth: 40,
|
||||
tabindex: null,
|
||||
document: window.document
|
||||
autofocus: null
|
||||
};
|
||||
|
||||
var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
|
||||
@@ -1831,7 +1903,7 @@ var CodeMirror = (function() {
|
||||
var win = /Win/.test(navigator.platform);
|
||||
|
||||
// Known modes, by name and by MIME
|
||||
var modes = {}, mimeModes = {};
|
||||
var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {};
|
||||
CodeMirror.defineMode = function(name, mode) {
|
||||
if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name;
|
||||
modes[name] = mode;
|
||||
@@ -1842,6 +1914,8 @@ var CodeMirror = (function() {
|
||||
CodeMirror.resolveMode = function(spec) {
|
||||
if (typeof spec == "string" && mimeModes.hasOwnProperty(spec))
|
||||
spec = mimeModes[spec];
|
||||
else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec))
|
||||
return CodeMirror.resolveMode("application/xml");
|
||||
if (typeof spec == "string") return {name: spec};
|
||||
else return spec || {name: "null"};
|
||||
};
|
||||
@@ -1926,7 +2000,7 @@ var CodeMirror = (function() {
|
||||
keyMap.basic = {
|
||||
"Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
|
||||
"End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
|
||||
"Delete": "delCharRight", "Backspace": "delCharLeft", "Tab": "indentMore", "Shift-Tab": "indentLess",
|
||||
"Delete": "delCharRight", "Backspace": "delCharLeft", "Tab": "insertTab", "Shift-Tab": "indentAuto",
|
||||
"Enter": "newlineAndIndent", "Insert": "toggleOverwrite"
|
||||
};
|
||||
// Note that the save and find-related commands aren't defined by
|
||||
@@ -1937,6 +2011,7 @@ var CodeMirror = (function() {
|
||||
"Ctrl-Left": "goWordLeft", "Ctrl-Right": "goWordRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
|
||||
"Ctrl-Backspace": "delWordLeft", "Ctrl-Delete": "delWordRight", "Ctrl-S": "save", "Ctrl-F": "find",
|
||||
"Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
|
||||
"Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
|
||||
fallthrough: "basic"
|
||||
};
|
||||
keyMap.macDefault = {
|
||||
@@ -1945,6 +2020,7 @@ var CodeMirror = (function() {
|
||||
"Alt-Right": "goWordRight", "Cmd-Left": "goLineStart", "Cmd-Right": "goLineEnd", "Alt-Backspace": "delWordLeft",
|
||||
"Ctrl-Alt-Backspace": "delWordRight", "Alt-Delete": "delWordRight", "Cmd-S": "save", "Cmd-F": "find",
|
||||
"Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
|
||||
"Cmd-[": "indentLess", "Cmd-]": "indentMore",
|
||||
fallthrough: ["basic", "emacsy"]
|
||||
};
|
||||
keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault;
|
||||
@@ -1987,6 +2063,8 @@ var CodeMirror = (function() {
|
||||
options.value = textarea.value;
|
||||
if (!options.tabindex && textarea.tabindex)
|
||||
options.tabindex = textarea.tabindex;
|
||||
if (options.autofocus == null && textarea.getAttribute("autofocus") != null)
|
||||
options.autofocus = true;
|
||||
|
||||
function save() {textarea.value = instance.getValue();}
|
||||
if (textarea.form) {
|
||||
@@ -2098,34 +2176,34 @@ var CodeMirror = (function() {
|
||||
};
|
||||
CodeMirror.StringStream = StringStream;
|
||||
|
||||
function MarkedText(from, to, className, set) {
|
||||
this.from = from; this.to = to; this.style = className; this.set = set;
|
||||
function MarkedText(from, to, className, marker) {
|
||||
this.from = from; this.to = to; this.style = className; this.marker = marker;
|
||||
}
|
||||
MarkedText.prototype = {
|
||||
attach: function(line) { this.set.push(line); },
|
||||
attach: function(line) { this.marker.set.push(line); },
|
||||
detach: function(line) {
|
||||
var ix = indexOf(this.set, line);
|
||||
if (ix > -1) this.set.splice(ix, 1);
|
||||
var ix = indexOf(this.marker.set, line);
|
||||
if (ix > -1) this.marker.set.splice(ix, 1);
|
||||
},
|
||||
split: function(pos, lenBefore) {
|
||||
if (this.to <= pos && this.to != null) return null;
|
||||
var from = this.from < pos || this.from == null ? null : this.from - pos + lenBefore;
|
||||
var to = this.to == null ? null : this.to - pos + lenBefore;
|
||||
return new MarkedText(from, to, this.style, this.set);
|
||||
return new MarkedText(from, to, this.style, this.marker);
|
||||
},
|
||||
dup: function() { return new MarkedText(null, null, this.style, this.set); },
|
||||
dup: function() { return new MarkedText(null, null, this.style, this.marker); },
|
||||
clipTo: function(fromOpen, from, toOpen, to, diff) {
|
||||
if (this.from != null && this.from >= from)
|
||||
this.from = Math.max(to, this.from) + diff;
|
||||
if (this.to != null && this.to > from)
|
||||
this.to = to < this.to ? this.to + diff : from;
|
||||
if (fromOpen && to > this.from && (to < this.to || this.to == null))
|
||||
this.from = null;
|
||||
else if (this.from != null && this.from >= from)
|
||||
this.from = Math.max(to, this.from) + diff;
|
||||
if (toOpen && (from < this.to || this.to == null) && (from > this.from || this.from == null))
|
||||
this.to = null;
|
||||
else if (this.to != null && this.to > from)
|
||||
this.to = to < this.to ? this.to + diff : from;
|
||||
},
|
||||
isDead: function() { return this.from != null && this.to != null && this.from >= this.to; },
|
||||
sameSet: function(x) { return this.set == x.set; }
|
||||
sameSet: function(x) { return this.marker == x.marker; }
|
||||
};
|
||||
|
||||
function Bookmark(pos) {
|
||||
@@ -2168,7 +2246,7 @@ var CodeMirror = (function() {
|
||||
this.styles = styles || [text, null];
|
||||
this.text = text;
|
||||
this.height = 1;
|
||||
this.marked = this.gutterMarker = this.className = this.handlers = null;
|
||||
this.marked = this.gutterMarker = this.className = this.bgClassName = this.handlers = null;
|
||||
this.stateAfter = this.parent = this.hidden = null;
|
||||
}
|
||||
Line.inheritMarks = function(text, orig) {
|
||||
@@ -2214,6 +2292,7 @@ var CodeMirror = (function() {
|
||||
if (newmark) {
|
||||
if (!taken.marked) taken.marked = [];
|
||||
taken.marked.push(newmark); newmark.attach(taken);
|
||||
if (newmark == mark) mk.splice(i--, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2637,10 +2716,10 @@ var CodeMirror = (function() {
|
||||
if (start < last.start) {
|
||||
for (var i = last.start - start - 1; i >= 0; --i)
|
||||
last.old.unshift(old[i]);
|
||||
last.added += last.start - start;
|
||||
oldoff = Math.min(0, added - old.length);
|
||||
last.added += last.start - start + oldoff;
|
||||
last.start = start;
|
||||
}
|
||||
else if (last.start < start) {
|
||||
} else if (last.start < start) {
|
||||
oldoff = start - last.start;
|
||||
added += oldoff;
|
||||
}
|
||||
@@ -2707,19 +2786,21 @@ var CodeMirror = (function() {
|
||||
|
||||
var Pass = CodeMirror.Pass = {toString: function(){return "CodeMirror.Pass";}};
|
||||
|
||||
// Detect drag-and-drop
|
||||
var dragAndDrop = function() {
|
||||
// IE8 has ondragstart and ondrop properties, but doesn't seem to
|
||||
// actually support ondragstart the way it's supposed to work.
|
||||
if (/MSIE [1-8]\b/.test(navigator.userAgent)) return false;
|
||||
var div = document.createElement('div');
|
||||
return "draggable" in div;
|
||||
}();
|
||||
|
||||
var gecko = /gecko\/\d{7}/i.test(navigator.userAgent);
|
||||
var ie = /MSIE \d/.test(navigator.userAgent);
|
||||
var ie_lt9 = /MSIE [1-8]\b/.test(navigator.userAgent);
|
||||
var webkit = /WebKit\//.test(navigator.userAgent);
|
||||
var chrome = /Chrome\//.test(navigator.userAgent);
|
||||
var khtml = /KHTML\//.test(navigator.userAgent);
|
||||
|
||||
// Detect drag-and-drop
|
||||
var dragAndDrop = function() {
|
||||
// There is *some* kind of drag-and-drop support in IE6-8, but I
|
||||
// couldn't get it to work yet.
|
||||
if (ie_lt9) return false;
|
||||
var div = document.createElement('div');
|
||||
return "draggable" in div || "dragDrop" in div;
|
||||
}();
|
||||
|
||||
var lineSep = "\n";
|
||||
// Feature-detect whether newlines in textareas are converted to \r\n
|
||||
@@ -2873,7 +2954,7 @@ var CodeMirror = (function() {
|
||||
var keyNames = {3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
|
||||
19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
|
||||
36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
|
||||
46: "Delete", 59: ";", 91: "Mod", 92: "Mod", 93: "Mod", 186: ";", 187: "=", 188: ",",
|
||||
46: "Delete", 59: ";", 91: "Mod", 92: "Mod", 93: "Mod", 127: "Delete", 186: ";", 187: "=", 188: ",",
|
||||
189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", 221: "]", 222: "'", 63276: "PageUp",
|
||||
63277: "PageDown", 63275: "End", 63273: "Home", 63234: "Left", 63232: "Up", 63235: "Right",
|
||||
63233: "Down", 63302: "Insert", 63272: "Delete"};
|
||||
174
CodeMirror-2.23/lib/util/closetag.js
Normal file
@@ -0,0 +1,174 @@
|
||||
/**
|
||||
* 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 });
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -80,7 +80,7 @@ CodeMirror.tagRangeFinder = function(cm, line) {
|
||||
}
|
||||
|
||||
if (found) {
|
||||
var startTag = "(\\<\\/" + tag + "\\>)|(\\<" + tag + "\\>)|(\\<" + tag + "\s)|(\\<" + tag + "$)";
|
||||
var startTag = "(\\<\\/" + tag + "\\>)|(\\<" + tag + "\\>)|(\\<" + tag + "\\s)|(\\<" + tag + "$)";
|
||||
var startTagRegExp = new RegExp(startTag, "g");
|
||||
var endTag = "</" + tag + ">";
|
||||
var depth = 1;
|
||||
@@ -1,4 +1,4 @@
|
||||
// ============== Formatting extensions ============================
|
||||
// ============== Formatting extensions ============================
|
||||
// A common storage for all mode-specific formatting features
|
||||
if (!CodeMirror.modeExtensions) CodeMirror.modeExtensions = {};
|
||||
|
||||
@@ -113,8 +113,10 @@
|
||||
base = 1;
|
||||
else if (obj.className == "function") {
|
||||
if (window.jQuery != null && (obj.string == '$' || obj.string == 'jQuery') &&
|
||||
(typeof jQuery == 'function')) base = jQuery();
|
||||
else if (window._ != null && (obj.string == '_') && (typeof _ == 'function')) base = _();
|
||||
(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];
|
||||
@@ -29,6 +29,10 @@
|
||||
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";
|
||||
@@ -53,6 +57,8 @@
|
||||
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);
|
||||
}
|
||||
});
|
||||
@@ -96,6 +96,6 @@ void* zmq_thread_init(void* zmq_context, int signal_fd) {
|
||||
<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).</p>
|
||||
code), <code>text/x-csharp</code> (C#).</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -92,7 +92,7 @@ CodeMirror.defineMode("css", function(config) {
|
||||
var style = state.tokenize(stream, state);
|
||||
|
||||
var context = state.stack[state.stack.length-1];
|
||||
if (type == "hash" && context == "rule") style = "atom";
|
||||
if (type == "hash" && context != "rule") style = "string-2";
|
||||
else if (style == "variable") {
|
||||
if (context == "rule") style = "number";
|
||||
else if (!context || context == "@media{") style = "tag";
|
||||
@@ -319,8 +319,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
kwAllowed: true,
|
||||
cc: [],
|
||||
lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
|
||||
localVars: null,
|
||||
context: null,
|
||||
localVars: parserConfig.localVars,
|
||||
context: parserConfig.localVars && {vars: parserConfig.localVars},
|
||||
indented: 0
|
||||
};
|
||||
},
|
||||
@@ -334,7 +334,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
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.reAllowed = !!(type == "operator" || type == "keyword c" || type.match(/^[\[{}\(,;:]$/));
|
||||
state.kwAllowed = type != '.';
|
||||
return parseJS(state, style, type, content, stream);
|
||||
},
|
||||
@@ -264,4 +264,5 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("application/xml", "xml");
|
||||
CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
|
||||
if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
|
||||
CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
|
||||
27
editor.php
@@ -74,6 +74,9 @@ function createNewCMInstance(num) {window['cM'+num] = CodeMirror(document.body,
|
||||
canDoEndTag=false;
|
||||
}
|
||||
}
|
||||
if(top.ICEcoder.tagString.slice(0,1)=="/"||top.ICEcoder.tagString.slice(0,1)=="?") {
|
||||
canDoEndTag=false;
|
||||
}
|
||||
fileName = top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1];
|
||||
if (!top.ICEcoder.codeAssist||fileName.indexOf(".js")>0||fileName.indexOf(".css")>0) {
|
||||
canDoEndTag=false;
|
||||
@@ -86,7 +89,8 @@ function createNewCMInstance(num) {window['cM'+num] = CodeMirror(document.body,
|
||||
for (i=0;i<numTabs-1;i++) {
|
||||
tabs += "\t";
|
||||
}
|
||||
endTag = "</" + top.ICEcoder.htmlTagArray[top.ICEcoder.htmlTagArray.length-1] + ">";
|
||||
//endTag = "</" + top.ICEcoder.htmlTagArray[top.ICEcoder.htmlTagArray.length-1] + ">";
|
||||
endTag = "</" + top.ICEcoder.tagString + ">";
|
||||
if (top.ICEcoder.tagString=="script") {endTag="</"+"script>"};
|
||||
if(top.ICEcoder.tagString=="title"||top.ICEcoder.tagString=="a"||top.ICEcoder.tagString=="li"||top.ICEcoder.tagString=="span"||(top.ICEcoder.tagString.slice(0,1)=="h"&&parseInt(top.ICEcoder.tagString.slice(1,2),10)>=1&&parseInt(top.ICEcoder.tagString.slice(1,2),10)<=7)) {
|
||||
window['cM'+top.ICEcoder.cMInstances[top.ICEcoder.selectedTab-1]].replaceSelection(endTag);
|
||||
@@ -102,25 +106,14 @@ function createNewCMInstance(num) {window['cM'+num] = CodeMirror(document.body,
|
||||
};
|
||||
lastKeyCode = e.keyCode;
|
||||
},
|
||||
extraKeys: {"Enter": false}
|
||||
});
|
||||
onGutterClick: top.ICEcoder.foldCode,
|
||||
extraKeys: {"Tab": "indentMore", "Shift-Tab": "indentLess"}
|
||||
});
|
||||
|
||||
// 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");
|
||||
// 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");
|
||||
};
|
||||
|
||||
<?php
|
||||
//for ($i=1;$i<=10;$i++) {
|
||||
?>
|
||||
//cM<?php echo $i;?>.getWrapperElement().getElementsByClassName("CodeMirror-lines")[0].addEventListener("click", function(){
|
||||
// if (top.ICEcoder.results && top.ICEcoder.results.length>0) {
|
||||
// top.document.getElementById('results').innerHTML = top.ICEcoder.results.length + " results";
|
||||
// }
|
||||
// top.ICEcoder.findMode = false;
|
||||
//}, false);
|
||||
<?php
|
||||
//;};
|
||||
?>
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
@@ -95,7 +95,7 @@ function fileManager_dir($directory, $return_link, $first_call=true) {
|
||||
$fileManager .= fileManager_dir("$directory/$this_file", $return_link , false);
|
||||
$fileManager .= "</li>";
|
||||
} else {
|
||||
$fileManager .= "<li class=\"pft-directory\" style=\"cursor: default\"><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: #888888\"> [HIDDEN] ".$fileAtts."</span></li>";
|
||||
}
|
||||
} else {
|
||||
// File
|
||||
@@ -117,7 +117,7 @@ function fileManager_dir($directory, $return_link, $first_call=true) {
|
||||
$chmodInfo = substr(sprintf('%o', fileperms($link)), -4);
|
||||
$fileAtts = '<span style="color: #888888; font-size: 8px">'.$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\"> <span id=\"".str_replace("/","|",str_replace($docRoot,"",$link))."\">" . htmlspecialchars($this_file) . "</span> ".$fileAtts."</a></li>";
|
||||
$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>";
|
||||
@@ -142,14 +142,14 @@ function php4_scandir($dir) {
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html onMouseDown="top.ICEcoder.mouseDown=true" onMouseUp="top.ICEcoder.mouseDown=false" onMouseMove="top.ICEcoder.getMouseXY(event);top.ICEcoder.canResizeFilesW()" onContextMenu="top.ICEcoder.rightClickedFile=top.ICEcoder.thisFileFolderLink; top.ICEcoder.selectFileFolder(); return top.ICEcoder.showMenu()" onClick="top.document.getElementById('fileMenu').style.display='none'">
|
||||
<html onMouseDown="top.ICEcoder.mouseDown=true" onMouseUp="top.ICEcoder.mouseDown=false" onMouseMove="top.ICEcoder.getMouseXY(event);top.ICEcoder.canResizeFilesW()" onContextMenu="top.ICEcoder.rightClickedFile=top.ICEcoder.thisFileFolderLink; top.ICEcoder.selectFileFolder(); return top.ICEcoder.showMenu()" onClick="top.ICEcoder.selectFileFolder()">
|
||||
<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()" onClick="top.ICEcoder.selectFileFolder()" onDblClick="top.ICEcoder.openFile()" onKeyDown="return top.ICEcoder.interceptKeys('files', event);" onKeyUp="top.ICEcoder.resetKeys(event);">
|
||||
<body onLoad="top.ICEcoder.fileManager()" onDblClick="top.ICEcoder.openFile()" onKeyDown="return top.ICEcoder.interceptKeys('files', event);" onKeyUp="top.ICEcoder.resetKeys(event);">
|
||||
<?php
|
||||
echo fileManager($_SERVER['DOCUMENT_ROOT'], "[link]");
|
||||
?>
|
||||
|
||||
BIN
images/delete.png
Normal file
|
After Width: | Height: | Size: 739 B |
BIN
images/new-file.png
Normal file
|
After Width: | Height: | Size: 512 B |
BIN
images/new-folder.png
Normal file
|
After Width: | Height: | Size: 377 B |
BIN
images/open.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
images/rename.png
Normal file
|
After Width: | Height: | Size: 253 B |
BIN
images/save.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
images/view.png
Normal file
|
After Width: | Height: | Size: 982 B |
33
index.php
@@ -63,8 +63,10 @@ echo 'fullPath = "'.$docRoot.'";'.PHP_EOL;
|
||||
</div>
|
||||
|
||||
<div id="fileMenu" class="fileMenu" onMouseOut="this.style.display='none'" onMouseOver="ICEcoder.changeFilesW('expand')" onMouseOut="ICEcoder.changeFilesW('contract')">
|
||||
<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>
|
||||
<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>
|
||||
</span>
|
||||
<a href="javascript:top.ICEcoder.deleteFile(top.ICEcoder.rightClickedFile)" onMouseOver="document.getElementById('fileMenu').style.display='inline-block'">Delete</a>
|
||||
<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>
|
||||
@@ -74,7 +76,8 @@ echo 'fullPath = "'.$docRoot.'";'.PHP_EOL;
|
||||
<div class="plugins">
|
||||
<?php
|
||||
for ($i=0;$i<count($plugins);$i++) {
|
||||
echo '<a href="'.$plugins[$i][3].'" target="'.$plugins[$i][4].'"><img src="'.$plugins[$i][1].'" style="'.$plugins[$i][2].'" alt="'.$plugins[$i][0].'"></a>';
|
||||
$target = explode(":",$plugins[$i][4]);
|
||||
echo '<a href="'.$plugins[$i][3].'" target="'.$target[0].'"><img src="'.$plugins[$i][1].'" style="'.$plugins[$i][2].'" alt="'.$plugins[$i][0].'"></a>';
|
||||
};
|
||||
?>
|
||||
</div>
|
||||
@@ -84,11 +87,25 @@ echo 'fullPath = "'.$docRoot.'";'.PHP_EOL;
|
||||
|
||||
<div id="files" class="files" onMouseOver="ICEcoder.changeFilesW('expand')" onMouseOut="ICEcoder.changeFilesW('contract'); top.document.getElementById('fileMenu').style.display='none';">
|
||||
<div class="account" id="account">
|
||||
<form name="login" action="index.php" method="POST">
|
||||
<input type="password" name="loginPassword" class="accountPassword">
|
||||
<input type="submit" name="submit" value="Login" class="button">
|
||||
</form>
|
||||
<a nohref style="cursor: pointer" onClick="ICEcoder.lockUnlockNav()"><img src="images/file-manager-icons/padlock.png" id="fmLock" class="lock"></a>
|
||||
<?php if($_SESSION['userLevel']<10) {?>
|
||||
<form name="login" action="index.php" method="POST">
|
||||
<input type="password" name="loginPassword" class="accountPassword">
|
||||
<input type="submit" name="submit" value="Login" class="button">
|
||||
</form>
|
||||
<?php } else {
|
||||
$lockStyleExtra = ' style="margin-top: -22px"';
|
||||
?>
|
||||
<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>
|
||||
</div>
|
||||
<?php ;};?>
|
||||
<a nohref style="cursor: pointer" onClick="ICEcoder.lockUnlockNav()"><img src="images/file-manager-icons/padlock.png" id="fmLock" class="lock"<?php echo $lockStyleExtra; ?>></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>
|
||||
|
||||
@@ -64,7 +64,7 @@ body {overflow: hidden;
|
||||
}
|
||||
|
||||
.header {position: absolute; display: inline-block; width: 100%; height: 40px; background-color: #ffffff; text-align: right; z-index: 2}
|
||||
.header .plugins {position: absolute; display: inline-block; left: 27px; top: 3px}
|
||||
.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}
|
||||
@@ -75,6 +75,8 @@ body {overflow: hidden;
|
||||
box-shadow: 0px 0px 10px 4px rgba(0,0,0,0.4);
|
||||
}
|
||||
.files .account {display: inline-block; height: 50px; width: 250px; margin-top: 40px; background-color: #888888}
|
||||
.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 .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}
|
||||
|
||||
517
lib/coder.js
@@ -27,16 +27,15 @@ var ICEcoder = {
|
||||
serverQueueItems: [], // Array of URLs to call in order
|
||||
|
||||
// Don't consider these tags as part of nesting as they're singles, JS or PHP code blocks
|
||||
tagNestExceptions: ["!DOCTYPE","meta","link","img","br","hr","input","script","?"],
|
||||
tagNestExceptions: ["!DOCTYPE","meta","link","img","br","hr","input","script","?php","?"],
|
||||
|
||||
// On load, set aliases, set the layout and get the nest location
|
||||
init: function() {
|
||||
var aliasArray = ["header","files","account","fmLock","filesFrame","editor","tabsBar","findBar","content","footer","nestValid","nestDisplay","charDisplay"];
|
||||
ICEcoder.tD = top.document;
|
||||
|
||||
// Create our ID aliases
|
||||
for (var i=0;i<aliasArray.length;i++) {
|
||||
ICEcoder[aliasArray[i]] = ICEcoder.tD.getElementById(aliasArray[i]);
|
||||
ICEcoder[aliasArray[i]] = top.document.getElementById(aliasArray[i]);
|
||||
}
|
||||
|
||||
// Set layout & the nest location
|
||||
@@ -46,18 +45,13 @@ var ICEcoder = {
|
||||
top.document.getElementById('loadingMask').style.visibility = "hidden";
|
||||
},
|
||||
|
||||
// Set out our layout according to the browser size
|
||||
// Set our layout according to the browser size
|
||||
setLayout: function(dontSetEditor) {
|
||||
var winW, winH, headerH, footerH, accountH, tabsBarH, findBarH, cMCSS;
|
||||
|
||||
// Determin width & height available
|
||||
if (window.innerWidth) {
|
||||
var winW = window.innerWidth;
|
||||
var winH = window.innerHeight;
|
||||
} else {
|
||||
var winW = document.body.clientWidth;
|
||||
var winH = document.body.clientHeight;
|
||||
}
|
||||
window.innerWidth ? winW = window.innerWidth : winW = document.body.clientWidth;
|
||||
window.innerHeight ? winH = window.innerHeight : winH = document.body.clientHeight;
|
||||
|
||||
// Apply sizes to various elements of the page
|
||||
headerH = 40, footerH = 30, accountH = 50, tabsBarH = 21, findBarH = 28;
|
||||
@@ -67,6 +61,7 @@ var ICEcoder = {
|
||||
fmLock.style.marginLeft = (this.filesW-27) + "px";
|
||||
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";
|
||||
ICEcoder.content.style.height = (winH-headerH-footerH-tabsBarH-findBarH) + "px";
|
||||
@@ -82,11 +77,11 @@ var ICEcoder = {
|
||||
|
||||
// Clean up our loaded code
|
||||
contentCleanUp: function() {
|
||||
var fileName;
|
||||
var fileName, cM, content;
|
||||
|
||||
// If it's not a JS or CSS file, replace & and our temp </textarea> value
|
||||
fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1];
|
||||
if (fileName.indexOf(".js")<0&&fileName.indexOf(".css")<0) {
|
||||
|
||||
var cM, content;
|
||||
cM = ICEcoder.getcMInstance();
|
||||
content = cM.getValue();
|
||||
if (top.ICEcoder.codeAssist) {content = content.replace(/ & /g,' & ');};
|
||||
@@ -101,6 +96,7 @@ var ICEcoder = {
|
||||
// Work out the nesting depth location on demand and update our display if required
|
||||
getNestLocation: function(updateNestDisplay) {
|
||||
var cM, openTag, nestCheck, startPos, tagStart, canDoTheEndTag, tagEnd, tagEndJS, fileName;
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
nestCheck = cM.getValue();
|
||||
|
||||
@@ -117,7 +113,7 @@ var ICEcoder = {
|
||||
|
||||
// Get the tag name and if it's the start of a code block, set the var for that
|
||||
tagStart=nestCheck.substr(startPos,nestCheck.length).split(" ")[0].split(">")[0].split("\n")[0];
|
||||
if (tagStart=="script"||tagStart=="?") {ICEcoder.codeBlock=true}
|
||||
if (tagStart=="script"||tagStart=="?php"||tagStart=="?") {ICEcoder.codeBlock=true}
|
||||
if (tagStart!="") {ICEcoder.tagStart = tagStart}
|
||||
};
|
||||
|
||||
@@ -145,6 +141,7 @@ var ICEcoder = {
|
||||
tagEnd=tagEnd.substr(tagEnd.lastIndexOf('<')+1,tagEnd.length);
|
||||
tagEnd=tagEnd.substr(tagEnd.lastIndexOf(' ')+1,tagEnd.length);
|
||||
tagEnd=tagEnd.substr(tagEnd.lastIndexOf('\t')+1,tagEnd.length);
|
||||
tagEnd=tagEnd.substr(tagEnd.lastIndexOf('\n')+1,tagEnd.length);
|
||||
tagEnd=tagEnd.substr(tagEnd.lastIndexOf(';')+1,tagEnd.length);
|
||||
|
||||
if (!ICEcoder.codeBlock) {
|
||||
@@ -159,7 +156,7 @@ var ICEcoder = {
|
||||
}
|
||||
} else if (
|
||||
((ICEcoder.tagStart=="script"||ICEcoder.tagStart=="/script")&&tagEndJS=="</script")||
|
||||
(ICEcoder.tagStart=="?"&&tagEnd=="?")) {
|
||||
((ICEcoder.tagStart=="?php"||ICEcoder.tagStart=="?")&&tagEnd=="?")) {
|
||||
ICEcoder.codeBlock=false;
|
||||
}
|
||||
}
|
||||
@@ -191,6 +188,7 @@ var ICEcoder = {
|
||||
// Detect keys/combos plus identify our area and set the vars, perform actions
|
||||
interceptKeys: function(area, evt) {
|
||||
var key;
|
||||
|
||||
key = evt.keyCode ? evt.keyCode : evt.which ? evt.which : evt.charCode;
|
||||
|
||||
// DEL (Delete file)
|
||||
@@ -215,13 +213,23 @@ var ICEcoder = {
|
||||
top.ICEcoder.ctrlKeyDown = false;
|
||||
return false;
|
||||
|
||||
// CTRL+G (Go to Line)
|
||||
// CTRL+G (Go to line)
|
||||
} else if(key==71 && top.ICEcoder.ctrlKeyDown==true) {
|
||||
top.document.getElementById('goToLineNo').focus();
|
||||
top.ICEcoder.ctrlKeyDown = false;
|
||||
return false;
|
||||
|
||||
// CTRL+S (Save)
|
||||
// CTRL+I (Get info)
|
||||
} else if(key==73 && top.ICEcoder.ctrlKeyDown==true && area == "content") {
|
||||
var searchPrefix = "";
|
||||
if (top.ICEcoder.caretLocType!="Content") {
|
||||
searchPrefix = top.ICEcoder.caretLocType.toLowerCase()+" ";
|
||||
}
|
||||
window.open("http://www.google.com/#output=search&q="+searchPrefix+top.ICEcoder.getcMInstance().getSelection());
|
||||
top.ICEcoder.ctrlKeyDown = false;
|
||||
return false;
|
||||
|
||||
// CTRL+S (Save), CTRL+Shift+S (Save As)
|
||||
} else if(key==83 && top.ICEcoder.ctrlKeyDown==true) {
|
||||
if(top.ICEcoder.shiftKeyDown==true) {
|
||||
top.ICEcoder.saveFile('saveAs');
|
||||
@@ -238,11 +246,16 @@ var ICEcoder = {
|
||||
top.ICEcoder.ctrlKeyDown = false;
|
||||
return false;
|
||||
|
||||
// ESC (Comment/Uncomment line)
|
||||
// ESC in content area (Comment/Uncomment line)
|
||||
} else if(key==27 && area == "content") {
|
||||
top.ICEcoder.lineCommentToggle();
|
||||
return false;
|
||||
|
||||
// ESC not in content area (Cancel all actions)
|
||||
} else if(key==27 && area != "content") {
|
||||
top.ICEcoder.cancelAllActions();
|
||||
return false;
|
||||
|
||||
// Any other key
|
||||
} else {
|
||||
return key;
|
||||
@@ -252,6 +265,7 @@ var ICEcoder = {
|
||||
// Reset the state of keys back to the normal state
|
||||
resetKeys: function(evt) {
|
||||
var key;
|
||||
|
||||
key = evt.keyCode ? evt.keyCode : evt.which ? evt.which : evt.charCode;
|
||||
|
||||
if (key==17) {top.ICEcoder.ctrlKeyDown = false;}
|
||||
@@ -261,7 +275,6 @@ var ICEcoder = {
|
||||
|
||||
// Set the width of the file manager on demand
|
||||
changeFilesW: function(expandContract) {
|
||||
var expandContract;
|
||||
|
||||
if (!ICEcoder.lockedNav) {
|
||||
if ("undefined" != typeof ICEcoder.changeFilesInt) {clearInterval(ICEcoder.changeFilesInt)};
|
||||
@@ -306,15 +319,15 @@ var ICEcoder = {
|
||||
}
|
||||
},
|
||||
|
||||
// Change tabs by reloading content
|
||||
// Change tabs by switching visibility of instances
|
||||
switchTab: function(newTab) {
|
||||
var cM;
|
||||
|
||||
// Identify tab that's currently selected & show the instance
|
||||
// Identify tab that's currently selected & get the instance
|
||||
ICEcoder.selectedTab = newTab;
|
||||
cM = ICEcoder.getcMInstance();
|
||||
|
||||
// Switch mode
|
||||
// Switch mode to HTML, PHP, CSS etc
|
||||
ICEcoder.switchMode();
|
||||
|
||||
// Set all cM instances to be hidden, then make our selected instance visable
|
||||
@@ -324,7 +337,6 @@ var ICEcoder = {
|
||||
cM.setOption('theme','icecoder visible');
|
||||
|
||||
// Focus on & refresh our selected instance
|
||||
cM = ICEcoder.getcMInstance();
|
||||
cM.focus();
|
||||
cM.refresh();
|
||||
|
||||
@@ -334,14 +346,17 @@ var ICEcoder = {
|
||||
|
||||
// Reset all tabs to be without a highlight and then highlight the selected
|
||||
redoTabHighlight: function(selectedTab) {
|
||||
for(var i=1;i<=10;i++) {
|
||||
var bgVPos;
|
||||
|
||||
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";
|
||||
}
|
||||
ICEcoder.changedContent[selectedTab-1]==1 ? top.ICEcoder.fMIconVis('fMSave',1) : top.ICEcoder.fMIconVis('fMSave',0.3);
|
||||
},
|
||||
|
||||
// Starts a new file by setting a few vars & clearing the editor
|
||||
// Starts a new file by setting a few vars & creating a new cM instance
|
||||
newTab: function() {
|
||||
var cM;
|
||||
|
||||
@@ -397,8 +412,8 @@ var ICEcoder = {
|
||||
// Indicate if the nesting structure of the code is OK
|
||||
updateNestingIndicator: function () {
|
||||
var cM, fileName;
|
||||
cM = ICEcoder.getcMInstance();
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1];
|
||||
ICEcoder.caretPos=cM.getValue().length;
|
||||
ICEcoder.getNestLocation();
|
||||
@@ -415,9 +430,9 @@ var ICEcoder = {
|
||||
// Get the caret position on demand
|
||||
getCaretPosition: function() {
|
||||
var cM, content, line, char, charPos, charCount;
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
content = cM.getValue();
|
||||
|
||||
line = cM.getCursor().line;
|
||||
char = cM.getCursor().ch;
|
||||
charPos = 0;
|
||||
@@ -432,8 +447,8 @@ var ICEcoder = {
|
||||
// Update the code type, line & character display
|
||||
updateCharDisplay: function() {
|
||||
var cM;
|
||||
cM = ICEcoder.getcMInstance();
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
ICEcoder.caretLocationType();
|
||||
ICEcoder.charDisplay.innerHTML = ICEcoder.caretLocType + ", Line: " + (cM.getCursor().line+1) + ", Char: " + cM.getCursor().ch;
|
||||
},
|
||||
@@ -441,8 +456,8 @@ var ICEcoder = {
|
||||
// Determine which area of the document we're in
|
||||
caretLocationType: function () {
|
||||
var cM, caretLocType, caretChunk, fileName;
|
||||
cM = ICEcoder.getcMInstance();
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
caretLocType = "Unknown";
|
||||
caretChunk = cM.getValue().substr(0,ICEcoder.caretPos+1);
|
||||
if (caretChunk.lastIndexOf("<script")>caretChunk.lastIndexOf("</script>")&&caretLocType=="Unknown") {caretLocType = "JavaScript"};
|
||||
@@ -450,7 +465,6 @@ var ICEcoder = {
|
||||
if (caretChunk.lastIndexOf("<")>caretChunk.lastIndexOf(">")&&caretLocType=="Unknown") {caretLocType = "HTML"};
|
||||
if (caretLocType=="Unknown") {caretLocType = "Content"};
|
||||
|
||||
var fileName;
|
||||
fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1];
|
||||
if (fileName.indexOf(".js")>0) {caretLocType="JavaScript"};
|
||||
if (fileName.indexOf(".css")>0) {caretLocType="CSS"};
|
||||
@@ -477,10 +491,9 @@ var ICEcoder = {
|
||||
|
||||
// Close the tab upon request
|
||||
closeTab: function(closeTabNum) {
|
||||
|
||||
var cM, okToRemove;
|
||||
cM = ICEcoder.getcMInstance();
|
||||
|
||||
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?');
|
||||
@@ -489,11 +502,11 @@ var ICEcoder = {
|
||||
if (okToRemove) {
|
||||
// recursively copy over all tabs & data from the tab to the right, if there is one
|
||||
for (var i=closeTabNum;i<ICEcoder.openFiles.length;i++) {
|
||||
ICEcoder.tD.getElementById('tab'+i).innerHTML = ICEcoder.tD.getElementById('tab'+(i+1)).innerHTML;
|
||||
top.document.getElementById('tab'+i).innerHTML = top.document.getElementById('tab'+(i+1)).innerHTML;
|
||||
ICEcoder.openFiles[i-1] = ICEcoder.openFiles[i];
|
||||
|
||||
// reduce the tab reference number on the closeTab link by 1
|
||||
ICEcoder.tD.getElementById('tab'+i).innerHTML = ICEcoder.tD.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+")");
|
||||
}
|
||||
|
||||
// hide the instance we're closing by setting the hide class, clear the value & remove from the array
|
||||
@@ -502,8 +515,8 @@ var ICEcoder = {
|
||||
top.ICEcoder.cMInstances.splice(closeTabNum-1,1);
|
||||
|
||||
// clear the rightmost tab (or only one left in a 1 tab scenario) & remove from the array
|
||||
ICEcoder.tD.getElementById('tab'+ICEcoder.openFiles.length).style.display = "none";
|
||||
ICEcoder.tD.getElementById('tab'+ICEcoder.openFiles.length).innerHTML = "";
|
||||
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
|
||||
@@ -512,7 +525,8 @@ var ICEcoder = {
|
||||
|
||||
// hide the content area if we have no tabs open
|
||||
if (ICEcoder.openFiles.length==0) {
|
||||
ICEcoder.tD.getElementById('content').style.visibility = "hidden";
|
||||
top.document.getElementById('content').style.visibility = "hidden";
|
||||
top.ICEcoder.fMIconVis('fMView',0.3);
|
||||
} else {
|
||||
// Switch the mode & the tab
|
||||
ICEcoder.switchMode();
|
||||
@@ -534,9 +548,9 @@ var ICEcoder = {
|
||||
|
||||
var aMenus = ICEcoder.filesFrame.contentWindow.document.getElementsByTagName("LI");
|
||||
for (var i=0; i<aMenus.length; i++) {
|
||||
var mclass = aMenus[i].className;
|
||||
var mclass = aMenus[i].className;
|
||||
if (mclass.indexOf("pft-directory") > -1) {
|
||||
var submenu=aMenus[i].childNodes;
|
||||
var submenu=aMenus[i].childNodes;
|
||||
for (var j=0; j<submenu.length; j++) {
|
||||
if (submenu[j].tagName == "A") {
|
||||
submenu[j].onclick = function() {
|
||||
@@ -558,8 +572,9 @@ var ICEcoder = {
|
||||
}
|
||||
submenu[j].className = (mclass.indexOf("open") > -1) ? "open" : "closed";
|
||||
}
|
||||
if (submenu[j].tagName == "UL")
|
||||
if (submenu[j].tagName == "UL") {
|
||||
submenu[j].style.display = (mclass.indexOf("open") > -1) ? "block" : "none";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -576,69 +591,77 @@ var ICEcoder = {
|
||||
selectFileFolder: function() {
|
||||
var resetFile, shortURL, foundSelectedFile, foundShortURL, foundFile;
|
||||
|
||||
// If we've clicked somewhere other than a file/folder
|
||||
if (top.ICEcoder.thisFileFolderLink=="") {
|
||||
if (!top.ICEcoder.ctrlKeyDown) {
|
||||
// Deselect all files
|
||||
for (var i=0;i<=top.ICEcoder.selectedFiles.length;i++) {
|
||||
if (top.ICEcoder.selectedFiles[i]) {
|
||||
resetFile = top.ICEcoder.filesFrame.contentWindow.document.getElementById(top.ICEcoder.selectedFiles[i]);
|
||||
resetFile.style.backgroundColor="#dddddd";
|
||||
resetFile.style.color="#000000";
|
||||
// If we've clicked somewhere other than a file/folder
|
||||
if (top.ICEcoder.thisFileFolderLink=="") {
|
||||
if (!top.ICEcoder.ctrlKeyDown) {
|
||||
// Deselect all files
|
||||
for (var i=0;i<=top.ICEcoder.selectedFiles.length;i++) {
|
||||
if (top.ICEcoder.selectedFiles[i]) {
|
||||
resetFile = top.ICEcoder.filesFrame.contentWindow.document.getElementById(top.ICEcoder.selectedFiles[i]);
|
||||
ICEcoder.selectDeselectFile('deselect',resetFile);
|
||||
}
|
||||
}
|
||||
// Set our array to contain 0 items
|
||||
top.ICEcoder.selectedFiles.length = 0;
|
||||
}
|
||||
// Set our arrray to contain 0 items
|
||||
top.ICEcoder.selectedFiles.length = 0;
|
||||
}
|
||||
} else {
|
||||
// We clicked a file/folder. Work out a shortened URL for the file, with pipes instead of slashes
|
||||
shortURL = top.ICEcoder.thisFileFolderLink.substr((top.ICEcoder.thisFileFolderLink.indexOf(shortURLStarts)+top.shortURLStarts.length),top.ICEcoder.thisFileFolderLink.length).replace(/\//g,"|");
|
||||
|
||||
// If we have the CTRL key down
|
||||
if (top.ICEcoder.ctrlKeyDown) {
|
||||
foundSelectedFile=false;
|
||||
// Reset all files to not be highlighted
|
||||
for (i=0;i<=top.ICEcoder.selectedFiles.length;i++) {
|
||||
if (top.ICEcoder.selectedFiles[i]==shortURL) {
|
||||
resetFile = ICEcoder.filesFrame.contentWindow.document.getElementById(top.ICEcoder.selectedFiles[i]);
|
||||
resetFile.style.backgroundColor="#dddddd";
|
||||
resetFile.style.color="#000000";
|
||||
top.ICEcoder.selectedFiles.splice(i);
|
||||
foundSelectedFile=true;
|
||||
}
|
||||
}
|
||||
if (!foundSelectedFile) {
|
||||
foundFile = ICEcoder.filesFrame.contentWindow.document.getElementById(shortURL);
|
||||
foundFile.style.backgroundColor="#888888";
|
||||
foundFile.style.color="#f8f8f8";
|
||||
top.ICEcoder.selectedFiles.push(shortURL);
|
||||
}
|
||||
// We are single clicking
|
||||
} else {
|
||||
// First deselect all files
|
||||
for (i=0;i<top.ICEcoder.selectedFiles.length;i++) {
|
||||
resetFile = ICEcoder.filesFrame.contentWindow.document.getElementById(top.ICEcoder.selectedFiles[i]);
|
||||
resetFile.style.backgroundColor="#dddddd";
|
||||
resetFile.style.color="#000000";
|
||||
}
|
||||
// Set our arrray to contain 0 items
|
||||
top.ICEcoder.selectedFiles.length = 0;
|
||||
// We clicked a file/folder. Work out a shortened URL for the file, with pipes instead of slashes
|
||||
shortURL = top.ICEcoder.thisFileFolderLink.substr((top.ICEcoder.thisFileFolderLink.indexOf(shortURLStarts)+top.shortURLStarts.length),top.ICEcoder.thisFileFolderLink.length).replace(/\//g,"|");
|
||||
|
||||
// If we have the CTRL key down
|
||||
if (top.ICEcoder.ctrlKeyDown) {
|
||||
foundSelectedFile=false;
|
||||
// Deselect previously selected file?
|
||||
for (i=0;i<=top.ICEcoder.selectedFiles.length;i++) {
|
||||
if (top.ICEcoder.selectedFiles[i]==shortURL) {
|
||||
resetFile = ICEcoder.filesFrame.contentWindow.document.getElementById(top.ICEcoder.selectedFiles[i]);
|
||||
ICEcoder.selectDeselectFile('deselect',resetFile);
|
||||
top.ICEcoder.selectedFiles.splice(i);
|
||||
foundSelectedFile=true;
|
||||
}
|
||||
}
|
||||
if (!foundSelectedFile) {
|
||||
foundFile = ICEcoder.filesFrame.contentWindow.document.getElementById(shortURL);
|
||||
ICEcoder.selectDeselectFile('select',foundFile);
|
||||
top.ICEcoder.selectedFiles.push(shortURL);
|
||||
}
|
||||
// We are single clicking
|
||||
} else {
|
||||
// First deselect all files
|
||||
for (i=0;i<top.ICEcoder.selectedFiles.length;i++) {
|
||||
resetFile = ICEcoder.filesFrame.contentWindow.document.getElementById(top.ICEcoder.selectedFiles[i]);
|
||||
ICEcoder.selectDeselectFile('deselect',resetFile);
|
||||
}
|
||||
// Set our arrray to contain 0 items
|
||||
top.ICEcoder.selectedFiles.length = 0;
|
||||
|
||||
// Add our URL and highlight the file
|
||||
top.ICEcoder.selectedFiles.push(shortURL);
|
||||
foundFile = ICEcoder.filesFrame.contentWindow.document.getElementById(shortURL);
|
||||
foundFile.style.backgroundColor="#888888";
|
||||
foundFile.style.color="#f8f8f8";
|
||||
// Add our URL and highlight the file
|
||||
top.ICEcoder.selectedFiles.push(shortURL);
|
||||
foundFile = ICEcoder.filesFrame.contentWindow.document.getElementById(shortURL);
|
||||
ICEcoder.selectDeselectFile('select',foundFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Adjust the file & replace select values depending on if we have files selected
|
||||
if (!top.ICEcoder.selectedFiles[0]) {
|
||||
document.findAndReplace.target[2].innerHTML = "all files";
|
||||
document.findAndReplace.target[3].innerHTML = "all filenames";
|
||||
} else {
|
||||
document.findAndReplace.target[2].innerHTML = "selected files";
|
||||
document.findAndReplace.target[3].innerHTML = "selected filenames";
|
||||
}
|
||||
// Adjust the file & replace select values depending on if we have files selected
|
||||
if (!top.ICEcoder.selectedFiles[0]) {
|
||||
document.findAndReplace.target[2].innerHTML = "all files";
|
||||
document.findAndReplace.target[3].innerHTML = "all filenames";
|
||||
} else {
|
||||
document.findAndReplace.target[2].innerHTML = "selected files";
|
||||
document.findAndReplace.target[3].innerHTML = "selected filenames";
|
||||
}
|
||||
|
||||
// Finally, show or grey out the relevant file manager icons
|
||||
top.ICEcoder.selectedFiles.length == 1 ? top.ICEcoder.fMIconVis('fMOpen',1) : top.ICEcoder.fMIconVis('fMOpen',0.3);
|
||||
top.ICEcoder.selectedFiles.length == 1 && top.ICEcoder.thisFileFolderType == "folder" ? top.ICEcoder.fMIconVis('fMNewFile',1) : top.ICEcoder.fMIconVis('fMNewFile',0.3);
|
||||
top.ICEcoder.selectedFiles.length == 1 && top.ICEcoder.thisFileFolderType == "folder" ? top.ICEcoder.fMIconVis('fMNewFolder',1) : top.ICEcoder.fMIconVis('fMNewFolder',0.3);
|
||||
top.ICEcoder.selectedFiles.length == 1 ? top.ICEcoder.fMIconVis('fMDelete',1) : top.ICEcoder.fMIconVis('fMDelete',0.3);
|
||||
top.ICEcoder.selectedFiles.length == 1 ? top.ICEcoder.fMIconVis('fMRename',1) : top.ICEcoder.fMIconVis('fMRename',0.3);
|
||||
},
|
||||
|
||||
// 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";
|
||||
},
|
||||
|
||||
// Create a new file (start & instant save)
|
||||
@@ -652,9 +675,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+'/','');
|
||||
|
||||
if (newFolder) {
|
||||
newFolder = shortURL + "/" + newFolder;
|
||||
top.ICEcoder.serverQueue("add","lib/file-control.php?action=newFolder&file="+newFolder.replace(/\//g,"|"));
|
||||
@@ -664,53 +685,54 @@ var ICEcoder = {
|
||||
|
||||
// Open a file on demand
|
||||
openFile: function() {
|
||||
if (top.ICEcoder.thisFileFolderLink!="" && top.ICEcoder.thisFileFolderType=="file") {
|
||||
var shortURL, canOpenFile;
|
||||
if (top.ICEcoder.thisFileFolderLink!="" && top.ICEcoder.thisFileFolderType=="file") {
|
||||
var shortURL, canOpenFile;
|
||||
|
||||
// work out a shortened URL for the file
|
||||
shortURL = top.ICEcoder.thisFileFolderLink.replace(/\|/g,"/");
|
||||
shortURL = shortURL.substr((shortURL.indexOf(shortURLStarts)+shortURLStarts.length),shortURL.length);
|
||||
// work out a shortened URL for the file
|
||||
shortURL = top.ICEcoder.thisFileFolderLink.replace(/\|/g,"/");
|
||||
shortURL = shortURL.substr((shortURL.indexOf(shortURLStarts)+shortURLStarts.length),shortURL.length);
|
||||
|
||||
// No reason why we can't open a file (so far)
|
||||
canOpenFile = true;
|
||||
// No reason why we can't open a file (so far)
|
||||
canOpenFile = true;
|
||||
|
||||
// Limit to 10 files open at a time
|
||||
if (top.ICEcoder.openFiles.length<10) {
|
||||
// check if we've already got it in our array
|
||||
for (var i=0;i<top.ICEcoder.openFiles.length;i++) {
|
||||
if (top.ICEcoder.openFiles[i]==shortURL && shortURL!="/[NEW]") {
|
||||
// we have, so don't bother opening again
|
||||
canOpenFile = false;
|
||||
// instead, switch to that tab
|
||||
top.ICEcoder.switchTab(i+1);
|
||||
// Limit to 10 files open at a time
|
||||
if (top.ICEcoder.openFiles.length<10) {
|
||||
// check if we've already got it in our array
|
||||
for (var i=0;i<top.ICEcoder.openFiles.length;i++) {
|
||||
if (top.ICEcoder.openFiles[i]==shortURL && shortURL!="/[NEW]") {
|
||||
// we have, so don't bother opening again
|
||||
canOpenFile = false;
|
||||
// instead, switch to that tab
|
||||
top.ICEcoder.switchTab(i+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// show a message because we have 10 files open
|
||||
alert('Sorry, you can only have 10 files open at a time!');
|
||||
canOpenFile = false;
|
||||
}
|
||||
|
||||
// if we're still OK to open it...
|
||||
if (canOpenFile) {
|
||||
top.ICEcoder.shortURL = shortURL;
|
||||
if (shortURL!="/[NEW]") {
|
||||
// replace forward slashes with pipes so it get be placed in a querystring
|
||||
top.ICEcoder.thisFileFolderLink = top.ICEcoder.thisFileFolderLink.replace(/\//g,"|");
|
||||
top.ICEcoder.serverQueue("add","lib/file-control.php?action=load&file="+top.ICEcoder.thisFileFolderLink);
|
||||
top.ICEcoder.serverMessage('<b>Opening File</b><br>'+top.ICEcoder.shortURL);
|
||||
} else {
|
||||
top.ICEcoder.createNewTab();
|
||||
// show a message because we have 10 files open
|
||||
alert('Sorry, you can only have 10 files open at a time!');
|
||||
canOpenFile = false;
|
||||
}
|
||||
|
||||
// if we're still OK to open it...
|
||||
if (canOpenFile) {
|
||||
top.ICEcoder.shortURL = shortURL;
|
||||
if (shortURL!="/[NEW]") {
|
||||
// replace forward slashes with pipes so it get be placed in a querystring
|
||||
top.ICEcoder.thisFileFolderLink = top.ICEcoder.thisFileFolderLink.replace(/\//g,"|");
|
||||
top.ICEcoder.serverQueue("add","lib/file-control.php?action=load&file="+top.ICEcoder.thisFileFolderLink);
|
||||
top.ICEcoder.serverMessage('<b>Opening File</b><br>'+top.ICEcoder.shortURL);
|
||||
} else {
|
||||
top.ICEcoder.createNewTab();
|
||||
}
|
||||
top.ICEcoder.fMIconVis('fMView',1);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Save a file on demand
|
||||
saveFile: function(saveAs) {
|
||||
var saveType;
|
||||
|
||||
if (saveAs) {saveType = "saveAs"} else {saveType = "save"};
|
||||
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.serverMessage('<b>Saving</b><br>'+ICEcoder.openFiles[ICEcoder.selectedTab-1]);
|
||||
},
|
||||
@@ -720,14 +742,10 @@ 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 = false;
|
||||
renamedFile = prompt('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>';
|
||||
@@ -744,13 +762,12 @@ var ICEcoder = {
|
||||
var delFiles, selectedFilesList;
|
||||
|
||||
delFiles = confirm('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 = "";
|
||||
for (var i=0;i<top.ICEcoder.selectedFiles.length;i++) {
|
||||
selectedFilesList += top.ICEcoder.selectedFiles[i];
|
||||
if (i<top.ICEcoder.selectedFiles.length-1) {selectedFilesList+=";"}
|
||||
if (i<top.ICEcoder.selectedFiles.length-1) {selectedFilesList+=";"};
|
||||
}
|
||||
top.ICEcoder.serverQueue("add","lib/file-control.php?action=delete&file="+selectedFilesList);
|
||||
top.ICEcoder.serverMessage('<b>Deleting File</b><br>'+top.ICEcoder.selectedFiles.toString().replace(/\|/g,"/").replace(/,/g,"\n"));
|
||||
@@ -759,7 +776,12 @@ var ICEcoder = {
|
||||
|
||||
// Show menu on right clicking in file manager
|
||||
showMenu: function() {
|
||||
var menuType, folderMenuItems;
|
||||
|
||||
if ("undefined" != typeof top.ICEcoder.thisFileFolderLink && top.ICEcoder.thisFileFolderLink!="") {
|
||||
top.ICEcoder.selectedFiles[0].indexOf(".")>0 ? menuType = "file" : menuType = "folder";
|
||||
folderMenuItems = top.document.getElementById('folderMenuItems');
|
||||
menuType == "folder" ? folderMenuItems.style.display = "block" : folderMenuItems.style.display = "none";
|
||||
document.getElementById('fileMenu').style.display = "inline-block";
|
||||
document.getElementById('fileMenu').style.left = (top.ICEcoder.mouseX+20) + "px";
|
||||
document.getElementById('fileMenu').style.top = (top.ICEcoder.mouseY-top.document.getElementById('filesFrame').contentWindow.document.body.scrollTop+80) + "px";
|
||||
@@ -814,11 +836,9 @@ var ICEcoder = {
|
||||
|
||||
// If we have results
|
||||
if (ICEcoder.results.length>0) {
|
||||
|
||||
// Show results only
|
||||
if (resultsOnly) {
|
||||
parent.parent.document.getElementById('results').innerHTML = ICEcoder.results.length + " results";
|
||||
|
||||
// We need to take action instead
|
||||
} else {
|
||||
lineCount=1;
|
||||
@@ -874,8 +894,8 @@ var ICEcoder = {
|
||||
// Go to a specific line number
|
||||
goToLine: function() {
|
||||
var cM;
|
||||
cM = ICEcoder.getcMInstance();
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
cM.setCursor(document.getElementById('goToLineNo').value-1);
|
||||
cM.focus();
|
||||
return false;
|
||||
@@ -884,10 +904,9 @@ var ICEcoder = {
|
||||
// Switch the CodeMirror mode on demand
|
||||
switchMode: function() {
|
||||
var cM;
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
|
||||
fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1];
|
||||
|
||||
if (fileName.indexOf('.js')>0) {
|
||||
cM.setOption("mode","javascript");
|
||||
} else if (fileName.indexOf('.css')>0) {
|
||||
@@ -900,6 +919,7 @@ var ICEcoder = {
|
||||
// Lock & unlock the file manager navigation on demand
|
||||
lockUnlockNav: function() {
|
||||
var lockIcon;
|
||||
|
||||
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";
|
||||
@@ -909,12 +929,10 @@ var ICEcoder = {
|
||||
getcMInstance: function(newTab) {
|
||||
var cM;
|
||||
|
||||
if (newTab=="new") {
|
||||
if (newTab=="new"||(newTab!="new" && ICEcoder.openFiles.length>0)) {
|
||||
cM = top.ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[ICEcoder.selectedTab-1]];
|
||||
} else if (ICEcoder.openFiles.length==0) {
|
||||
cM = top.ICEcoder.content.contentWindow['cM1'];
|
||||
} else {
|
||||
cM = top.ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[ICEcoder.selectedTab-1]];
|
||||
cM = top.ICEcoder.content.contentWindow['cM1'];
|
||||
}
|
||||
return cM;
|
||||
},
|
||||
@@ -925,7 +943,7 @@ var ICEcoder = {
|
||||
if (plugTarget=="_parent"||plugTarget=="_top"||plugTarget=="_self"||plugTarget=="") {
|
||||
setInterval('window.location=\''+plugURL+'\'',plugTimer*1000*60);
|
||||
|
||||
// for pluginActions iframe instances
|
||||
// for fileControl iframe instances
|
||||
} else if (plugTarget.indexOf("fileControl")==0) {
|
||||
setInterval(function() {top.ICEcoder.serverQueue("add",plugURL);top.ICEcoder.serverMessage(plugTarget.split(":")[1]);},plugTimer*1000*60);
|
||||
|
||||
@@ -937,37 +955,44 @@ var ICEcoder = {
|
||||
|
||||
// Comment or uncomment line on keypress
|
||||
lineCommentToggle: function() {
|
||||
var cM, lineContent, cursorPos;
|
||||
var cM, cursorPos, linePos, lineContent, lCLen, adjustCursor;
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
|
||||
cursorPos = cM.getCursor().ch;
|
||||
lineContent = cM.getLine(cM.getCursor().line);
|
||||
linePos = cM.getCursor().line;
|
||||
lineContent = cM.getLine(linePos);
|
||||
lCLen = lineContent.length;
|
||||
adjustCursor = 3;
|
||||
|
||||
if (ICEcoder.caretLocType=="JavaScript"||ICEcoder.caretLocType=="PHP") {
|
||||
if (lineContent.slice(0,3)!="// ") {
|
||||
cM.setLine(cM.getCursor().line, "// " + lineContent);
|
||||
cM.setCursor(cM.getCursor().line, cursorPos+3);
|
||||
if (ICEcoder.caretLocType=="JavaScript"||ICEcoder.caretLocType=="PHP"||ICEcoder.caretLocType=="CSS") {
|
||||
if (cM.somethingSelected()) {
|
||||
if (cM.getSelection().slice(0,2)!="/*") {
|
||||
cM.replaceSelection("/*" + cM.getSelection() + "*/");
|
||||
} else {
|
||||
cM.replaceSelection(cM.getSelection().slice(2,cM.getSelection().length-2));
|
||||
}
|
||||
} else {
|
||||
cM.setLine(cM.getCursor().line, lineContent.slice(3,lineContent.length));
|
||||
cM.setCursor(cM.getCursor().line, cursorPos-3);
|
||||
}
|
||||
} else if (ICEcoder.caretLocType=="CSS") {
|
||||
if (lineContent.slice(0,3)!="/* ") {
|
||||
cM.setLine(cM.getCursor().line, "/* " + lineContent + " */");
|
||||
cM.setCursor(cM.getCursor().line, cursorPos+3);
|
||||
} else {
|
||||
cM.setLine(cM.getCursor().line, lineContent.slice(3,lineContent.length).slice(0,lineContent.length-5));
|
||||
cM.setCursor(cM.getCursor().line, cursorPos-3);
|
||||
if (ICEcoder.caretLocType=="CSS") {
|
||||
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 {
|
||||
lineContent.slice(0,3)!="// " ? cM.setLine(linePos, "// " + lineContent) : cM.setLine(linePos, lineContent.slice(3,lCLen));
|
||||
if (lineContent.slice(0,3)=="// ") {adjustCursor = -adjustCursor};
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (lineContent.slice(0,4)!="<!--") {
|
||||
cM.setLine(cM.getCursor().line, "<!--" + lineContent + "//-->");
|
||||
cM.setCursor(cM.getCursor().line, cursorPos+4);
|
||||
if (cM.somethingSelected()) {
|
||||
if (cM.getSelection().slice(0,4)!="<!--") {
|
||||
cM.replaceSelection("<!--" + cM.getSelection() + "//-->");
|
||||
} else {
|
||||
cM.replaceSelection(cM.getSelection().slice(4,cM.getSelection().length-5));
|
||||
}
|
||||
} else {
|
||||
cM.setLine(cM.getCursor().line, lineContent.slice(4,lineContent.length).slice(0,lineContent.length-9));
|
||||
cM.setCursor(cM.getCursor().line, cursorPos-4);
|
||||
lineContent.slice(0,4)!="<!--" ? cM.setLine(linePos, "<!--" + lineContent + "//-->") : cM.setLine(linePos, lineContent.slice(4,lCLen).slice(0,lCLen-9));
|
||||
lineContent.slice(0,4)=="<!--" ? adjustCursor = -4 : adjustCursor = 4;
|
||||
}
|
||||
}
|
||||
if (!cM.somethingSelected()) {cM.setCursor(linePos, cursorPos+adjustCursor)};
|
||||
},
|
||||
|
||||
// Get the mouse position on demand
|
||||
@@ -976,7 +1001,6 @@ var ICEcoder = {
|
||||
|
||||
IE = document.all ? true : false;
|
||||
if (!IE) {document.captureEvents(Event.MOUSEMOVE)};
|
||||
|
||||
if (IE) {
|
||||
top.ICEcoder.mouseX = event.clientX + document.body.scrollLeft;
|
||||
top.ICEcoder.mouseY = event.clientY + document.body.scrollTop;
|
||||
@@ -992,7 +1016,6 @@ var ICEcoder = {
|
||||
var winH;
|
||||
|
||||
window.innerWidth ? winH = window.innerHeight : winH = document.body.clientHeight;
|
||||
|
||||
if (!top.ICEcoder.mouseDown) {top.ICEcoder.draggingFilesW = false};
|
||||
|
||||
if ((top.ICEcoder.mouseX > top.ICEcoder.filesW-7 && top.ICEcoder.mouseX < top.ICEcoder.filesW+7 && top.ICEcoder.mouseY > 40+50 && top.ICEcoder.mouseY < winH-30-40) || top.ICEcoder.draggingFilesW) {
|
||||
@@ -1011,13 +1034,8 @@ var ICEcoder = {
|
||||
|
||||
// Determin if this is a file or folder and based on that, set the CSS styling & link
|
||||
file.indexOf(".")>0 ? actionElemType = "file" : actionElemType = "folder";
|
||||
if (actionElemType=="file") {
|
||||
cssStyle = "pft-file ext-" + file.substr(file.indexOf(".")+1,file.length);
|
||||
hrefLink = "nohref";
|
||||
} else {
|
||||
cssStyle = "pft-directory";
|
||||
hrefLink = "href=\"#\"";
|
||||
}
|
||||
actionElemType=="file" ? cssStyle = "pft-file ext-" + file.substr(file.indexOf(".")+1,file.length) : cssStyle = "pft-directory";
|
||||
actionElemType=="file" ? hrefLink = "nohref" : hrefLink = "href=\"#\"";
|
||||
|
||||
// Identify our target element & the first child element in it's location
|
||||
targetElem = document.getElementById('filesFrame').contentWindow.document.getElementById(location.replace(/\//g,"|"));
|
||||
@@ -1043,13 +1061,10 @@ var ICEcoder = {
|
||||
// There are items in that location, so add our new item in the right position
|
||||
} else {
|
||||
|
||||
for (i=0;i<=locNest.childNodes.length-1;i++) {
|
||||
for (var i=0;i<=locNest.childNodes.length-1;i++) {
|
||||
// Identify if the item we're considering is a file or folder
|
||||
if (locNest.childNodes[i].className.indexOf('directory')>0) {
|
||||
elemType = "folder";
|
||||
} else {
|
||||
elemType = "file";
|
||||
}
|
||||
locNest.childNodes[i].className.indexOf('directory')>0 ? elemType = "folder" : elemType = "file";
|
||||
|
||||
// Get the name of the item
|
||||
nameLI = locNest.childNodes[i].getElementsByTagName('span')[0].innerHTML;
|
||||
|
||||
@@ -1059,12 +1074,10 @@ var ICEcoder = {
|
||||
newLI = document.createElement("li");
|
||||
newLI.className = cssStyle;
|
||||
newLI.innerHTML = '<a '+hrefLink+' onMouseOver="top.ICEcoder.overFileFolder(\''+elemType+'\',\''+fullPath+location+'/'+file+'\')" onMouseOut="top.ICEcoder.overFileFolder(\''+elemType+'\',\'\')" style="position: relative; left:-22px" class="closed"> <span id="'+location.replace(/\//g,"|")+'|'+file+'">'+file+'</a>';
|
||||
|
||||
// Append or insert depending on which of the above if statements is true
|
||||
if (i==locNest.childNodes.length-1) {
|
||||
locNest.appendChild(newLI,locNest.childNodes[i]);
|
||||
} else {
|
||||
locNest.insertBefore(newLI,locNest.childNodes[i]);
|
||||
}
|
||||
i==locNest.childNodes.length-1 ? locNest.appendChild(newLI,locNest.childNodes[i]) : locNest.insertBefore(newLI,locNest.childNodes[i]);
|
||||
|
||||
// Escape from this loop now
|
||||
i=locNest.childNodes.length;
|
||||
}
|
||||
@@ -1098,9 +1111,7 @@ var ICEcoder = {
|
||||
var cM;
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
|
||||
top.ICEcoder.codeAssist ? top.ICEcoder.codeAssist = false : top.ICEcoder.codeAssist = true;
|
||||
|
||||
top.ICEcoder.cssColorPreview();
|
||||
cM.focus();
|
||||
},
|
||||
@@ -1110,12 +1121,8 @@ var ICEcoder = {
|
||||
var serverMessage;
|
||||
|
||||
serverMessage = document.getElementById('serverMessage');
|
||||
if (message) {
|
||||
serverMessage.innerHTML = message;
|
||||
serverMessage.style.opacity = 1;
|
||||
} else {
|
||||
serverMessage.style.opacity = 0;
|
||||
}
|
||||
if (message) {serverMessage.innerHTML = message};
|
||||
message ? serverMessage.style.opacity = 1 : serverMessage.style.opacity = 0;
|
||||
},
|
||||
|
||||
// Queue items up for processing in turn
|
||||
@@ -1123,7 +1130,6 @@ var ICEcoder = {
|
||||
var cM,nextSaveID,txtArea,topSaveID,element;
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
|
||||
// Firstly, work out how many saves we have to carry out
|
||||
nextSaveID=0;
|
||||
for (i=0;i<ICEcoder.serverQueueItems.length;i++) {
|
||||
@@ -1144,7 +1150,7 @@ var ICEcoder = {
|
||||
}
|
||||
}
|
||||
if (action=="del") {
|
||||
if (ICEcoder.serverQueueItems[0].indexOf('action=save')>0) {
|
||||
if (ICEcoder.serverQueueItems[0] && ICEcoder.serverQueueItems[0].indexOf('action=save')>0) {
|
||||
topSaveID = nextSaveID-1;
|
||||
for (i=1;i<topSaveID;i++) {
|
||||
document.getElementById('saveTemp'+i).value = document.getElementById('saveTemp'+(i+1)).value;
|
||||
@@ -1167,7 +1173,6 @@ var ICEcoder = {
|
||||
var cM,string,startPosAdj,endPosAdj,nextSpace,oldBlock,newBlock;
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
|
||||
string = cM.getLine(cM.getCursor().line);
|
||||
startPosAdj = string.slice(0,cM.getCursor().ch).length - string.slice(0,cM.getCursor().ch).lastIndexOf(' ') - 1;
|
||||
nextSpace = string.slice(cM.getCursor().ch,string.length).indexOf(' ');
|
||||
@@ -1184,8 +1189,112 @@ var ICEcoder = {
|
||||
newBlock.style.display = "block";
|
||||
newBlock.style.width = newBlock.style.height = "20px";
|
||||
newBlock.style.backgroundColor = string;
|
||||
if (newBlock.style.backgroundColor=="") {newBlock.style.display = "none"};
|
||||
top.document.getElementById('header').appendChild(newBlock);
|
||||
cM.addWidget(cM.getCursor(), top.document.getElementById('cssColor'), true);
|
||||
}
|
||||
},
|
||||
|
||||
// Carry out actions when clicking icons above file manager
|
||||
fMIcon: function(action) {
|
||||
|
||||
if (action=="save" && ICEcoder.openFiles.length>0) {
|
||||
top.ICEcoder.saveFile();
|
||||
}
|
||||
|
||||
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) {
|
||||
top.ICEcoder.thisFileFolderType='file';
|
||||
top.ICEcoder.openFile();
|
||||
}
|
||||
if (action=="newFile") {top.ICEcoder.newFile();}
|
||||
if (action=="newFolder") {top.ICEcoder.newFolder();}
|
||||
if (action=="delete") {top.ICEcoder.deleteFile(top.ICEcoder.rightClickedFile);}
|
||||
if (action=="rename") {top.ICEcoder.renameFile(top.ICEcoder.rightClickedFile);}
|
||||
}
|
||||
|
||||
if (action=="view" && ICEcoder.openFiles.length>0) {
|
||||
window.open(top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1]);
|
||||
}
|
||||
},
|
||||
|
||||
// Change opacity of the file manager icons on demand
|
||||
fMIconVis: function(icon, vis) {
|
||||
if (top.document.getElementById(icon)) {
|
||||
top.document.getElementById(icon).style.opacity = vis;
|
||||
}
|
||||
},
|
||||
|
||||
// Cancel all actions on pressing Esc in non content areas
|
||||
cancelAllActions: function() {
|
||||
// Stop whatever the parent may be loading, plus clear any file manager tasks other than the current one
|
||||
window.stop();
|
||||
if (ICEcoder.serverQueueItems.length>0) {
|
||||
ICEcoder.serverQueueItems.splice(1,ICEcoder.serverQueueItems.length);
|
||||
}
|
||||
top.document.getElementById('loadingMask').style.visibility = "hidden";
|
||||
top.ICEcoder.serverMessage('<b style="color: #dd0000">Cancelled tasks</b>');
|
||||
setTimeout(function() {top.ICEcoder.serverMessage();},2000);
|
||||
},
|
||||
|
||||
// Fold or show code by clicking line nos in the gutter
|
||||
foldCode: function(instance,lineNo,mouseEvt) {
|
||||
var cM, string, origLine, origChar, collapseTag, nestDepth, cursor, lastLine;
|
||||
|
||||
cM = top.ICEcoder.getcMInstance();
|
||||
|
||||
setTimeout(function() {
|
||||
// If the next line is hidden, unhide lines until we reach a line that isn't hidden
|
||||
if (cM.lineInfo(lineNo+1).handle.hidden) {
|
||||
for (var i=lineNo;i<=1000000;i++) {
|
||||
cM.lineInfo(i+1).handle.hidden ? cM.showLine(i+1) : i=1000000;
|
||||
if (!cM.lineInfo(i+1).handle.hidden) {
|
||||
cM.clearMarker(i);
|
||||
}
|
||||
}
|
||||
// Clear the gutter marker
|
||||
cM.clearMarker(lineNo);
|
||||
} else {
|
||||
// Get the line of text, plus set our original (current) line & char position
|
||||
string = cM.getLine(lineNo);
|
||||
origLine = cM.getCursor().line;
|
||||
origChar = cM.getCursor().ch;
|
||||
|
||||
// Then shoft the cursor to just after the first > char
|
||||
cM.setCursor(lineNo,string.indexOf(">")+1);
|
||||
|
||||
setTimeout(function() {
|
||||
// Get the tag we're collapsing on and it's nest depth
|
||||
collapseTag = top.ICEcoder.htmlTagArray[top.ICEcoder.htmlTagArray.length-1];
|
||||
nestDepth = top.ICEcoder.htmlTagArray.length;
|
||||
|
||||
setTimeout(function() {
|
||||
// If we don't have the end tag on the same line
|
||||
if (string.indexOf("</"+collapseTag+">",string.indexOf("<"+collapseTag+">"))==-1) {
|
||||
// Find each matching end tag in turn and if it's the same nest depth, we have the correct one
|
||||
cursor = cM.getSearchCursor("</"+collapseTag+">",cM.getCursor());
|
||||
for (var i=0;i<=1000000;i++) {
|
||||
lastLine = cursor.findNext();
|
||||
lastLine = cursor.to().line;
|
||||
cM.setCursor(cursor.to().line,cursor.to().ch);
|
||||
if (top.ICEcoder.htmlTagArray.length==nestDepth-1) {
|
||||
i=1000000;
|
||||
}
|
||||
}
|
||||
// Now we can hide lines in that range
|
||||
for (i=lineNo+1;i<lastLine;i++) {
|
||||
cM.hideLine(i);
|
||||
}
|
||||
}
|
||||
// Finally, set the marker in the gutter and return our cursor to the original position
|
||||
cM.setMarker(lineNo, "<span style=\"color: #ffffff; cursor: pointer\">+</span> %N%")
|
||||
cM.setCursor(origLine,origChar);
|
||||
},1);
|
||||
|
||||
},1);
|
||||
};
|
||||
},1);
|
||||
}
|
||||
};
|
||||
@@ -36,8 +36,8 @@ html, body {margin: 0px}
|
||||
.cm-s-icecoder span.cm-link {color: #ff0;}
|
||||
|
||||
.cm-s-icecoder .CodeMirror-selected {background: #037 !important;}
|
||||
.cm-s-icecoder .CodeMirror-gutter {background: #333; border-right: 1px solid #e8e8e8;}
|
||||
.cm-s-icecoder .CodeMirror-gutter-text {color: #999; width: 35px;}
|
||||
.cm-s-icecoder .CodeMirror-gutter {background: #333; border-right: 1px solid #e8e8e8}
|
||||
.cm-s-icecoder .CodeMirror-gutter-text {color: #999; width: 35px; cursor: default}
|
||||
.cm-s-icecoder .CodeMirror-cursor {border-left: 1px solid white !important;}
|
||||
.cm-s-icecoder .CodeMirror-matchingbracket{border: 1px solid grey; color: black !important;}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ if ($_GET['action']=="save") {
|
||||
}
|
||||
$saveFile = str_replace("\\","/",$_SERVER['DOCUMENT_ROOT']).$file;
|
||||
$saveFile = str_replace("//","/",$saveFile);
|
||||
if (is_writable($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);
|
||||
|
||||
@@ -35,7 +35,7 @@ body {margin: 0px; overflow: auto}
|
||||
.fileManager li {margin-left: 15px;}
|
||||
|
||||
/* Default file */
|
||||
.fileManager LI.pft-file { list-style-image: url(../images/file-manager-icons/file.png); cursor: pointer;}
|
||||
.fileManager LI.pft-file { list-style-image: url(../images/file-manager-icons/file.png); }
|
||||
|
||||
/* Additional file types */
|
||||
.fileManager LI.ext-3gp { list-style-image: url(../images/file-manager-icons/film.png); }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
$versionNo = "v 0.5.9";
|
||||
$codeMirrorDir = "CodeMirror-2.22";
|
||||
$cMThisVer = 2.22;
|
||||
$versionNo = "v 0.6.1";
|
||||
$codeMirrorDir = "CodeMirror-2.23";
|
||||
$cMThisVer = 2.23;
|
||||
$testcMVersion = false; // test if we're using the latest CodeMirror version
|
||||
$restrictedFiles = array("wp-",".php",".asp",".aspx");
|
||||
$bannedFiles = array("_coder","wp-",".exe");
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<body>
|
||||
<script>
|
||||
top.ICEcoder.serverMessage("<b>Zipping Open Files</b>");
|
||||
</script>
|
||||
<?php
|
||||
// ------------------------------------
|
||||
// backupOpenFiles by Matt Pass
|
||||
|
||||