fixed syntax error in t3editor, whitespace cleanup in t3editor javascript files
authorIngo Renner <ingo.renner@typo3.org>
Wed, 13 Feb 2008 11:45:29 +0000 (11:45 +0000)
committerIngo Renner <ingo.renner@typo3.org>
Wed, 13 Feb 2008 11:45:29 +0000 (11:45 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@3154 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/t3editor/jslib/parsejavascript.js
typo3/sysext/t3editor/jslib/parsetyposcript.js
typo3/sysext/t3editor/jslib/select.js
typo3/sysext/t3editor/jslib/stringstream.js
typo3/sysext/t3editor/jslib/t3editor.js
typo3/sysext/t3editor/jslib/tokenizejavascript.js
typo3/sysext/t3editor/jslib/tokenizetyposcript.js

index 7ad1f09..54bde07 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
 2008-02-13  Ingo Renner  <ingo@typo3.org>
 
        * removed ugly background color from save buttons in docheader when they were focused
+       * fixed syntax error in t3editor
+       * whitespace cleanup in t3editor javascript files
 
 2008-02-12  Jeff Segars  <jeff@webempoweredchurch.org>
 
index fde545a..4bd3c37 100644 (file)
@@ -32,7 +32,7 @@
 // parentheses, etc, and know when you are inside a string or comment.
 var parseJavaScript = function() {
   // Token types that can be considered to be atoms.
-  var atomicTypes = setObject("atom", "number", "variable", "string", "regexp");  
+  var atomicTypes = setObject("atom", "number", "variable", "string", "regexp");
 
   // Constructor for the lexical context objects.
   function JSLexical(indented, column, type, align, prev) {
@@ -87,7 +87,7 @@ var parseJavaScript = function() {
     // below to communicate with the driver loop in the 'next'
     // function.
     var consume, marked;
-  
+
     // The iterator object.
     var parser = {next: next, copy: copy};
 
@@ -123,7 +123,7 @@ var parseJavaScript = function() {
         lexical.align = true;
 
       // Execute actions until one 'consumes' the token and we can
-      // return it. Marked is used to 
+      // return it. Marked is used to
       while(true){
         consume = marked = false;
        // Take and execute the topmost action.
@@ -149,7 +149,7 @@ var parseJavaScript = function() {
     // between runs of the parser.
     function copy(){
       var _context = context, _lexical = lexical, _cc = cc.concat([]), _regexp = tokens.regexp, _comment = tokens.inComment;
-  
+
       return function(input){
         context = _context;
         lexical = _lexical;
@@ -210,7 +210,7 @@ var parseJavaScript = function() {
       }
       return false;
     }
-  
+
     // Push a new lexical context of the given type.
     function pushlex(type){
       var result = function(){
@@ -227,7 +227,7 @@ var parseJavaScript = function() {
     // The 'lex' flag on these actions is used by the 'next' function
     // to know they can (and have to) be ran before moving on to the
     // next token.
-  
+
     // Creates an action that discards tokens until it finds one of
     // the given type.
     function expect(wanted){
@@ -334,7 +334,7 @@ var parseJavaScript = function() {
     function funarg(type, value){
       if (type == "variable"){register(value); cont();}
     }
-  
+
     return parser;
   }
 }();
index 69fa957..7fed2d7 100755 (executable)
@@ -1,5 +1,5 @@
 /* TypoScript parser
- * 
+ *
  * based on parsejavascript.js by Marijn Haverbeke
  *
  * A parser that can be plugged into the CodeMirror system has to
@@ -141,7 +141,7 @@ var parseTypoScript = function() {
                                lexical.align = true;
                        }
                        // Execute actions until one 'consumes' the token and we can
-                       // return it. Marked is used to 
+                       // return it. Marked is used to
                        while (true) {
                                consume = marked = false;
                                // Take and execute the topmost action.
@@ -190,7 +190,7 @@ var parseTypoScript = function() {
                                cc.push(fs[i]);
                        }
                }
-               
+
                // cont and pass are used by the action functions to add other
                // actions to the stack. cont will cause the current token to be
                // consumed, pass will leave it for the next action.
@@ -198,12 +198,12 @@ var parseTypoScript = function() {
                        push(arguments);
                        consume = true;
                }
-               
+
                function pass() {
                        push(arguments);
                        consume = false;
                }
-               
+
                // Used to change the style of the current token.
                function mark(style) {
                        marked = style;
@@ -220,12 +220,12 @@ var parseTypoScript = function() {
                                }
                        };
                }
-               
+
                // Pop off the current scope.
                function popcontext() {
                        context = context.prev;
                }
-               
+
                // Register a variable in the current scope.
                function register(varname) {
                        if (context) {
@@ -242,12 +242,12 @@ var parseTypoScript = function() {
                        result.lex = true;
                        return result;
                }
-               
+
                // Pop off the current lexical context.
                function poplex() {
                        lexical = lexical.prev;
                }
-               
+
                poplex.lex = true;
                // The 'lex' flag on these actions is used by the 'next' function
                // to know they can (and have to) be ran before moving on to the
@@ -283,45 +283,45 @@ var parseTypoScript = function() {
                function expression(type) {
                        if (atomicTypes.hasOwnProperty(type)) {
                                cont(maybeoperator);
-                       
+
                        } else if (type == "function") {
                                cont(functiondef);
-                       
+
                        } else if (type == "keyword c") {
                                cont(expression);
-                       
+
                        } else if (type == "(") {
                                cont(pushlex(")"), expression, expect(")"), poplex);
-                       
+
                        } else if (type == "operator") {
                                cont(expression);
-                       
+
                        } else if (type == "[") {
                                cont(pushlex("]"), commasep(expression), expect("]"), poplex);
-                       
+
                        } else if (type == "{") {
                                cont(pushlex("}"), commasep(objprop), expect("}"), poplex);
                        }
                }
-               
+
                // Called for places where operators, function calls, or
                // subscripts are valid. Will skip on to the next action if none
                // is found.
                function maybeoperator(type) {
                        if (type == "operator") {
                                cont(expression);
-                       
+
                        } else if (type == "(") {
                                cont(pushlex(")"), expression, commasep(expression), expect(")"), poplex);
-                       
+
                        } else if (type == ".") {
                                cont(property, maybeoperator);
-                       
+
                        } else if (type == "[") {
                                cont(pushlex("]"), expression, expect("]"), poplex);
-                       } 
+                       }
                }
-               
+
                // When a statement starts with a variable name, it might be a
                // label. If no colon follows, it's a regular statement.
                function maybelabel(type) {
@@ -331,7 +331,7 @@ var parseTypoScript = function() {
                                pass(maybeoperator, expect(";"), poplex);
                        }
                }
-               
+
                // Property names need to have their style adjusted -- the
                // tokenizer think they are variables.
                function property(type) {
@@ -340,7 +340,7 @@ var parseTypoScript = function() {
                                cont();
                        }
                }
-               
+
                // This parses a property and its value in an object literal.
                function objprop(type) {
                        if (type == "variable") {
@@ -375,7 +375,7 @@ var parseTypoScript = function() {
 
                // Look for statements until a closing brace is found.
                function condition(type) {
-                       if (type == "]") 7
+                       if (type == "]") {
                                cont();
                        } else {
                                pass(statement, block);
@@ -393,7 +393,7 @@ var parseTypoScript = function() {
                                cont();
                        }
                }
-               
+
                function vardef2(type) {
                        if (type == "operator") {
                                cont(expression, vardef2);
@@ -401,7 +401,7 @@ var parseTypoScript = function() {
                                cont(vardef1);
                        }
                }
-               
+
                // For loops.
                function forspec1(type, value) {
                        if (type == "var") {
@@ -410,7 +410,7 @@ var parseTypoScript = function() {
                                cont(expression, forspec2);
                        }
                }
-               
+
                function forspec2(type) {
                        if (type == ",") {
                                cont(forspec1);
@@ -419,7 +419,7 @@ var parseTypoScript = function() {
                                cont(expression, expect(";"), expression);
                        }
                }
-               
+
                // A function definition creates a new context, and the variables
                // in its argument list have to be added to this context.
                function functiondef(type, value) {
@@ -430,7 +430,7 @@ var parseTypoScript = function() {
                                cont(pushcontext, commasep(funarg), expect(")"), statement, popcontext);
                        }
                }
-               
+
                function funarg(type, value) {
                        if (type == "variable") {
                                register(value);
index fe9699a..3d675cf 100755 (executable)
@@ -26,7 +26,7 @@ var select = {};
                if (!node) {
                        return null;
                }
-               
+
                while (!node.previousSibling && node.parentNode != top) {
                        node = node.parentNode;
                }
@@ -138,7 +138,7 @@ var select = {};
                        }
                };
        }
-       
+
        // W3C model
        else {
                // Well, Opera isn't even supported at the moment, but it almost
@@ -191,7 +191,7 @@ var select = {};
 
                        normalize(result.start);
                        normalize(result.end);
-                       
+
                        // Make the links back to the selection object (see
                        // replaceSelection).
                        if (result.start.node) {
@@ -240,7 +240,7 @@ var select = {};
                                sel.window.document.body.scrollLeft = sel.scrollX;
                                sel.window.document.body.scrollTop = sel.scrollY;
                        }
-                       
+
                        try {
                                setPoint(sel.start, "Start");
                                setPoint(sel.end, "End");
@@ -299,7 +299,7 @@ var select = {};
                                                this.start = topLevelNodeBefore(end, this.container);
                                        }
                                }
-                               
+
                                // Occasionally, browsers will return the HTML node as
                                // selection (Opera does this all the time, which is the
                                // reason this editor does not work on that browser). If the
@@ -318,7 +318,7 @@ var select = {};
                                                this.start = end.childNodes[range.endOffset - 1];
                                        }
                                }
-                               
+
                                // In any other case, we have a regular node. If the cursor is
                                // at the end of the node, we use the node itself, if it is at
                                // the start, we use the node before it, and in any other
@@ -344,7 +344,7 @@ var select = {};
                        } else {
                                range.setEndBefore(this.container.firstChild || this.container);
                        }
-                       
+
                        range.collapse(false);
                        selectRange(range, this.win);
                };
index ed16b3d..6bbe525 100644 (file)
@@ -61,7 +61,7 @@ function multiStringStream(source) {
                }
                return peeked;
        }
-       
+
        function next() {
                if (peeked) {
                        var temp = peeked;
@@ -77,7 +77,7 @@ function multiStringStream(source) {
                }
                return current.charAt(pos++);
        }
-       
+
        function get() {
                var temp = accum;
                var realPos = peeked ? pos - 1: pos;
index fb78964..09dc944 100755 (executable)
@@ -23,7 +23,7 @@
 *
 *  This copyright notice MUST APPEAR in all copies of the script!
 ***************************************************************/
-/* t3editor.js is based on codemirror.js from the Codemirror editor. 
+/* t3editor.js is based on codemirror.js from the Codemirror editor.
  * See LICENSE file for further informations
  */
 
@@ -118,7 +118,7 @@ var t3editor = function() {
                        } else if (node.nodeName == "BR" && node.childNodes.length == 0) {
                                result.push(node);
                        } else {
-                               // forEach(node.childNodes, simplifyNode);
+                                       // forEach(node.childNodes, simplifyNode);
                                $A(node.childNodes).each(simplifyNode);
                                if (!leaving && newlineElements.hasOwnProperty(node.nodeName)) {
                                        leaving = true;
@@ -165,8 +165,7 @@ var t3editor = function() {
                                return function(newnode) {
                                        parent.insertBefore(newnode, next);
                                };
-                       }
-                       else {
+                       } else {
                                return function(newnode) {
                                        parent.appendChild(newnode);
                                };
@@ -214,8 +213,8 @@ var t3editor = function() {
 
                // Check whether a node is a normalized <span> element.
                function partNode(node) {
-                       if (node.nodeName == "SPAN" 
-                         && node.childNodes.length == 1 
+                       if (node.nodeName == "SPAN"
+                         && node.childNodes.length == 1
                          && node.firstChild.nodeType == 3) {
                                node.currentText = node.firstChild.nodeValue;
                                return true;
@@ -285,7 +284,7 @@ var t3editor = function() {
                        "class": "t3e_modalOverlay",
                        "id": "t3e_modalOverlay_wait"
                });
-               
+
                this.modalOverlay.hide();
                this.modalOverlay.setStyle(this.outerdiv.getDimensions());
                this.modalOverlay.setStyle({
@@ -297,21 +296,21 @@ var t3editor = function() {
                        "class": "t3e_modalOverlay",
                        "id": "t3e_modalOverlay_help"
                });
-               
+
                // TODO: fill with senseful content, make it dynamic
-               this.helpOverlay.innerHTML = 
+               this.helpOverlay.innerHTML =
                "<div class='closedok_icon'>"+
                 "<a href='javascript:void(0)' onclick='t3e_instances[" + this.index + "].toggleHelp();'>"+
                 "<img src='"+PATH_t3e+"../t3skin/icons/gfx/closedok.gif' alt='click here to close this help window' title='click here to close this help window' />"+
                 "</a></div>" +
-               "<h2>t3editor</h2>" + 
+               "<h2>t3editor</h2>" +
                "<p>'t3editor' is a javascript-driven code editor with syntax highlighting for TypoScript</p><br/>" +
-               "<p>It's based on the 'Codemirror' editor.</p><br/><br/>" + 
-               "<p>Hotkeys:</p>" + 
-               "<p>" + 
-               "<strong>CTRL-S</strong> save/send code to server<br/>" + 
-               "<strong>CTRL-F11</strong> toggle fullscreen mode<br/>" + 
-               "<strong>CTRL-SPACE</strong> auto-complete (based on letters at current cursor-position)<br/>" + 
+               "<p>It's based on the 'Codemirror' editor.</p><br/><br/>" +
+               "<p>Hotkeys:</p>" +
+               "<p>" +
+               "<strong>CTRL-S</strong> save/send code to server<br/>" +
+               "<strong>CTRL-F11</strong> toggle fullscreen mode<br/>" +
+               "<strong>CTRL-SPACE</strong> auto-complete (based on letters at current cursor-position)<br/>" +
                "</p><br/>" +
                "";
                this.helpOverlay.hide();
@@ -358,7 +357,7 @@ var t3editor = function() {
                this.outerdiv.appendChild(this.footer_wrap);
 
                // footer item: show help Window
-               // TODO make this more flexible! And get rid of inline css and unsed options!   
+               // TODO make this more flexible! And get rid of inline css and unsed options!
                this.fitem_help = this.createFooterItem('Help', true, "this.toggleHelp()");
                this.footer_wrap.appendChild(this.fitem_help);
 
@@ -369,10 +368,10 @@ var t3editor = function() {
                });
 
                // TODO make this more flexible! And get rid of inline css and unsed options!
-               this.fitem_options_overlay.innerHTML = '<ul>' + 
-                       // '<li style="color:grey"><input type="checkbox" disabled="disabled" /> Syntax highlighting</li>'+ 
-                       '<li><input type="checkbox" onclick="t3e_instances[' + this.index + '].fitem_options_overlay.hide();t3e_instances[' + this.index + '].toggleAutoComplete();" id="t3e_autocomplete" checked="checked" /><label for="t3e_autocomplete">AutoCompletion</label></li>' + 
-                       '<li><input type="checkbox" onclick="t3e_instances[' + this.index + '].fitem_options_overlay.hide();t3e_instances[' + this.index + '].toggleFullscreen();" id="t3e_fullscreen" /> <label for="t3e_fullscreen">Fullscreen</label></li>' + 
+               this.fitem_options_overlay.innerHTML = '<ul>' +
+                       // '<li style="color:grey"><input type="checkbox" disabled="disabled" /> Syntax highlighting</li>'+
+                       '<li><input type="checkbox" onclick="t3e_instances[' + this.index + '].fitem_options_overlay.hide();t3e_instances[' + this.index + '].toggleAutoComplete();" id="t3e_autocomplete" checked="checked" /><label for="t3e_autocomplete">AutoCompletion</label></li>' +
+                       '<li><input type="checkbox" onclick="t3e_instances[' + this.index + '].fitem_options_overlay.hide();t3e_instances[' + this.index + '].toggleFullscreen();" id="t3e_fullscreen" /> <label for="t3e_fullscreen">Fullscreen</label></li>' +
                        // '<li style="color:grey"><input type="checkbox" disabled="disabled" /> other fancy stuff</li>'+
                        '</ul>';
                this.fitem_options_overlay.hide();
@@ -397,10 +396,10 @@ var t3editor = function() {
 
                this.doc.open();
                this.doc.write(
-                       "<html><head>" + 
-                       "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + 
-                       t3eOptions.stylesheet + 
-                       "\"/></head>" + 
+                       "<html><head>" +
+                       "<link rel=\"stylesheet\" type=\"text/css\" href=\"" +
+                       t3eOptions.stylesheet +
+                       "\"/></head>" +
                        "<body class=\"editbox\" spellcheck=\"false\"></body></html>");
                this.doc.close();
 
@@ -422,8 +421,8 @@ var t3editor = function() {
                        this.init(content);
 
                } else {
-                       // connect(this.iframe, "onload", bind(function(){disconnectAll(this.iframe, "onload"); this.init(content);}, this));
-                       Event.observe(this.iframe, "load", 
+                               // connect(this.iframe, "onload", bind(function(){disconnectAll(this.iframe, "onload"); this.init(content);}, this));
+                       Event.observe(this.iframe, "load",
                        function() {
                                this.init(content);
                        }.bindAsEventListener(this));
@@ -439,7 +438,7 @@ var t3editor = function() {
                textModified: false,
                // editor-content has been modified
                saveAjaxEvent: null,
-               // Event for save code with ajax        
+               // Event for save code with ajax
 
                // Called after we are sure that our frame has a body
                init: function(code) {
@@ -517,25 +516,25 @@ var t3editor = function() {
 
                        if (mouseover) {
                                item.addClassName('t3e_clickable');
-                               Event.observe(item, "mouseover", 
+                               Event.observe(item, "mouseover",
                                        function(e) {
                                                Event.element(e).addClassName('t3e_footeritem_active');
                                        });
-                               Event.observe(item, "mouseout", 
+                               Event.observe(item, "mouseout",
                                        function(e) {
                                                Event.element(e).removeClassName('t3e_footeritem_active');
                                        });
                        }
                        if (typeof clickAction == 'object') {
                                // display an overlay
-                               Event.observe(item, "click", 
+                               Event.observe(item, "click",
                                        function(e) {
                                                clickAction.toggle();
                                        });
 
                        } else if (typeof clickAction == 'string' && clickAction != '') {
                                // execute a method
-                               Event.observe(item, "click", 
+                               Event.observe(item, "click",
                                        function(e) {
                                                eval(clickAction);
                                        }.bindAsEventListener(this));
@@ -586,7 +585,7 @@ var t3editor = function() {
                                w = this.textarea.getDimensions().width;
 
                        } else {
-                               // turn fullscreen on
+                                       // turn fullscreen on
                                this.outerdiv.addClassName('t3e_fullscreen');
                                h = this.outerdiv.offsetParent.getHeight();
                                w = this.outerdiv.offsetParent.getWidth();
@@ -637,22 +636,22 @@ var t3editor = function() {
                                        // make UL list of completation words
                                        var html = '<ul>';
                                        for (i = 0; i < this.words.length; i++) {
-                                               html += '<li style="height:16px;vertical-align:middle;" ' + 
+                                               html += '<li style="height:16px;vertical-align:middle;" ' +
                                                        'id="ac_word_' + i + '" ' +
                                                        'onclick="t3e_instances[' + this.index + '].clicked=true; ' +
                                                         't3e_instances[' + this.index + '].insertCurrWordAtCursor();" ' +
                                                        'onmouseover="t3e_instances[' + this.index + '].highlightCurrWord(' + i + ');">' +
-                                                       '<span class="word_' + this.words[i].type + '">' + 
-                                                       this.words[i].word + 
+                                                       '<span class="word_' + this.words[i].type + '">' +
+                                                       this.words[i].word +
                                                        '</span></li>';
                                        }
                                        html += '</ul>';
-                                       
+
                                        //put HTML and show box
                                        this.autoCompleteBox.innerHTML = html;
                                        this.autoCompleteBox.show();
                                        this.autoCompleteBox.scrollTop = 0;
-                                       
+
                                        //  init styles
                                        if (this.words.length > this.options.acWords) {
                                                this.autoCompleteBox.style.overflowY = 'scroll';
@@ -669,7 +668,7 @@ var t3editor = function() {
                                                        width: 'auto'
                                                });
                                        }
-                                       
+
                                        // positioned box to word
                                        this.autoCompleteBox.setStyle({
                                                left: (Position.cumulativeOffset(this.iframe)[0]
@@ -682,15 +681,15 @@ var t3editor = function() {
                                                     + cursor.start.offsetHeight
                                                     - this.container.scrollTop) + 'px'
                                        });
-                                       
-                                       // set flag to 1 - needed for continue typing word. 
+
+                                       // set flag to 1 - needed for continue typing word.
                                        this.ac = 1;
                                        // highlight first word in list
                                        this.highlightCurrWord(0);
                                }
                        }
                },
-               
+
                // Get word where cursor focused
                getLastWord: function() {
                        var cursor = new select.Cursor(this.container);
@@ -754,7 +753,7 @@ var t3editor = function() {
                        this.autoCompleteBox.hide();
 
                },
-               
+
                // return words for autocomplete by trigger (part of word)
                getCompleteWordsByTrigger: function(trigger) {
                        result = [];
@@ -792,7 +791,7 @@ var t3editor = function() {
                                this.autoCompleteBox.scrollTop = this.ac_up * 16;
                        }
                },
-               
+
                //move cursor in autocomplete box down
                autoCompleteBoxMoveDownCursor: function() {
                        // if previous position was last word in list - then move cursor to first word if not than  position ++
@@ -803,7 +802,7 @@ var t3editor = function() {
                        }
                        // highlight new cursor position
                        this.highlightCurrWord(id);
-                       
+
                        // update id of first and last showing words and scroll box
                        if (this.currWord > this.ac_down || this.currWord == 0) {
                                this.ac_down = this.currWord;
@@ -844,7 +843,7 @@ var t3editor = function() {
 
                        this.fitem_status.update(bodyContentLineCount + ' lines');
                        this.fitem_name.update(
-                               this.documentname + 
+                               this.documentname +
                                (this.textModified ? ' <span alt="document has been modified">*</span>': ''));
                },
 
@@ -860,8 +859,8 @@ var t3editor = function() {
                                // DOM compliant
                                scrOfY = this.doc.body.scrollTop;
                                scrOfX = this.doc.body.scrollLeft;
-                       } else if (this.doc.documentElement 
-                         && (this.doc.documentElement.scrollLeft 
+                       } else if (this.doc.documentElement
+                         && (this.doc.documentElement.scrollLeft
                          || this.doc.documentElement.scrollTop)) {
                                // IE6 standards compliant mode
                                scrOfY = this.doc.documentElement.scrollTop;
@@ -907,8 +906,8 @@ var t3editor = function() {
                        if (code == "") {
                                this.container.appendChild(this.win.document.createElement('SPAN'));
                                this.container.appendChild(
-                                       (Prototype.Browser.Gecko && !Prototype.Browser.WebKit) ? 
-                                        this.win.document.createElement('BR') : 
+                                       (Prototype.Browser.Gecko && !Prototype.Browser.WebKit) ?
+                                        this.win.document.createElement('BR') :
                                         this.win.document.createElement('SPAN'));
                        }
 
@@ -988,7 +987,7 @@ var t3editor = function() {
 
                        }
                },
-               
+
                // mark the node at the cursor dirty when a non-safe key is
                // released.
                keyUp: function(event) {
@@ -1102,7 +1101,7 @@ var t3editor = function() {
                        this.cursorObj = cursor.start;
 
                        // remove current highlights
-                       Selector.findChildElements(this.doc, 
+                       Selector.findChildElements(this.doc,
                                $A(['.highlight-bracket', '.error-bracket'])
                        ).each(function(item) {
                                item.className = item.className.replace(' highlight-bracket', '');
@@ -1135,7 +1134,7 @@ var t3editor = function() {
                                        maybeMatch = maybeMatch.nextSibling;
                                }
                        }
-                       
+
                        // we have a closing bracket, search backward for an opening bracket
                        if (cursor.start.className.indexOf('curly-bracket-close') != -1) {
                                var maybeMatch = cursor.start.previousSibling;
@@ -1198,13 +1197,13 @@ var t3editor = function() {
 
                        // Sometimes the first character on a line can influence the
                        // correct indentation, so we retrieve it.
-                       var firstText = whiteSpace ? 
-                                         whiteSpace.nextSibling : 
-                                         start ? 
-                                           start.nextSibling : 
+                       var firstText = whiteSpace ?
+                                         whiteSpace.nextSibling :
+                                         start ?
+                                           start.nextSibling :
                                            this.container.firstChild;
-                       var firstChar = (start && firstText && firstText.currentText) ? 
-                                       firstText.currentText.charAt(0) : 
+                       var firstChar = (start && firstText && firstText.currentText) ?
+                                       firstText.currentText.charAt(0) :
                                        "";
 
                        // Ask the lexical context for the correct indentation, and
@@ -1345,23 +1344,23 @@ var t3editor = function() {
                if (!container.firstChild) {
                        return;
                }
-               
+
                // Backtrack to the first node before from that has a partial
                // parse stored.
                while (from && !from.parserFromHere) {
                        from = from.previousSibling;
                }
-               
+
                // If we are at the end of the document, do nothing.
                if (from && !from.nextSibling) {
                        return;
                }
-               
+
                // Check whether a part (<span> node) and the corresponding token
                // match.
                function correctPart(token, part) {
-                       return ! part.reduced 
-                               && part.currentText == token.value 
+                       return ! part.reduced
+                               && part.currentText == token.value
                                && hasClass(part, token.style);
                }
                // Shorten the text associated with a part by chopping off
@@ -1373,7 +1372,7 @@ var t3editor = function() {
                        part.currentText = part.currentText.substring(minus);
                        part.reduced = true;
                }
-               
+
                // Create a part corresponding to a given token.
                function tokenPart(token) {
                        var part = new Element('SPAN', {
@@ -1388,8 +1387,8 @@ var t3editor = function() {
                // Get the token stream. If from is null, we start with a new
                // parser from the start of the frame, otherwise a partial parse
                // is resumed.
-               var parsed = from ? 
-                       from.parserFromHere(multiStringStream(traverseDOM(from.nextSibling))) : 
+               var parsed = from ?
+                       from.parserFromHere(multiStringStream(traverseDOM(from.nextSibling))) :
                        this.options.parser(multiStringStream(traverseDOM(container.firstChild)));
 
                // parts is a wrapper that makes it possible to 'delay' going to
@@ -1400,7 +1399,7 @@ var t3editor = function() {
                var parts = {
                        current: null,
                        forward: false,
-                       
+
                        // Get the current part.
                        get: function() {
                                if (!this.current) {
@@ -1411,7 +1410,7 @@ var t3editor = function() {
                                this.forward = false;
                                return this.current;
                        },
-                       
+
                        // Advance to the next part (do not fetch it yet).
                        next: function() {
                                if (this.forward) {
@@ -1419,7 +1418,7 @@ var t3editor = function() {
                                }
                                this.forward = true;
                        },
-                       
+
                        // Remove the current part from the DOM tree, and move to the
                        // next.
                        remove: function() {
@@ -1427,7 +1426,7 @@ var t3editor = function() {
                                container.removeChild(this.current ? this.current.nextSibling: container.firstChild);
                                this.forward = true;
                        },
-                       
+
                        // Advance to the next part that is not empty, discarding empty
                        // parts.
                        nextNonEmpty: function() {
@@ -1452,10 +1451,10 @@ var t3editor = function() {
                try {
                        while (true) {
                                // stopped by StopIteration
-                               
+
                                token = parsed.next();
                                var part = parts.nextNonEmpty();
-                               
+
                                if (token.value == "\n") {
                                        // The idea of the two streams actually staying synchronized
                                        // is such a long shot that we explicitly check.
@@ -1568,7 +1567,7 @@ function t3editor_toggleEditor(checkbox, index) {
 
 // everything ready: turn textarea's into fancy editors
 if (!Prototype.Browser.MobileSafari) {
-       Event.observe(window, 'load', 
+       Event.observe(window, 'load',
                function() {
                        $$('textarea.t3editor').each(
                                function(textarea, i) {
index d723f58..2b748e3 100644 (file)
@@ -83,7 +83,7 @@ var tokenizeJavaScript = function(){
         escaped = next == "\\";
       }
     }
-  
+
     function readHexNumber(){
       source.next(); // skip the 'x'
       nextWhile(isHexDigit);
index 8813b59..6a0e148 100755 (executable)
@@ -1,5 +1,5 @@
-/* Tokenizer for TypoScript code 
- * 
+/* Tokenizer for TypoScript code
+ *
  * based on tokenizejavascript.js by Marijn Haverbeke
  */
 
@@ -1215,7 +1215,7 @@ var tokenizeTypoScript = function() {
        var isDigit = matcher(/[0-9]/);
        var isHexDigit = matcher(/[0-9A-Fa-f]/);
        var isWordChar = matcher(/[\w\$_]/);
-       
+
        function isWhiteSpace(ch) {
                // Unfortunately, IE's regexp matcher thinks non-breaking spaces
                // aren't whitespace. Also, in our scheme newlines are no
@@ -1258,7 +1258,7 @@ var tokenizeTypoScript = function() {
                                source.next();
                        }
                }
-               
+
                // Advance the stream until the given character (not preceded by a
                // backslash) is encountered (or a newline is found).
                function nextUntilUnescaped(end) {
@@ -1279,14 +1279,14 @@ var tokenizeTypoScript = function() {
                        nextWhile(isHexDigit);
                        return result("number", "atom");
                }
-               
+
                function readNumber() {
                        nextWhile(isDigit);
                        if (source.peek() == ".") {
                                source.next();
                                nextWhile(isDigit);
                        }
-                       
+
                        if (source.peek() == "e" || source.peek() == "E") {
                                source.next();
                                if (source.peek() == "-") {
@@ -1296,7 +1296,7 @@ var tokenizeTypoScript = function() {
                        }
                        return result("number", "atom");
                }
-               
+
                // Read a word, look it up in keywords. If not found, it is a
                // variable, otherwise it is a keyword of the type found.
                function readWord() {
@@ -1306,17 +1306,17 @@ var tokenizeTypoScript = function() {
                                type: 'keyword',
                                style: typoscriptWords[word]
                        };
-                       return known ? 
-                               result(known.type, known.style, word) : 
+                       return known ?
+                               result(known.type, known.style, word) :
                                result("variable", "other", word);
                }
-               
+
                function readRegexp() {
                        nextUntilUnescaped("/");
                        nextWhile(matcher(/[gi]/));
                        return result("regexp", "string");
                }
-               
+
                // Mutli-line comments are tricky. We want to return the newlines
                // embedded in them as regular newline tokens, and then continue
                // returning a comment token for every line of the comment. So
@@ -1337,7 +1337,7 @@ var tokenizeTypoScript = function() {
                                }
                                maybeEnd = (next == "*");
                        }
-                       
+
                        return result("comment", "ts-comment");
                }
 
@@ -1354,10 +1354,10 @@ var tokenizeTypoScript = function() {
                                        style: "whitespace",
                                        value: source.get()
                                };
-                               
+
                        } else if (this.inComment) {
                                token = readMultilineComment.call(this, ch);
-                               
+
                        } else if (this.inValue) {
                                token = nextUntilUnescaped(null) || {
                                        type: "value",
@@ -1365,10 +1365,10 @@ var tokenizeTypoScript = function() {
                                        value: source.get()
                                };
                                this.inValue = false;
-                               
+
                        } else if (isWhiteSpace(ch)) {
                                token = nextWhile(isWhiteSpace) || result("whitespace", "whitespace");
-                               
+
                        } else if (ch == "\"" || ch == "'") {
                                token = nextUntilUnescaped(ch) || result("string", "string");
 
@@ -1399,10 +1399,10 @@ var tokenizeTypoScript = function() {
 
                        } else if (ch == "/") {
                                next = source.peek();
-                               
+
                                if (next == "*") {
                                        token = readMultilineComment.call(this, ch);
-                               
+
                                } else if (next == "/") {
                                        token = nextUntilUnescaped(null) || result("comment", "ts-comment");
 
@@ -1412,7 +1412,7 @@ var tokenizeTypoScript = function() {
                                } else {
                                        token = nextWhile(isOperatorChar) || result("operator", "ts-operator");
                                }
-                               
+
                        } else if (ch == "#") {
                                token = nextUntilUnescaped(null) || result("comment", "ts-comment");
 
@@ -1422,7 +1422,7 @@ var tokenizeTypoScript = function() {
                        } else {
                                token = readWord();
                        }
-                       
+
                        // JavaScript's syntax rules for when a slash might be the start
                        // of a regexp and when it is just a division operator are kind
                        // of non-obvious. This decides, based on the current token,