Merge pull request #343 from cweider/modulize

Modulize
This commit is contained in:
Peter 'Pita' Martischka 2012-01-22 10:22:40 -08:00
commit 947d53e231
41 changed files with 369 additions and 44 deletions

View File

@ -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 + "/.." +

View File

@ -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');
@ -52,10 +53,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
@ -151,7 +163,7 @@ exports.minifyJS = function(req, res, next)
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)
@ -162,21 +174,31 @@ exports.minifyJS = function(req, res, next)
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 isnt 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")
{
embeds[filename] = compressJS([data]);
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;
@ -197,14 +219,9 @@ exports.minifyJS = function(req, res, next)
//put all together and write it into a file
function(callback)
{
//put all javascript files in an array
var values = [];
for(var i in jsFiles)
{
values.push(fileValues[jsFiles[i]]);
}
//minify all javascript files to one
var values = [];
tarCode(jsFiles, fileValues, function (content) {values.push(content)});
var result = compressJS(values);
async.parallel([
@ -280,18 +297,44 @@ exports.minifyJS = function(req, res, next)
{
if(ERR(err)) return;
for(var i=0;i<jsFiles.length;i++)
{
var fileName = jsFiles[i];
res.write("\n\n\n/*** File: static/js/" + fileName + " ***/\n\n\n");
res.write(fileValues[fileName]);
}
tarCode(jsFiles, fileValues, function (content) {res.write(content)});
res.end();
});
}
}
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) {
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)
{
var complete = values.join("\n");

View File

@ -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"

View File

@ -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",

View File

@ -28,6 +28,8 @@ Ace2Editor.registry = {
nextId: 1
};
var plugins = require('/plugins').plugins;
function Ace2Editor()
{
var ace2 = Ace2Editor;
@ -214,24 +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('<script type="text/javascript">');
buffer.push(Ace2Editor.EMBEDED[KERNEL_SOURCE]);
buffer.push('<\/script>');
} else {
buffer.push('<script type="application/javascript" src="'+KERNEL_SOURCE+'"><\/script>');
}
}
function pushScriptTagsFor(buffer, files) {
var sorted = sortFilesByEmbeded(files);
var embededFiles = sorted.embeded;
var remoteFiles = sorted.remote;
if (embededFiles.length > 0) {
buffer.push('<script type="text/javascript">');
for (var i = 0, ii = embededFiles.length; i < ii; i++) {
var file = embededFiles[i];
buffer.push(Ace2Editor.EMBEDED[file].replace(/<\//g, '<\\/'));
buffer.push(';\n');
}
buffer.push('<\/script>');
}
for (var i = 0, ii = remoteFiles.length; i < ii; i++) {
var file = remoteFiles[i];
file = file.replace(/^\.\.\/static\/js\//, '../minified/');
buffer.push('<script type="application/javascript" src="' + file + '"><\/script>');
}
buffer.push('<script type="text/javascript">');
for (var i = 0, ii = embededFiles.length; i < ii; i++) {
var file = embededFiles[i];
buffer.push(Ace2Editor.EMBEDED[file].replace(/<\//g, '<\\/'));
buffer.push(';\n');
}
for (var i = 0, ii = files.length; i < ii; i++) {
var file = files[i];
file = file.replace(/^\.\.\/static\/js\//, '');
buffer.push('require('+ JSON.stringify('/' + file) + ');\n');
}
buffer.push('<\/script>');
}
function pushStyleTagsFor(buffer, files) {
var sorted = sortFilesByEmbeded(files);
@ -317,6 +336,7 @@ function Ace2Editor()
$$INCLUDE_JS("../static/js/linestylefilter.js");
$$INCLUDE_JS("../static/js/domline.js");
$$INCLUDE_JS("../static/js/ace2_inner.js");
pushRequireScriptTo(iframeHTML);
pushScriptTagsFor(iframeHTML, includedJS);
iframeHTML.push('<style type="text/css" title="dynamicsyntax"></style>');
@ -370,3 +390,5 @@ function Ace2Editor()
return editor;
}
exports.Ace2Editor = Ace2Editor;

View File

@ -147,7 +147,17 @@ function htmlPrettyEscape(str)
}).replace(/\r?\n/g, '\\n');
}
if (typeof exports !== "undefined")
{
exports.map = map;
}
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;

View File

@ -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)
{
@ -5858,3 +5887,5 @@ function OUTER(gscope)
};
OUTER(this);
exports.OUTER = OUTER; // This is probably unimportant.

View File

@ -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.)
@ -758,3 +764,5 @@ function loadBroadcastJS()
receiveAuthorData(clientVars.historicalAuthorData);
}
exports.loadBroadcastJS = loadBroadcastJS;

View File

@ -125,3 +125,5 @@ function loadBroadcastRevisionsJS()
};
}
}
exports.loadBroadcastRevisionsJS = loadBroadcastRevisionsJS;

View File

@ -496,3 +496,5 @@ function loadBroadcastSliderJS()
$("#viewlatest").html(loc == BroadcastSlider.getSliderLength() ? "Viewing latest content" : "View latest content");
})
}
exports.loadBroadcastSliderJS = loadBroadcastSliderJS;

View File

@ -20,6 +20,8 @@
* limitations under the License.
*/
var Changeset = require('/easysync2').Changeset;
var AttribPool = require('/easysync2').AttribPool;
function makeChangesetTracker(scheduler, apool, aceCallbacksProvider)
{
@ -207,3 +209,5 @@ function makeChangesetTracker(scheduler, apool, aceCallbacksProvider)
};
}
exports.makeChangesetTracker = makeChangesetTracker;

View File

@ -20,6 +20,8 @@
* limitations under the License.
*/
var padutils = require('/pad_utils').padutils;
var chat = (function()
{
var bottomMargin = "0px";
@ -82,13 +84,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 +152,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
@ -172,3 +175,5 @@ var chat = (function()
return self;
}());
exports.chat = chat;

View File

@ -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;
@ -722,3 +724,6 @@ function selectElementContents(elem)
}
}
}
exports.getCollabClient = getCollabClient;
exports.selectElementContents = selectElementContents;

View File

@ -119,3 +119,5 @@ 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])];
}
exports.colorutils = colorutils;

View File

@ -25,6 +25,14 @@
var _MAX_LIST_LEVEL = 8;
var Changeset = require('/easysync2').Changeset
var plugins = undefined;
try {
plugins = require('/plugins').plugins;
} catch (e) {
// silence
}
function sanitizeUnicode(s)
{
return s.replace(/[\uffff\ufffe\ufeff\ufdd0-\ufdef\ud800-\udfff]/g, '?');
@ -692,3 +700,6 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
return cc;
}
exports.sanitizeUnicode = sanitizeUnicode;
exports.makeContentCollector = makeContentCollector;

View File

@ -118,3 +118,5 @@ function makeCSSManager(emptyStylesheetTitle, top)
}
};
}
exports.makeCSSManager = makeCSSManager;

View File

@ -114,3 +114,5 @@ function makeCSSManager(emptyStylesheetTitle)
}
};
}
exports.makeCSSManager = makeCSSManager;

View File

@ -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()
{};
@ -310,3 +318,5 @@ domline.processSpaces = function(s, doesWrap)
}
return parts.join('');
};
exports.domline = domline;

View File

@ -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()
{};
@ -309,3 +317,5 @@ domline.processSpaces = function(s, doesWrap)
}
return parts.join('');
};
exports.domline = domline;

View File

@ -193,3 +193,5 @@ function makeResizableHPane(left, sep, right, minLeft, minRight, sepWidth, sepOf
}
});
}
exports.makeDraggable = makeDraggable;

View File

@ -2508,3 +2508,6 @@ Changeset.followAttributes = function(att1, att2, pool)
}
return buf.toString();
};
exports.Changeset = Changeset;
exports.AttribPool = AttribPool;

View File

@ -2269,3 +2269,6 @@ Changeset.inverse = function(cs, lines, alines, pool)
return Changeset.checkRep(builder.toString());
};
exports.Changeset = Changeset;
exports.AttribPool = AttribPool;

View File

@ -27,6 +27,15 @@
// requires: top
// requires: plugins
// requires: undefined
var Changeset = require('/easysync2').Changeset
var plugins = undefined;
try {
plugins = require('/plugins').plugins;
} catch (e) {
// silence
}
var linestylefilter = {};
linestylefilter.ATTRIB_CLASSES = {
@ -352,3 +361,5 @@ linestylefilter.populateDomLine = function(textLine, aline, apool, domLineObj)
func = linestylefilter.getLineStyleFilter(text.length, aline, func, apool);
func(text, '');
};
exports.linestylefilter = linestylefilter;

View File

@ -25,6 +25,15 @@
// requires: top
// requires: plugins
// requires: undefined
var Changeset = require('/easysync2_client').Changeset
var plugins = undefined;
try {
plugins = require('/plugins').plugins;
} catch (e) {
// silence
}
var linestylefilter = {};
linestylefilter.ATTRIB_CLASSES = {
@ -350,3 +359,5 @@ linestylefilter.populateDomLine = function(textLine, aline, apool, domLineObj)
func = linestylefilter.getLineStyleFilter(text.length, aline, func, apool);
func(text, '');
};
exports.linestylefilter = linestylefilter;

View File

@ -32,6 +32,19 @@ settings.globalUserName = false;
settings.hideQRCode = false;
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()
{
//start the costum js
@ -272,13 +285,13 @@ function handshake()
{
$("#editorloadingbox").html("<b>You need a password to access this pad</b><br>" +
"<input id='passwordinput' type='password' name='password'>"+
"<button type='button' onclick='savePassword()'>ok</button>");
"<button type='button' onclick=\"" + padutils.escapeHtml('require('+JSON.stringify(module.id)+").savePassword()") + "\">ok</button>");
}
else if(obj.accessStatus == "wrongPassword")
{
$("#editorloadingbox").html("<b>You're password was wrong</b><br>" +
"<input id='passwordinput' type='password' name='password'>"+
"<button type='button' onclick='savePassword()'>ok</button>");
"<button type='button' onclick=\"" + padutils.escapeHtml('require('+JSON.stringify(module.id)+").savePassword()") + "\">ok</button>");
}
}
@ -413,7 +426,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;
@ -953,3 +966,14 @@ var alertBar = (function()
};
return self;
}());
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;

View File

@ -20,6 +20,8 @@
* limitations under the License.
*/
var padmodals = require('/pad_modals').padmodals;
var padconnectionstatus = (function()
{
@ -85,3 +87,5 @@ var padconnectionstatus = (function()
};
return self;
}());
exports.padconnectionstatus = padconnectionstatus;

View File

@ -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)
{
@ -126,3 +129,5 @@ var padcookie = (function()
};
return self;
}());
exports.padcookie = padcookie;

View File

@ -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()
@ -456,3 +462,5 @@ var paddocbar = (function()
};
return self;
}());
exports.paddocbar = paddocbar;

View File

@ -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()
{
@ -230,3 +234,5 @@ var padeditbar = (function()
};
return self;
}());
exports.padeditbar = padeditbar;

View File

@ -20,15 +20,23 @@
* limitations under the License.
*/
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()
{
@ -150,3 +158,5 @@ var padeditor = (function()
};
return self;
}());
exports.padeditor = padeditor;

View File

@ -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
@ -325,3 +333,5 @@ var padimpexp = (function()
};
return self;
}());
exports.padimpexp = padimpexp;

View File

@ -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();
},
@ -364,3 +370,5 @@ var padmodals = (function()
};
return self;
}());
exports.padmodals = padmodals;

View File

@ -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()
@ -518,3 +522,5 @@ var padsavedrevs = (function()
};
return self;
}());
exports.padsavedrevs = padsavedrevs;

View File

@ -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 = $('<div id="guestprompt-' + encodedUserId + '" class="guestprompt"><div class="choices"><a href="javascript:void(paduserlist.answerGuestPrompt(\'' + encodedUserId + '\',false))">Deny</a> <a href="javascript:void(paduserlist.answerGuestPrompt(\'' + encodedUserId + '\',true))">Approve</a></div><div class="guestname"><strong>Guest:</strong> ' + padutils.escapeHtml(displayName) + '</div></div>');
box = $('<div id="'+padutils.escapeHtml('guestprompt-' + encodedUserId) + '" class="guestprompt"><div class="choices"><a href="' + padutils.escapeHtml('javascript:void(require('+JSON.stringify(module.id)+').paduserlist.answerGuestPrompt(' + JSON.stringify(encodedUserId) + ',false))')+'">Deny</a> <a href="' + padutils.escapeHtml('javascript:void(require('+JSON.stringify(module.id)+').paduserlist.answerGuestPrompt(' + JSON.stringify(encodedUserId) + ',true))') + '">Approve</a></div><div class="guestname"><strong>Guest:</strong> ' + padutils.escapeHtml(displayName) + '</div></div>');
$("#guestprompts").append(box);
}
else
@ -805,3 +810,5 @@ function showColorPicker()
$($("#colorpickerswatches li")[myUserInfo.colorId]).addClass("picked"); //seems weird
}
}
exports.paduserlist = paduserlist;

View File

@ -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);
@ -486,3 +488,5 @@ window.onerror = function test (msg, url, linenumber)
return false;
};
exports.padutils = padutils;

View File

@ -31,3 +31,5 @@ plugins = {
}).join(sep || "");
}
};
exports.plugins = plugins;

View File

@ -488,3 +488,5 @@ that is a string.
}
return self;
}
exports.newSkipList = newSkipList;

View File

@ -20,8 +20,10 @@
* limitations under the License.
*/
var Changeset = require('/easysync2').Changeset;
var extend = require('/ace2_common').extend;
undoModule = (function()
var undoModule = (function()
{
var stack = (function()
{
@ -329,3 +331,5 @@ undoModule = (function()
apool: null
}; // apool is filled in by caller
})();
exports.undoModule = undoModule;

View File

@ -384,3 +384,5 @@ function makeVirtualLineView(lineNode)
}
}
exports.makeVirtualLineView = makeVirtualLineView;

View File

@ -13,6 +13,7 @@
var clientVars = {};
// ]]>
</script>
<script src="../static/js/require-kernel.js"></script>
<script src="../socket.io/socket.io.js"></script>
<script src="../minified/pad.js"></script>
<link href="../static/custom/pad.css" rel="stylesheet">
@ -337,5 +338,13 @@
<input type="hidden" class="missedChanges" name="missedChanges"/>
</form>
<script>
/* TODO: These globals shouldn't exist. */
pad = require('/pad2').pad;
chat = require('/chat').chat;
padeditbar = require('/pad_editbar').padeditbar;
padimpexp = require('/pad_impexp').padimpexp;
</script>
</body>
</html>

View File

@ -9,6 +9,7 @@
<link rel="stylesheet" href="../../static/css/timeslider.css">
<style type="text/css" title="dynamicsyntax"></style>
<script type="text/javascript" src="../../static/js/require-kernel.js"></script>
<script type="text/javascript" src="../../socket.io/socket.io.js"></script>
<script type="text/javascript" src="../../minified/timeslider.js"></script>
@ -19,6 +20,10 @@
// <![CDATA[
var clientVars = {};
/* TODO: These globals shouldn't exist. */
padeditbar = require('/pad_editbar').padeditbar;
padimpexp = require('/pad_impexp').padimpexp;
function createCookie(name,value,days)
{
if (days) {
@ -141,9 +146,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();