Merge pull request #404 from cweider/misc-fixins

Misc fixins
This commit is contained in:
John McLear 2012-02-05 15:06:41 -08:00
commit cbe0b6d6bb
9 changed files with 43 additions and 141 deletions

View file

@ -141,9 +141,6 @@ async.waterfall([
gracefulShutdown();
});
//serve minified files
app.get('/minified/:filename', minify.minifyJS);
//serve static files
app.get('/static/js/require-kernel.js', function (req, res, next) {
res.header("Content-Type","application/javascript; charset: utf-8");

View file

@ -337,6 +337,15 @@ function Ace2Editor()
$$INCLUDE_JS("../static/js/domline.js");
$$INCLUDE_JS("../static/js/ace2_inner.js");
pushRequireScriptTo(iframeHTML);
// Inject my plugins into my child.
iframeHTML.push('\
<script type="text/javascript">\
require.define("/plugins", null);\n\
require.define("/plugins.js", function (require, exports, module) {\
module.exports = parent.parent.require("/plugins");\
});\
</script>\
');
pushScriptTagsFor(iframeHTML, includedJS);
iframeHTML.push('<style type="text/css" title="dynamicsyntax"></style>');
@ -362,19 +371,6 @@ function Ace2Editor()
// (throbs busy while typing)
outerHTML.push('<link rel="stylesheet" type="text/css" href="data:text/css,"/>', '\x3cscript>\n', outerScript.replace(/<\//g, '<\\/'), '\n\x3c/script>', '</head><body id="outerdocbody"><div id="sidediv"><!-- --></div><div id="linemetricsdiv">x</div><div id="overlaysdiv"><!-- --></div></body></html>');
if (!Array.prototype.map) Array.prototype.map = function(fun)
{ //needed for IE
if (typeof fun != "function") throw new TypeError();
var len = this.length;
var res = new Array(len);
var thisp = arguments[1];
for (var i = 0; i < len; i++)
{
if (i in this) res[i] = fun.call(thisp, this[i], i, this);
}
return res;
};
var outerFrame = document.createElement("IFRAME");
outerFrame.frameBorder = 0; // for IE
info.frame = outerFrame;

View file

@ -20,11 +20,6 @@
* limitations under the License.
*/
$(window).bind("load", function()
{
getCollabClient.windowLoaded = true;
});
var chat = require('/chat').chat;
// Dependency fill on init. This exists for `pad.socket` only.
@ -268,19 +263,6 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
}*/
}
function setUpSocketWhenWindowLoaded()
{
if (getCollabClient.windowLoaded)
{
setUpSocket();
}
else
{
setTimeout(setUpSocketWhenWindowLoaded, 200);
}
}
setTimeout(setUpSocketWhenWindowLoaded, 0);
var hiccupCount = 0;
function handleCometHiccup(params)
@ -654,8 +636,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
}, 0);
}
var self;
return (self = {
var self = {
setOnUserJoin: function(cb)
{
callbacks.onUserJoin = cb;
@ -698,7 +679,10 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
callWhenNotCommitting: callWhenNotCommitting,
addHistoricalAuthors: tellAceAboutHistoricalAuthors,
setChannelState: setChannelState
});
};
$(document).ready(setUpSocket);
return self;
}
function selectElementContents(elem)

View file

@ -26,12 +26,7 @@
var _MAX_LIST_LEVEL = 8;
var Changeset = require('/easysync2').Changeset
var plugins = undefined;
try {
plugins = require('/plugins').plugins;
} catch (e) {
// silence
}
var plugins = require('/plugins').plugins;
function sanitizeUnicode(s)
{
@ -42,15 +37,7 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
{
browser = browser || {};
var plugins_;
if (typeof(plugins) != 'undefined')
{
plugins_ = plugins;
}
else
{
plugins_ = parent.parent.plugins;
}
var plugins_ = plugins;
var dom = domInterface || {
isNodeText: function(n)

View file

@ -26,12 +26,8 @@
// requires: plugins
// requires: undefined
var plugins = undefined;
try {
plugins = require('/plugins').plugins;
} catch (e) {
// silence
}
var plugins = require('/plugins').plugins;
var map = require('/ace2_common').map;
var domline = {};
domline.noop = function()
@ -148,20 +144,12 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
var extraOpenTags = "";
var extraCloseTags = "";
var plugins_;
if (typeof(plugins) != 'undefined')
{
plugins_ = plugins;
}
else
{
plugins_ = parent.parent.plugins;
}
var plugins_ = plugins;
plugins_.callHook("aceCreateDomLine", {
map(plugins_.callHook("aceCreateDomLine", {
domline: domline,
cls: cls
}).map(function(modifier)
}), function(modifier)
{
cls = modifier.cls;
extraOpenTags = extraOpenTags + modifier.extraOpenTags;

View file

@ -25,12 +25,8 @@
// requires: plugins
// requires: undefined
var plugins = undefined;
try {
plugins = require('/plugins').plugins;
} catch (e) {
// silence
}
var plugins = require('/plugins').plugins;
var map = require('/ace2_common').map;
var domline = {};
domline.noop = function()
@ -147,20 +143,12 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
var extraOpenTags = "";
var extraCloseTags = "";
var plugins_;
if (typeof(plugins) != 'undefined')
{
plugins_ = plugins;
}
else
{
plugins_ = parent.parent.plugins;
}
var plugins_ = plugins;
plugins_.callHook("aceCreateDomLine", {
map(plugins_.callHook("aceCreateDomLine", {
domline: domline,
cls: cls
}).map(function(modifier)
}), function(modifier)
{
cls = modifier.cls;
extraOpenTags = extraOpenTags + modifier.extraOpenTags;

View file

@ -29,12 +29,8 @@
// requires: undefined
var Changeset = require('/easysync2').Changeset
var plugins = undefined;
try {
plugins = require('/plugins').plugins;
} catch (e) {
// silence
}
var plugins = require('/plugins').plugins;
var map = require('/ace2_common').map;
var linestylefilter = {};
@ -59,15 +55,7 @@ linestylefilter.getAuthorClassName = function(author)
linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFunc, apool)
{
var plugins_;
if (typeof(plugins) != 'undefined')
{
plugins_ = plugins;
}
else
{
plugins_ = parent.parent.plugins;
}
var plugins_ = plugins;
if (lineLength == 0) return textAndClassFunc;
@ -312,21 +300,13 @@ linestylefilter.getFilterStack = function(lineText, textAndClassFunc, browser)
{
var func = linestylefilter.getURLFilter(lineText, textAndClassFunc);
var plugins_;
if (typeof(plugins) != 'undefined')
{
plugins_ = plugins;
}
else
{
plugins_ = parent.parent.plugins;
}
var plugins_ = plugins;
var hookFilters = plugins_.callHook("aceGetFilterStack", {
linestylefilter: linestylefilter,
browser: browser
});
hookFilters.map(function(hookFilter)
map(hookFilters, function(hookFilter)
{
func = hookFilter(lineText, func);
});

View file

@ -27,12 +27,8 @@
// requires: undefined
var Changeset = require('/easysync2_client').Changeset
var plugins = undefined;
try {
plugins = require('/plugins').plugins;
} catch (e) {
// silence
}
var plugins = require('/plugins').plugins;
var map = require('/ace2_common').map;
var linestylefilter = {};
@ -57,15 +53,7 @@ linestylefilter.getAuthorClassName = function(author)
linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFunc, apool)
{
var plugins_;
if (typeof(plugins) != 'undefined')
{
plugins_ = plugins;
}
else
{
plugins_ = parent.parent.plugins;
}
var plugins_ = plugins;
if (lineLength == 0) return textAndClassFunc;
@ -310,21 +298,13 @@ linestylefilter.getFilterStack = function(lineText, textAndClassFunc, browser)
{
var func = linestylefilter.getURLFilter(lineText, textAndClassFunc);
var plugins_;
if (typeof(plugins) != 'undefined')
{
plugins_ = plugins;
}
else
{
plugins_ = parent.parent.plugins;
}
var plugins_ = plugins;
var hookFilters = plugins_.callHook("aceGetFilterStack", {
linestylefilter: linestylefilter,
browser: browser
});
hookFilters.map(function(hookFilter)
map(hookFilters, function(hookFilter)
{
func = hookFilter(lineText, func);
});

View file

@ -4,7 +4,7 @@
* TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED
*/
plugins = {
var plugins = {
callHook: function(hookName, args)
{
var global = (function () {return this}());
@ -25,10 +25,12 @@ plugins = {
if (sep == undefined) sep = '';
if (pre == undefined) pre = '';
if (post == undefined) post = '';
return plugins.callHook(hookName, args).map(function(x)
{
return pre + x + post
}).join(sep || "");
var newCallhooks = [];
var callhooks = plugins.callHook(hookName, args);
for (var i = 0, ii = callhooks.length; i < ii; i++) {
newCallhooks[i] = pre + callhooks[i] + post;
}
return newCallhooks.join(sep || "");
}
};