openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

closebrackets.html (1678B)


      1 <!doctype html>
      2 
      3 <title>CodeMirror: Closebrackets Demo</title>
      4 <meta charset="utf-8"/>
      5 <link rel=stylesheet href="../doc/docs.css">
      6 
      7 <link rel="stylesheet" href="../lib/codemirror.css">
      8 <script src="../lib/codemirror.js"></script>
      9 <script src="../addon/edit/closebrackets.js"></script>
     10 <script src="../mode/javascript/javascript.js"></script>
     11 <style type="text/css">
     12       .CodeMirror {border-top: 1px solid #888; border-bottom: 1px solid #888;}
     13     </style>
     14 <div id=nav>
     15   <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
     16 
     17   <ul>
     18     <li><a href="../index.html">Home</a>
     19     <li><a href="../doc/manual.html">Manual</a>
     20     <li><a href="https://github.com/codemirror/codemirror">Code</a>
     21   </ul>
     22   <ul>
     23     <li><a class=active href="#">Closebrackets</a>
     24   </ul>
     25 </div>
     26 
     27 <article>
     28 <h2>Closebrackets Demo</h2>
     29 <form><textarea id="code" name="code">function Grid(width, height) {
     30   this.width = width;
     31   this.height = height;
     32   this.cells = new Array(width * height);
     33 }
     34 Grid.prototype.valueAt = function(point) {
     35   return this.cells[point.y * this.width + point.x];
     36 };
     37 Grid.prototype.setValueAt = function(point, value) {
     38   this.cells[point.y * this.width + point.x] = value;
     39 };
     40 Grid.prototype.isInside = function(point) {
     41   return point.x >= 0 && point.y >= 0 &&
     42          point.x < this.width && point.y < this.height;
     43 };
     44 Grid.prototype.moveValue = function(from, to) {
     45   this.setValueAt(to, this.valueAt(from));
     46   this.setValueAt(from, undefined);
     47 };</textarea></form>
     48 
     49     <script type="text/javascript">
     50       var editor = CodeMirror.fromTextArea(document.getElementById("code"), {autoCloseBrackets: true});
     51     </script>
     52   </article>