You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2009/03/19 12:24:20 UTC

svn commit: r755931 [8/9] - in /camel/trunk/components/camel-web/src/main/webapp/js/bespin: ./ client/ cmd/ editor/ mobwrite/ page/ page/dashboard/ page/editor/ page/index/ syntax/ user/ util/

Added: camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/css.js
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/css.js?rev=755931&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/css.js (added)
+++ camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/css.js Thu Mar 19 11:24:18 2009
@@ -0,0 +1,267 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ * See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * The Original Code is Bespin.
+ *
+ * The Initial Developer of the Original Code is Mozilla.
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Bespin Team (bespin@mozilla.com)
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+// = CSS Syntax Highlighting Implementation =
+//
+// You can guess what this does. ;-)
+
+dojo.provide("bespin.syntax.css");
+
+
+// ** {{{ bespin.syntax.CSSSyntaxEngine }}} **
+//
+// Tracks syntax highlighting data on a per-line basis. This is a quick-and-dirty implementation that
+// does the right thing for key/value pairs, #000000, and the like.
+// Doesn't actually grok the zones of "propertykey: propertyvalue" as it should.
+
+bespin.syntax.Constants = {
+    C_STYLE_COMMENT: "c-comment",
+    STRING: "string",
+    KEYWORD: "keyword",
+    PUNCTUATION: "punctuation",
+    OTHER: "plain",
+    NAME: "attribute-name",
+    VALUE: "attribute-value",
+    IMPORTANT: "important",
+    COLOR: "color",
+    SIZES: "sizes",
+    ID: "cssid",
+    COLOR_OR_ID: "color_or_id"
+};
+
+dojo.declare("bespin.syntax.CSSSyntaxEngine", null, {
+    keywords: ['ascent', 'azimuth', 'background-attachment', 'background-color', 'background-image', 'background-position',
+        'background-repeat', 'background', 'baseline', 'bbox', 'border-collapse', 'border-color', 'border-spacing', 'border-style',
+        'border-top', 'border-right', 'border-bottom', 'border-left', 'border-top-color', 'border-right-color', 'border-bottom-color',
+        'border-left-color', 'border-top-style', 'border-right-style', 'border-bottom-style', 'border-left-style', 'border-top-width',
+        'border-right-width', 'border-bottom-width', 'border-left-width', 'border-width', 'border', 'cap-height', 'caption-side', 'centerline',
+        'clear', 'clip', 'color', 'content', 'counter-increment', 'counter-reset', 'cue-after', 'cue-before', 'cue', 'cursor', 'definition-src',
+        'descent', 'direction', 'display', 'elevation', 'empty-cells', 'float', 'font-size-adjust', 'font-family', 'font-size', 'font-stretch',
+        'font-style', 'font-variant', 'font-weight', 'font', 'height', 'letter-spacing', 'line-height', 'list-style-image', 'list-style-position',
+        'list-style-type', 'list-style', 'margin-top', 'margin-right', 'margin-bottom', 'margin-left', 'margin', 'marker-offset', 'marks', 'mathline',
+        'max-height','max-width', 'min-height', 'min-width', 'orphans', 'outline-color', 'outline-style', 'outline-width', 'outline', 'overflow',
+        'padding-top', 'padding-right', 'padding-bottom', 'padding-left', 'padding', 'page', 'page-break-after', 'page-break-before',
+        'page-break-inside', 'pause', 'pause-after', 'pause-before', 'pitch', 'pitch-range', 'play-during', 'position',
+        'quotes', 'richness', 'size', 'slope', 'src', 'speak-header', 'speak-numeral', 'speak-punctuation', 'speak', 'speech-rate', 'stemh', 'stemv',
+        'stress', 'table-layout', 'text-align', 'text-decoration', 'text-indent', 'text-shadow', 'text-transform', 'unicode-bidi', 'unicode-range',
+        'units-per-em', 'vertical-align', 'visibility', 'voice-family', 'volume', 'white-space', 'widows', 'width', 'widths', 'word-spacing',
+        'x-height', 'z-index'],
+
+    values: ['above', 'absolute', 'all', 'always', 'aqua', 'armenian', 'attr', 'aural', 'auto', 'avoid', 'baseline', 'behind', 'below',
+        'bidi-override', 'black', 'blink', 'block', 'blue', 'bold', 'bolder', 'both', 'bottom', 'braille', 'capitalize', 'caption',
+        'center', 'center-left', 'center-right', 'circle', 'close-quote', 'code', 'collapse', 'compact', 'condensed',
+        'continuous', 'counter', 'counters', 'crop', 'cross', 'crosshair', 'cursive', 'dashed', 'decimal', 'decimal-leading-zero', 'default',
+        'digits', 'disc', 'dotted', 'double', 'embed', 'embossed', 'e-resize', 'expanded', 'extra-condensed', 'extra-expanded', 'fantasy',
+        'far-left', 'far-right', 'fast', 'faster', 'fixed', 'format', 'fuchsia', 'gray', 'green', 'groove', 'handheld', 'hebrew', 'help',
+        'hidden', 'hide', 'high', 'higher', 'icon', 'inline-table', 'inline', 'inset', 'inside', 'invert',
+        'italic', 'justify', 'landscape', 'large', 'larger', 'left-side', 'left', 'leftwards', 'level', 'lighter', 'lime', 'line-through',
+        'list-item', 'local', 'loud', 'lower-alpha', 'lowercase', 'lower-greek', 'lower-latin', 'lower-roman', 'lower', 'low', 'ltr', 'marker',
+        'maroon', 'medium', 'message-box', 'middle', 'mix', 'move', 'narrower', 'navy', 'ne-resize', 'no-close-quote', 'none', 'no-open-quote',
+        'no-repeat', 'normal', 'nowrap', 'n-resize', 'nw-resize', 'oblique', 'olive', 'once', 'open-quote', 'outset', 'outside', 'overline',
+        'pointer', 'portrait', 'pre', 'print', 'projection', 'purple', 'red', 'relative', 'repeat', 'repeat-x', 'repeat-y', 'rgb', 'ridge',
+        'right', 'right-side', 'rightwards', 'rtl', 'run-in', 'screen', 'scroll', 'semi-condensed', 'semi-expanded', 'separate', 'se-resize',
+        'show', 'silent', 'silver', 'slower', 'slow', 'small', 'small-caps', 'small-caption', 'smaller', 'soft', 'solid', 'speech', 'spell-out',
+        'square', 's-resize', 'static', 'status-bar', 'sub', 'super', 'sw-resize', 'table-caption', 'table-cell', 'table-column',
+        'table-column-group', 'table-footer-group', 'table-header-group', 'table-row', 'table-row-group', 'teal', 'text-bottom', 'text-top',
+        'thick', 'thin', 'top', 'transparent', 'tty', 'tv', 'ultra-condensed', 'ultra-expanded', 'underline', 'upper-alpha', 'uppercase',
+        'upper-latin', 'upper-roman', 'url', 'visible', 'wait', 'white', 'wider', 'w-resize', 'x-fast', 'x-high', 'x-large', 'x-loud', 'x-low',
+        'x-slow', 'x-small', 'x-soft', 'xx-large', 'xx-small', 'yellow',
+        'monospace', 'tahoma', 'verdana', 'arial', 'helvetica', 'sans-serif', 'serif'],
+
+    sizeRegex: "(?:em|pt|px|%)",
+
+    important: '!important',
+
+    punctuation: '{ } / + * . , ; ( ) ? : = " \''.split(" "),
+
+    highlight: function(line, meta) {
+        var K = bespin.syntax.Constants;    // aliasing the constants for shorter reference ;-)
+
+        var regions = {};  // contains the individual style types as keys, with array of start/stop positions as value
+
+        if (!meta) meta = {}; // may not get it first time
+
+        // current state, maintained as we parse through each character in the line; values at any time should be consistent
+        var currentStyle = (meta.inMultilineComment) ? K.C_STYLE_COMMENT : undefined;
+        var currentRegion = {}; // should always have a start property for a non-blank buffer
+        var buffer = "";
+
+        // these properties are related to the parser state above but are special cases
+        var stringChar = "";    // the character used to start the current string
+        var multiline = meta.inMultilineComment;  // this line contains an unterminated multi-line comment
+
+        for (var i = 0; i < line.length; i++) {
+            var c = line.charAt(i);
+
+            // check if we're in a comment and whether this character ends the comment
+            if (currentStyle == K.C_STYLE_COMMENT) {
+                if (c == "/" && /\*$/.test(buffer)) { // has the c-style comment just ended?
+                    currentRegion.stop = i + 1; // get the final / too
+                    this.addRegion(regions, currentStyle, currentRegion);
+                    currentRegion = {};
+                    currentStyle = undefined;
+                    multiline = false;
+                    buffer = "";
+                } else {
+                    if (buffer == "") currentRegion = { start: i };
+                    buffer += c;
+                }
+
+                continue;
+            }
+
+            // check if we have a hash character
+            if (this.isHashChar(c)) {
+                 currentStyle = K.COLOR_OR_ID;
+
+                 if (buffer == "") currentRegion = { start: i };
+                 buffer += c;
+
+                 continue;
+            }
+
+
+            if (this.isWhiteSpaceOrPunctuation(c)) {
+                // check if we're in a string
+                if (currentStyle == K.STRING) {
+                    // if this is not an unescaped end quote (either a single quote or double quote to match how the string started) then keep going
+                    if ( ! (c == stringChar && !/\\$/.test(buffer))) {
+                        if (buffer == "") currentRegion = { start: i };
+                        buffer += c;
+                        continue;
+                    }
+                }
+
+                if (currentStyle == K.COLOR_OR_ID) {
+                    // if this is not an unescaped end quote (either a single quote or double quote to match how the string started) then keep going
+                    if (buffer.match(/#[0-9AaBbCcDdEeFf]{3,6}/)) {
+                        currentStyle = K.COLOR;
+                    } else {
+                        currentStyle = K.OTHER;
+                    }
+                    currentRegion.stop = i;
+
+                    this.addRegion(regions, currentStyle, currentRegion);
+
+                    currentRegion = { start: i }; // clear
+                    stringChar = "";
+                    buffer = c;
+
+                    currentStyle = undefined;
+
+                    continue;
+                }
+
+                // if the buffer is full, add it to the regions
+                if (buffer != "") {
+                    currentRegion.stop = i;
+
+                    // if this is a string, we're all set to add it; if not, figure out if its a keyword, value, or important
+                    if (currentStyle != K.STRING) {
+                        if (this.keywords.indexOf(buffer) != -1) {
+                            // the buffer contains a keyword
+                            currentStyle = K.KEYWORD;
+                        } else if (this.values.indexOf(buffer.toLowerCase()) != -1) {
+                            currentStyle = K.VALUE;
+                        } else if (buffer.match(this.sizeRegex)) {
+                            currentStyle = K.SIZE;
+                        } else if (this.important.indexOf(buffer) != -1) {
+                            currentStyle = K.IMPORTANT;
+                        } else {
+                            currentStyle = K.OTHER;
+                        }
+                    }
+                    this.addRegion(regions, currentStyle, currentRegion);
+                    currentRegion = {};
+                    stringChar = "";
+                    buffer = "";
+                    // i don't clear the current style here so I can check if it was a string below
+                }
+
+                if (this.isPunctuation(c)) {
+                    if (c == "*" && i > 0 && (line.charAt(i - 1) == "/")) {
+                        // remove the previous region in the punctuation bucket, which is a forward slash
+                        regions[K.PUNCTUATION].pop();
+
+                        // we are in a c-style comment
+                        multiline = true;
+                        currentStyle = K.C_STYLE_COMMENT;
+                        currentRegion = { start: i - 1 };
+                        buffer = "/*";
+                        continue;
+                    }
+
+                    // add an ad-hoc region for just this one punctuation character
+                    this.addRegion(regions, K.PUNCTUATION, { start: i, stop: i + 1 });
+                }
+
+                // find out if the current quote is the end or the beginning of the string
+                if ((c == "'" || c == '"') && (currentStyle != K.STRING)) {
+                    currentStyle = K.STRING;
+                    stringChar = c;
+                } else {
+                    currentStyle = undefined;
+                }
+
+                continue;
+            }
+
+            if (buffer == "") currentRegion = { start: i };
+            buffer += c;
+        }
+
+        // check for a trailing character inside of a string or a comment
+        if (buffer != "") {
+            if (!currentStyle) currentStyle = K.OTHER;
+            currentRegion.stop = line.length;
+            this.addRegion(regions, currentStyle, currentRegion);
+        }
+
+        return { regions: regions, meta: { inMultilineComment: multiline } };
+    },
+
+    addRegion: function(regions, type, data) {
+        if (!regions[type]) regions[type] = [];
+        regions[type].push(data);
+    },
+
+    isHashChar: function(ch) {
+        return ch == "#";
+    },
+
+    isWhiteSpaceOrPunctuation: function(ch) {
+        return this.isPunctuation(ch) || this.isWhiteSpace(ch);
+    },
+
+    isPunctuation: function(ch) {
+        return this.punctuation.indexOf(ch) != -1;
+    },
+
+    isWhiteSpace: function(ch) {
+        return ch == " ";
+    }
+});
+
+// Register this puppy
+bespin.syntax.EngineResolver.register(new bespin.syntax.CSSSyntaxEngine(), ['css']);

Propchange: camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/css.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/html.js
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/html.js?rev=755931&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/html.js (added)
+++ camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/html.js Thu Mar 19 11:24:18 2009
@@ -0,0 +1,178 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ * See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * The Original Code is Bespin.
+ *
+ * The Initial Developer of the Original Code is Mozilla.
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Bespin Team (bespin@mozilla.com)
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+// = HTML Syntax Highlighting Implementation =
+//
+// Module for syntax highlighting HTML.
+
+dojo.provide("bespin.syntax.html");
+
+// ** {{{ bespin.syntax.HTMLSyntaxEngine }}} **
+//
+// Tracks syntax highlighting data on a per-line basis. This is a quick-and-dirty implementation that
+// supports keywords and the like, but doesn't actually understand HTML as it should.
+
+bespin.syntax.HTMLConstants = {
+    HTML_STYLE_COMMENT: "comment",
+    STRING: "string",
+    KEYWORD: "keyword",
+    PUNCTUATION: "punctuation",
+    OTHER: "plain"
+};
+
+
+dojo.declare("bespin.syntax.HTMLSyntaxEngine", null, {
+    keywordRegex: "/*(html|head|body|doctype|link|script|div|span|img|h1|h2|h3|h4|h5|h6|ul|li|ol|blockquote)",
+
+    punctuation: '< > = " \'',
+
+    highlight: function(line, meta) {
+        if (!meta) meta = {};
+
+        var K = bespin.syntax.HTMLConstants;    // aliasing the constants for shorter reference ;-)
+
+        var regions = {};                               // contains the individual style types as keys, with array of start/stop positions as value
+
+        // current state, maintained as we parse through each character in the line; values at any time should be consistent
+        var currentStyle = (meta.inMultilineComment) ? K.HTML_STYLE_COMMENT : undefined;
+        var currentRegion = {}; // should always have a start property for a non-blank buffer
+        var buffer = "";
+
+        // these properties are related to the parser state above but are special cases
+        var stringChar = "";    // the character used to start the current string
+        var multiline = meta.inMultilineComment;  // this line contains an unterminated multi-line comment
+
+        for (var i = 0; i < line.length; i++) {
+            var c = line.charAt(i);
+
+            // check if we're in a comment and whether this character ends the comment
+            if (currentStyle == K.HTML_STYLE_COMMENT) {
+                if (c == ">" && bespin.util.endsWith(buffer, "--") &&
+                        ! (/<!--/.test(buffer) && !meta.inMultiLineComment && currentRegion.start == i - 4) &&
+                        ! (/<!---/.test(buffer)  && !meta.inMultiLineComment && currentRegion.start == i - 5)   // I'm really tired
+                        ) { // has the multiline comment just ended?
+                    currentRegion.stop = i + 1;
+                    this.addRegion(regions, currentStyle, currentRegion);
+                    currentRegion = {};
+                    currentStyle = undefined;
+                    multiline = false;
+                    buffer = "";
+                } else {
+                    if (buffer == "") currentRegion = { start: i };
+                    buffer += c;
+                }
+
+                continue;
+            }
+
+            if (this.isWhiteSpaceOrPunctuation(c)) {
+                // check if we're in a string
+                if (currentStyle == K.STRING) {
+                    // if this is not an unescaped end quote (either a single quote or double quote to match how the string started) then keep going
+                    if ( ! (c == stringChar && !/\\$/.test(buffer))) {
+                        if (buffer == "") currentRegion = { start: i };
+                        buffer += c;
+                        continue;
+                    }
+                }
+
+                // if the buffer is full, add it to the regions
+                if (buffer != "") {
+                    currentRegion.stop = i;
+
+                    if (currentStyle != K.STRING) {   // if this is a string, we're all set to add it; if not, figure out if its a keyword
+                        if (buffer.match(this.keywordRegex)) {
+                            // the buffer contains a keyword
+                            currentStyle = K.KEYWORD;
+                        } else {
+                            currentStyle = K.OTHER;
+                        }
+                    }
+                    this.addRegion(regions, currentStyle, currentRegion);
+                    currentRegion = {};
+                    stringChar = "";
+                    buffer = "";
+                    // i don't clear the current style here so I can check if it was a string below
+                }
+
+                if (this.isPunctuation(c)) {
+                    if (c == "<" && (line.length > i + 3) && (line.substring(i, i + 4) == "<!--")) {
+                        // we are in a multiline comment
+                        multiline = true;
+                        currentStyle = K.HTML_STYLE_COMMENT;
+                        currentRegion = { start: i };
+                        buffer = "<!--";
+                        i += 3;
+                        continue;
+                    }
+
+                    // add an ad-hoc region for just this one punctuation character
+                    this.addRegion(regions, K.PUNCTUATION, { start: i, stop: i + 1 });
+                }
+
+                // find out if the current quote is the end or the beginning of the string
+                if ((c == "'" || c == '"') && (currentStyle != K.STRING)) {
+                    currentStyle = K.STRING;
+                    stringChar = c;
+                } else {
+                    currentStyle = undefined;
+                }
+
+                continue;
+            }
+
+            if (buffer == "") currentRegion = { start: i };
+            buffer += c;
+        }
+
+        // check for a trailing character inside of a string or a comment
+        if (buffer != "") {
+            if (!currentStyle) currentStyle = K.OTHER;
+            currentRegion.stop = line.length;
+            this.addRegion(regions, currentStyle, currentRegion);
+        }
+
+        return { regions: regions, meta: { inMultilineComment: multiline } };
+    },
+
+    addRegion: function(regions, type, data) {
+        if (!regions[type]) regions[type] = [];
+        regions[type].push(data);
+    },
+
+    isWhiteSpaceOrPunctuation: function(ch) {
+        return this.isPunctuation(ch) || this.isWhiteSpace(ch);
+    },
+
+    isPunctuation: function(ch) {
+        return this.punctuation.indexOf(ch) != -1;
+    },
+
+    isWhiteSpace: function(ch) {
+        return ch == " ";
+    }
+});
+
+// Register
+bespin.syntax.EngineResolver.register(new bespin.syntax.HTMLSyntaxEngine(), ['html', 'htm', 'xml', 'xhtml', 'shtml']);

Propchange: camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/html.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/javascript.js
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/javascript.js?rev=755931&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/javascript.js (added)
+++ camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/javascript.js Thu Mar 19 11:24:18 2009
@@ -0,0 +1,193 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ * See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * The Original Code is Bespin.
+ *
+ * The Initial Developer of the Original Code is Mozilla.
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Bespin Team (bespin@mozilla.com)
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+// = JavaScript Syntax Highlighting Implementation =
+//
+// Module for syntax highlighting JavaScript.
+
+dojo.provide("bespin.syntax.javascript");
+
+// ** {{{ bespin.syntax.JavaScriptSyntaxEngine }}} **
+//
+// Tracks syntax highlighting data on a per-line basis. This is a quick-and-dirty implementation that
+// supports five basic highlights: keywords, punctuation, strings, comments, and "everything else", all
+// lumped into one last bucket.
+
+bespin.syntax.JavaScriptConstants = {
+    C_STYLE_COMMENT: "c-comment",
+    LINE_COMMENT: "comment",
+    STRING: "string",
+    KEYWORD: "keyword",
+    PUNCTUATION: "punctuation",
+    OTHER: "plain"
+};
+
+dojo.declare("bespin.syntax.JavaScriptSyntaxEngine", null, {
+    keywords: 'abstract boolean break byte case catch char class const continue debugger ' +
+                    'default delete do double else enum export extends false final finally float ' +
+                    'for function goto if implements import in instanceof int interface long native ' +
+                    'new null package private protected public return short static super switch ' +
+                    'synchronized this throw throws transient true try typeof var void volatile while with'.split(" "),
+
+    punctuation: '{ } > < / + - % * . , ; ( ) ? : = " \''.split(" "),
+
+    highlight: function(line, meta) {
+        if (!meta) meta = {};
+
+        var K = bespin.syntax.JavaScriptConstants;    // aliasing the constants for shorter reference ;-)
+
+        var regions = {};                               // contains the individual style types as keys, with array of start/stop positions as value
+
+        // current state, maintained as we parse through each character in the line; values at any time should be consistent
+        var currentStyle = (meta.inMultilineComment) ? K.C_STYLE_COMMENT : undefined;
+        var currentRegion = {}; // should always have a start property for a non-blank buffer
+        var buffer = "";
+
+        // these properties are related to the parser state above but are special cases
+        var stringChar = "";    // the character used to start the current string
+        var multiline = meta.inMultilineComment;
+
+        for (var i = 0; i < line.length; i++) {
+            var c = line.charAt(i);
+
+            // check if we're in a comment and whether this character ends the comment
+            if (currentStyle == K.C_STYLE_COMMENT) {
+                if (c == "/" && /\*$/.test(buffer)) { // has the c-style comment just ended?
+                    currentRegion.stop = i + 1;
+                    this.addRegion(regions, currentStyle, currentRegion);
+                    currentRegion = {};
+                    currentStyle = undefined;
+                    multiline = false;
+                    buffer = "";
+                } else {
+                    if (buffer == "") currentRegion = { start: i };
+                    buffer += c;
+                }
+
+                continue;
+            }
+
+            if (this.isWhiteSpaceOrPunctuation(c)) {
+                // check if we're in a string
+                if (currentStyle == K.STRING) {
+                    // if this is not an unescaped end quote (either a single quote or double quote to match how the string started) then keep going
+                    if ( ! (c == stringChar && !/\\$/.test(buffer))) {
+                        if (buffer == "") currentRegion = { start: i };
+                        buffer += c;
+                        continue;
+                    }
+                }
+
+                // if the buffer is full, add it to the regions
+                if (buffer != "") {
+                    currentRegion.stop = i;
+
+                    if (currentStyle != K.STRING) {   // if this is a string, we're all set to add it; if not, figure out if its a keyword
+                        if (this.keywords.indexOf(buffer) != -1) {
+                            // the buffer contains a keyword
+                            currentStyle = K.KEYWORD;
+                        } else {
+                            currentStyle = K.OTHER;
+                        }
+                    }
+                    this.addRegion(regions, currentStyle, currentRegion);
+                    currentRegion = {};
+                    stringChar = "";
+                    buffer = "";
+                    // i don't clear the current style here so I can check if it was a string below
+                }
+
+                if (this.isPunctuation(c)) {
+                    if (c == "*" && i > 0 && (line.charAt(i - 1) == "/")) {
+                        // remove the previous region in the punctuation bucket, which is a forward slash
+                        regions[K.PUNCTUATION].pop();
+
+                        // we are in a c-style comment
+                        multiline = true;
+                        currentStyle = K.C_STYLE_COMMENT;
+                        currentRegion = { start: i - 1 };
+                        buffer = "/*";
+                        continue;
+                    }
+
+                    // check for a line comment; this ends the parsing for the rest of the line
+                    if (c == '/' && i > 0 && (line.charAt(i - 1) == '/')) {
+                        currentRegion = { start: i - 1, stop: line.length };
+                        currentStyle = K.LINE_COMMENT;
+                        this.addRegion(regions, currentStyle, currentRegion);
+                        buffer = "";
+                        currentStyle = undefined;
+                        currentRegion = {};
+                        break;      // once we get a line comment, we're done!
+                    }
+
+                    // add an ad-hoc region for just this one punctuation character
+                    this.addRegion(regions, K.PUNCTUATION, { start: i, stop: i + 1 });
+                }
+
+                // find out if the current quote is the end or the beginning of the string
+                if ((c == "'" || c == '"') && (currentStyle != K.STRING)) {
+                    currentStyle = K.STRING;
+                    stringChar = c;
+                } else {
+                    currentStyle = undefined;
+                }
+
+                continue;
+            }
+
+            if (buffer == "") currentRegion = { start: i };
+            buffer += c;
+        }
+
+        // check for a trailing character inside of a string or a comment
+        if (buffer != "") {
+            if (!currentStyle) currentStyle = K.OTHER;
+            currentRegion.stop = line.length;
+            this.addRegion(regions, currentStyle, currentRegion);
+        }
+
+        return { regions: regions, meta: { inMultilineComment: multiline } };
+    },
+
+    addRegion: function(regions, type, data) {
+        if (!regions[type]) regions[type] = [];
+        regions[type].push(data);
+    },
+
+    isWhiteSpaceOrPunctuation: function(ch) {
+        return this.isPunctuation(ch) || this.isWhiteSpace(ch);
+    },
+
+    isPunctuation: function(ch) {
+        return this.punctuation.indexOf(ch) != -1;
+    },
+
+    isWhiteSpace: function(ch) {
+        return ch == " ";
+    }
+});
+
+// Register
+bespin.syntax.EngineResolver.register(new bespin.syntax.JavaScriptSyntaxEngine(), ['js', 'javascript', 'ecmascript', 'jsm', 'java']);

Propchange: camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/javascript.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/php.js
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/php.js?rev=755931&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/php.js (added)
+++ camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/php.js Thu Mar 19 11:24:18 2009
@@ -0,0 +1,579 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ * See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * The Original Code is Bespin.
+ *
+ * The Initial Developer of the Original Code is Mozilla.
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Bespin Team (bespin@mozilla.com)
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+// = PHP Syntax Highlighting Implementation =
+//
+// Module for syntax highlighting PHP.
+
+dojo.provide("bespin.syntax.php");
+
+// ** {{{ bespin.syntax.PHPSyntaxEngine }}} **
+//
+// Tracks syntax highlighting data on a per-line basis. This is a quick-and-dirty implementation that
+// supports five basic highlights: keywords, punctuation, strings, comments, and "everything else", all
+// lumped into one last bucket.
+
+bespin.syntax.PHPConstants = {
+    C_STYLE_COMMENT: "c-comment",
+    LINE_COMMENT: "comment",
+    STRING: "string",
+    KEYWORD: "keyword",
+    PUNCTUATION: "punctuation",
+    OTHER: "plain"
+};
+
+dojo.declare("bespin.syntax.PHPSyntaxEngine", null, {
+    keywords: 'include require include_once require_once for foreach as if elseif else while do endwhile ' +
+		'endif switch case endswitch endfor endforeach ' +
+		'return break continue ' +
+		'language class const ' +
+		'default DEFAULT_INCLUDE_PATH extends ' +
+		'E_ALL E_COMPILE_ERROR E_COMPILE_WARNING ' +
+		'E_CORE_ERROR E_CORE_WARNING E_ERROR ' +
+		'E_NOTICE E_PARSE E_STRICT E_USER_ERROR ' +
+		'E_USER_NOTICE E_USER_WARNING E_WARNING ' +
+		'false function interface new null ' +
+		'PEAR_EXTENSION_DIR PEAR_INSTALL_DIR ' +
+		'PHP_BINDIR PHP_CONFIG_FILE_PATH PHP_DATADIR ' +
+		'PHP_EXTENSION_DIR PHP_LIBDIR ' +
+		'PHP_LOCALSTATEDIR PHP_OS ' +
+		'PHP_OUTPUT_HANDLER_CONT PHP_OUTPUT_HANDLER_END ' +
+		'PHP_OUTPUT_HANDLER_START PHP_SYSCONFDIR ' +
+		'PHP_VERSION private public self true ' +
+		'var __CLASS__ __FILE__ __LINE__ __METHOD__ __FUNCTION__ ' +
+		'abs acos acosh addcslashes addslashes aggregate ' +
+		'aggregate_methods aggregate_methods_by_list ' +
+		'aggregate_methods_by_regexp ' +
+		'aggregate_properties ' +
+		'aggregate_properties_by_list ' +
+		'aggregate_properties_by_regexp aggregation_info ' +
+		'apache_child_terminate apache_get_version ' +
+		'apache_lookup_uri apache_note ' +
+		'apache_request_headers apache_response_headers ' +
+		'apache_setenv array array_change_key_case ' +
+		'array_chunk array_count_values array_diff ' +
+		'array_diff_assoc array_fill array_filter ' +
+		'array_flip array_intersect ' +
+		'array_intersect_assoc array_keys ' +
+		'array_key_exists array_map array_merge ' +
+		'array_merge_recursive array_multisort ' +
+		'array_pad array_pop array_push array_rand ' +
+		'array_reduce array_reverse array_search ' +
+		'array_shift array_slice array_splice ' +
+		'array_sum array_unique array_unshift ' +
+		'array_values array_walk arsort asin ' +
+		'asinh asort assert assert_options atan ' +
+		'atan2 atanh base64_decode base64_encode ' +
+		'basename base_convert bcadd bccomp ' +
+		'bcdiv bcmod bcmul bcpow bcscale ' +
+		'bcsqrt bcsub bin2hex bindec ' +
+		'bindtextdomain bind_textdomain_codeset ' +
+		'bzclose bzcompress bzdecompress bzerrno ' +
+		'bzerror bzerrstr bzflush bzopen bzread ' +
+		'bzwrite call_user_func call_user_func_array ' +
+		'call_user_method call_user_method_array ' +
+		'cal_days_in_month cal_from_jd cal_info ' +
+		'cal_to_jd ceil chdir checkdate ' +
+		'checkdnsrr chgrp chmod chop chown ' +
+		'chr chunk_split class_exists ' +
+		'clearstatcache closedir closelog compact ' +
+		'connection_aborted connection_status ' +
+		'constant convert_cyr_string copy cos ' +
+		'cosh count count_chars crc32 ' +
+		'create_function crypt ctype_alnum ' +
+		'ctype_alpha ctype_cntrl ctype_digit ' +
+		'ctype_graph ctype_lower ctype_print ' +
+		'ctype_punct ctype_space ctype_upper ' +
+		'ctype_xdigit current date dba_close ' +
+		'dba_delete dba_exists dba_fetch ' +
+		'dba_firstkey dba_handlers dba_insert ' +
+		'dba_list dba_nextkey dba_open ' +
+		'dba_optimize dba_popen dba_replace ' +
+		'dba_sync dcgettext dcngettext deaggregate ' +
+		'debug_backtrace debug_zval_dump decbin ' +
+		'dechex decoct define defined ' +
+		'define_syslog_variables deg2rad dgettext ' +
+		'die dir dirname diskfreespace ' +
+		'disk_free_space disk_total_space dl ' +
+		'dngettext doubleval each easter_date ' +
+		'easter_days echo empty end ereg ' +
+		'eregi eregi_replace ereg_replace ' +
+		'error_log error_reporting escapeshellarg ' +
+		'escapeshellcmd eval exec exif_imagetype ' +
+		'exif_read_data exif_tagname exif_thumbnail ' +
+		'exit exp explode expm1 ' +
+		'extension_loaded extract ezmlm_hash ' +
+		'fclose feof fflush fgetc fgetcsv ' +
+		'fgets fgetss file fileatime filectime ' +
+		'filegroup fileinode filemtime fileowner ' +
+		'fileperms filepro filepro_fieldcount ' +
+		'filepro_fieldname filepro_fieldtype ' +
+		'filepro_fieldwidth filepro_retrieve ' +
+		'filepro_rowcount filesize filetype ' +
+		'file_exists file_get_contents floatval ' +
+		'flock floor flush fmod fnmatch ' +
+		'fopen fpassthru fputs fread frenchtojd ' +
+		'fscanf fseek fsockopen fstat ftell ' +
+		'ftok ftp_cdup ftp_chdir ftp_close ' +
+		'ftp_connect ftp_delete ftp_exec ftp_fget ' +
+		'ftp_fput ftp_get ftp_get_option ftp_login ' +
+		'ftp_mdtm ftp_mkdir ftp_nb_continue ' +
+		'ftp_nb_fget ftp_nb_fput ftp_nb_get ' +
+		'ftp_nb_put ftp_nlist ftp_pasv ftp_put ' +
+		'ftp_pwd ftp_quit ftp_rawlist ftp_rename ' +
+		'ftp_rmdir ftp_set_option ftp_site ' +
+		'ftp_size ftp_ssl_connect ftp_systype ' +
+		'ftruncate function_exists func_get_arg ' +
+		'func_get_args func_num_args fwrite ' +
+		'getallheaders getcwd getdate getenv ' +
+		'gethostbyaddr gethostbyname gethostbynamel ' +
+		'getimagesize getlastmod getmxrr getmygid ' +
+		'getmyinode getmypid getmyuid getopt ' +
+		'getprotobyname getprotobynumber getrandmax ' +
+		'getrusage getservbyname getservbyport ' +
+		'gettext gettimeofday gettype get_browser ' +
+		'get_cfg_var get_class get_class_methods ' +
+		'get_class_vars get_current_user ' +
+		'get_declared_classes get_defined_constants ' +
+		'get_defined_functions get_defined_vars ' +
+		'get_extension_funcs get_html_translation_table ' +
+		'get_included_files get_include_path ' +
+		'get_loaded_extensions get_magic_quotes_gpc ' +
+		'get_magic_quotes_runtime get_meta_tags ' +
+		'get_object_vars get_parent_class ' +
+		'get_required_files get_resource_type glob ' +
+		'global gmdate gmmktime gmstrftime ' +
+		'gregoriantojd gzclose gzcompress ' +
+		'gzdeflate gzencode gzeof gzfile gzgetc ' +
+		'gzgets gzgetss gzinflate gzopen ' +
+		'gzpassthru gzputs gzread gzrewind ' +
+		'gzseek gztell gzuncompress gzwrite ' +
+		'header headers_sent hebrev hebrevc ' +
+		'hexdec highlight_file highlight_string ' +
+		'htmlentities htmlspecialchars ' +
+		'html_entity_decode hypot i18n_convert ' +
+		'i18n_discover_encoding i18n_http_input ' +
+		'i18n_http_output i18n_internal_encoding ' +
+		'i18n_ja_jp_hantozen i18n_mime_header_decode ' +
+		'i18n_mime_header_encode iconv ' +
+		'iconv_get_encoding iconv_set_encoding ' +
+		'ignore_user_abort image_type_to_mime_type ' +
+		'implode import_request_variables ini_alter ' +
+		'ini_get ini_get_all ini_restore ini_set ' +
+		'intval in_array ip2long iptcembed ' +
+		'iptcparse isset is_a is_array is_bool ' +
+		'is_callable is_dir is_double ' +
+		'is_executable is_file is_finite is_float ' +
+		'is_infinite is_int is_integer is_link ' +
+		'is_long is_nan is_null is_numeric ' +
+		'is_object is_readable is_real is_resource ' +
+		'is_scalar is_string is_subclass_of ' +
+		'is_uploaded_file is_writable is_writeable ' +
+		'jddayofweek jdmonthname jdtofrench ' +
+		'jdtogregorian jdtojewish jdtojulian ' +
+		'jdtounix jewishtojd join juliantojd ' +
+		'key key_exists krsort ksort lcg_value ' +
+		'levenshtein link linkinfo list ' +
+		'localeconv localtime log log1p log10 ' +
+		'long2ip lstat ltrim magic_quotes_runtime ' +
+		'mail max mbereg mberegi ' +
+		'mberegi_replace mbereg_match mbereg_replace ' +
+		'mbereg_search mbereg_search_getpos ' +
+		'mbereg_search_getregs mbereg_search_init ' +
+		'mbereg_search_pos mbereg_search_regs ' +
+		'mbereg_search_setpos mbregex_encoding ' +
+		'mbsplit mbstrcut mbstrlen mbstrpos ' +
+		'mbstrrpos mbsubstr mb_convert_case ' +
+		'mb_convert_encoding mb_convert_kana ' +
+		'mb_convert_variables mb_decode_mimeheader ' +
+		'mb_decode_numericentity mb_detect_encoding ' +
+		'mb_detect_order mb_encode_mimeheader ' +
+		'mb_encode_numericentity mb_ereg mb_eregi ' +
+		'mb_eregi_replace mb_ereg_match ' +
+		'mb_ereg_replace mb_ereg_search ' +
+		'mb_ereg_search_getpos mb_ereg_search_getregs ' +
+		'mb_ereg_search_init mb_ereg_search_pos ' +
+		'mb_ereg_search_regs mb_ereg_search_setpos ' +
+		'mb_get_info mb_http_input mb_http_output ' +
+		'mb_internal_encoding mb_language ' +
+		'mb_output_handler mb_parse_str ' +
+		'mb_preferred_mime_name mb_regex_encoding ' +
+		'mb_regex_set_options mb_send_mail mb_split ' +
+		'mb_strcut mb_strimwidth mb_strlen ' +
+		'mb_strpos mb_strrpos mb_strtolower ' +
+		'mb_strtoupper mb_strwidth ' +
+		'mb_substitute_character mb_substr ' +
+		'mb_substr_count md5 md5_file ' +
+		'memory_get_usage metaphone method_exists ' +
+		'microtime min mkdir mktime ' +
+		'money_format move_uploaded_file ' +
+		'mt_getrandmax mt_rand mt_srand mysql ' +
+		'mysql_affected_rows mysql_client_encoding ' +
+		'mysql_close mysql_connect mysql_createdb ' +
+		'mysql_create_db mysql_data_seek mysql_dbname ' +
+		'mysql_db_name mysql_db_query mysql_dropdb ' +
+		'mysql_drop_db mysql_errno mysql_error ' +
+		'mysql_escape_string mysql_fetch_array ' +
+		'mysql_fetch_assoc mysql_fetch_field ' +
+		'mysql_fetch_lengths mysql_fetch_object ' +
+		'mysql_fetch_row mysql_fieldflags ' +
+		'mysql_fieldlen mysql_fieldname ' +
+		'mysql_fieldtable mysql_fieldtype ' +
+		'mysql_field_flags mysql_field_len ' +
+		'mysql_field_name mysql_field_seek ' +
+		'mysql_field_table mysql_field_type ' +
+		'mysql_freeresult mysql_free_result ' +
+		'mysql_get_client_info mysql_get_host_info ' +
+		'mysql_get_proto_info mysql_get_server_info ' +
+		'mysql_info mysql_insert_id mysql_listdbs ' +
+		'mysql_listfields mysql_listtables ' +
+		'mysql_list_dbs mysql_list_fields ' +
+		'mysql_list_processes mysql_list_tables ' +
+		'mysql_numfields mysql_numrows ' +
+		'mysql_num_fields mysql_num_rows ' +
+		'mysql_pconnect mysql_ping mysql_query ' +
+		'mysql_real_escape_string mysql_result ' +
+		'mysql_selectdb mysql_select_db mysql_stat ' +
+		'mysql_tablename mysql_table_name ' +
+		'mysql_thread_id mysql_unbuffered_query ' +
+		'natcasesort natsort next ngettext ' +
+		'nl2br nl_langinfo number_format ob_clean ' +
+		'ob_end_clean ob_end_flush ob_flush ' +
+		'ob_get_clean ob_get_contents ob_get_flush ' +
+		'ob_get_length ob_get_level ob_get_status ' +
+		'ob_gzhandler ob_iconv_handler ' +
+		'ob_implicit_flush ob_list_handlers ob_start ' +
+		'octdec opendir openlog openssl_csr_export ' +
+		'openssl_csr_export_to_file openssl_csr_new ' +
+		'openssl_csr_sign openssl_error_string ' +
+		'openssl_free_key openssl_get_privatekey ' +
+		'openssl_get_publickey openssl_open ' +
+		'openssl_pkcs7_decrypt openssl_pkcs7_encrypt ' +
+		'openssl_pkcs7_sign openssl_pkcs7_verify ' +
+		'openssl_pkey_export openssl_pkey_export_to_file ' +
+		'openssl_pkey_free openssl_pkey_get_private ' +
+		'openssl_pkey_get_public openssl_pkey_new ' +
+		'openssl_private_decrypt openssl_private_encrypt ' +
+		'openssl_public_decrypt openssl_public_encrypt ' +
+		'openssl_seal openssl_sign openssl_verify ' +
+		'openssl_x509_checkpurpose ' +
+		'openssl_x509_check_private_key ' +
+		'openssl_x509_export openssl_x509_export_to_file ' +
+		'openssl_x509_free openssl_x509_parse ' +
+		'openssl_x509_read ord output_add_rewrite_var ' +
+		'output_reset_rewrite_vars overload pack ' +
+		'parse_ini_file parse_str parse_url ' +
+		'passthru pathinfo pclose pfsockopen ' +
+		'pg_affected_rows pg_cancel_query ' +
+		'pg_clientencoding pg_client_encoding ' +
+		'pg_close pg_cmdtuples pg_connect ' +
+		'pg_connection_busy pg_connection_reset ' +
+		'pg_connection_status pg_convert pg_copy_from ' +
+		'pg_copy_to pg_dbname pg_delete ' +
+		'pg_end_copy pg_errormessage pg_escape_bytea ' +
+		'pg_escape_string pg_exec pg_fetch_all ' +
+		'pg_fetch_array pg_fetch_assoc ' +
+		'pg_fetch_object pg_fetch_result pg_fetch_row ' +
+		'pg_fieldisnull pg_fieldname pg_fieldnum ' +
+		'pg_fieldprtlen pg_fieldsize pg_fieldtype ' +
+		'pg_field_is_null pg_field_name pg_field_num ' +
+		'pg_field_prtlen pg_field_size pg_field_type ' +
+		'pg_freeresult pg_free_result pg_getlastoid ' +
+		'pg_get_notify pg_get_pid pg_get_result ' +
+		'pg_host pg_insert pg_last_error ' +
+		'pg_last_notice pg_last_oid pg_loclose ' +
+		'pg_locreate pg_loexport pg_loimport ' +
+		'pg_loopen pg_loread pg_loreadall ' +
+		'pg_lounlink pg_lowrite pg_lo_close ' +
+		'pg_lo_create pg_lo_export pg_lo_import ' +
+		'pg_lo_open pg_lo_read pg_lo_read_all ' +
+		'pg_lo_seek pg_lo_tell pg_lo_unlink ' +
+		'pg_lo_write pg_meta_data pg_numfields ' +
+		'pg_numrows pg_num_fields pg_num_rows ' +
+		'pg_options pg_pconnect pg_ping pg_port ' +
+		'pg_put_line pg_query pg_result ' +
+		'pg_result_error pg_result_seek ' +
+		'pg_result_status pg_select pg_send_query ' +
+		'pg_setclientencoding pg_set_client_encoding ' +
+		'pg_trace pg_tty pg_unescape_bytea ' +
+		'pg_untrace pg_update phpcredits phpinfo ' +
+		'phpversion php_ini_scanned_files ' +
+		'php_logo_guid php_sapi_name php_uname pi ' +
+		'popen pos posix_ctermid posix_errno ' +
+		'posix_getcwd posix_getegid posix_geteuid ' +
+		'posix_getgid posix_getgrgid posix_getgrnam ' +
+		'posix_getgroups posix_getlogin posix_getpgid ' +
+		'posix_getpgrp posix_getpid posix_getppid ' +
+		'posix_getpwnam posix_getpwuid ' +
+		'posix_getrlimit posix_getsid posix_getuid ' +
+		'posix_get_last_error posix_isatty posix_kill ' +
+		'posix_mkfifo posix_setegid posix_seteuid ' +
+		'posix_setgid posix_setpgid posix_setsid ' +
+		'posix_setuid posix_strerror posix_times ' +
+		'posix_ttyname posix_uname pow preg_grep ' +
+		'preg_match preg_match_all preg_quote ' +
+		'preg_replace preg_replace_callback ' +
+		'preg_split prev print printf print_r ' +
+		'proc_close proc_open putenv ' +
+		'quoted_printable_decode quotemeta rad2deg ' +
+		'rand range rawurldecode rawurlencode ' +
+		'readdir readfile readgzfile readlink ' +
+		'read_exif_data realpath ' +
+		'register_shutdown_function ' +
+		'register_tick_function rename reset ' +
+		'restore_error_handler restore_include_path ' +
+		'rewind rewinddir rmdir round rsort ' +
+		'rtrim sem_acquire sem_get sem_release ' +
+		'sem_remove serialize session_cache_expire ' +
+		'session_cache_limiter session_decode ' +
+		'session_destroy session_encode ' +
+		'session_get_cookie_params session_id ' +
+		'session_is_registered session_module_name ' +
+		'session_name session_regenerate_id ' +
+		'session_register session_save_path ' +
+		'session_set_cookie_params ' +
+		'session_set_save_handler session_start ' +
+		'session_unregister session_unset ' +
+		'session_write_close setcookie setlocale ' +
+		'settype set_error_handler set_file_buffer ' +
+		'set_include_path set_magic_quotes_runtime ' +
+		'set_socket_blocking set_time_limit sha1 ' +
+		'sha1_file shell_exec shmop_close ' +
+		'shmop_delete shmop_open shmop_read ' +
+		'shmop_size shmop_write shm_attach ' +
+		'shm_detach shm_get_var shm_put_var ' +
+		'shm_remove shm_remove_var show_source ' +
+		'shuffle similar_text sin sinh sizeof ' +
+		'sleep socket_accept socket_bind ' +
+		'socket_clear_error socket_close ' +
+		'socket_connect socket_create ' +
+		'socket_create_listen socket_create_pair ' +
+		'socket_getopt socket_getpeername ' +
+		'socket_getsockname socket_get_option ' +
+		'socket_get_status socket_iovec_add ' +
+		'socket_iovec_alloc socket_iovec_delete ' +
+		'socket_iovec_fetch socket_iovec_free ' +
+		'socket_iovec_set socket_last_error ' +
+		'socket_listen socket_read socket_readv ' +
+		'socket_recv socket_recvfrom socket_recvmsg ' +
+		'socket_select socket_send socket_sendmsg ' +
+		'socket_sendto socket_setopt socket_set_block ' +
+		'socket_set_blocking socket_set_nonblock ' +
+		'socket_set_option socket_set_timeout ' +
+		'socket_shutdown socket_strerror socket_write ' +
+		'socket_writev sort soundex split ' +
+		'spliti sprintf sql_regcase sqrt srand ' +
+		'sscanf stat static strcasecmp strchr ' +
+		'strcmp strcoll strcspn ' +
+		'stream_context_create ' +
+		'stream_context_get_options ' +
+		'stream_context_set_option ' +
+		'stream_context_set_params stream_filter_append ' +
+		'stream_filter_prepend stream_get_meta_data ' +
+		'stream_register_wrapper stream_select ' +
+		'stream_set_blocking stream_set_timeout ' +
+		'stream_set_write_buffer stream_wrapper_register ' +
+		'strftime stripcslashes stripslashes ' +
+		'strip_tags stristr strlen strnatcasecmp ' +
+		'strnatcmp strncasecmp strncmp strpos ' +
+		'strrchr strrev strrpos strspn strstr ' +
+		'strtok strtolower strtotime strtoupper ' +
+		'strtr strval str_pad str_repeat ' +
+		'str_replace str_rot13 str_shuffle ' +
+		'str_word_count substr substr_count ' +
+		'substr_replace symlink syslog system ' +
+		'tan tanh tempnam textdomain time ' +
+		'tmpfile token_get_all token_name touch ' +
+		'trigger_error trim uasort ucfirst ' +
+		'ucwords uksort umask uniqid unixtojd ' +
+		'unlink unpack unregister_tick_function ' +
+		'unserialize unset urldecode urlencode ' +
+		'user_error usleep usort utf8_decode ' +
+		'utf8_encode var_dump var_export ' +
+		'version_compare virtual vprintf vsprintf ' +
+		'wddx_add_vars wddx_deserialize ' +
+		'wddx_packet_end wddx_packet_start ' +
+		'wddx_serialize_value wddx_serialize_vars ' +
+		'wordwrap xml_error_string ' +
+		'xml_get_current_byte_index ' +
+		'xml_get_current_column_number ' +
+		'xml_get_current_line_number xml_get_error_code ' +
+		'xml_parse xml_parser_create ' +
+		'xml_parser_create_ns xml_parser_free ' +
+		'xml_parser_get_option xml_parser_set_option ' +
+		'xml_parse_into_struct ' +
+		'xml_set_character_data_handler ' +
+		'xml_set_default_handler xml_set_element_handler ' +
+		'xml_set_end_namespace_decl_handler ' +
+		'xml_set_external_entity_ref_handler ' +
+		'xml_set_notation_decl_handler xml_set_object ' +
+		'xml_set_processing_instruction_handler ' +
+		'xml_set_start_namespace_decl_handler ' +
+		'xml_set_unparsed_entity_decl_handler yp_all ' +
+		'yp_cat yp_errno yp_err_string yp_first ' +
+		'yp_get_default_domain yp_master yp_match ' +
+		'yp_next yp_order zend_logo_guid ' +
+		'zend_version zlib_get_coding_type'.split(" "),
+
+    punctuation: '{ } ?> <?= <?php > < / + - % * . , ; ( ) ? : = " \''.split(" "),
+
+    highlight: function(line, meta) {           
+        if (!meta) meta = {};
+
+        var K = bespin.syntax.PHPConstants;    // aliasing the constants for shorter reference ;-)
+
+        var regions = {};                               // contains the individual style types as keys, with array of start/stop positions as value
+
+        // current state, maintained as we parse through each character in the line; values at any time should be consistent
+        var currentStyle = (meta.inMultilineComment) ? K.C_STYLE_COMMENT : undefined;
+        var currentRegion = {}; // should always have a start property for a non-blank buffer
+        var buffer = "";
+
+        // these properties are related to the parser state above but are special cases
+        var stringChar = "";    // the character used to start the current string
+        var multiline = meta.inMultilineComment;
+
+        for (var i = 0; i < line.length; i++) {
+            var c = line.charAt(i);
+
+            // check if we're in a comment and whether this character ends the comment
+            if (currentStyle == K.C_STYLE_COMMENT) {
+                if (c == "/" && /\*$/.test(buffer)) { // has the c-style comment just ended?
+                    currentRegion.stop = i + 1;
+                    this.addRegion(regions, currentStyle, currentRegion);
+                    currentRegion = {};
+                    currentStyle = undefined;
+                    multiline = false;
+                    buffer = "";
+                } else {
+                    if (buffer == "") currentRegion = { start: i };
+                    buffer += c;
+                }
+
+                continue;
+            }
+
+            if (this.isWhiteSpaceOrPunctuation(c)) {
+                // check if we're in a string
+                if (currentStyle == K.STRING) {
+                    // if this is not an unescaped end quote (either a single quote or double quote to match how the string started) then keep going
+                    if ( ! (c == stringChar && !/\\$/.test(buffer))) { 
+                        if (buffer == "") currentRegion = { start: i };
+                        buffer += c;
+                        continue;
+                    }
+                }
+
+                // if the buffer is full, add it to the regions
+                if (buffer != "") {
+                    currentRegion.stop = i;
+
+                    if (currentStyle != K.STRING) {   // if this is a string, we're all set to add it; if not, figure out if its a keyword
+                        if (this.keywords.indexOf(buffer) != -1) {
+                            // the buffer contains a keyword
+                            currentStyle = K.KEYWORD;
+                        } else {
+                            currentStyle = K.OTHER;
+                        }
+                    }
+                    this.addRegion(regions, currentStyle, currentRegion);
+                    currentRegion = {};
+                    stringChar = "";
+                    buffer = "";
+                    // i don't clear the current style here so I can check if it was a string below
+                }
+
+                if (this.isPunctuation(c)) {
+                    if (c == "*" && i > 0 && (line.charAt(i - 1) == "/")) {
+                        // remove the previous region in the punctuation bucket, which is a forward slash
+                        regions[K.PUNCTUATION].pop();
+
+                        // we are in a c-style comment
+                        multiline = true;
+                        currentStyle = K.C_STYLE_COMMENT;
+                        currentRegion = { start: i - 1 };
+                        buffer = "/*";
+                        continue;
+                    }
+
+                    // check for a line comment; this ends the parsing for the rest of the line
+                    if (c == '/' && i > 0 && (line.charAt(i - 1) == '/')) {
+                        currentRegion = { start: i - 1, stop: line.length };
+                        currentStyle = K.LINE_COMMENT;
+                        this.addRegion(regions, currentStyle, currentRegion);
+                        buffer = "";
+                        currentStyle = undefined;
+                        currentRegion = {};
+                        break;      // once we get a line comment, we're done!
+                    }
+
+                    // add an ad-hoc region for just this one punctuation character
+                    this.addRegion(regions, K.PUNCTUATION, { start: i, stop: i + 1 });
+                }
+
+                // find out if the current quote is the end or the beginning of the string
+                if ((c == "'" || c == '"') && (currentStyle != K.STRING)) {
+                    currentStyle = K.STRING;
+                    stringChar = c;
+                } else {
+                    currentStyle = undefined;
+                }
+
+                continue;
+            }
+
+            if (buffer == "") currentRegion = { start: i };
+            buffer += c;
+        }
+
+        // check for a trailing character inside of a string or a comment
+        if (buffer != "") {
+            if (!currentStyle) currentStyle = K.OTHER;
+            currentRegion.stop = line.length;
+            this.addRegion(regions, currentStyle, currentRegion);
+        }
+
+        return { regions: regions, meta: { inMultilineComment: multiline } };
+    },
+
+    addRegion: function(regions, type, data) {
+        if (!regions[type]) regions[type] = [];
+        regions[type].push(data);
+    },
+
+    isWhiteSpaceOrPunctuation: function(ch) {
+        return this.isPunctuation(ch) || this.isWhiteSpace(ch);
+    },
+
+    isPunctuation: function(ch) {
+        return this.punctuation.indexOf(ch) != -1;
+    },
+
+    isWhiteSpace: function(ch) {
+        return ch == " ";
+    }
+});
+
+// Register
+bespin.syntax.EngineResolver.register(new bespin.syntax.PHPSyntaxEngine(), ['php', 'php3', 'php4', 'php5']);

Propchange: camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/php.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/syntax.js
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/syntax.js?rev=755931&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/syntax.js (added)
+++ camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/syntax.js Thu Mar 19 11:24:18 2009
@@ -0,0 +1,189 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ * See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * The Original Code is Bespin.
+ *
+ * The Initial Developer of the Original Code is Mozilla.
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Bespin Team (bespin@mozilla.com)
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+// = Syntax Highlighting =
+//
+// Module for dealing with the syntax highlighting.
+//
+// The core model talks to specific engines to do the work and then packages it up to send to the editor.
+
+dojo.provide("bespin.syntax.syntax");
+
+
+// ** {{{ bespin.syntax.Model }}} **
+//
+// Tracks syntax highlighting data on a per-line basis.
+
+dojo.declare("bespin.syntax.Model", null, {
+    constructor: function(editor) {
+        this.editor = editor;
+        this.lineCache = [];
+        this.lineMetaInfo = [];
+        this.syntaxType = "";
+    },
+
+    // ** {{{ Meta Info }}} **
+    //
+    // We store meta info on the lines, such as the fact that it is in a multiline comment
+    setLineMetaInfo: function(lineNumber, meta) {
+        this.lineMetaInfo[lineNumber] = meta;
+    },
+
+    getLineMetaInfo: function(lineNumber) {
+        return this.lineMetaInfo[lineNumber];
+    },
+
+    // ** {{{ Caching }}} **
+    //
+    // Optionally, keep a cache of the highlighted model
+    invalidateCache: function(lineNumber) {
+        delete this.lineCache[lineNumber];
+    },
+
+    invalidateEntireCache: function() {
+        this.lineCache = [];
+    },
+
+    addToCache: function(lineNumber, line) {
+        this.lineCache[lineNumber] = line;
+    },
+
+    getFromCache: function(lineNumber) {
+        return this.lineCache[lineNumber];
+    },
+
+    mergeSyntaxResults: function(regions) {
+        // TO BE COMPLETED
+        // This function has to take the regions and take sub pieces and tie them into the full line
+        // For example, imagine an HTML engine that sees <script>....</script>
+        // It will pass .... into the JavaScript engine and take those results with a base of 0 and return the real location
+        var base = 0;
+        for (var i = 0; i < regions.length; i++) {
+            var region = region[i];
+            //base += region.
+        }
+    },
+
+    // -- Main API
+    // ** {{{ getSyntaxStyles }}} **
+    //
+    // This is the main API.
+    //
+    // Given the line number and syntax type (e.g. css, js, html) hunt down the engine, ask it to syntax highlight, and return the regions
+    getSyntaxStyles: function(lineText, lineNumber, syntaxType) {
+        if (this.syntaxType != syntaxType) {
+            this.invalidateEntireCache();
+            this.engine = bespin.syntax.EngineResolver.resolve(syntaxType);
+            this.syntaxType = syntaxType;
+        } else { // Possible for caching to be real here
+            // var cached = this.getFromCache(lineNumber);
+            // if (cached) return cached;
+        }
+
+        // Get the row contents as one string
+        var syntaxResult = { // setup the result
+            text: lineText,
+            regions: []
+        };
+
+        var meta;
+
+        // we have the ability to have subtypes within the main parser
+        // E.g. HTML can have JavaScript or CSS within
+        if (typeof this.engine['innertypes'] == "function") {
+            var syntaxTypes = this.engine.innertypes(lineText);
+
+            for (var i = 0; i < syntaxTypes.length; i++) {
+                var type = syntaxTypes[i];
+                meta = { inMultiLineComment: this.inMultiLineComment(), offset: type.start }; // pass in an offset
+                var pieceRegions = [];
+                var fromResolver = bespin.syntax.EngineResolver.highlight(type.type, lineText.substring(type.start, type.stop), meta);
+                if (fromResolver.meta && (i == syntaxTypes.length - 1) ){
+                    this.setLineMetaInfo(lineNumber, fromResolver.meta);
+                }
+                pieceRegions.push(fromResolver);
+            }
+            syntaxResult.regions.push(this.mergeSyntaxResults(pieceRegions));
+        } else {
+            meta = (lineNumber > 0) ? this.getLineMetaInfo(lineNumber - 1) : {};
+            var result = this.engine.highlight(lineText, meta);
+            this.setLineMetaInfo(lineNumber, result.meta);
+            syntaxResult.regions.push(result.regions);
+        }
+
+        this.addToCache(lineNumber, syntaxResult);
+        return syntaxResult;
+    }
+});
+
+// ** {{{ bespin.Ssntax.EngineResolver }}} **
+//
+// The resolver holds the engines that are available to do the actual syntax highlighting
+//
+// It holds a default engine that returns the line back in the clear
+
+bespin.syntax.EngineResolver = function() {
+  var engines = {};
+
+  // ** {{{ NoopSyntaxEngine }}} **
+  //
+  // Return a plain region that is the entire line
+  var NoopSyntaxEngine = {
+      highlight: function(line, meta) {
+          return { regions: {
+              plain: [{
+                  start: 0,
+                  stop: line.length
+              }]
+          } };
+      }
+      //innersyntax: function() {},
+  };
+
+  return {
+      // ** {{{ highlight }}} **
+      //
+      // A high level highlight function that uses the {{{type}}} to get the engine, and asks it to highlight
+      highlight: function(type, line, meta) {
+          this.resolve(type).highlight(line, meta);
+      },
+
+      // ** {{{ register }}} **
+      //
+      // Engines register themselves,
+      // e.g. {{{Bespin.Syntax.EngineResolver.register(new Bespin.Syntax.CSSSyntaxEngine(), ['css']);}}}
+      register: function(syntaxEngine, types) {
+          for (var i = 0; i < types.length; i++) {
+              engines[types[i]] = syntaxEngine;
+          }
+      },
+
+      // ** {{{ resolve }}} **
+      //
+      // Hunt down the engine for the given {{{type}}} (e.g. css, js, html) or return the {{{NoopSyntaxEngine}}}
+      resolve: function(type) {
+          return engines[type] || NoopSyntaxEngine;
+      }
+  };
+}();

Propchange: camel/trunk/components/camel-web/src/main/webapp/js/bespin/syntax/syntax.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-web/src/main/webapp/js/bespin/user/dependencies.js
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/webapp/js/bespin/user/dependencies.js?rev=755931&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/webapp/js/bespin/user/dependencies.js (added)
+++ camel/trunk/components/camel-web/src/main/webapp/js/bespin/user/dependencies.js Thu Mar 19 11:24:18 2009
@@ -0,0 +1,34 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ * See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * The Original Code is Bespin.
+ *
+ * The Initial Developer of the Original Code is Mozilla.
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Bespin Team (bespin@mozilla.com)
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+dojo.provide("bespin.user.dependencies");
+
+dojo.require("dojo.cookie");
+dojo.require("dijit._base.place");
+
+dojo.require("bespin.bespin");
+dojo.require("bespin.util.navigate");
+dojo.require("bespin.client.server");
+dojo.require("bespin.user.utils");
+dojo.require("bespin.user.register");
\ No newline at end of file

Propchange: camel/trunk/components/camel-web/src/main/webapp/js/bespin/user/dependencies.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-web/src/main/webapp/js/bespin/user/register.js
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/webapp/js/bespin/user/register.js?rev=755931&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/webapp/js/bespin/user/register.js (added)
+++ camel/trunk/components/camel-web/src/main/webapp/js/bespin/user/register.js Thu Mar 19 11:24:18 2009
@@ -0,0 +1,113 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ * See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * The Original Code is Bespin.
+ *
+ * The Initial Developer of the Original Code is Mozilla.
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Bespin Team (bespin@mozilla.com)
+ *
+ * ***** END LICENSE BLOCK ***** */
+ 
+dojo.provide("bespin.user.register"); 
+
+// Login, logout and registration functions for the Bespin front page.
+
+(function() {
+    var server = bespin.get('server') || bespin.register('server', new bespin.client.Server());
+    var utils = bespin.user.utils;
+    var webpieces = bespin.util.webpieces;
+    
+    dojo.mixin(bespin.user, {
+        login: function() {
+            if (utils.showingBrowserCompatScreen()) return;
+
+            if (dojo.byId("username").value && dojo.byId("password").value) {
+                // try to find the httpSessionId
+                var cookies = document.cookie.split(';');
+                var foundValue = "";
+                for (var i = 0; i < cookies.length; i++) {
+                    var cookie = cookies[i];
+                    while (cookie.charAt(0) == ' ') cookie = cookie.substring(1, cookie.length);
+                    if (cookie.indexOf("anticsrf=") == 0) {
+                        foundValue = cookie.substring(dwr.engine._sessionCookieName.length + 1, cookie.length);
+                        break;
+                    }
+                }
+
+                server.login(dojo.byId("username").value, dojo.byId("password").value, 
+                    foundValue, 
+                    utils.whenLoginSucceeded,
+                    utils.whenLoginFailed);
+            } else {
+                webpieces.showStatus("Please give me both a username and a password");
+            }
+        },
+
+        logout: function() {
+            server.logout(); 
+            dojo.style('logged_in', 'display', 'none');
+            dojo.style('not_logged_in', 'display', 'block');
+        }    
+    }); 
+    
+    dojo.mixin(bespin.user.register, {
+        checkUsername: function() {
+            var username_error = [];
+            var username = dojo.byId("register_username").value;
+            if (username.length < 4) {
+                username_error.push("Usernames must be at least 4 characters long");   
+            }
+            if (/[<>| '"]/.test(username)) {
+                username_error.push("Usernames must not contain any of: <>| '\"");   
+            }
+            dojo.byId('register_username_error').innerHTML = username_error.join(", ");
+        },
+        checkPassword: function() {
+            dojo.byId('register_password_error').innerHTML = (dojo.byId('register_password').value.length < 6) ? "Passwords must be at least 6 characters long" : "";
+        },
+        checkConfirm: function() {
+            dojo.byId('register_confirm_error').innerHTML = (dojo.byId('register_password').value != dojo.byId('register_confirm').value) ? "Passwords do not match" : "";
+        },
+        checkEmail: function() {
+            dojo.byId('register_email_error').innerHTML = (!utils.validateEmail(dojo.byId('register_email').value)) ? "Invalid email address" : "";
+        },
+        showForm: function() {
+            if (utils.showingBrowserCompatScreen()) return;
+            dojo.style('logged_in', 'display', 'none');
+            dojo.style('not_logged_in', 'display', 'none');
+            dojo.style('overlay', 'display', 'block');
+            dojo.style('centerpopup', 'display', 'block');            
+            webpieces.showCenterPopup(dojo.byId('centerpopup'));  
+        },
+        hideForm: function() {
+            webpieces.hideCenterPopup(dojo.byId('centerpopup'));
+            server.currentuser(utils.whenAlreadyLoggedIn, utils.whenNotAlreadyLoggedIn);
+        },
+        send: function() {
+            this.hideForm();
+            server.signup(dojo.byId("register_username").value, 
+                dojo.byId("register_password").value, 
+                dojo.byId('register_email').value, 
+                utils.whenLoginSucceeded, 
+                utils.whenLoginFailed, 
+                utils.whenUsernameInUse);
+        },
+        cancel: function() { 
+            this.hideForm();
+        }
+    });
+})();
\ No newline at end of file

Propchange: camel/trunk/components/camel-web/src/main/webapp/js/bespin/user/register.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-web/src/main/webapp/js/bespin/user/utils.js
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/webapp/js/bespin/user/utils.js?rev=755931&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/webapp/js/bespin/user/utils.js (added)
+++ camel/trunk/components/camel-web/src/main/webapp/js/bespin/user/utils.js Thu Mar 19 11:24:18 2009
@@ -0,0 +1,82 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ * See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * The Original Code is Bespin.
+ *
+ * The Initial Developer of the Original Code is Mozilla.
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Bespin Team (bespin@mozilla.com)
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+dojo.provide("bespin.user.utils");
+
+dojo.require("bespin.util.webpieces");
+
+// = Utility functions for the Bespin front page =
+//
+// Dealing with login on the front page of the site and beyond
+
+dojo.mixin(bespin.user.utils, {
+    whenLoginSucceeded: function() {
+        bespin.util.navigate.dashboard();
+    },
+
+    whenLoginFailed: function() {
+        bespin.util.webpieces.showStatus("Sorry, login didn't work. Try again? Caps lock on?");
+    },
+
+    whenUsernameInUse: function() {
+        bespin.util.webpieces.showStatus("The username is taken. Please choose another.");
+    },
+
+    whenAlreadyLoggedIn: function(userinfo) {
+        dojo.byId('display_username').innerHTML = userinfo.username;
+        dojo.style('logged_in', 'display', 'block');
+    },
+
+    whenNotAlreadyLoggedIn: function() {
+        dojo.style('not_logged_in', 'display', 'block');
+    },
+
+    // make sure that the browser can do our wicked shizzle
+    checkBrowserAbility: function() {
+        if (typeof dojo.byId('testcanvas').getContext != "function") return false; // no canvas
+
+        var ctx = dojo.byId('testcanvas').getContext("2d");
+
+        if (ctx.fillText || ctx.mozDrawText) {
+            return true; // you need text support my friend
+        } else {
+            return false;
+        }
+    },
+
+    showingBrowserCompatScreen: function() {
+       if (!this.checkBrowserAbility()) { // if you don't have the ability
+            bespin.util.webpieces.showCenterPopup(dojo.byId('browser_not_compat'));
+
+            return true;
+        } else {
+            return false;
+        }
+    },
+
+    validateEmail: function(str) {
+        var filter=/^([\w-+_]+(?:\.[\w-+_]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
+        return filter.test(str);
+    }
+});

Propchange: camel/trunk/components/camel-web/src/main/webapp/js/bespin/user/utils.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-web/src/main/webapp/js/bespin/util/canvas.js
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/webapp/js/bespin/util/canvas.js?rev=755931&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/webapp/js/bespin/util/canvas.js (added)
+++ camel/trunk/components/camel-web/src/main/webapp/js/bespin/util/canvas.js Thu Mar 19 11:24:18 2009
@@ -0,0 +1,80 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ * See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * The Original Code is Bespin.
+ *
+ * The Initial Developer of the Original Code is Mozilla.
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Bespin Team (bespin@mozilla.com)
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+dojo.provide("bespin.util.canvas");
+
+// = Canvas Shim =
+//
+// Make canvas work the same on the different browsers and their quirks
+
+// ** {{{ bespin.util.fixcanvas.fix }}} **
+//
+// Take the context and clean it up
+
+dojo.mixin(bespin.util.canvas, {
+    fix: function(ctx) {
+        // * upgrade Firefox 3.0.x text rendering to HTML 5 standard
+        if (!ctx.fillText && ctx.mozDrawText) {
+            ctx.fillText = function(textToDraw, x, y, maxWidth) {
+                ctx.translate(x, y);
+                ctx.mozTextStyle = ctx.font;
+                ctx.mozDrawText(textToDraw);
+                ctx.translate(-x, -y);
+            };
+        }
+
+        // * Setup measureText
+        if (!ctx.measureText && ctx.mozMeasureText) {
+            ctx.measureText = function(text) {
+                if (ctx.font) ctx.mozTextStyle = ctx.font;
+                var width = ctx.mozMeasureText(text);
+                return { width: width };
+            };
+        }
+
+        // * Setup html5MeasureText
+        if (ctx.measureText && !ctx.html5MeasureText) {
+            ctx.html5MeasureText = ctx.measureText;
+            ctx.measureText = function(text) {
+                var textMetrics = ctx.html5MeasureText(text);
+
+                // fake it 'til you make it
+                textMetrics.ascent = ctx.html5MeasureText("m").width;
+
+                return textMetrics;
+            };
+        }
+
+        // * for other browsers, no-op away
+        if (!ctx.fillText) {
+            ctx.fillText = function() {};
+        }
+
+        if (!ctx.measureText) {
+            ctx.measureText = function() { return 10; };
+        }
+
+        return ctx;
+    }
+});

Propchange: camel/trunk/components/camel-web/src/main/webapp/js/bespin/util/canvas.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-web/src/main/webapp/js/bespin/util/keys.js
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/webapp/js/bespin/util/keys.js?rev=755931&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/webapp/js/bespin/util/keys.js (added)
+++ camel/trunk/components/camel-web/src/main/webapp/js/bespin/util/keys.js Thu Mar 19 11:24:18 2009
@@ -0,0 +1,170 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ * See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * The Original Code is Bespin.
+ *
+ * The Initial Developer of the Original Code is Mozilla.
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Bespin Team (bespin@mozilla.com)
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+dojo.provide("bespin.util.keys");
+
+// = Key Helpers =
+//
+// Helpful code to deal with key handling and processing
+// Consists of two core pieces:
+//
+// * {{{bespin.util.keys.Key}}} is a map of keys to key codes
+// * {{{bespin.util.keys.fillArguments}}} converts a string "CTRL A" to its key and modifier
+//
+// TODO: Having the keys in the same scope as the method is really bad :)
+
+// ** {{{ bespin.util.keys.Key }}} **
+//
+// Alpha keys, and special keys (ENTER, BACKSPACE) have key codes that our code needs to check.
+// This gives you a way to say Key.ENTER when matching a key code instead of "13"
+
+bespin.util.keys.Key = {
+
+// -- Numbers
+  ZERO: 48,
+  ONE: 49,
+  TWO: 50,
+  THREE: 51,
+  FOUR: 52,
+  FIVE: 53,
+  SIX: 54,
+  SEVEN: 55,
+  EIGHT: 56,
+  NINE: 57,
+  
+// -- Alphabet
+  A: 65,
+  B: 66,
+  C: 67,
+  D: 68,
+  E: 69,
+  F: 70,
+  G: 71,
+  H: 72,
+  I: 73,
+  J: 74,
+  K: 75,
+  L: 76,
+  M: 77,
+  N: 78,
+  O: 79,
+  P: 80,
+  Q: 81,
+  R: 82,
+  S: 83,
+  T: 84,
+  U: 85,
+  V: 86,
+  W: 87,
+  X: 88,
+  Y: 89,
+  Z: 90,
+
+// -- Special Keys
+  BACKSPACE: 8,
+  TAB: 9,
+  ENTER: 13,
+  ESCAPE: 27,
+  END: 35,
+  HOME: 36,
+  ARROW_LEFT: 37,
+  ARROW_UP: 38,
+  ARROW_RIGHT: 39,
+  ARROW_DOWN: 40,
+  DELETE: 46,
+  PAGE_UP: 33,
+  PAGE_DOWN: 34,
+  PLUS: 61,
+  MINUS: 109,
+  TILDE: 192
+};
+
+// ** {{{ bespin.util.keys.fillArguments }}} **
+//
+// Fill out the arguments for action, key, modifiers
+//
+// {{{string}}} can be something like "CTRL S"
+// {{{args}}} is the args that you want to modify. This is common as you may already have args.action.
+
+bespin.util.keys.fillArguments = function(string, args) {
+    var keys = string.split(' ');
+    args = args || {};
+    
+    var modifiers = [];   
+    dojo.forEach(keys, function(key) {
+       if (key.length > 1) { // more than just an alpha/numeric
+           modifiers.push(key);
+       } else {
+           args.key = key;
+       }
+    });
+
+    if (modifiers.length == 0) { // none if that is true
+        args.modifiers = "none";
+    } else {
+        args.modifiers = modifiers.join(',');
+    }
+    
+    return args;
+};
+
+// ** {{{ bespin.util.keys.PassThroughCharCodes }}} **
+//
+// Cache the character codes that we want to pass through to the browser
+// Should map to list below
+bespin.util.keys.PassThroughCharCodes = dojo.map(["k", "l", "n", "o", "t", "w", "+", "-", "~", 
+    "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], function(item){ return item.charCodeAt(0); });
+
+// ** {{{ bespin.util.keys.PassThroughKeyCodes }}} **
+//
+// Cache the key codes that we want to pass through to the browser
+// Should map to list above 
+bespin.util.keys.PassThroughKeyCodes = (function() {
+    var Key = bespin.util.keys.Key;
+    return [Key.C, Key.X, Key.V, Key.K, Key.L, Key.N, Key.O, Key.T, Key.W, Key.PLUS, Key.MINUS, Key.TILDE,
+            Key.ZERO, Key.ONE, Key.TWO, Key.THREE, Key.FOUR, Key.FIVE, Key.SIX, Key.SEVEN, Key.EIGHT, Key.NINE];   
+})();
+
+// ** {{{ bespin.util.keys.passThroughToBrowser }}} **
+//
+// Given the event, return true if you want to allow the event to pass through to the browser.
+// For example, allow Apple-L to go to location, Apple-K for search. Apple-# for a tab.
+//
+// {{{e}}} Event that came into an {{{onkeydown}}} handler
+
+bespin.util.keys.passThroughToBrowser = function(e) {
+    var Key = bespin.util.keys.Key;
+    
+    if (!e.ctrlKey) { // let normal characters through
+        return true;
+    } else if (e.metaKey || e.altKey) { // Apple or Alt key
+        if (e.type == "keypress") {   
+            if (dojo.some(bespin.util.keys.PassThroughCharCodes, function(item) { return (item == e.charCode); })) return true;  
+        } else {
+            if (dojo.some(bespin.util.keys.PassThroughKeyCodes, function(item) { return (item == e.keyCode); })) return true; 
+        }
+    }
+                                                 
+    return false;
+};

Propchange: camel/trunk/components/camel-web/src/main/webapp/js/bespin/util/keys.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-web/src/main/webapp/js/bespin/util/mousewheelevent.js
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/webapp/js/bespin/util/mousewheelevent.js?rev=755931&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/webapp/js/bespin/util/mousewheelevent.js (added)
+++ camel/trunk/components/camel-web/src/main/webapp/js/bespin/util/mousewheelevent.js Thu Mar 19 11:24:18 2009
@@ -0,0 +1,33 @@
+/*
+ * Orginal: http://adomas.org/javascript-mouse-wheel/
+ * prototype extension by "Frank Monnerjahn" themonnie @gmail.com
+ *
+ * Tweaked to map everyting to Mozilla's event.detail result
+ */
+
+dojo.provide("bespin.util.mousewheelevent");
+
+dojo.mixin(bespin.util.mousewheelevent, {
+    wheel: function(event) {
+        var delta = 0;
+        if (!event) event = window.event;
+        if (event.wheelDelta) {
+            delta = -(event.wheelDelta/620);
+            if (window.opera) delta = -delta;
+        } else if (event.detail) {
+            delta = event.detail;
+        }  
+
+        return Math.round(delta); // Safari Round
+    },
+    
+    axis: function(event) {
+        var returnType = "vertical";
+        if (event.axis) { // Firefox 3.1 world
+            if (event.axis == event.HORIZONTAL_AXIS) returnType = "horizontal";
+        } else if (event.wheelDeltaY || event.wheelDeltaX) {
+            if (event.wheelDeltaX == event.wheelDelta) returnType = "horizontal";
+        } else if (event.shiftKey) returnType = "horizontal";
+        return returnType;
+    }
+});
\ No newline at end of file

Propchange: camel/trunk/components/camel-web/src/main/webapp/js/bespin/util/mousewheelevent.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-web/src/main/webapp/js/bespin/util/navigate.js
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/webapp/js/bespin/util/navigate.js?rev=755931&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/webapp/js/bespin/util/navigate.js (added)
+++ camel/trunk/components/camel-web/src/main/webapp/js/bespin/util/navigate.js Thu Mar 19 11:24:18 2009
@@ -0,0 +1,88 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
+ * See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * The Original Code is Bespin.
+ *
+ * The Initial Developer of the Original Code is Mozilla.
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Bespin Team (bespin@mozilla.com)
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+dojo.provide("bespin.util.navigate");
+
+dojo.require("bespin.client.settings");
+
+// = Navigate =
+//
+// Simple wrapper to force navigation to a project URL without all using location.href
+
+// ** {{{ bespin.util.navigate }}} **
+//
+// new up an object that will return public methods and hide private ones
+
+(function() {
+
+    // ** {{{ Yup, you can be private }}} **
+    //
+    // Generic location changer
+
+    var go = function(url, newTab) {
+        if (newTab) {
+            window.open(url, "_blank");
+        } else {
+            location.href = url;
+        }
+    };
+
+
+    // ** {{{ Public }}} **
+    //
+    // Simple methods to construct URLs within Bespin and go to them
+
+    dojo.mixin(bespin.util.navigate, {
+        dashboard: function(newTab) {
+            var pathSelected = (new bespin.client.settings.URL()).get('fromDashboardPath')
+            if (pathSelected) {
+                go("dashboard.html#path="+pathSelected, newTab);    // this contains the pathSelected parameter!
+            } else {
+                go("dashboard.html", newTab);
+            }
+        },
+
+        home: function(newTab) {
+            go("index.html", newTab);
+        },
+
+        quickEdit: function(newTab) {
+    		go("editor.html#new=true", newTab);
+    	},
+
+        editor: function(project, path, newTab) {
+            var url = "editor.html#";
+            var args = [];
+
+            if (project) args.push("project=" + project);
+            if (path) args.push("path=" + path);
+            var selectedPath = bespin.page.dashboard.tree.getSelectedPath(true);
+            if (selectedPath)   args.push('fromDashboardPath='+selectedPath);
+
+            if (args.length > 0) url += args.join("&");
+
+            go(url, newTab);
+        }
+    });
+})();

Propchange: camel/trunk/components/camel-web/src/main/webapp/js/bespin/util/navigate.js
------------------------------------------------------------------------------
    svn:eol-style = native