diff --git a/experiments/msg_stream.html b/experiments/msg_stream.html new file mode 100644 index 00000000..c85e2fb4 --- /dev/null +++ b/experiments/msg_stream.html @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/experiments/o3.js b/experiments/o3.js new file mode 100644 index 00000000..b63dd408 --- /dev/null +++ b/experiments/o3.js @@ -0,0 +1,293 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + * + */ + +// #ifdef __WITH_O3 +/** + * Helper class that aids in creating and controlling Ajax O3 instances + * + * @author Mike de Boer + * @version %I%, %G% + * @since 2.1 + * @namespace o3 + * @private + */ + + +(function(global) { +var sId = "Ajax.org", + sDefProduct = "O3Stem", + bAvailable = null, + iVersion = null, + embedded = false, + oO3Count = 0; + bEmbed = false, + sPlatform = null, + oInstMap = {}; + +function detect(o) { + var version; + var name = o && o.fullname ? o.fullname : "Ajax.org O3"; + + if (window.external && window.external.o3) { + version = window.external.o3.versionInfo.match(/v([\d]+\.[\d]+)/)[1]; + embedded = true; + } + else if (navigator.plugins && navigator.plugins[name]) { + version = navigator.plugins[name].description.match(/v([\d]+\.[\d]+)/)[1]; + } + else { + try { + var axo = new ActiveXObject(name); + version = axo.versionInfo.match(/v([\d]+\.[\d]+)/)[1]; + } + catch (e) {} + } + + if (version) { + iVersion = parseFloat(version); + bAvailable = true; + } + else { + iVersion = 0; + bAvailable = false; + } +} + +function sniff() { + var sAgent = navigator.userAgent.toLowerCase(); + var is_opera = sAgent.indexOf("opera") !== -1; + var is_konqueror = sAgent.indexOf("konqueror") != -1; + var is_safari = !is_opera && ((navigator.vendor + && navigator.vendor.match(/Apple/) ? true : false) + || sAgent.indexOf("safari") != -1 || is_konqueror); + var is_ie = (document.all && !is_opera && !is_safari); + bEmbed = !(is_ie && !is_opera); + + // OS sniffing: + + // windows... + if (sAgent.indexOf("win") != -1 || sAgent.indexOf("16bit") != -1) { + sPlatform = "win"; + if (sAgent.indexOf("win16") != -1 + || sAgent.indexOf("16bit") != -1 + || sAgent.indexOf("windows 3.1") != -1 + || sAgent.indexOf("windows 16-bit") != -1) + sPlatform += "16"; + else if (sAgent.indexOf("win32") != -1 + || sAgent.indexOf("32bit") != -1) + sPlatform += "32"; + else if (sAgent.indexOf("win32") != -1 + || sAgent.indexOf("32bit") != -1) + sPlatform += "64"; + } + // mac... + if (sAgent.indexOf("mac") != -1) { + sPlatform = "mac"; + if (sAgent.indexOf("ppc") != -1 || sAgent.indexOf("powerpc") != -1) + sPlatform += "ppc"; + else if (sAgent.indexOf("os x") != -1) + sPlatform += "osx"; + } + // linux... + if (sAgent.indexOf("inux") != -1) { + sPlatform = "linux"; + if (sAgent.indexOf("i686") > -1 || sAgent.indexOf("i386") > -1) + sPlatform += "32"; + else if (sAgent.indexOf("86_64")) + sPlatform += "64"; + else if (sAgent.indexOf("arm")) + sPlatform += "arm"; + } +} + +function installerUrl(o) { + return "http://www.ajax.org/o3/installer" + + (sPlatform ? "/platform/" + sPlatform : "") + + (o.guid ? "/guid/" + encodeURIComponent(o.guid) : ""); +} + +function escapeHtml(s) { + var c, ret = ""; + + if (s == null) return null; + + for (var i = 0, j = s.length; i < j; i++) { + c = s.charCodeAt(i); + if (((c > 96) && (c < 123)) || (( c > 64) && (c < 91)) + || ((c > 43) && (c < 58) && (c != 47)) || (c == 95)) + ret = ret + String.fromCharCode(c); + else + ret = ret + "&#" + c + ";"; + } + return ret; +} + +function createHtml(options) { + var out = []; + if (typeof options.width == "undefined") + options.width = 0; + if (typeof options.height == "undefined") + options.height = 0; + + out.push(bEmbed + ? ''); + if (options.params) { + var i, n, v; + for (i in options.params) { + if (!options.params[i]) continue; + n = escapeHtml(i); + v = escapeHtml(options.params[i]); + out.push(bEmbed + ? n + '="' + v + '" ' + : ' '); + } + } + out.push(bEmbed ? '> ' : ''); + + return out.join(""); +} + +function register(o, options) { + // do some funky registering stuff... + var key = (options.guid ? options.guid : "ajax.o3") + + (options.name ? "." + options.name : ""); + + if (!oInstMap[key]) + oInstMap[key] = []; + oInstMap[key].push(o); +} + +function get(guid) { + for (var i in oInstMap) { + if (i.indexOf(guid) > -1) + return oInstMap[i][0]; + } + + return null; +} + +function destroy(o) { + if (typeof o == "string") //guid provided + o = get(o); + if (!o) return; + // destroy references and domNode of this/ each plugin instance... + var i, j, k, inst; + for (i in oInstMap) { + inst = oInstMap[i]; + if (!inst.length) continue; + for (j = inst.length -1; j >= 0; j--) { + // if we're searching for 'o', check for a match first + if (o && inst[j] != o) continue; + for (k in o) { + if (typeof o[k] == "function") + o[k] = null; + } + inst[j].parentNode.removeChild(inst[j]); + inst.splice(j, 1); + } + } + + if (!o) + oInstMap = {}; +} + +// global API: +global.o3 = { + isAvailable: function(o) { + if (bAvailable === null) + detect(o); + + return bAvailable && ((o && o.version) ? iVersion === o.version : true); + }, + + getVersion: function() { + if (iVersion === null) + detect(); + + return iVersion; + }, + + create: function(guid, options) { + if (!options && typeof guid == "object") { + options = guid; + options.guid = false; + } + else { + options = options || {}; + options.guid = guid || false; + } + if (!options["fullname"]) { + options.fullname = (options.product || sDefProduct) + + (options.guid ? "-" + options.guid : "") + } + + // mini-browser sniffing: + sniff(); + + if (!this.isAvailable(options)) { + var sUrl = installerUrl(options); + return typeof options["oninstallprompt"] == "function" + ? options.oninstallprompt(sUrl) + : window.open(sUrl, "_blank"); + } + + if (typeof options["params"] == "undefined") + options.params = {}; + if (typeof options.params["type"] == "undefined") + options.params.type = "application/" + (options.fullname || "o3-XXXXXXXX"); + + options.id = sId + (options.name ? options.name : ""); + + var oO3; + if (!embedded) { + (options["parent"] || document.body).appendChild( + document.createElement("div")).innerHTML = createHtml(options); + + oO3 = document.getElementById(options.id); + } else { + oO3 = window.external.o3; + } + + if (oO3) { + register(oO3, options); + if (typeof options["onready"] == "function") + options.onready(oO3); + + return oO3; + } + + + return false; + }, + + destroy: destroy, + + get: get +}; + +})(this); + +// #endif diff --git a/experiments/o3debugger.html b/experiments/o3debugger.html new file mode 100644 index 00000000..d26ba98d --- /dev/null +++ b/experiments/o3debugger.html @@ -0,0 +1,532 @@ + + + + + + + + + +

+ + + + diff --git a/experiments/socket.html b/experiments/socket.html new file mode 100644 index 00000000..725d4b20 --- /dev/null +++ b/experiments/socket.html @@ -0,0 +1,43 @@ + + + + + + + + + + +
+ + + + diff --git a/jsTestDriver.conf b/jsTestDriver.conf index f047d8c9..12b88997 100644 --- a/jsTestDriver.conf +++ b/jsTestDriver.conf @@ -11,5 +11,8 @@ load: - src/ace/layer/*.js - src/ace/*.js - - src/test/*.js - - src/test/mode/*.js \ No newline at end of file + - src/debug/*.js + + - src/test/ace/*.js + - src/test/ace/mode/*.js + - src/test/debug/*.js \ No newline at end of file diff --git a/src/ace/BackgroundTokenizer.js b/src/ace/BackgroundTokenizer.js index 64b124d8..c521e026 100644 --- a/src/ace/BackgroundTokenizer.js +++ b/src/ace/BackgroundTokenizer.js @@ -33,8 +33,6 @@ ace.BackgroundTokenizer = function(tokenizer) { self.fireUpdateEvent(startLine, textLines.length - 1); }; - - this.$initEvents(); }; (function(){ diff --git a/src/ace/Document.js b/src/ace/Document.js index 83b5f173..d2de45f3 100644 --- a/src/ace/Document.js +++ b/src/ace/Document.js @@ -1,8 +1,6 @@ ace.provide("ace.Document"); ace.Document = function(text, mode) { - this.$initEvents(); - this.lines = []; this.modified = true; this.selection = new ace.Selection(this); diff --git a/src/ace/MEventEmitter.js b/src/ace/MEventEmitter.js index 22a94dac..cf72f70a 100644 --- a/src/ace/MEventEmitter.js +++ b/src/ace/MEventEmitter.js @@ -2,11 +2,9 @@ ace.provide("ace.MEventEmitter"); ace.MEventEmitter = function() { - this.$initEvents = function() { - this.$eventRegistry = {}; - }; - this.$dispatchEvent = function(eventName, e) { + this.$eventRegistry = this.$eventRegistry || {}; + var listeners = this.$eventRegistry[eventName]; if (!listeners || !listeners.length) return; @@ -19,6 +17,8 @@ ace.MEventEmitter = function() { }; this.addEventListener = function(eventName, callback) { + this.$eventRegistry = this.$eventRegistry || {}; + var listeners = this.$eventRegistry[eventName]; if (!listeners) { var listeners = this.$eventRegistry[eventName] = []; @@ -29,6 +29,8 @@ ace.MEventEmitter = function() { }; this.removeEventListener = function(eventName, callback) { + this.$eventRegistry = this.$eventRegistry || {}; + var listeners = this.$eventRegistry[eventName]; if (!listeners) { return; diff --git a/src/ace/ScrollBar.js b/src/ace/ScrollBar.js index ad622098..8e487f47 100644 --- a/src/ace/ScrollBar.js +++ b/src/ace/ScrollBar.js @@ -1,8 +1,6 @@ ace.provide("ace.ScrollBar"); ace.ScrollBar = function(parent) { - this.$initEvents(); - this.element = document.createElement("div"); this.element.className = "sb"; diff --git a/src/ace/Selection.js b/src/ace/Selection.js index 6d68825b..3f1eb3cc 100644 --- a/src/ace/Selection.js +++ b/src/ace/Selection.js @@ -3,8 +3,6 @@ ace.provide("ace.Selection"); ace.Selection = function(doc) { this.doc = doc; - this.$initEvents(); - this.clearSelection(); this.selectionLead = { row: 0, diff --git a/src/test/ChangeDocumentTest.js b/src/test/ace/ChangeDocumentTest.js similarity index 100% rename from src/test/ChangeDocumentTest.js rename to src/test/ace/ChangeDocumentTest.js diff --git a/src/test/DocumentTest.js b/src/test/ace/DocumentTest.js similarity index 100% rename from src/test/DocumentTest.js rename to src/test/ace/DocumentTest.js diff --git a/src/test/EventEmitterTest.js b/src/test/ace/EventEmitterTest.js similarity index 87% rename from src/test/EventEmitterTest.js rename to src/test/ace/EventEmitterTest.js index fba1793e..2c383c9e 100644 --- a/src/test/EventEmitterTest.js +++ b/src/test/ace/EventEmitterTest.js @@ -1,6 +1,5 @@ -var EventEmitter = function() { - this.$initEvents(); -}; +var EventEmitter = function() {}; + ace.implement(EventEmitter.prototype, ace.MEventEmitter); var EventEmitterTest = new TestCase("EventEmitterTest", { @@ -16,5 +15,4 @@ var EventEmitterTest = new TestCase("EventEmitterTest", { emitter.$dispatchEvent("juhu"); assertTrue(called); } -}); - +}); \ No newline at end of file diff --git a/src/test/MockRenderer.js b/src/test/ace/MockRenderer.js similarity index 100% rename from src/test/MockRenderer.js rename to src/test/ace/MockRenderer.js diff --git a/src/test/NavigationTest.js b/src/test/ace/NavigationTest.js similarity index 100% rename from src/test/NavigationTest.js rename to src/test/ace/NavigationTest.js diff --git a/src/test/RangeTest.js b/src/test/ace/RangeTest.js similarity index 100% rename from src/test/RangeTest.js rename to src/test/ace/RangeTest.js diff --git a/src/test/SearchTest.js b/src/test/ace/SearchTest.js similarity index 100% rename from src/test/SearchTest.js rename to src/test/ace/SearchTest.js diff --git a/src/test/SelectionTest.js b/src/test/ace/SelectionTest.js similarity index 100% rename from src/test/SelectionTest.js rename to src/test/ace/SelectionTest.js diff --git a/src/test/TextEditTest.js b/src/test/ace/TextEditTest.js similarity index 100% rename from src/test/TextEditTest.js rename to src/test/ace/TextEditTest.js diff --git a/src/test/VirtualRendererTest.js b/src/test/ace/VirtualRendererTest.js similarity index 100% rename from src/test/VirtualRendererTest.js rename to src/test/ace/VirtualRendererTest.js diff --git a/src/test/assertions.js b/src/test/ace/assertions.js similarity index 100% rename from src/test/assertions.js rename to src/test/ace/assertions.js diff --git a/src/test/mode/CssTest.js b/src/test/ace/mode/CssTest.js similarity index 100% rename from src/test/mode/CssTest.js rename to src/test/ace/mode/CssTest.js diff --git a/src/test/mode/CssTokenizerTest.js b/src/test/ace/mode/CssTokenizerTest.js similarity index 100% rename from src/test/mode/CssTokenizerTest.js rename to src/test/ace/mode/CssTokenizerTest.js diff --git a/src/test/mode/HtmlTokenizerTest.js b/src/test/ace/mode/HtmlTokenizerTest.js similarity index 100% rename from src/test/mode/HtmlTokenizerTest.js rename to src/test/ace/mode/HtmlTokenizerTest.js diff --git a/src/test/mode/JavaScriptTest.js b/src/test/ace/mode/JavaScriptTest.js similarity index 100% rename from src/test/mode/JavaScriptTest.js rename to src/test/ace/mode/JavaScriptTest.js diff --git a/src/test/mode/JavaScriptTokenizerTest.js b/src/test/ace/mode/JavaScriptTokenizerTest.js similarity index 100% rename from src/test/mode/JavaScriptTokenizerTest.js rename to src/test/ace/mode/JavaScriptTokenizerTest.js diff --git a/src/test/mode/TextTest.js b/src/test/ace/mode/TextTest.js similarity index 100% rename from src/test/mode/TextTest.js rename to src/test/ace/mode/TextTest.js diff --git a/src/test/mode/XmlTest.js b/src/test/ace/mode/XmlTest.js similarity index 100% rename from src/test/mode/XmlTest.js rename to src/test/ace/mode/XmlTest.js diff --git a/src/test/mode/XmlTokenizerTest.js b/src/test/ace/mode/XmlTokenizerTest.js similarity index 100% rename from src/test/mode/XmlTokenizerTest.js rename to src/test/ace/mode/XmlTokenizerTest.js