From 2b5d7a0048c1b5718b9870eed059f77a9c513136 Mon Sep 17 00:00:00 2001 From: Chad Weider Date: Sun, 15 Jan 2012 17:23:48 -0800 Subject: [PATCH 01/15] All files export their public interface if `exports` is available. --- static/js/ace.js | 4 ++++ static/js/ace2_common.js | 18 +++++++++++++++--- static/js/ace2_inner.js | 4 ++++ static/js/broadcast.js | 4 ++++ static/js/broadcast_revisions.js | 4 ++++ static/js/broadcast_slider.js | 4 ++++ static/js/changesettracker.js | 4 ++++ static/js/chat.js | 4 ++++ static/js/collab_client.js | 5 +++++ static/js/colorutils.js | 4 ++++ static/js/contentcollector.js | 5 +++++ static/js/cssmanager.js | 4 ++++ static/js/cssmanager_client.js | 4 ++++ static/js/domline.js | 4 ++++ static/js/domline_client.js | 4 ++++ static/js/draggable.js | 4 ++++ static/js/easysync2.js | 5 +++++ static/js/easysync2_client.js | 5 +++++ static/js/linestylefilter.js | 4 ++++ static/js/linestylefilter_client.js | 4 ++++ static/js/pad2.js | 13 +++++++++++++ static/js/pad_connectionstatus.js | 4 ++++ static/js/pad_cookie.js | 4 ++++ static/js/pad_docbar.js | 4 ++++ static/js/pad_editbar.js | 4 ++++ static/js/pad_editor.js | 4 ++++ static/js/pad_impexp.js | 4 ++++ static/js/pad_modals.js | 4 ++++ static/js/pad_savedrevs.js | 4 ++++ static/js/pad_userlist.js | 4 ++++ static/js/pad_utils.js | 4 ++++ static/js/plugins.js | 4 ++++ static/js/skiplist.js | 4 ++++ static/js/undomodule.js | 6 +++++- static/js/virtual_lines.js | 4 ++++ 35 files changed, 165 insertions(+), 4 deletions(-) diff --git a/static/js/ace.js b/static/js/ace.js index ffe00b078..3f52d315f 100644 --- a/static/js/ace.js +++ b/static/js/ace.js @@ -370,3 +370,7 @@ function Ace2Editor() return editor; } + +if (typeof exports !== 'undefined') { +exports.Ace2Editor = Ace2Editor; +} diff --git a/static/js/ace2_common.js b/static/js/ace2_common.js index 1414f855a..0918189c9 100644 --- a/static/js/ace2_common.js +++ b/static/js/ace2_common.js @@ -147,7 +147,19 @@ function htmlPrettyEscape(str) }).replace(/\r?\n/g, '\\n'); } -if (typeof exports !== "undefined") -{ - exports.map = map; +if (typeof exports !== 'undefined') { +exports.isNodeText = isNodeText; +exports.object = object; +exports.extend = extend; +exports.forEach = forEach; +exports.map = map; +exports.filter = filter; +exports.isArray = isArray; +exports.browser = browser; +exports.getAssoc = getAssoc; +exports.setAssoc = setAssoc; +exports.binarySearch = binarySearch; +exports.binarySearchInfinite = binarySearchInfinite; +exports.htmlPrettyEscape = htmlPrettyEscape; +exports.map = map; } diff --git a/static/js/ace2_inner.js b/static/js/ace2_inner.js index ec0d5dc45..ea6d7cbe2 100644 --- a/static/js/ace2_inner.js +++ b/static/js/ace2_inner.js @@ -5858,3 +5858,7 @@ function OUTER(gscope) }; OUTER(this); + +if (typeof exports !== 'undefined') { +exports.OUTER = OUTER; // This is probably unimportant. +} diff --git a/static/js/broadcast.js b/static/js/broadcast.js index 865574abd..edfeef9c6 100644 --- a/static/js/broadcast.js +++ b/static/js/broadcast.js @@ -758,3 +758,7 @@ function loadBroadcastJS() receiveAuthorData(clientVars.historicalAuthorData); } + +if (typeof exports !== 'undefined') { +exports.loadBroadcastJS = loadBroadcastJS; +} diff --git a/static/js/broadcast_revisions.js b/static/js/broadcast_revisions.js index 33a2f9dfa..f60e58bb8 100644 --- a/static/js/broadcast_revisions.js +++ b/static/js/broadcast_revisions.js @@ -125,3 +125,7 @@ function loadBroadcastRevisionsJS() }; } } + +if (typeof exports !== 'undefined') { +exports.loadBroadcastRevisionsJS = loadBroadcastRevisionsJS; +} diff --git a/static/js/broadcast_slider.js b/static/js/broadcast_slider.js index af5a50411..1d9f4928e 100644 --- a/static/js/broadcast_slider.js +++ b/static/js/broadcast_slider.js @@ -496,3 +496,7 @@ function loadBroadcastSliderJS() $("#viewlatest").html(loc == BroadcastSlider.getSliderLength() ? "Viewing latest content" : "View latest content"); }) } + +if (typeof exports !== 'undefined') { +exports.loadBroadcastSliderJS = loadBroadcastSliderJS; +} diff --git a/static/js/changesettracker.js b/static/js/changesettracker.js index cc7f64623..60c73d3d5 100644 --- a/static/js/changesettracker.js +++ b/static/js/changesettracker.js @@ -207,3 +207,7 @@ function makeChangesetTracker(scheduler, apool, aceCallbacksProvider) }; } + +if (typeof exports !== 'undefined') { +exports.makeChangesetTracker = makeChangesetTracker; +} diff --git a/static/js/chat.js b/static/js/chat.js index 71cd0c69d..1636ab690 100644 --- a/static/js/chat.js +++ b/static/js/chat.js @@ -172,3 +172,7 @@ var chat = (function() return self; }()); + +if (typeof exports !== 'undefined') { +exports.chat = chat; +} diff --git a/static/js/collab_client.js b/static/js/collab_client.js index bb2351fc3..3a40fba17 100644 --- a/static/js/collab_client.js +++ b/static/js/collab_client.js @@ -722,3 +722,8 @@ function selectElementContents(elem) } } } + +if (typeof exports !== 'undefined') { +exports.getCollabClient = getCollabClient; +exports.selectElementContents = selectElementContents; +} diff --git a/static/js/colorutils.js b/static/js/colorutils.js index 92d8da719..1fc452b6a 100644 --- a/static/js/colorutils.js +++ b/static/js/colorutils.js @@ -119,3 +119,7 @@ colorutils.blend = function(c1, c2, t) { return [colorutils.scale(t, c1[0], c2[0]), colorutils.scale(t, c1[1], c2[1]), colorutils.scale(t, c1[2], c2[2])]; } + +if (typeof exports !== 'undefined') { +exports.colorutils = colorutils; +} diff --git a/static/js/contentcollector.js b/static/js/contentcollector.js index 883ca09f0..e5a90586c 100644 --- a/static/js/contentcollector.js +++ b/static/js/contentcollector.js @@ -692,3 +692,8 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class return cc; } + +if (typeof exports !== 'undefined') { +exports.sanitizeUnicode = sanitizeUnicode; +exports.makeContentCollector = makeContentCollector; +} diff --git a/static/js/cssmanager.js b/static/js/cssmanager.js index b8208b83f..1d45f3024 100644 --- a/static/js/cssmanager.js +++ b/static/js/cssmanager.js @@ -118,3 +118,7 @@ function makeCSSManager(emptyStylesheetTitle, top) } }; } + +if (typeof exports !== 'undefined') { +exports.makeCSSManager = makeCSSManager; +} diff --git a/static/js/cssmanager_client.js b/static/js/cssmanager_client.js index 60bf9f8c5..3db467e31 100644 --- a/static/js/cssmanager_client.js +++ b/static/js/cssmanager_client.js @@ -114,3 +114,7 @@ function makeCSSManager(emptyStylesheetTitle) } }; } + +if (typeof exports !== 'undefined') { +exports.makeCSSManager = makeCSSManager; +} diff --git a/static/js/domline.js b/static/js/domline.js index 84aeb4a81..7ebf5b350 100644 --- a/static/js/domline.js +++ b/static/js/domline.js @@ -310,3 +310,7 @@ domline.processSpaces = function(s, doesWrap) } return parts.join(''); }; + +if (typeof exports !== 'undefined') { +exports.domline = domline; +} diff --git a/static/js/domline_client.js b/static/js/domline_client.js index 9f47dae54..e995140f4 100644 --- a/static/js/domline_client.js +++ b/static/js/domline_client.js @@ -309,3 +309,7 @@ domline.processSpaces = function(s, doesWrap) } return parts.join(''); }; + +if (typeof exports !== 'undefined') { +exports.domline = domline; +} diff --git a/static/js/draggable.js b/static/js/draggable.js index 7bf523eb5..1d0ddb4c3 100644 --- a/static/js/draggable.js +++ b/static/js/draggable.js @@ -193,3 +193,7 @@ function makeResizableHPane(left, sep, right, minLeft, minRight, sepWidth, sepOf } }); } + +if (typeof exports !== 'undefined') { +exports.makeDraggable = makeDraggable; +} diff --git a/static/js/easysync2.js b/static/js/easysync2.js index 17ab585d9..81a416b25 100644 --- a/static/js/easysync2.js +++ b/static/js/easysync2.js @@ -2508,3 +2508,8 @@ Changeset.followAttributes = function(att1, att2, pool) } return buf.toString(); }; + +if (typeof exports !== 'undefined') { +exports.Changeset = Changeset; +exports.AttribPool = AttribPool; +} diff --git a/static/js/easysync2_client.js b/static/js/easysync2_client.js index 3611da233..5745110e6 100644 --- a/static/js/easysync2_client.js +++ b/static/js/easysync2_client.js @@ -2269,3 +2269,8 @@ Changeset.inverse = function(cs, lines, alines, pool) return Changeset.checkRep(builder.toString()); }; + +if (typeof exports !== 'undefined') { +exports.Changeset = Changeset; +exports.AttribPool = AttribPool; +} diff --git a/static/js/linestylefilter.js b/static/js/linestylefilter.js index 13a746186..e990a68bc 100644 --- a/static/js/linestylefilter.js +++ b/static/js/linestylefilter.js @@ -352,3 +352,7 @@ linestylefilter.populateDomLine = function(textLine, aline, apool, domLineObj) func = linestylefilter.getLineStyleFilter(text.length, aline, func, apool); func(text, ''); }; + +if (typeof exports !== 'undefined') { +exports.linestylefilter = linestylefilter; +} diff --git a/static/js/linestylefilter_client.js b/static/js/linestylefilter_client.js index 9fd2a3f8c..a4536490f 100644 --- a/static/js/linestylefilter_client.js +++ b/static/js/linestylefilter_client.js @@ -350,3 +350,7 @@ linestylefilter.populateDomLine = function(textLine, aline, apool, domLineObj) func = linestylefilter.getLineStyleFilter(text.length, aline, func, apool); func(text, ''); }; + +if (typeof exports !== 'undefined') { +exports.linestylefilter = linestylefilter; +} diff --git a/static/js/pad2.js b/static/js/pad2.js index 5872b7a11..8a2c33847 100644 --- a/static/js/pad2.js +++ b/static/js/pad2.js @@ -953,3 +953,16 @@ var alertBar = (function() }; return self; }()); + +if (typeof exports !== 'undefined') { +exports.settings = settings; +exports.createCookie = createCookie; +exports.readCookie = readCookie; +exports.randomString = randomString; +exports.getParams = getParams; +exports.getUrlVars = getUrlVars; +exports.savePassword = savePassword; +exports.handshake = handshake; +exports.pad = pad; +exports.alertBar = alertBar; +} diff --git a/static/js/pad_connectionstatus.js b/static/js/pad_connectionstatus.js index d35eb02d6..bec359c36 100644 --- a/static/js/pad_connectionstatus.js +++ b/static/js/pad_connectionstatus.js @@ -85,3 +85,7 @@ var padconnectionstatus = (function() }; return self; }()); + +if (typeof exports !== 'undefined') { +exports.padconnectionstatus = padconnectionstatus; +} diff --git a/static/js/pad_cookie.js b/static/js/pad_cookie.js index 64211750d..d8eb464c7 100644 --- a/static/js/pad_cookie.js +++ b/static/js/pad_cookie.js @@ -126,3 +126,7 @@ var padcookie = (function() }; return self; }()); + +if (typeof exports !== 'undefined') { +exports.padcookie = padcookie; +} diff --git a/static/js/pad_docbar.js b/static/js/pad_docbar.js index c67ca55c4..09315c778 100644 --- a/static/js/pad_docbar.js +++ b/static/js/pad_docbar.js @@ -456,3 +456,7 @@ var paddocbar = (function() }; return self; }()); + +if (typeof exports !== 'undefined') { +exports.paddocbar = paddocbar; +} diff --git a/static/js/pad_editbar.js b/static/js/pad_editbar.js index 6cd5163de..6754e99c2 100644 --- a/static/js/pad_editbar.js +++ b/static/js/pad_editbar.js @@ -230,3 +230,7 @@ var padeditbar = (function() }; return self; }()); + +if (typeof exports !== 'undefined') { +exports.padeditbar = padeditbar; +} diff --git a/static/js/pad_editor.js b/static/js/pad_editor.js index 6daf5e7de..929112bbf 100644 --- a/static/js/pad_editor.js +++ b/static/js/pad_editor.js @@ -150,3 +150,7 @@ var padeditor = (function() }; return self; }()); + +if (typeof exports !== 'undefined') { +exports.padeditor = padeditor; +} diff --git a/static/js/pad_impexp.js b/static/js/pad_impexp.js index 23b7134c0..638991a64 100644 --- a/static/js/pad_impexp.js +++ b/static/js/pad_impexp.js @@ -325,3 +325,7 @@ var padimpexp = (function() }; return self; }()); + +if (typeof exports !== 'undefined') { +exports.padimpexp = padimpexp; +} diff --git a/static/js/pad_modals.js b/static/js/pad_modals.js index cf9d04355..d5e7811b9 100644 --- a/static/js/pad_modals.js +++ b/static/js/pad_modals.js @@ -364,3 +364,7 @@ var padmodals = (function() }; return self; }()); + +if (typeof exports !== 'undefined') { +exports.padmodals = padmodals; +} diff --git a/static/js/pad_savedrevs.js b/static/js/pad_savedrevs.js index 487e85f1a..7aadea71e 100644 --- a/static/js/pad_savedrevs.js +++ b/static/js/pad_savedrevs.js @@ -518,3 +518,7 @@ var padsavedrevs = (function() }; return self; }()); + +if (typeof exports !== 'undefined') { +exports.padsavedrevs = padsavedrevs; +} diff --git a/static/js/pad_userlist.js b/static/js/pad_userlist.js index 748674916..965132258 100644 --- a/static/js/pad_userlist.js +++ b/static/js/pad_userlist.js @@ -805,3 +805,7 @@ function showColorPicker() $($("#colorpickerswatches li")[myUserInfo.colorId]).addClass("picked"); //seems weird } } + +if (typeof exports !== 'undefined') { +exports.paduserlist = paduserlist; +} diff --git a/static/js/pad_utils.js b/static/js/pad_utils.js index 9083fa9b6..3c73aa069 100644 --- a/static/js/pad_utils.js +++ b/static/js/pad_utils.js @@ -486,3 +486,7 @@ window.onerror = function test (msg, url, linenumber) return false; }; + +if (typeof exports !== 'undefined') { +exports.padutils = padutils; +} diff --git a/static/js/plugins.js b/static/js/plugins.js index 741934620..2cf0e0e26 100644 --- a/static/js/plugins.js +++ b/static/js/plugins.js @@ -31,3 +31,7 @@ plugins = { }).join(sep || ""); } }; + +if (typeof exports !== 'undefined') { +exports.plugins = plugins; +} diff --git a/static/js/skiplist.js b/static/js/skiplist.js index c9654be46..995cd6bc7 100644 --- a/static/js/skiplist.js +++ b/static/js/skiplist.js @@ -488,3 +488,7 @@ that is a string. } return self; } + +if (typeof exports !== 'undefined') { +exports.newSkipList = newSkipList; +} diff --git a/static/js/undomodule.js b/static/js/undomodule.js index 3891629aa..a0073e19e 100644 --- a/static/js/undomodule.js +++ b/static/js/undomodule.js @@ -21,7 +21,7 @@ */ -undoModule = (function() +var undoModule = (function() { var stack = (function() { @@ -329,3 +329,7 @@ undoModule = (function() apool: null }; // apool is filled in by caller })(); + +if (typeof exports !== 'undefined') { +exports.undoModule = undoModule; +} diff --git a/static/js/virtual_lines.js b/static/js/virtual_lines.js index ece96b149..32fc58875 100644 --- a/static/js/virtual_lines.js +++ b/static/js/virtual_lines.js @@ -384,3 +384,7 @@ function makeVirtualLineView(lineNode) } } + +if (typeof exports !== 'undefined') { +exports.makeVirtualLineView = makeVirtualLineView; +} From 9e16b9a575efa51f608f8096f1a8c0b390faece8 Mon Sep 17 00:00:00 2001 From: Chad Weider Date: Tue, 17 Jan 2012 01:22:23 -0800 Subject: [PATCH 02/15] Always use the JS assets processed by Minify. This allows the preprocessing that will restrict scope of files to be done once in Minify. --- node/utils/Minify.js | 13 ++++++++++++- static/js/ace.js | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/node/utils/Minify.js b/node/utils/Minify.js index 1a214fb92..d3c8831af 100644 --- a/node/utils/Minify.js +++ b/node/utils/Minify.js @@ -52,10 +52,21 @@ exports.minifyJS = function(req, res, next) var jsFiles = undefined; if (Object.prototype.hasOwnProperty.call(tar, jsFilename)) { jsFiles = tar[jsFilename]; + _handle(req, res, jsFilename, jsFiles) } else { - return next(); + // Not in tar list, but try anyways, if it fails, pass to `next`. + jsFiles = [jsFilename]; + fs.stat(JS_DIR + jsFilename, function (error, stats) { + if (error || !stats.isFile()) { + next(); + } else { + _handle(req, res, jsFilename, jsFiles); + } + }); } +} +function _handle(req, res, jsFilename, jsFiles) { res.header("Content-Type","text/javascript"); //minifying is enabled diff --git a/static/js/ace.js b/static/js/ace.js index 3f52d315f..4735aaae7 100644 --- a/static/js/ace.js +++ b/static/js/ace.js @@ -230,6 +230,7 @@ function Ace2Editor() } for (var i = 0, ii = remoteFiles.length; i < ii; i++) { var file = remoteFiles[i]; + file = file.replace(/^\.\.\/static\/js\//, '../minified/'); buffer.push(' + diff --git a/static/timeslider.html b/static/timeslider.html index c1310cc6c..71b4443d2 100644 --- a/static/timeslider.html +++ b/static/timeslider.html @@ -19,6 +19,8 @@ // Date: Mon, 16 Jan 2012 00:37:48 -0800 Subject: [PATCH 06/15] Add missing dependency for `timeslider.js`. When dependencies are made explicity `pad_savedrevs.js` will be required by several of the `pad_*.js`. --- node/utils/tar.json | 1 + 1 file changed, 1 insertion(+) diff --git a/node/utils/tar.json b/node/utils/tar.json index 3b1ba63ca..92883bb74 100644 --- a/node/utils/tar.json +++ b/node/utils/tar.json @@ -35,6 +35,7 @@ , "pad_editbar.js" , "pad_docbar.js" , "pad_modals.js" + , "pad_savedrevs.js" , "pad_impexp.js" , "easysync2_client.js" , "domline_client.js" From 72d29b1c627d54453fe48a89b063631fec8e6859 Mon Sep 17 00:00:00 2001 From: Chad Weider Date: Sun, 15 Jan 2012 21:05:19 -0800 Subject: [PATCH 07/15] Inject the pad dependency into chat. --- static/js/chat.js | 7 ++++--- static/js/pad2.js | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/static/js/chat.js b/static/js/chat.js index 1636ab690..a0d0d9ac2 100644 --- a/static/js/chat.js +++ b/static/js/chat.js @@ -82,13 +82,13 @@ var chat = (function() send: function() { var text = $("#chatinput").val(); - pad.collabClient.sendMessage({"type": "CHAT_MESSAGE", "text": text}); + this._pad.collabClient.sendMessage({"type": "CHAT_MESSAGE", "text": text}); $("#chatinput").val(""); }, addMessage: function(msg, increment) { //correct the time - msg.time += pad.clientTimeOffset; + msg.time += this._pad.clientTimeOffset; //create the time string var minutes = "" + new Date(msg.time).getMinutes(); @@ -150,8 +150,9 @@ var chat = (function() self.scrollDown(); }, - init: function() + init: function(pad) { + this._pad = pad; $("#chatinput").keypress(function(evt) { //if the user typed enter, fire the send diff --git a/static/js/pad2.js b/static/js/pad2.js index 8a2c33847..5f454172f 100644 --- a/static/js/pad2.js +++ b/static/js/pad2.js @@ -413,7 +413,7 @@ var pad = { pad.clientTimeOffset = new Date().getTime() - clientVars.serverTimestamp; //initialize the chat - chat.init(); + chat.init(this); pad.initTime = +(new Date()); pad.padOptions = clientVars.initialOptions; From 7f98116a435d0204f91100cb24bfb4f1f49f41d3 Mon Sep 17 00:00:00 2001 From: Chad Weider Date: Sun, 15 Jan 2012 20:16:11 -0800 Subject: [PATCH 08/15] Implement `require` for most modules. --- static/js/ace2_inner.js | 29 +++++++++++++++++++++++++++++ static/js/broadcast.js | 6 ++++++ static/js/changesettracker.js | 2 ++ static/js/chat.js | 2 ++ static/js/collab_client.js | 2 ++ static/js/contentcollector.js | 2 ++ static/js/linestylefilter.js | 3 +++ static/js/linestylefilter_client.js | 3 +++ static/js/pad2.js | 3 +++ static/js/pad_editor.js | 1 + static/js/undomodule.js | 2 ++ 11 files changed, 55 insertions(+) diff --git a/static/js/ace2_inner.js b/static/js/ace2_inner.js index ea6d7cbe2..455958cd2 100644 --- a/static/js/ace2_inner.js +++ b/static/js/ace2_inner.js @@ -20,6 +20,35 @@ * limitations under the License. */ +var Ace2Common = require('/ace2_common'); +// Extract useful method defined in the other module. +var isNodeText = Ace2Common.isNodeText; +var object = Ace2Common.object; +var extend = Ace2Common.extend; +var forEach = Ace2Common.forEach; +var map = Ace2Common.map; +var filter = Ace2Common.filter; +var isArray = Ace2Common.isArray; +var browser = Ace2Common.browser; +var getAssoc = Ace2Common.getAssoc; +var setAssoc = Ace2Common.setAssoc; +var binarySearch = Ace2Common.binarySearch; +var binarySearchInfinite = Ace2Common.binarySearchInfinite; +var htmlPrettyEscape = Ace2Common.htmlPrettyEscape; +var map = Ace2Common.map; + +var makeChangesetTracker = require('/changesettracker').makeChangesetTracker; +var colorutils = require('/colorutils').colorutils; +var makeContentCollector = require('/contentcollector').makeContentCollector; +var makeCSSManager = require('/cssmanager').makeCSSManager; +var domline = require('/domline').domline; +var AttribPool = require('/easysync2').AttribPool; +var Changeset = require('/easysync2').Changeset; +var linestylefilter = require('/linestylefilter').linestylefilter; +var newSkipList = require('/skiplist').newSkipList; +var undoModule = require('/undomodule').undoModule; +var makeVirtualLineView = require('/virtual_lines').makeVirtualLineView; + function OUTER(gscope) { diff --git a/static/js/broadcast.js b/static/js/broadcast.js index edfeef9c6..f2aa048fb 100644 --- a/static/js/broadcast.js +++ b/static/js/broadcast.js @@ -22,6 +22,12 @@ var global = this; +var makeCSSManager = require('/cssmanager_client').makeCSSManager; +var domline = require('/domline_client').domline; +var Changeset = require('/easysync2_client').Changeset; +var AttribPool = require('/easysync2_client').AttribPool; +var linestylefilter = require('/linestylefilter_client').linestylefilter; + function loadBroadcastJS() { // just in case... (todo: this must be somewhere else in the client code.) diff --git a/static/js/changesettracker.js b/static/js/changesettracker.js index 60c73d3d5..db3ab9446 100644 --- a/static/js/changesettracker.js +++ b/static/js/changesettracker.js @@ -20,6 +20,8 @@ * limitations under the License. */ +var Changeset = require('/easysync2').Changeset; +var AttribPool = require('/easysync2').AttribPool; function makeChangesetTracker(scheduler, apool, aceCallbacksProvider) { diff --git a/static/js/chat.js b/static/js/chat.js index a0d0d9ac2..b4d15f4e5 100644 --- a/static/js/chat.js +++ b/static/js/chat.js @@ -20,6 +20,8 @@ * limitations under the License. */ +var padutils = require('/pad_utils').padutils; + var chat = (function() { var bottomMargin = "0px"; diff --git a/static/js/collab_client.js b/static/js/collab_client.js index 3a40fba17..1f4e21dc8 100644 --- a/static/js/collab_client.js +++ b/static/js/collab_client.js @@ -25,6 +25,8 @@ $(window).bind("load", function() getCollabClient.windowLoaded = true; }); +var chat = require('/chat').chat; + // Dependency fill on init. This exists for `pad.socket` only. // TODO: bind directly to the socket. var pad = undefined; diff --git a/static/js/contentcollector.js b/static/js/contentcollector.js index e5a90586c..d69d813d8 100644 --- a/static/js/contentcollector.js +++ b/static/js/contentcollector.js @@ -25,6 +25,8 @@ var _MAX_LIST_LEVEL = 8; +var Changeset = require('/easysync2').Changeset + function sanitizeUnicode(s) { return s.replace(/[\uffff\ufffe\ufeff\ufdd0-\ufdef\ud800-\udfff]/g, '?'); diff --git a/static/js/linestylefilter.js b/static/js/linestylefilter.js index e990a68bc..5d831ae80 100644 --- a/static/js/linestylefilter.js +++ b/static/js/linestylefilter.js @@ -27,6 +27,9 @@ // requires: top // requires: plugins // requires: undefined + +var Changeset = require('/easysync2').Changeset + var linestylefilter = {}; linestylefilter.ATTRIB_CLASSES = { diff --git a/static/js/linestylefilter_client.js b/static/js/linestylefilter_client.js index a4536490f..b9203c9fd 100644 --- a/static/js/linestylefilter_client.js +++ b/static/js/linestylefilter_client.js @@ -25,6 +25,9 @@ // requires: top // requires: plugins // requires: undefined + +var Changeset = require('/easysync2_client').Changeset + var linestylefilter = {}; linestylefilter.ATTRIB_CLASSES = { diff --git a/static/js/pad2.js b/static/js/pad2.js index 5f454172f..3964dae6b 100644 --- a/static/js/pad2.js +++ b/static/js/pad2.js @@ -32,6 +32,9 @@ settings.globalUserName = false; settings.hideQRCode = false; settings.rtlIsTrue = false; +var chat = require('/chat').chat; +var getCollabClient = require('/collab_client').getCollabClient; + $(document).ready(function() { //start the costum js diff --git a/static/js/pad_editor.js b/static/js/pad_editor.js index 929112bbf..5fc067cb2 100644 --- a/static/js/pad_editor.js +++ b/static/js/pad_editor.js @@ -20,6 +20,7 @@ * limitations under the License. */ +var Ace2Editor = require('/ace').Ace2Editor; var padeditor = (function() { diff --git a/static/js/undomodule.js b/static/js/undomodule.js index a0073e19e..b515180d4 100644 --- a/static/js/undomodule.js +++ b/static/js/undomodule.js @@ -20,6 +20,8 @@ * limitations under the License. */ +var Changeset = require('/easysync2').Changeset; +var extend = require('/ace2_common').extend; var undoModule = (function() { From fa2a6e9ee690eef161b5e286e3d21fb186283f1d Mon Sep 17 00:00:00 2001 From: Chad Weider Date: Sun, 15 Jan 2012 21:37:47 -0800 Subject: [PATCH 09/15] Implement `require` of dependencies for all `pad_*` modules. Create a lazily-defined local reference for pad on initialization in each pad module in order to avoid circular dependency. At some point in the future this dependency should instead be injected into each module on initialization. --- static/js/pad2.js | 14 ++++++++++++-- static/js/pad_connectionstatus.js | 2 ++ static/js/pad_cookie.js | 3 +++ static/js/pad_docbar.js | 6 ++++++ static/js/pad_editbar.js | 4 ++++ static/js/pad_editor.js | 9 ++++++++- static/js/pad_impexp.js | 8 ++++++++ static/js/pad_modals.js | 6 ++++++ static/js/pad_savedrevs.js | 6 +++++- static/js/pad_userlist.js | 7 ++++++- static/js/pad_utils.js | 2 ++ 11 files changed, 62 insertions(+), 5 deletions(-) diff --git a/static/js/pad2.js b/static/js/pad2.js index 3964dae6b..5369d422a 100644 --- a/static/js/pad2.js +++ b/static/js/pad2.js @@ -34,6 +34,16 @@ settings.rtlIsTrue = false; var chat = require('/chat').chat; var getCollabClient = require('/collab_client').getCollabClient; +var padconnectionstatus = require('/pad_connectionstatus').padconnectionstatus; +var padcookie = require('/pad_cookie').padcookie; +var paddocbar = require('/pad_docbar').paddocbar; +var padeditbar = require('/pad_editbar').padeditbar; +var padeditor = require('/pad_editor').padeditor; +var padimpexp = require('/pad_impexp').padimpexp; +var padmodals = require('/pad_modals').padmodals; +var padsavedrevs = require('/pad_savedrevs').padsavedrevs; +var paduserlist = require('/pad_userlist').paduserlist; +var padutils = require('/pad_utils').padutils; $(document).ready(function() { @@ -275,13 +285,13 @@ function handshake() { $("#editorloadingbox").html("You need a password to access this pad
" + ""+ - ""); + ""); } else if(obj.accessStatus == "wrongPassword") { $("#editorloadingbox").html("You're password was wrong
" + ""+ - ""); + ""); } } diff --git a/static/js/pad_connectionstatus.js b/static/js/pad_connectionstatus.js index bec359c36..d3a7648cb 100644 --- a/static/js/pad_connectionstatus.js +++ b/static/js/pad_connectionstatus.js @@ -20,6 +20,8 @@ * limitations under the License. */ +var padmodals = require('/pad_modals').padmodals; + var padconnectionstatus = (function() { diff --git a/static/js/pad_cookie.js b/static/js/pad_cookie.js index d8eb464c7..00dc28f39 100644 --- a/static/js/pad_cookie.js +++ b/static/js/pad_cookie.js @@ -85,9 +85,12 @@ var padcookie = (function() var alreadyWarnedAboutNoCookies = false; var inited = false; + var pad = undefined; var self = { init: function(prefsToSet) { + pad = require('/pad2').pad; // Sidestep circular dependency (should be injected). + var rawCookie = getRawCookie(); if (rawCookie) { diff --git a/static/js/pad_docbar.js b/static/js/pad_docbar.js index 09315c778..2bf1a1da0 100644 --- a/static/js/pad_docbar.js +++ b/static/js/pad_docbar.js @@ -20,6 +20,7 @@ * limitations under the License. */ +var padutils = require('/pad_utils').padutils; var paddocbar = (function() { @@ -113,11 +114,14 @@ var paddocbar = (function() self.renderPassword(); } + var pad = undefined; var self = { title: null, password: null, init: function(opts) { + pad = require('/pad2').pad; // Sidestep circular dependency (should be injected). + panels = { impexp: { animator: getPanelOpenCloseAnimator("impexp", 160) @@ -444,6 +448,8 @@ var paddocbar = (function() }, handleResizePage: function() { + // Side-step circular reference. This should be injected. + var padsavedrevs = require('/pad_savedrevs').padsavedrevs; padsavedrevs.handleResizePage(); }, hideLaterIfNoOtherInteraction: function() diff --git a/static/js/pad_editbar.js b/static/js/pad_editbar.js index 6754e99c2..774208940 100644 --- a/static/js/pad_editbar.js +++ b/static/js/pad_editbar.js @@ -20,6 +20,10 @@ * limitations under the License. */ +var padutils = require('/pad_utils').padutils; +var padeditor = require('/pad_editor').padeditor; +var padsavedrevs = require('/pad_savedrevs').padsavedrevs; + var padeditbar = (function() { diff --git a/static/js/pad_editor.js b/static/js/pad_editor.js index 5fc067cb2..45a90f006 100644 --- a/static/js/pad_editor.js +++ b/static/js/pad_editor.js @@ -20,16 +20,23 @@ * limitations under the License. */ -var Ace2Editor = require('/ace').Ace2Editor; +var padcookie = require('/pad_cookie').padcookie; +var padutils = require('/pad_utils').padutils; var padeditor = (function() { + var Ace2Editor = undefined; + var pad = undefined; + var settings = undefined; var self = { ace: null, // this is accessed directly from other files viewZoom: 100, init: function(readyFunc, initialViewOptions) { + Ace2Editor = require('/ace').Ace2Editor; + pad = require('/pad2').pad; // Sidestep circular dependency (should be injected). + settings = require('/pad2').settings; function aceReady() { diff --git a/static/js/pad_impexp.js b/static/js/pad_impexp.js index 638991a64..8f187a5cb 100644 --- a/static/js/pad_impexp.js +++ b/static/js/pad_impexp.js @@ -20,6 +20,7 @@ * limitations under the License. */ +var paddocbar = require('/pad_docbar').paddocbar; var padimpexp = (function() { @@ -233,9 +234,16 @@ var padimpexp = (function() } ///// + var pad = undefined; var self = { init: function() { + try { + pad = require('/pad2').pad; // Sidestep circular dependency (should be injected). + } catch (e) { + // skip (doesn't require pad when required by timeslider) + } + //get /p/padname var pad_root_path = new RegExp(/.*\/p\/[^\/]+/).exec(document.location.pathname) //get http://example.com/p/padname diff --git a/static/js/pad_modals.js b/static/js/pad_modals.js index d5e7811b9..9d24c5f1a 100644 --- a/static/js/pad_modals.js +++ b/static/js/pad_modals.js @@ -20,6 +20,9 @@ * limitations under the License. */ +var padutils = require('/pad_utils').padutils; +var paddocbar = require('/pad_docbar').paddocbar; + var padmodals = (function() { @@ -70,9 +73,12 @@ var padmodals = (function() clearShareBoxTo(); } + var pad = undefined; var self = { init: function() { + pad = require('/pad2').pad; // Sidestep circular dependency (should be injected). + self.initFeedback(); self.initShareBox(); }, diff --git a/static/js/pad_savedrevs.js b/static/js/pad_savedrevs.js index 7aadea71e..964c83386 100644 --- a/static/js/pad_savedrevs.js +++ b/static/js/pad_savedrevs.js @@ -20,6 +20,8 @@ * limitations under the License. */ +var padutils = require('/pad_utils').padutils; +var paddocbar = require('/pad_docbar').paddocbar; var padsavedrevs = (function() { @@ -39,7 +41,7 @@ var padsavedrevs = (function() box.find(".srauthor").html("by " + padutils.escapeHtml(revisionInfo.savedBy)); var viewLink = '/ep/pad/view/' + pad.getPadId() + '/' + revisionInfo.id; box.find(".srview").attr('href', viewLink); - var restoreLink = 'javascript:void padsavedrevs.restoreRevision(' + rnum + ');'; + var restoreLink = 'javascript:void(require('+JSON.stringify(module.id)+').padsavedrevs.restoreRevision(' + JSON.stringify(rnum) + ');'; box.find(".srrestore").attr('href', restoreLink); box.find(".srname").click(function(evt) { @@ -345,9 +347,11 @@ var padsavedrevs = (function() $(document).unbind('mouseup', clearScrollRepeatTimer); } + var pad = undefined; var self = { init: function(initialRevisions) { + pad = require('/pad2').pad; // Sidestep circular dependency (should be injected). self.newRevisionList(initialRevisions, true); $("#savedrevs-savenow").click(function() diff --git a/static/js/pad_userlist.js b/static/js/pad_userlist.js index 965132258..b9d08932e 100644 --- a/static/js/pad_userlist.js +++ b/static/js/pad_userlist.js @@ -20,6 +20,8 @@ * limitations under the License. */ +var padutils = require('/pad_utils').padutils; + var myUserInfo = {}; var colorPickerOpen = false; @@ -460,9 +462,12 @@ var paduserlist = (function() return true; }, 1000); + var pad = undefined; var self = { init: function(myInitialUserInfo) { + pad = require('/pad2').pad; // Sidestep circular dependency (should be injected). + self.setMyUserInfo(myInitialUserInfo); $("#otheruserstable tr").remove(); @@ -652,7 +657,7 @@ var paduserlist = (function() if (box.length == 0) { // make guest prompt box - box = $('
Guest: ' + padutils.escapeHtml(displayName) + '
'); + box = $('
Guest: ' + padutils.escapeHtml(displayName) + '
'); $("#guestprompts").append(box); } else diff --git a/static/js/pad_utils.js b/static/js/pad_utils.js index 3c73aa069..30ff308c0 100644 --- a/static/js/pad_utils.js +++ b/static/js/pad_utils.js @@ -34,6 +34,7 @@ var padutils = { }, uniqueId: function() { + var pad = require('/pad2').pad; // Sidestep circular dependency function encodeNum(n, width) { // returns string that is exactly 'width' chars, padding with zeros @@ -226,6 +227,7 @@ var padutils = { }, timediff: function(d) { + var pad = require('/pad2').pad; // Sidestep circular dependency function format(n, word) { n = Math.round(n); From 86f31c752d60957768bff7a684c156277d74e2cf Mon Sep 17 00:00:00 2001 From: Chad Weider Date: Sun, 15 Jan 2012 21:52:03 -0800 Subject: [PATCH 10/15] Implement `require` for for plugin module. --- static/js/ace.js | 2 ++ static/js/contentcollector.js | 6 ++++++ static/js/domline.js | 8 ++++++++ static/js/domline_client.js | 8 ++++++++ static/js/linestylefilter.js | 6 ++++++ static/js/linestylefilter_client.js | 6 ++++++ 6 files changed, 36 insertions(+) diff --git a/static/js/ace.js b/static/js/ace.js index 4735aaae7..78a79d7ec 100644 --- a/static/js/ace.js +++ b/static/js/ace.js @@ -28,6 +28,8 @@ Ace2Editor.registry = { nextId: 1 }; +var plugins = require('/plugins').plugins; + function Ace2Editor() { var ace2 = Ace2Editor; diff --git a/static/js/contentcollector.js b/static/js/contentcollector.js index d69d813d8..5f78a3f24 100644 --- a/static/js/contentcollector.js +++ b/static/js/contentcollector.js @@ -26,6 +26,12 @@ var _MAX_LIST_LEVEL = 8; var Changeset = require('/easysync2').Changeset +var plugins = undefined; +try { + plugins = require('/plugins').plugins; +} catch (e) { + // silence +} function sanitizeUnicode(s) { diff --git a/static/js/domline.js b/static/js/domline.js index 7ebf5b350..2d8913928 100644 --- a/static/js/domline.js +++ b/static/js/domline.js @@ -25,6 +25,14 @@ // requires: top // requires: plugins // requires: undefined + +var plugins = undefined; +try { + plugins = require('/plugins').plugins; +} catch (e) { + // silence +} + var domline = {}; domline.noop = function() {}; diff --git a/static/js/domline_client.js b/static/js/domline_client.js index e995140f4..6a09a1723 100644 --- a/static/js/domline_client.js +++ b/static/js/domline_client.js @@ -24,6 +24,14 @@ // requires: top // requires: plugins // requires: undefined + +var plugins = undefined; +try { + plugins = require('/plugins').plugins; +} catch (e) { + // silence +} + var domline = {}; domline.noop = function() {}; diff --git a/static/js/linestylefilter.js b/static/js/linestylefilter.js index 5d831ae80..9558ed71b 100644 --- a/static/js/linestylefilter.js +++ b/static/js/linestylefilter.js @@ -29,6 +29,12 @@ // requires: undefined var Changeset = require('/easysync2').Changeset +var plugins = undefined; +try { + plugins = require('/plugins').plugins; +} catch (e) { + // silence +} var linestylefilter = {}; diff --git a/static/js/linestylefilter_client.js b/static/js/linestylefilter_client.js index b9203c9fd..9b1cb83dc 100644 --- a/static/js/linestylefilter_client.js +++ b/static/js/linestylefilter_client.js @@ -27,6 +27,12 @@ // requires: undefined var Changeset = require('/easysync2_client').Changeset +var plugins = undefined; +try { + plugins = require('/plugins').plugins; +} catch (e) { + // silence +} var linestylefilter = {}; From 1b89e7e2903877487ee72b8df39f07b4ed1d8a36 Mon Sep 17 00:00:00 2001 From: Chad Weider Date: Mon, 16 Jan 2012 02:10:34 -0800 Subject: [PATCH 11/15] Implement `require` in HTML pages. --- static/pad.html | 8 ++++++++ static/timeslider.html | 10 +++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/static/pad.html b/static/pad.html index 33df2d4f3..fba52b782 100644 --- a/static/pad.html +++ b/static/pad.html @@ -340,5 +340,13 @@ + + diff --git a/static/timeslider.html b/static/timeslider.html index 71b4443d2..a416562e8 100644 --- a/static/timeslider.html +++ b/static/timeslider.html @@ -21,6 +21,10 @@ var require = (function (path) {return (function () {return this}())}); + /* TODO: These globals shouldn't exist. */ + padeditbar = require('/pad_editbar').padeditbar; + padimpexp = require('/pad_impexp').padimpexp; + function createCookie(name,value,days) { if (days) { @@ -143,9 +147,9 @@ clientVars = message.data; //load all script that doesn't work without the clientVars - loadBroadcastSliderJS(); - loadBroadcastRevisionsJS(); - loadBroadcastJS(); + require('/broadcast_slider').loadBroadcastSliderJS(); + require('/broadcast_revisions').loadBroadcastRevisionsJS(); + require('/broadcast').loadBroadcastJS(); //initialize export ui padimpexp.init(); From 8bf0e7c2aaa457b991955650e1e32e1f0e5357bc Mon Sep 17 00:00:00 2001 From: Chad Weider Date: Sun, 15 Jan 2012 22:53:44 -0800 Subject: [PATCH 12/15] Allow dashes in included file names. --- node/utils/Minify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/utils/Minify.js b/node/utils/Minify.js index 12efc547a..8b198f3e1 100644 --- a/node/utils/Minify.js +++ b/node/utils/Minify.js @@ -162,7 +162,7 @@ function _handle(req, res, jsFilename, jsFiles) { return; } - var founds = fileValues["ace.js"].match(/\$\$INCLUDE_[a-zA-Z_]+\([a-zA-Z0-9.\/_"]+\)/gi); + var founds = fileValues["ace.js"].match(/\$\$INCLUDE_[a-zA-Z_]+\([a-zA-Z0-9.\/_"-]+\)/gi); //go trough all includes async.forEach(founds, function (item, callback) From 71dfced06de716dcc24cdc933ee02bdb4e75d535 Mon Sep 17 00:00:00 2001 From: Chad Weider Date: Sun, 15 Jan 2012 22:56:41 -0800 Subject: [PATCH 13/15] Provide filename to isolation function. --- node/utils/Minify.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/node/utils/Minify.js b/node/utils/Minify.js index 8b198f3e1..016739b1a 100644 --- a/node/utils/Minify.js +++ b/node/utils/Minify.js @@ -179,7 +179,8 @@ function _handle(req, res, jsFilename, jsFiles) { if(type == "JS") { - embeds[filename] = compressJS([isolateJS(data)]); + var shortFilename = filename.replace(/^..\/static\/js\//, ''); + embeds[filename] = compressJS([isolateJS(data, shortFilename)]); } else { @@ -297,14 +298,14 @@ function tarCode(filesInOrder, files, write) { for(var i = 0, ii = filesInOrder.length; i < filesInOrder.length; i++) { var filename = filesInOrder[i]; write("\n\n\n/*** File: static/js/" + filename + " ***/\n\n\n"); - write(isolateJS(files[filename])); + write(isolateJS(files[filename], filename)); } } // Wrap the following code in a self executing function and assign exports to // global. This is a first step towards removing symbols from the global scope. // exports is global and require is a function that returns global. -function isolateJS(code) { +function isolateJS(code, filename) { return '(function (exports, require) {' + code + '\n' + '}(function () {return this}(), (function (path) {return (function () {return this}())})));\n'; From 62e0a8f26c3dea9d46818dd5ae9599cf375ad91e Mon Sep 17 00:00:00 2001 From: Chad Weider Date: Sun, 15 Jan 2012 22:07:45 -0800 Subject: [PATCH 14/15] Use require-kernel for require functionality. --- node/server.js | 8 ++++++++ node/utils/Minify.js | 40 ++++++++++++++++++++++++++++++++-------- package.json | 1 + static/js/ace.js | 35 ++++++++++++++++++++++++++--------- static/pad.html | 4 +--- static/timeslider.html | 3 +-- 6 files changed, 69 insertions(+), 22 deletions(-) diff --git a/node/server.js b/node/server.js index 422bbe120..c0d6ce6ad 100644 --- a/node/server.js +++ b/node/server.js @@ -114,7 +114,15 @@ 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"); + res.write(minify.requireDefinition()); + res.end(); + }); app.get('/static/*', function(req, res) { var filePath = path.normalize(__dirname + "/.." + diff --git a/node/utils/Minify.js b/node/utils/Minify.js index 016739b1a..348f25373 100644 --- a/node/utils/Minify.js +++ b/node/utils/Minify.js @@ -29,6 +29,7 @@ var pro = require("uglify-js").uglify; var path = require('path'); var Buffer = require('buffer').Buffer; var gzip = require('gzip'); +var RequireKernel = require('require-kernel'); var server = require('../server'); var os = require('os'); @@ -173,22 +174,31 @@ function _handle(req, res, jsFilename, jsFiles) { var type = item.match(/INCLUDE_[A-Z]+/g)[0].substr("INCLUDE_".length); //read the included file - fs.readFile(ROOT_DIR + filename, "utf-8", function(err, data) + var shortFilename = filename.replace(/^..\/static\/js\//, ''); + if (shortFilename == 'require-kernel.js') { + // the kernel isn’t actually on the file system. + handleEmbed(null, requireDefinition()); + } else { + fs.readFile(ROOT_DIR + filename, "utf-8", handleEmbed); + } + function handleEmbed(err, data) { if(ERR(err, callback)) return; if(type == "JS") { - var shortFilename = filename.replace(/^..\/static\/js\//, ''); - embeds[filename] = compressJS([isolateJS(data, shortFilename)]); + if (shortFilename == 'require-kernel.js') { + embeds[filename] = compressJS([data]); + } else { + embeds[filename] = compressJS([isolateJS(data, shortFilename)]); + } } else { embeds[filename] = compressCSS([data]); } - callback(); - }); + } }, function(err) { if(ERR(err, callback)) return; @@ -294,21 +304,35 @@ function _handle(req, res, jsFilename, jsFiles) { } } +exports.requireDefinition = requireDefinition; +function requireDefinition() { + return 'var require = ' + RequireKernel.kernelSource + ';\n'; +} + function tarCode(filesInOrder, files, write) { for(var i = 0, ii = filesInOrder.length; i < filesInOrder.length; i++) { var filename = filesInOrder[i]; write("\n\n\n/*** File: static/js/" + filename + " ***/\n\n\n"); write(isolateJS(files[filename], filename)); } + + for(var i = 0, ii = filesInOrder.length; i < filesInOrder.length; i++) { + var filename = filesInOrder[i]; + write('require(' + JSON.stringify('/' + filename.replace(/^\/+/, '')) + ');\n'); + } } // Wrap the following code in a self executing function and assign exports to // global. This is a first step towards removing symbols from the global scope. // exports is global and require is a function that returns global. function isolateJS(code, filename) { - return '(function (exports, require) {' - + code + '\n' - + '}(function () {return this}(), (function (path) {return (function () {return this}())})));\n'; + var srcPath = JSON.stringify('/' + filename); + var srcPathAbbv = JSON.stringify('/' + filename.replace(/\.js$/, '')); + return 'require.define({' + + srcPath + ': ' + + 'function (require, exports, module) {' + code + '}' + + (srcPath != srcPathAbbv ? '\n,' + srcPathAbbv + ': null' : '') + + '});\n'; } function compressJS(values) diff --git a/package.json b/package.json index efc89fd7a..6567e5324 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "name": "Robin Buse" } ], "dependencies" : { + "require-kernel" : "1.0.0", "socket.io" : "0.8.7", "ueberDB" : "0.1.3", "async" : "0.1.15", diff --git a/static/js/ace.js b/static/js/ace.js index 78a79d7ec..8ecfbc0cb 100644 --- a/static/js/ace.js +++ b/static/js/ace.js @@ -216,25 +216,41 @@ function Ace2Editor() return {embeded: embededFiles, remote: remoteFiles}; } + function pushRequireScriptTo(buffer) { + /* Folling is for packaging regular expression. */ + /* $$INCLUDE_JS("../static/js/require-kernel.js"); */ + var KERNEL_SOURCE = '../static/js/require-kernel.js'; + if (Ace2Editor.EMBEDED && Ace2Editor.EMBEDED[KERNEL_SOURCE]) { + buffer.push(' + - diff --git a/static/timeslider.html b/static/timeslider.html index a416562e8..4e85047e3 100644 --- a/static/timeslider.html +++ b/static/timeslider.html @@ -9,6 +9,7 @@ + @@ -19,8 +20,6 @@ // Date: Mon, 16 Jan 2012 00:47:10 -0800 Subject: [PATCH 15/15] Remove guards surrounding export steps. --- static/js/ace.js | 2 -- static/js/ace2_common.js | 2 -- static/js/ace2_inner.js | 2 -- static/js/broadcast.js | 2 -- static/js/broadcast_revisions.js | 2 -- static/js/broadcast_slider.js | 2 -- static/js/changesettracker.js | 2 -- static/js/chat.js | 2 -- static/js/collab_client.js | 2 -- static/js/colorutils.js | 2 -- static/js/contentcollector.js | 2 -- static/js/cssmanager.js | 2 -- static/js/cssmanager_client.js | 2 -- static/js/domline.js | 2 -- static/js/domline_client.js | 2 -- static/js/draggable.js | 2 -- static/js/easysync2.js | 2 -- static/js/easysync2_client.js | 2 -- static/js/linestylefilter.js | 2 -- static/js/linestylefilter_client.js | 2 -- static/js/pad2.js | 2 -- static/js/pad_connectionstatus.js | 2 -- static/js/pad_cookie.js | 2 -- static/js/pad_docbar.js | 2 -- static/js/pad_editbar.js | 2 -- static/js/pad_editor.js | 2 -- static/js/pad_impexp.js | 2 -- static/js/pad_modals.js | 2 -- static/js/pad_savedrevs.js | 2 -- static/js/pad_userlist.js | 2 -- static/js/pad_utils.js | 2 -- static/js/plugins.js | 2 -- static/js/skiplist.js | 2 -- static/js/undomodule.js | 2 -- static/js/virtual_lines.js | 2 -- 35 files changed, 70 deletions(-) diff --git a/static/js/ace.js b/static/js/ace.js index 8ecfbc0cb..6854b1142 100644 --- a/static/js/ace.js +++ b/static/js/ace.js @@ -391,6 +391,4 @@ function Ace2Editor() return editor; } -if (typeof exports !== 'undefined') { exports.Ace2Editor = Ace2Editor; -} diff --git a/static/js/ace2_common.js b/static/js/ace2_common.js index 0918189c9..1ce7810aa 100644 --- a/static/js/ace2_common.js +++ b/static/js/ace2_common.js @@ -147,7 +147,6 @@ function htmlPrettyEscape(str) }).replace(/\r?\n/g, '\\n'); } -if (typeof exports !== 'undefined') { exports.isNodeText = isNodeText; exports.object = object; exports.extend = extend; @@ -162,4 +161,3 @@ exports.binarySearch = binarySearch; exports.binarySearchInfinite = binarySearchInfinite; exports.htmlPrettyEscape = htmlPrettyEscape; exports.map = map; -} diff --git a/static/js/ace2_inner.js b/static/js/ace2_inner.js index 455958cd2..e97847721 100644 --- a/static/js/ace2_inner.js +++ b/static/js/ace2_inner.js @@ -5888,6 +5888,4 @@ function OUTER(gscope) OUTER(this); -if (typeof exports !== 'undefined') { exports.OUTER = OUTER; // This is probably unimportant. -} diff --git a/static/js/broadcast.js b/static/js/broadcast.js index f2aa048fb..b49b185a5 100644 --- a/static/js/broadcast.js +++ b/static/js/broadcast.js @@ -765,6 +765,4 @@ function loadBroadcastJS() receiveAuthorData(clientVars.historicalAuthorData); } -if (typeof exports !== 'undefined') { exports.loadBroadcastJS = loadBroadcastJS; -} diff --git a/static/js/broadcast_revisions.js b/static/js/broadcast_revisions.js index f60e58bb8..364ac3e8c 100644 --- a/static/js/broadcast_revisions.js +++ b/static/js/broadcast_revisions.js @@ -126,6 +126,4 @@ function loadBroadcastRevisionsJS() } } -if (typeof exports !== 'undefined') { exports.loadBroadcastRevisionsJS = loadBroadcastRevisionsJS; -} diff --git a/static/js/broadcast_slider.js b/static/js/broadcast_slider.js index 1d9f4928e..972190acb 100644 --- a/static/js/broadcast_slider.js +++ b/static/js/broadcast_slider.js @@ -497,6 +497,4 @@ function loadBroadcastSliderJS() }) } -if (typeof exports !== 'undefined') { exports.loadBroadcastSliderJS = loadBroadcastSliderJS; -} diff --git a/static/js/changesettracker.js b/static/js/changesettracker.js index db3ab9446..7b0fb3e46 100644 --- a/static/js/changesettracker.js +++ b/static/js/changesettracker.js @@ -210,6 +210,4 @@ function makeChangesetTracker(scheduler, apool, aceCallbacksProvider) } -if (typeof exports !== 'undefined') { exports.makeChangesetTracker = makeChangesetTracker; -} diff --git a/static/js/chat.js b/static/js/chat.js index b4d15f4e5..475d01939 100644 --- a/static/js/chat.js +++ b/static/js/chat.js @@ -176,6 +176,4 @@ var chat = (function() return self; }()); -if (typeof exports !== 'undefined') { exports.chat = chat; -} diff --git a/static/js/collab_client.js b/static/js/collab_client.js index 1f4e21dc8..b697d4853 100644 --- a/static/js/collab_client.js +++ b/static/js/collab_client.js @@ -725,7 +725,5 @@ function selectElementContents(elem) } } -if (typeof exports !== 'undefined') { exports.getCollabClient = getCollabClient; exports.selectElementContents = selectElementContents; -} diff --git a/static/js/colorutils.js b/static/js/colorutils.js index 1fc452b6a..9bba39ad2 100644 --- a/static/js/colorutils.js +++ b/static/js/colorutils.js @@ -120,6 +120,4 @@ colorutils.blend = function(c1, c2, t) return [colorutils.scale(t, c1[0], c2[0]), colorutils.scale(t, c1[1], c2[1]), colorutils.scale(t, c1[2], c2[2])]; } -if (typeof exports !== 'undefined') { exports.colorutils = colorutils; -} diff --git a/static/js/contentcollector.js b/static/js/contentcollector.js index 5f78a3f24..fd90a07be 100644 --- a/static/js/contentcollector.js +++ b/static/js/contentcollector.js @@ -701,7 +701,5 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class return cc; } -if (typeof exports !== 'undefined') { exports.sanitizeUnicode = sanitizeUnicode; exports.makeContentCollector = makeContentCollector; -} diff --git a/static/js/cssmanager.js b/static/js/cssmanager.js index 1d45f3024..46075e578 100644 --- a/static/js/cssmanager.js +++ b/static/js/cssmanager.js @@ -119,6 +119,4 @@ function makeCSSManager(emptyStylesheetTitle, top) }; } -if (typeof exports !== 'undefined') { exports.makeCSSManager = makeCSSManager; -} diff --git a/static/js/cssmanager_client.js b/static/js/cssmanager_client.js index 3db467e31..6d9d989e8 100644 --- a/static/js/cssmanager_client.js +++ b/static/js/cssmanager_client.js @@ -115,6 +115,4 @@ function makeCSSManager(emptyStylesheetTitle) }; } -if (typeof exports !== 'undefined') { exports.makeCSSManager = makeCSSManager; -} diff --git a/static/js/domline.js b/static/js/domline.js index 2d8913928..5de33c5aa 100644 --- a/static/js/domline.js +++ b/static/js/domline.js @@ -319,6 +319,4 @@ domline.processSpaces = function(s, doesWrap) return parts.join(''); }; -if (typeof exports !== 'undefined') { exports.domline = domline; -} diff --git a/static/js/domline_client.js b/static/js/domline_client.js index 6a09a1723..b999e3589 100644 --- a/static/js/domline_client.js +++ b/static/js/domline_client.js @@ -318,6 +318,4 @@ domline.processSpaces = function(s, doesWrap) return parts.join(''); }; -if (typeof exports !== 'undefined') { exports.domline = domline; -} diff --git a/static/js/draggable.js b/static/js/draggable.js index 1d0ddb4c3..8d1975459 100644 --- a/static/js/draggable.js +++ b/static/js/draggable.js @@ -194,6 +194,4 @@ function makeResizableHPane(left, sep, right, minLeft, minRight, sepWidth, sepOf }); } -if (typeof exports !== 'undefined') { exports.makeDraggable = makeDraggable; -} diff --git a/static/js/easysync2.js b/static/js/easysync2.js index 81a416b25..cef868a1d 100644 --- a/static/js/easysync2.js +++ b/static/js/easysync2.js @@ -2509,7 +2509,5 @@ Changeset.followAttributes = function(att1, att2, pool) return buf.toString(); }; -if (typeof exports !== 'undefined') { exports.Changeset = Changeset; exports.AttribPool = AttribPool; -} diff --git a/static/js/easysync2_client.js b/static/js/easysync2_client.js index 5745110e6..f4f3d08fb 100644 --- a/static/js/easysync2_client.js +++ b/static/js/easysync2_client.js @@ -2270,7 +2270,5 @@ Changeset.inverse = function(cs, lines, alines, pool) return Changeset.checkRep(builder.toString()); }; -if (typeof exports !== 'undefined') { exports.Changeset = Changeset; exports.AttribPool = AttribPool; -} diff --git a/static/js/linestylefilter.js b/static/js/linestylefilter.js index 9558ed71b..fa1b40dee 100644 --- a/static/js/linestylefilter.js +++ b/static/js/linestylefilter.js @@ -362,6 +362,4 @@ linestylefilter.populateDomLine = function(textLine, aline, apool, domLineObj) func(text, ''); }; -if (typeof exports !== 'undefined') { exports.linestylefilter = linestylefilter; -} diff --git a/static/js/linestylefilter_client.js b/static/js/linestylefilter_client.js index 9b1cb83dc..7ff5bef41 100644 --- a/static/js/linestylefilter_client.js +++ b/static/js/linestylefilter_client.js @@ -360,6 +360,4 @@ linestylefilter.populateDomLine = function(textLine, aline, apool, domLineObj) func(text, ''); }; -if (typeof exports !== 'undefined') { exports.linestylefilter = linestylefilter; -} diff --git a/static/js/pad2.js b/static/js/pad2.js index 5369d422a..65cd72218 100644 --- a/static/js/pad2.js +++ b/static/js/pad2.js @@ -967,7 +967,6 @@ var alertBar = (function() return self; }()); -if (typeof exports !== 'undefined') { exports.settings = settings; exports.createCookie = createCookie; exports.readCookie = readCookie; @@ -978,4 +977,3 @@ exports.savePassword = savePassword; exports.handshake = handshake; exports.pad = pad; exports.alertBar = alertBar; -} diff --git a/static/js/pad_connectionstatus.js b/static/js/pad_connectionstatus.js index d3a7648cb..1de024e8d 100644 --- a/static/js/pad_connectionstatus.js +++ b/static/js/pad_connectionstatus.js @@ -88,6 +88,4 @@ var padconnectionstatus = (function() return self; }()); -if (typeof exports !== 'undefined') { exports.padconnectionstatus = padconnectionstatus; -} diff --git a/static/js/pad_cookie.js b/static/js/pad_cookie.js index 00dc28f39..24dc1e3fa 100644 --- a/static/js/pad_cookie.js +++ b/static/js/pad_cookie.js @@ -130,6 +130,4 @@ var padcookie = (function() return self; }()); -if (typeof exports !== 'undefined') { exports.padcookie = padcookie; -} diff --git a/static/js/pad_docbar.js b/static/js/pad_docbar.js index 2bf1a1da0..cf461c93d 100644 --- a/static/js/pad_docbar.js +++ b/static/js/pad_docbar.js @@ -463,6 +463,4 @@ var paddocbar = (function() return self; }()); -if (typeof exports !== 'undefined') { exports.paddocbar = paddocbar; -} diff --git a/static/js/pad_editbar.js b/static/js/pad_editbar.js index 774208940..d542b05d7 100644 --- a/static/js/pad_editbar.js +++ b/static/js/pad_editbar.js @@ -235,6 +235,4 @@ var padeditbar = (function() return self; }()); -if (typeof exports !== 'undefined') { exports.padeditbar = padeditbar; -} diff --git a/static/js/pad_editor.js b/static/js/pad_editor.js index 45a90f006..bb775e957 100644 --- a/static/js/pad_editor.js +++ b/static/js/pad_editor.js @@ -159,6 +159,4 @@ var padeditor = (function() return self; }()); -if (typeof exports !== 'undefined') { exports.padeditor = padeditor; -} diff --git a/static/js/pad_impexp.js b/static/js/pad_impexp.js index 8f187a5cb..aa99541ea 100644 --- a/static/js/pad_impexp.js +++ b/static/js/pad_impexp.js @@ -334,6 +334,4 @@ var padimpexp = (function() return self; }()); -if (typeof exports !== 'undefined') { exports.padimpexp = padimpexp; -} diff --git a/static/js/pad_modals.js b/static/js/pad_modals.js index 9d24c5f1a..81ef0776b 100644 --- a/static/js/pad_modals.js +++ b/static/js/pad_modals.js @@ -371,6 +371,4 @@ var padmodals = (function() return self; }()); -if (typeof exports !== 'undefined') { exports.padmodals = padmodals; -} diff --git a/static/js/pad_savedrevs.js b/static/js/pad_savedrevs.js index 964c83386..bb52658b2 100644 --- a/static/js/pad_savedrevs.js +++ b/static/js/pad_savedrevs.js @@ -523,6 +523,4 @@ var padsavedrevs = (function() return self; }()); -if (typeof exports !== 'undefined') { exports.padsavedrevs = padsavedrevs; -} diff --git a/static/js/pad_userlist.js b/static/js/pad_userlist.js index b9d08932e..e0a12f838 100644 --- a/static/js/pad_userlist.js +++ b/static/js/pad_userlist.js @@ -811,6 +811,4 @@ function showColorPicker() } } -if (typeof exports !== 'undefined') { exports.paduserlist = paduserlist; -} diff --git a/static/js/pad_utils.js b/static/js/pad_utils.js index 30ff308c0..aa469d87b 100644 --- a/static/js/pad_utils.js +++ b/static/js/pad_utils.js @@ -489,6 +489,4 @@ window.onerror = function test (msg, url, linenumber) return false; }; -if (typeof exports !== 'undefined') { exports.padutils = padutils; -} diff --git a/static/js/plugins.js b/static/js/plugins.js index 2cf0e0e26..ce3ec9bd7 100644 --- a/static/js/plugins.js +++ b/static/js/plugins.js @@ -32,6 +32,4 @@ plugins = { } }; -if (typeof exports !== 'undefined') { exports.plugins = plugins; -} diff --git a/static/js/skiplist.js b/static/js/skiplist.js index 995cd6bc7..385f08f0d 100644 --- a/static/js/skiplist.js +++ b/static/js/skiplist.js @@ -489,6 +489,4 @@ that is a string. return self; } -if (typeof exports !== 'undefined') { exports.newSkipList = newSkipList; -} diff --git a/static/js/undomodule.js b/static/js/undomodule.js index b515180d4..aff41a70c 100644 --- a/static/js/undomodule.js +++ b/static/js/undomodule.js @@ -332,6 +332,4 @@ var undoModule = (function() }; // apool is filled in by caller })(); -if (typeof exports !== 'undefined') { exports.undoModule = undoModule; -} diff --git a/static/js/virtual_lines.js b/static/js/virtual_lines.js index 32fc58875..2bcf5ed63 100644 --- a/static/js/virtual_lines.js +++ b/static/js/virtual_lines.js @@ -385,6 +385,4 @@ function makeVirtualLineView(lineNode) } -if (typeof exports !== 'undefined') { exports.makeVirtualLineView = makeVirtualLineView; -}