/**
 * Distributed under the BSD license:
 *
 * Copyright (c) 2010, Ajax.org B.V.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of Ajax.org B.V. nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *
 * Modifications by Fernando Bevilacqua <dovyski@gmail.com>
 *
 */

var CodebotEditorAce = new function() {
    this.create = function(theTab, theContent, theNode) {
        var aEditor = null, aReader;

        aEditor = ace.edit(theTab.container);
        aEditor.setTheme("ace/theme/tomorrow_night_eighties"); // TODO: get theme from Codebot?
        aEditor.getSession().setMode("ace/mode/javascript"); // TODO: choose mode based on file extension.
        aEditor.getSession().setOption("useWorker", false);

        if(theContent instanceof Blob) {
            aReader = new FileReader();
			aReader.readAsText(theContent);

            aReader.onloadend = function() {
                aEditor.setValue(aReader.result);
                aEditor.session.selection.clearSelection();
                theTab.setDirty(false);
			};
        } else {
            aEditor.setValue(theContent);
            aEditor.session.selection.clearSelection();
        }

        // TODO: remove this CODEBOT singleton call.
        for(var i in CODEBOT.preferences.get().editor) {
            aEditor.setOption(i, CODEBOT.preferences.get().editor[i]);
        }

        aEditor.getSession().on('change', function(e) {
            theTab.setDirty(true);
        });

        return aEditor;
    };
};

@@ -1,853 +1,679 @@
 /*
-*
 %0A 
-* Distributed under the BSD license:%0A *%0A * Copyright (c) 2010, Ajax.org B.V.%0A * All rights reserved.%0A *%0A * Redistribution and use in source and binary forms, with or without%0A * modification, are permitted provided that the following conditions are met:%0A *     * Redistributions of source code must retain the above copyright%0A *       notice, this list of conditions and the following disclaimer.
+   The MIT License (MIT)%0A%0A    Copyright (c) 2016 Fernando Bevilacqua%0A%0A    Permission is hereby granted, free of charge, to any person obtaining a copy of%0A    this software and associated documentation files (the %22Software%22), to deal in
 %0A 
-*
    
-  * Redi
+the Software without re
 stri
-bu
+c
 tion
-s in binary form must reproduce the above copy
+, including without limitation the 
 right
+s to
 %0A 
-*
    
-    notice, this list of conditions and the following disclaimer in the
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 %0A 
-*
    
-    documentation and/or other materials provided with th
+the Software, and to permit persons to whom the Softwar
 e 
-d
 is
-tribution.%0A *     * Neither the name of Ajax.org B.V. nor the%0A *       names of its contributors may be used to endorse or promote products%0A *       derived from this software without specific prior written permission.%0A *%0A * THIS
+ furnished to do so,%0A    subject to the following conditions:%0A%0A    The above copyright notice and this permission notice shall be included in all%0A    copies or substantial portions of the Software.%0A%0A    THE
  SOF
@@ -694,68 +694,46 @@
 DED 
-BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS %22AS IS%22 AND%0A * ANY
+%22AS IS%22, WITHOUT WARRANTY OF ANY KIND,
  EXP
@@ -739,24 +739,28 @@
 PRESS OR
+%0A   
  IMPLIED
  WARRANT
@@ -751,27 +751,16 @@
  IMPLIED
- WARRANTIES
 , INCLUD
@@ -754,33 +754,32 @@
 PLIED, INCLUDING
-,
  BUT NOT LIMITED
@@ -785,24 +785,12 @@
 D TO
-,
  THE
- IMPLIED%0A *
  WAR
@@ -819,20 +819,17 @@
 LITY
- AND
+,
  FITNESS
  FOR
@@ -824,16 +824,20 @@
  FITNESS
+%0A   
  FOR A P
@@ -859,24 +859,26 @@
 SE A
-RE%0A * DISCLAIMED
+ND NONINFRINGEMENT
 . IN
@@ -897,379 +897,140 @@
 ALL 
-AJAX.ORG B.V. BE LIABLE FOR ANY%0A * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES%0A * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;%0A * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND%0A * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT%0A * (INCLUDING NEGLIGENCE
+THE AUTHORS OR%0A    COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER%0A    IN AN ACTION OF CONTRACT, TORT
  OR 
@@ -1038,17 +1038,17 @@
 THERWISE
-)
+,
  ARISING
@@ -1052,176 +1052,106 @@
 ING 
-IN ANY WAY OUT OF THE USE OF THIS%0A * SOFTWARE, EVEN IF ADVI
+FROM, OUT OF OR IN%0A    CONNECTION WITH THE SOFTWARE OR THE U
 SE
-D
  O
-F THE POSSIBILITY OF SUCH DAMAGE.%0A *%0A *%0A * Modifications by Fernando Bevilacqua %3Cdovyski@gmail.com%3E%0A *%0A 
+R OTHER DEALINGS IN THE SOFTWARE.%0A
 */%0A%0A

Change text to right license