Merge branch 'master' of github.com:Pita/etherpad-lite
commit
9f9eb6e928
|
@ -1,6 +1,6 @@
|
||||||
node_modules
|
node_modules
|
||||||
settings.json
|
settings.json
|
||||||
static/js/jquery.min.js
|
static/js/jquery.js
|
||||||
APIKEY.txt
|
APIKEY.txt
|
||||||
bin/abiword.exe
|
bin/abiword.exe
|
||||||
bin/node.exe
|
bin/node.exe
|
||||||
|
|
|
@ -58,7 +58,7 @@ Here is the **[FAQ](https://github.com/Pita/etherpad-lite/wiki/FAQ)**
|
||||||
|
|
||||||
<ol>
|
<ol>
|
||||||
<li>Install the dependencies. We need gzip, git, curl, libssl develop libraries, python and gcc. <br><i>For Debian/Ubuntu</i> <code>apt-get install gzip git-core curl python libssl-dev build-essential</code><br>
|
<li>Install the dependencies. We need gzip, git, curl, libssl develop libraries, python and gcc. <br><i>For Debian/Ubuntu</i> <code>apt-get install gzip git-core curl python libssl-dev build-essential</code><br>
|
||||||
<i>For Fedora/CentOS</i> <code>yum install gzip git-core curl python openssl-dev && yum groupinstall "Development Tools"</code>
|
<i>For Fedora/CentOS</i> <code>yum install gzip git-core curl python openssl-devel && yum groupinstall "Development Tools"</code>
|
||||||
</li><br>
|
</li><br>
|
||||||
<li>Install node.js
|
<li>Install node.js
|
||||||
<ol type="a">
|
<ol type="a">
|
||||||
|
@ -98,7 +98,7 @@ Look at this wiki pages:
|
||||||
You can find more information in the [wiki](https://github.com/Pita/etherpad-lite/wiki). Feel free to improve these wiki pages
|
You can find more information in the [wiki](https://github.com/Pita/etherpad-lite/wiki). Feel free to improve these wiki pages
|
||||||
|
|
||||||
# Develop
|
# Develop
|
||||||
If you're new to git and github, start here <http://learn.github.com/p/intro.html>.
|
If you're new to git and github, start by watching [this video](http://youtu.be/67-Q26YH97E) then read this [git guide](http://learn.github.com/p/intro.html).
|
||||||
|
|
||||||
If you're new to node.js, start with this video <http://youtu.be/jo_B4LTHi3I>.
|
If you're new to node.js, start with this video <http://youtu.be/jo_B4LTHi3I>.
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,8 @@ npm install || {
|
||||||
echo "Ensure jQuery is downloaded and up to date..."
|
echo "Ensure jQuery is downloaded and up to date..."
|
||||||
DOWNLOAD_JQUERY="true"
|
DOWNLOAD_JQUERY="true"
|
||||||
NEEDED_VERSION="1.7"
|
NEEDED_VERSION="1.7"
|
||||||
if [ -f "static/js/jquery.min.js" ]; then
|
if [ -f "static/js/jquery.js" ]; then
|
||||||
VERSION=$(cat static/js/jquery.min.js | head -n 3 | grep -o "v[0-9].[0-9]");
|
VERSION=$(cat static/js/jquery.js | head -n 3 | grep -o "v[0-9].[0-9]");
|
||||||
|
|
||||||
if [ ${VERSION#v} = $NEEDED_VERSION ]; then
|
if [ ${VERSION#v} = $NEEDED_VERSION ]; then
|
||||||
DOWNLOAD_JQUERY="false"
|
DOWNLOAD_JQUERY="false"
|
||||||
|
@ -57,7 +57,7 @@ if [ -f "static/js/jquery.min.js" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $DOWNLOAD_JQUERY = "true" ]; then
|
if [ $DOWNLOAD_JQUERY = "true" ]; then
|
||||||
curl -lo static/js/jquery.min.js http://code.jquery.com/jquery-$NEEDED_VERSION.min.js || exit 1
|
curl -lo static/js/jquery.js http://code.jquery.com/jquery-$NEEDED_VERSION.js || exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Remove all minified data to force node creating it new
|
#Remove all minified data to force node creating it new
|
||||||
|
|
|
@ -78,7 +78,12 @@ async.waterfall([
|
||||||
{
|
{
|
||||||
//create server
|
//create server
|
||||||
var app = express.createServer();
|
var app = express.createServer();
|
||||||
|
|
||||||
|
app.use(function (req, res, next) {
|
||||||
|
res.header("Server", serverName);
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
|
||||||
//load modules that needs a initalized db
|
//load modules that needs a initalized db
|
||||||
readOnlyManager = require("./db/ReadOnlyManager");
|
readOnlyManager = require("./db/ReadOnlyManager");
|
||||||
exporthtml = require("./utils/ExportHtml");
|
exporthtml = require("./utils/ExportHtml");
|
||||||
|
@ -109,31 +114,24 @@ async.waterfall([
|
||||||
gracefulShutdown();
|
gracefulShutdown();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//serve minified files
|
||||||
|
app.get('/minified/:filename', minify.minifyJS);
|
||||||
|
|
||||||
//serve static files
|
//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)
|
app.get('/static/*', function(req, res)
|
||||||
{
|
{
|
||||||
res.header("Server", serverName);
|
|
||||||
var filePath = path.normalize(__dirname + "/.." +
|
var filePath = path.normalize(__dirname + "/.." +
|
||||||
req.url.replace(/\.\./g, '').split("?")[0]);
|
req.url.replace(/\.\./g, '').split("?")[0]);
|
||||||
res.sendfile(filePath, { maxAge: exports.maxAge });
|
res.sendfile(filePath, { maxAge: exports.maxAge });
|
||||||
});
|
});
|
||||||
|
|
||||||
//serve minified files
|
//serve minified files
|
||||||
app.get('/minified/:id', function(req, res, next)
|
app.get('/minified/:filename', minify.minifyJS);
|
||||||
{
|
|
||||||
res.header("Server", serverName);
|
|
||||||
|
|
||||||
var id = req.params.id;
|
|
||||||
|
|
||||||
if(id == "pad.js" || id == "timeslider.js")
|
|
||||||
{
|
|
||||||
minify.minifyJS(req,res,id);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
next();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//checks for padAccess
|
//checks for padAccess
|
||||||
function hasPadAccess(req, res, callback)
|
function hasPadAccess(req, res, callback)
|
||||||
|
@ -178,8 +176,6 @@ async.waterfall([
|
||||||
//serve read only pad
|
//serve read only pad
|
||||||
app.get('/ro/:id', function(req, res)
|
app.get('/ro/:id', function(req, res)
|
||||||
{
|
{
|
||||||
res.header("Server", serverName);
|
|
||||||
|
|
||||||
var html;
|
var html;
|
||||||
var padId;
|
var padId;
|
||||||
var pad;
|
var pad;
|
||||||
|
@ -264,7 +260,6 @@ async.waterfall([
|
||||||
app.get('/p/:pad', function(req, res, next)
|
app.get('/p/:pad', function(req, res, next)
|
||||||
{
|
{
|
||||||
goToPad(req, res, function() {
|
goToPad(req, res, function() {
|
||||||
res.header("Server", serverName);
|
|
||||||
var filePath = path.normalize(__dirname + "/../static/pad.html");
|
var filePath = path.normalize(__dirname + "/../static/pad.html");
|
||||||
res.sendfile(filePath, { maxAge: exports.maxAge });
|
res.sendfile(filePath, { maxAge: exports.maxAge });
|
||||||
});
|
});
|
||||||
|
@ -274,7 +269,6 @@ async.waterfall([
|
||||||
app.get('/p/:pad/timeslider', function(req, res, next)
|
app.get('/p/:pad/timeslider', function(req, res, next)
|
||||||
{
|
{
|
||||||
goToPad(req, res, function() {
|
goToPad(req, res, function() {
|
||||||
res.header("Server", serverName);
|
|
||||||
var filePath = path.normalize(__dirname + "/../static/timeslider.html");
|
var filePath = path.normalize(__dirname + "/../static/timeslider.html");
|
||||||
res.sendfile(filePath, { maxAge: exports.maxAge });
|
res.sendfile(filePath, { maxAge: exports.maxAge });
|
||||||
});
|
});
|
||||||
|
@ -301,7 +295,6 @@ async.waterfall([
|
||||||
}
|
}
|
||||||
|
|
||||||
res.header("Access-Control-Allow-Origin", "*");
|
res.header("Access-Control-Allow-Origin", "*");
|
||||||
res.header("Server", serverName);
|
|
||||||
|
|
||||||
hasPadAccess(req, res, function()
|
hasPadAccess(req, res, function()
|
||||||
{
|
{
|
||||||
|
@ -321,8 +314,6 @@ async.waterfall([
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
res.header("Server", serverName);
|
|
||||||
|
|
||||||
hasPadAccess(req, res, function()
|
hasPadAccess(req, res, function()
|
||||||
{
|
{
|
||||||
importHandler.doImport(req, res, req.params.pad);
|
importHandler.doImport(req, res, req.params.pad);
|
||||||
|
@ -335,7 +326,6 @@ async.waterfall([
|
||||||
//This is for making an api call, collecting all post information and passing it to the apiHandler
|
//This is for making an api call, collecting all post information and passing it to the apiHandler
|
||||||
var apiCaller = function(req, res, fields)
|
var apiCaller = function(req, res, fields)
|
||||||
{
|
{
|
||||||
res.header("Server", serverName);
|
|
||||||
res.header("Content-Type", "application/json; charset=utf-8");
|
res.header("Content-Type", "application/json; charset=utf-8");
|
||||||
|
|
||||||
apiLogger.info("REQUEST, " + req.params.func + ", " + JSON.stringify(fields));
|
apiLogger.info("REQUEST, " + req.params.func + ", " + JSON.stringify(fields));
|
||||||
|
@ -396,7 +386,6 @@ async.waterfall([
|
||||||
//serve index.html under /
|
//serve index.html under /
|
||||||
app.get('/', function(req, res)
|
app.get('/', function(req, res)
|
||||||
{
|
{
|
||||||
res.header("Server", serverName);
|
|
||||||
var filePath = path.normalize(__dirname + "/../static/index.html");
|
var filePath = path.normalize(__dirname + "/../static/index.html");
|
||||||
res.sendfile(filePath, { maxAge: exports.maxAge });
|
res.sendfile(filePath, { maxAge: exports.maxAge });
|
||||||
});
|
});
|
||||||
|
@ -404,7 +393,6 @@ async.waterfall([
|
||||||
//serve robots.txt
|
//serve robots.txt
|
||||||
app.get('/robots.txt', function(req, res)
|
app.get('/robots.txt', function(req, res)
|
||||||
{
|
{
|
||||||
res.header("Server", serverName);
|
|
||||||
var filePath = path.normalize(__dirname + "/../static/robots.txt");
|
var filePath = path.normalize(__dirname + "/../static/robots.txt");
|
||||||
res.sendfile(filePath, { maxAge: exports.maxAge });
|
res.sendfile(filePath, { maxAge: exports.maxAge });
|
||||||
});
|
});
|
||||||
|
@ -412,7 +400,6 @@ async.waterfall([
|
||||||
//serve favicon.ico
|
//serve favicon.ico
|
||||||
app.get('/favicon.ico', function(req, res)
|
app.get('/favicon.ico', function(req, res)
|
||||||
{
|
{
|
||||||
res.header("Server", serverName);
|
|
||||||
var filePath = path.normalize(__dirname + "/../static/custom/favicon.ico");
|
var filePath = path.normalize(__dirname + "/../static/custom/favicon.ico");
|
||||||
res.sendfile(filePath, { maxAge: exports.maxAge }, function(err)
|
res.sendfile(filePath, { maxAge: exports.maxAge }, function(err)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,10 +28,15 @@ var jsp = require("uglify-js").parser;
|
||||||
var pro = require("uglify-js").uglify;
|
var pro = require("uglify-js").uglify;
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var Buffer = require('buffer').Buffer;
|
var Buffer = require('buffer').Buffer;
|
||||||
var gzip = require('gzip');
|
var zlib = require('zlib');
|
||||||
|
var RequireKernel = require('require-kernel');
|
||||||
var server = require('../server');
|
var server = require('../server');
|
||||||
var os = require('os');
|
var os = require('os');
|
||||||
|
|
||||||
|
var ROOT_DIR = path.normalize(__dirname + "/../" );
|
||||||
|
var JS_DIR = ROOT_DIR + '../static/js/';
|
||||||
|
var CSS_DIR = ROOT_DIR + '../static/css/';
|
||||||
|
var CACHE_DIR = ROOT_DIR + '../var/';
|
||||||
var TAR_PATH = path.join(__dirname, 'tar.json');
|
var TAR_PATH = path.join(__dirname, 'tar.json');
|
||||||
var tar = JSON.parse(fs.readFileSync(TAR_PATH, 'utf8'));
|
var tar = JSON.parse(fs.readFileSync(TAR_PATH, 'utf8'));
|
||||||
|
|
||||||
|
@ -40,20 +45,31 @@ var tar = JSON.parse(fs.readFileSync(TAR_PATH, 'utf8'));
|
||||||
* @param req the Express request
|
* @param req the Express request
|
||||||
* @param res the Express response
|
* @param res the Express response
|
||||||
*/
|
*/
|
||||||
exports.minifyJS = function(req, res, jsFilename)
|
exports.minifyJS = function(req, res, next)
|
||||||
{
|
{
|
||||||
res.header("Content-Type","text/javascript");
|
var jsFilename = req.params['filename'];
|
||||||
|
|
||||||
//choose the js files we need
|
//choose the js files we need
|
||||||
var jsFiles = undefined;
|
var jsFiles = undefined;
|
||||||
if (Object.prototype.hasOwnProperty.call(tar, jsFilename)) {
|
if (Object.prototype.hasOwnProperty.call(tar, jsFilename)) {
|
||||||
jsFiles = tar[jsFilename];
|
jsFiles = tar[jsFilename];
|
||||||
|
_handle(req, res, jsFilename, jsFiles)
|
||||||
} else {
|
} else {
|
||||||
throw new Error("there is no profile for creating " + name);
|
// 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);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var rootPath = path.normalize(__dirname + "/../../" );
|
function _handle(req, res, jsFilename, jsFiles) {
|
||||||
|
res.header("Content-Type","text/javascript");
|
||||||
|
|
||||||
//minifying is enabled
|
//minifying is enabled
|
||||||
if(settings.minify)
|
if(settings.minify)
|
||||||
{
|
{
|
||||||
|
@ -65,7 +81,7 @@ exports.minifyJS = function(req, res, jsFilename)
|
||||||
//find out the highest modification date
|
//find out the highest modification date
|
||||||
function(callback)
|
function(callback)
|
||||||
{
|
{
|
||||||
var folders2check = [rootPath + "static/css", rootPath + "static/js"];
|
var folders2check = [CSS_DIR, JS_DIR];
|
||||||
|
|
||||||
//go trough this two folders
|
//go trough this two folders
|
||||||
async.forEach(folders2check, function(path, callback)
|
async.forEach(folders2check, function(path, callback)
|
||||||
|
@ -104,7 +120,7 @@ exports.minifyJS = function(req, res, jsFilename)
|
||||||
function(callback)
|
function(callback)
|
||||||
{
|
{
|
||||||
//check the modification time of the minified js
|
//check the modification time of the minified js
|
||||||
fs.stat(rootPath + "var/minified_" + jsFilename, function(err, stats)
|
fs.stat(CACHE_DIR + "/minified_" + jsFilename, function(err, stats)
|
||||||
{
|
{
|
||||||
if(err && err.code != "ENOENT")
|
if(err && err.code != "ENOENT")
|
||||||
{
|
{
|
||||||
|
@ -129,7 +145,7 @@ exports.minifyJS = function(req, res, jsFilename)
|
||||||
{
|
{
|
||||||
async.forEach(jsFiles, function (item, callback)
|
async.forEach(jsFiles, function (item, callback)
|
||||||
{
|
{
|
||||||
fs.readFile(rootPath + "static/js/" + item, "utf-8", function(err, data)
|
fs.readFile(JS_DIR + item, "utf-8", function(err, data)
|
||||||
{
|
{
|
||||||
if(ERR(err, callback)) return;
|
if(ERR(err, callback)) return;
|
||||||
fileValues[item] = data;
|
fileValues[item] = data;
|
||||||
|
@ -147,7 +163,7 @@ exports.minifyJS = function(req, res, jsFilename)
|
||||||
return;
|
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
|
//go trough all includes
|
||||||
async.forEach(founds, function (item, callback)
|
async.forEach(founds, function (item, callback)
|
||||||
|
@ -158,21 +174,31 @@ exports.minifyJS = function(req, res, jsFilename)
|
||||||
var type = item.match(/INCLUDE_[A-Z]+/g)[0].substr("INCLUDE_".length);
|
var type = item.match(/INCLUDE_[A-Z]+/g)[0].substr("INCLUDE_".length);
|
||||||
|
|
||||||
//read the included file
|
//read the included file
|
||||||
fs.readFile(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(ERR(err, callback)) return;
|
||||||
|
|
||||||
if(type == "JS")
|
if(type == "JS")
|
||||||
{
|
{
|
||||||
embeds[filename] = compressJS([data]);
|
if (shortFilename == 'require-kernel.js') {
|
||||||
|
embeds[filename] = compressJS([data]);
|
||||||
|
} else {
|
||||||
|
embeds[filename] = compressJS([isolateJS(data, shortFilename)]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
embeds[filename] = compressCSS([data]);
|
embeds[filename] = compressCSS([data]);
|
||||||
}
|
}
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
});
|
}
|
||||||
}, function(err)
|
}, function(err)
|
||||||
{
|
{
|
||||||
if(ERR(err, callback)) return;
|
if(ERR(err, callback)) return;
|
||||||
|
@ -193,42 +219,28 @@ exports.minifyJS = function(req, res, jsFilename)
|
||||||
//put all together and write it into a file
|
//put all together and write it into a file
|
||||||
function(callback)
|
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
|
//minify all javascript files to one
|
||||||
|
var values = [];
|
||||||
|
tarCode(jsFiles, fileValues, function (content) {values.push(content)});
|
||||||
var result = compressJS(values);
|
var result = compressJS(values);
|
||||||
|
|
||||||
async.parallel([
|
async.parallel([
|
||||||
//write the results plain in a file
|
//write the results plain in a file
|
||||||
function(callback)
|
function(callback)
|
||||||
{
|
{
|
||||||
fs.writeFile(rootPath + "var/minified_" + jsFilename, result, "utf8", callback);
|
fs.writeFile(CACHE_DIR + "minified_" + jsFilename, result, "utf8", callback);
|
||||||
},
|
},
|
||||||
//write the results compressed in a file
|
//write the results compressed in a file
|
||||||
function(callback)
|
function(callback)
|
||||||
{
|
{
|
||||||
//spawn a gzip process if we're on a unix system
|
zlib.gzip(result, function(err, compressedResult){
|
||||||
if(os.type().indexOf("Windows") == -1)
|
//weird gzip bug that returns 0 instead of null if everything is ok
|
||||||
{
|
err = err === 0 ? null : err;
|
||||||
gzip(result, 9, function(err, compressedResult){
|
|
||||||
//weird gzip bug that returns 0 instead of null if everything is ok
|
if(ERR(err, callback)) return;
|
||||||
err = err === 0 ? null : err;
|
|
||||||
|
|
||||||
if(ERR(err, callback)) return;
|
fs.writeFile(CACHE_DIR + "minified_" + jsFilename + ".gz", compressedResult, callback);
|
||||||
|
});
|
||||||
fs.writeFile(rootPath + "var/minified_" + jsFilename + ".gz", compressedResult, callback);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
//skip this step on windows
|
|
||||||
else
|
|
||||||
{
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],callback);
|
],callback);
|
||||||
}
|
}
|
||||||
|
@ -245,12 +257,12 @@ exports.minifyJS = function(req, res, jsFilename)
|
||||||
var pathStr;
|
var pathStr;
|
||||||
if(gzipSupport && os.type().indexOf("Windows") == -1)
|
if(gzipSupport && os.type().indexOf("Windows") == -1)
|
||||||
{
|
{
|
||||||
pathStr = path.normalize(rootPath + "var/minified_" + jsFilename + ".gz");
|
pathStr = path.normalize(CACHE_DIR + "minified_" + jsFilename + ".gz");
|
||||||
res.header('Content-Encoding', 'gzip');
|
res.header('Content-Encoding', 'gzip');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pathStr = path.normalize(rootPath + "var/minified_" + jsFilename );
|
pathStr = path.normalize(CACHE_DIR + "minified_" + jsFilename );
|
||||||
}
|
}
|
||||||
|
|
||||||
res.sendfile(pathStr, { maxAge: server.maxAge });
|
res.sendfile(pathStr, { maxAge: server.maxAge });
|
||||||
|
@ -264,7 +276,7 @@ exports.minifyJS = function(req, res, jsFilename)
|
||||||
//read all js files
|
//read all js files
|
||||||
async.forEach(jsFiles, function (item, callback)
|
async.forEach(jsFiles, function (item, callback)
|
||||||
{
|
{
|
||||||
fs.readFile(rootPath + "static/js/" + item, "utf-8", function(err, data)
|
fs.readFile(JS_DIR + item, "utf-8", function(err, data)
|
||||||
{
|
{
|
||||||
if(ERR(err, callback)) return;
|
if(ERR(err, callback)) return;
|
||||||
fileValues[item] = data;
|
fileValues[item] = data;
|
||||||
|
@ -276,18 +288,44 @@ exports.minifyJS = function(req, res, jsFilename)
|
||||||
{
|
{
|
||||||
if(ERR(err)) return;
|
if(ERR(err)) return;
|
||||||
|
|
||||||
for(var i=0;i<jsFiles.length;i++)
|
tarCode(jsFiles, fileValues, function (content) {res.write(content)});
|
||||||
{
|
|
||||||
var fileName = jsFiles[i];
|
|
||||||
res.write("\n\n\n/*** File: static/js/" + fileName + " ***/\n\n\n");
|
|
||||||
res.write(fileValues[fileName]);
|
|
||||||
}
|
|
||||||
|
|
||||||
res.end();
|
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)
|
function compressJS(values)
|
||||||
{
|
{
|
||||||
var complete = values.join("\n");
|
var complete = values.join("\n");
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"pad.js": [
|
"pad.js": [
|
||||||
"jquery.min.js"
|
"jquery.js"
|
||||||
, "pad_utils.js"
|
, "pad_utils.js"
|
||||||
, "plugins.js"
|
, "plugins.js"
|
||||||
, "undo-xpopup.js"
|
, "undo-xpopup.js"
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
, "farbtastic.js"
|
, "farbtastic.js"
|
||||||
]
|
]
|
||||||
, "timeslider.js": [
|
, "timeslider.js": [
|
||||||
"jquery.min.js"
|
"jquery.js"
|
||||||
, "plugins.js"
|
, "plugins.js"
|
||||||
, "undo-xpopup.js"
|
, "undo-xpopup.js"
|
||||||
, "json2.js"
|
, "json2.js"
|
||||||
|
@ -35,6 +35,7 @@
|
||||||
, "pad_editbar.js"
|
, "pad_editbar.js"
|
||||||
, "pad_docbar.js"
|
, "pad_docbar.js"
|
||||||
, "pad_modals.js"
|
, "pad_modals.js"
|
||||||
|
, "pad_savedrevs.js"
|
||||||
, "pad_impexp.js"
|
, "pad_impexp.js"
|
||||||
, "easysync2_client.js"
|
, "easysync2_client.js"
|
||||||
, "domline_client.js"
|
, "domline_client.js"
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
"name": "Robin Buse" }
|
"name": "Robin Buse" }
|
||||||
],
|
],
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
|
"require-kernel" : "1.0.0",
|
||||||
"socket.io" : "0.8.7",
|
"socket.io" : "0.8.7",
|
||||||
"ueberDB" : "0.1.3",
|
"ueberDB" : "0.1.3",
|
||||||
"async" : "0.1.15",
|
"async" : "0.1.15",
|
||||||
|
@ -17,7 +18,6 @@
|
||||||
"express" : "2.5.0",
|
"express" : "2.5.0",
|
||||||
"clean-css" : "0.2.4",
|
"clean-css" : "0.2.4",
|
||||||
"uglify-js" : "1.1.1",
|
"uglify-js" : "1.1.1",
|
||||||
"gzip" : "0.1.0",
|
|
||||||
"formidable" : "1.0.7",
|
"formidable" : "1.0.7",
|
||||||
"log4js" : "0.3.9",
|
"log4js" : "0.3.9",
|
||||||
"jsdom-nocontextifiy" : "0.2.10",
|
"jsdom-nocontextifiy" : "0.2.10",
|
||||||
|
|
|
@ -28,9 +28,10 @@ Ace2Editor.registry = {
|
||||||
nextId: 1
|
nextId: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var plugins = require('/plugins').plugins;
|
||||||
|
|
||||||
function Ace2Editor()
|
function Ace2Editor()
|
||||||
{
|
{
|
||||||
var thisFunctionsName = "Ace2Editor";
|
|
||||||
var ace2 = Ace2Editor;
|
var ace2 = Ace2Editor;
|
||||||
|
|
||||||
var editor = {};
|
var editor = {};
|
||||||
|
@ -215,24 +216,41 @@ function Ace2Editor()
|
||||||
|
|
||||||
return {embeded: embededFiles, remote: remoteFiles};
|
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) {
|
function pushScriptTagsFor(buffer, files) {
|
||||||
var sorted = sortFilesByEmbeded(files);
|
var sorted = sortFilesByEmbeded(files);
|
||||||
var embededFiles = sorted.embeded;
|
var embededFiles = sorted.embeded;
|
||||||
var remoteFiles = sorted.remote;
|
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++) {
|
for (var i = 0, ii = remoteFiles.length; i < ii; i++) {
|
||||||
var file = remoteFiles[i];
|
var file = remoteFiles[i];
|
||||||
|
file = file.replace(/^\.\.\/static\/js\//, '../minified/');
|
||||||
buffer.push('<script type="application/javascript" src="' + file + '"><\/script>');
|
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) {
|
function pushStyleTagsFor(buffer, files) {
|
||||||
var sorted = sortFilesByEmbeded(files);
|
var sorted = sortFilesByEmbeded(files);
|
||||||
|
@ -318,11 +336,16 @@ function Ace2Editor()
|
||||||
$$INCLUDE_JS("../static/js/linestylefilter.js");
|
$$INCLUDE_JS("../static/js/linestylefilter.js");
|
||||||
$$INCLUDE_JS("../static/js/domline.js");
|
$$INCLUDE_JS("../static/js/domline.js");
|
||||||
$$INCLUDE_JS("../static/js/ace2_inner.js");
|
$$INCLUDE_JS("../static/js/ace2_inner.js");
|
||||||
|
pushRequireScriptTo(iframeHTML);
|
||||||
pushScriptTagsFor(iframeHTML, includedJS);
|
pushScriptTagsFor(iframeHTML, includedJS);
|
||||||
|
|
||||||
iframeHTML.push('<style type="text/css" title="dynamicsyntax"></style>');
|
iframeHTML.push('<style type="text/css" title="dynamicsyntax"></style>');
|
||||||
iframeHTML.push('</head><body id="innerdocbody" class="syntax" spellcheck="false"> </body></html>');
|
iframeHTML.push('</head><body id="innerdocbody" class="syntax" spellcheck="false"> </body></html>');
|
||||||
|
|
||||||
|
// Expose myself to global for my child frame.
|
||||||
|
var thisFunctionsName = "ChildAccessibleAce2Editor";
|
||||||
|
(function () {return this}())[thisFunctionsName] = Ace2Editor;
|
||||||
|
|
||||||
var outerScript = 'editorId = "' + info.id + '"; editorInfo = parent.' + thisFunctionsName + '.registry[editorId]; ' + 'window.onload = function() ' + '{ window.onload = null; setTimeout' + '(function() ' + '{ var iframe = document.createElement("IFRAME"); ' + 'iframe.scrolling = "no"; var outerdocbody = document.getElementById("outerdocbody"); ' + 'iframe.frameBorder = 0; iframe.allowTransparency = true; ' + // for IE
|
var outerScript = 'editorId = "' + info.id + '"; editorInfo = parent.' + thisFunctionsName + '.registry[editorId]; ' + 'window.onload = function() ' + '{ window.onload = null; setTimeout' + '(function() ' + '{ var iframe = document.createElement("IFRAME"); ' + 'iframe.scrolling = "no"; var outerdocbody = document.getElementById("outerdocbody"); ' + 'iframe.frameBorder = 0; iframe.allowTransparency = true; ' + // for IE
|
||||||
'outerdocbody.insertBefore(iframe, outerdocbody.firstChild); ' + 'iframe.ace_outerWin = window; ' + 'readyFunc = function() { editorInfo.onEditorReady(); readyFunc = null; editorInfo = null; }; ' + 'var doc = iframe.contentWindow.document; doc.open(); var text = (' + JSON.stringify(iframeHTML.join('\n')) + ');doc.write(text); doc.close(); ' + '}, 0); }';
|
'outerdocbody.insertBefore(iframe, outerdocbody.firstChild); ' + 'iframe.ace_outerWin = window; ' + 'readyFunc = function() { editorInfo.onEditorReady(); readyFunc = null; editorInfo = null; }; ' + 'var doc = iframe.contentWindow.document; doc.open(); var text = (' + JSON.stringify(iframeHTML.join('\n')) + ');doc.write(text); doc.close(); ' + '}, 0); }';
|
||||||
|
|
||||||
|
@ -367,3 +390,5 @@ function Ace2Editor()
|
||||||
|
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.Ace2Editor = Ace2Editor;
|
||||||
|
|
|
@ -80,14 +80,8 @@ function isArray(testObject)
|
||||||
return testObject && typeof testObject === 'object' && !(testObject.propertyIsEnumerable('length')) && typeof testObject.length === 'number';
|
return testObject && typeof testObject === 'object' && !(testObject.propertyIsEnumerable('length')) && typeof testObject.length === 'number';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof exports !== "undefined")
|
var userAgent = (((function () {return this;})().navigator || {}).userAgent || 'node-js').toLowerCase();
|
||||||
{
|
|
||||||
userAgent = "node-js";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
userAgent = navigator.userAgent.toLowerCase();
|
|
||||||
}
|
|
||||||
// Figure out what browser is being used (stolen from jquery 1.2.1)
|
// Figure out what browser is being used (stolen from jquery 1.2.1)
|
||||||
var browser = {
|
var browser = {
|
||||||
version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1],
|
version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1],
|
||||||
|
@ -153,7 +147,17 @@ function htmlPrettyEscape(str)
|
||||||
}).replace(/\r?\n/g, '\\n');
|
}).replace(/\r?\n/g, '\\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof exports !== "undefined")
|
exports.isNodeText = isNodeText;
|
||||||
{
|
exports.object = object;
|
||||||
exports.map = map;
|
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;
|
||||||
|
|
|
@ -20,6 +20,35 @@
|
||||||
* limitations under the License.
|
* 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)
|
function OUTER(gscope)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -5868,3 +5897,5 @@ function OUTER(gscope)
|
||||||
};
|
};
|
||||||
|
|
||||||
OUTER(this);
|
OUTER(this);
|
||||||
|
|
||||||
|
exports.OUTER = OUTER; // This is probably unimportant.
|
||||||
|
|
|
@ -22,6 +22,12 @@
|
||||||
|
|
||||||
var global = this;
|
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()
|
function loadBroadcastJS()
|
||||||
{
|
{
|
||||||
// just in case... (todo: this must be somewhere else in the client code.)
|
// just in case... (todo: this must be somewhere else in the client code.)
|
||||||
|
@ -758,3 +764,5 @@ function loadBroadcastJS()
|
||||||
|
|
||||||
receiveAuthorData(clientVars.historicalAuthorData);
|
receiveAuthorData(clientVars.historicalAuthorData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.loadBroadcastJS = loadBroadcastJS;
|
||||||
|
|
|
@ -125,3 +125,5 @@ function loadBroadcastRevisionsJS()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.loadBroadcastRevisionsJS = loadBroadcastRevisionsJS;
|
||||||
|
|
|
@ -496,3 +496,5 @@ function loadBroadcastSliderJS()
|
||||||
$("#viewlatest").html(loc == BroadcastSlider.getSliderLength() ? "Viewing latest content" : "View latest content");
|
$("#viewlatest").html(loc == BroadcastSlider.getSliderLength() ? "Viewing latest content" : "View latest content");
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.loadBroadcastSliderJS = loadBroadcastSliderJS;
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var Changeset = require('/easysync2').Changeset;
|
||||||
|
var AttribPool = require('/easysync2').AttribPool;
|
||||||
|
|
||||||
function makeChangesetTracker(scheduler, apool, aceCallbacksProvider)
|
function makeChangesetTracker(scheduler, apool, aceCallbacksProvider)
|
||||||
{
|
{
|
||||||
|
@ -207,3 +209,5 @@ function makeChangesetTracker(scheduler, apool, aceCallbacksProvider)
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.makeChangesetTracker = makeChangesetTracker;
|
||||||
|
|
|
@ -20,8 +20,11 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var padutils = require('/pad_utils').padutils;
|
||||||
|
|
||||||
var chat = (function()
|
var chat = (function()
|
||||||
{
|
{
|
||||||
|
var isStuck = false;
|
||||||
var bottomMargin = "0px";
|
var bottomMargin = "0px";
|
||||||
var sDuration = 500;
|
var sDuration = 500;
|
||||||
var hDuration = 750;
|
var hDuration = 750;
|
||||||
|
@ -66,6 +69,22 @@ var chat = (function()
|
||||||
chatMentions = 0;
|
chatMentions = 0;
|
||||||
document.title = title;
|
document.title = title;
|
||||||
},
|
},
|
||||||
|
stickToScreen: function() // Make chat stick to right hand side of screen
|
||||||
|
{
|
||||||
|
console.log(isStuck);
|
||||||
|
chat.show();
|
||||||
|
if(!isStuck){ // Stick it to
|
||||||
|
$('#chatbox').css({"right":"0px", "top":"35px", "border-radius":"0px", "height":"auto"});
|
||||||
|
$('#editorcontainer').css({"right":"170px", "width":"auto"});
|
||||||
|
isStuck = true;
|
||||||
|
}
|
||||||
|
else{ // Unstick it
|
||||||
|
$('#chatbox').css({"right":"20px", "top":"auto", "border-top-left-radius":"5px", "border-top-right-radius":"5px", "height":"200px"});
|
||||||
|
$('#editorcontainer').css({"right":"0px", "width":"100%"});
|
||||||
|
isStuck = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
,
|
||||||
hide: function ()
|
hide: function ()
|
||||||
{
|
{
|
||||||
$("#chatcounter").text("0");
|
$("#chatcounter").text("0");
|
||||||
|
@ -82,13 +101,13 @@ var chat = (function()
|
||||||
send: function()
|
send: function()
|
||||||
{
|
{
|
||||||
var text = $("#chatinput").val();
|
var text = $("#chatinput").val();
|
||||||
pad.collabClient.sendMessage({"type": "CHAT_MESSAGE", "text": text});
|
this._pad.collabClient.sendMessage({"type": "CHAT_MESSAGE", "text": text});
|
||||||
$("#chatinput").val("");
|
$("#chatinput").val("");
|
||||||
},
|
},
|
||||||
addMessage: function(msg, increment)
|
addMessage: function(msg, increment)
|
||||||
{
|
{
|
||||||
//correct the time
|
//correct the time
|
||||||
msg.time += pad.clientTimeOffset;
|
msg.time += this._pad.clientTimeOffset;
|
||||||
|
|
||||||
//create the time string
|
//create the time string
|
||||||
var minutes = "" + new Date(msg.time).getMinutes();
|
var minutes = "" + new Date(msg.time).getMinutes();
|
||||||
|
@ -150,8 +169,9 @@ var chat = (function()
|
||||||
self.scrollDown();
|
self.scrollDown();
|
||||||
|
|
||||||
},
|
},
|
||||||
init: function()
|
init: function(pad)
|
||||||
{
|
{
|
||||||
|
this._pad = pad;
|
||||||
$("#chatinput").keypress(function(evt)
|
$("#chatinput").keypress(function(evt)
|
||||||
{
|
{
|
||||||
//if the user typed enter, fire the send
|
//if the user typed enter, fire the send
|
||||||
|
@ -172,3 +192,5 @@ var chat = (function()
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
exports.chat = chat;
|
||||||
|
|
|
@ -25,12 +25,22 @@ $(window).bind("load", function()
|
||||||
getCollabClient.windowLoaded = true;
|
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;
|
||||||
|
function getSocket() {
|
||||||
|
return pad && pad.socket;
|
||||||
|
}
|
||||||
|
|
||||||
/** Call this when the document is ready, and a new Ace2Editor() has been created and inited.
|
/** Call this when the document is ready, and a new Ace2Editor() has been created and inited.
|
||||||
ACE's ready callback does not need to have fired yet.
|
ACE's ready callback does not need to have fired yet.
|
||||||
"serverVars" are from calling doc.getCollabClientVars() on the server. */
|
"serverVars" are from calling doc.getCollabClientVars() on the server. */
|
||||||
function getCollabClient(ace2editor, serverVars, initialUserInfo, options)
|
function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
||||||
{
|
{
|
||||||
var editor = ace2editor;
|
var editor = ace2editor;
|
||||||
|
pad = _pad; // Inject pad to avoid a circular dependency.
|
||||||
|
|
||||||
var rev = serverVars.rev;
|
var rev = serverVars.rev;
|
||||||
var padId = serverVars.padId;
|
var padId = serverVars.padId;
|
||||||
|
@ -81,7 +91,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options)
|
||||||
|
|
||||||
$(window).bind("unload", function()
|
$(window).bind("unload", function()
|
||||||
{
|
{
|
||||||
if (socket)
|
if (getSocket())
|
||||||
{
|
{
|
||||||
setChannelState("DISCONNECTED", "unload");
|
setChannelState("DISCONNECTED", "unload");
|
||||||
}
|
}
|
||||||
|
@ -111,7 +121,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options)
|
||||||
|
|
||||||
function handleUserChanges()
|
function handleUserChanges()
|
||||||
{
|
{
|
||||||
if ((!socket) || channelState == "CONNECTING")
|
if ((!getSocket()) || channelState == "CONNECTING")
|
||||||
{
|
{
|
||||||
if (channelState == "CONNECTING" && (((+new Date()) - initialStartConnectTime) > 20000))
|
if (channelState == "CONNECTING" && (((+new Date()) - initialStartConnectTime) > 20000))
|
||||||
{
|
{
|
||||||
|
@ -295,7 +305,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options)
|
||||||
|
|
||||||
function sendMessage(msg)
|
function sendMessage(msg)
|
||||||
{
|
{
|
||||||
socket.json.send(
|
getSocket().json.send(
|
||||||
{
|
{
|
||||||
type: "COLLABROOM",
|
type: "COLLABROOM",
|
||||||
component: "pad",
|
component: "pad",
|
||||||
|
@ -337,7 +347,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options)
|
||||||
{
|
{
|
||||||
if (window.console) console.log(evt);
|
if (window.console) console.log(evt);
|
||||||
|
|
||||||
if (!socket) return;
|
if (!getSocket()) return;
|
||||||
if (!evt.data) return;
|
if (!evt.data) return;
|
||||||
var wrapper = evt;
|
var wrapper = evt;
|
||||||
if (wrapper.type != "COLLABROOM") return;
|
if (wrapper.type != "COLLABROOM") return;
|
||||||
|
@ -442,7 +452,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options)
|
||||||
userInfo.userId = userId;
|
userInfo.userId = userId;
|
||||||
userSet[userId] = userInfo;
|
userSet[userId] = userInfo;
|
||||||
tellAceActiveAuthorInfo(userInfo);
|
tellAceActiveAuthorInfo(userInfo);
|
||||||
if (!socket) return;
|
if (!getSocket()) return;
|
||||||
sendMessage(
|
sendMessage(
|
||||||
{
|
{
|
||||||
type: "USERINFO_UPDATE",
|
type: "USERINFO_UPDATE",
|
||||||
|
@ -714,3 +724,6 @@ function selectElementContents(elem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.getCollabClient = getCollabClient;
|
||||||
|
exports.selectElementContents = selectElementContents;
|
||||||
|
|
|
@ -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])];
|
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;
|
||||||
|
|
|
@ -25,6 +25,14 @@
|
||||||
|
|
||||||
var _MAX_LIST_LEVEL = 8;
|
var _MAX_LIST_LEVEL = 8;
|
||||||
|
|
||||||
|
var Changeset = require('/easysync2').Changeset
|
||||||
|
var plugins = undefined;
|
||||||
|
try {
|
||||||
|
plugins = require('/plugins').plugins;
|
||||||
|
} catch (e) {
|
||||||
|
// silence
|
||||||
|
}
|
||||||
|
|
||||||
function sanitizeUnicode(s)
|
function sanitizeUnicode(s)
|
||||||
{
|
{
|
||||||
return s.replace(/[\uffff\ufffe\ufeff\ufdd0-\ufdef\ud800-\udfff]/g, '?');
|
return s.replace(/[\uffff\ufffe\ufeff\ufdd0-\ufdef\ud800-\udfff]/g, '?');
|
||||||
|
@ -692,3 +700,6 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
|
||||||
|
|
||||||
return cc;
|
return cc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.sanitizeUnicode = sanitizeUnicode;
|
||||||
|
exports.makeContentCollector = makeContentCollector;
|
||||||
|
|
|
@ -118,3 +118,5 @@ function makeCSSManager(emptyStylesheetTitle, top)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.makeCSSManager = makeCSSManager;
|
||||||
|
|
|
@ -114,3 +114,5 @@ function makeCSSManager(emptyStylesheetTitle)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.makeCSSManager = makeCSSManager;
|
||||||
|
|
|
@ -25,6 +25,14 @@
|
||||||
// requires: top
|
// requires: top
|
||||||
// requires: plugins
|
// requires: plugins
|
||||||
// requires: undefined
|
// requires: undefined
|
||||||
|
|
||||||
|
var plugins = undefined;
|
||||||
|
try {
|
||||||
|
plugins = require('/plugins').plugins;
|
||||||
|
} catch (e) {
|
||||||
|
// silence
|
||||||
|
}
|
||||||
|
|
||||||
var domline = {};
|
var domline = {};
|
||||||
domline.noop = function()
|
domline.noop = function()
|
||||||
{};
|
{};
|
||||||
|
@ -310,3 +318,5 @@ domline.processSpaces = function(s, doesWrap)
|
||||||
}
|
}
|
||||||
return parts.join('');
|
return parts.join('');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.domline = domline;
|
||||||
|
|
|
@ -24,6 +24,14 @@
|
||||||
// requires: top
|
// requires: top
|
||||||
// requires: plugins
|
// requires: plugins
|
||||||
// requires: undefined
|
// requires: undefined
|
||||||
|
|
||||||
|
var plugins = undefined;
|
||||||
|
try {
|
||||||
|
plugins = require('/plugins').plugins;
|
||||||
|
} catch (e) {
|
||||||
|
// silence
|
||||||
|
}
|
||||||
|
|
||||||
var domline = {};
|
var domline = {};
|
||||||
domline.noop = function()
|
domline.noop = function()
|
||||||
{};
|
{};
|
||||||
|
@ -309,3 +317,5 @@ domline.processSpaces = function(s, doesWrap)
|
||||||
}
|
}
|
||||||
return parts.join('');
|
return parts.join('');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.domline = domline;
|
||||||
|
|
|
@ -193,3 +193,5 @@ function makeResizableHPane(left, sep, right, minLeft, minRight, sepWidth, sepOf
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.makeDraggable = makeDraggable;
|
||||||
|
|
|
@ -2508,3 +2508,6 @@ Changeset.followAttributes = function(att1, att2, pool)
|
||||||
}
|
}
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.Changeset = Changeset;
|
||||||
|
exports.AttribPool = AttribPool;
|
||||||
|
|
|
@ -2269,3 +2269,6 @@ Changeset.inverse = function(cs, lines, alines, pool)
|
||||||
|
|
||||||
return Changeset.checkRep(builder.toString());
|
return Changeset.checkRep(builder.toString());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.Changeset = Changeset;
|
||||||
|
exports.AttribPool = AttribPool;
|
||||||
|
|
|
@ -27,6 +27,15 @@
|
||||||
// requires: top
|
// requires: top
|
||||||
// requires: plugins
|
// requires: plugins
|
||||||
// requires: undefined
|
// requires: undefined
|
||||||
|
|
||||||
|
var Changeset = require('/easysync2').Changeset
|
||||||
|
var plugins = undefined;
|
||||||
|
try {
|
||||||
|
plugins = require('/plugins').plugins;
|
||||||
|
} catch (e) {
|
||||||
|
// silence
|
||||||
|
}
|
||||||
|
|
||||||
var linestylefilter = {};
|
var linestylefilter = {};
|
||||||
|
|
||||||
linestylefilter.ATTRIB_CLASSES = {
|
linestylefilter.ATTRIB_CLASSES = {
|
||||||
|
@ -352,3 +361,5 @@ linestylefilter.populateDomLine = function(textLine, aline, apool, domLineObj)
|
||||||
func = linestylefilter.getLineStyleFilter(text.length, aline, func, apool);
|
func = linestylefilter.getLineStyleFilter(text.length, aline, func, apool);
|
||||||
func(text, '');
|
func(text, '');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.linestylefilter = linestylefilter;
|
||||||
|
|
|
@ -25,6 +25,15 @@
|
||||||
// requires: top
|
// requires: top
|
||||||
// requires: plugins
|
// requires: plugins
|
||||||
// requires: undefined
|
// requires: undefined
|
||||||
|
|
||||||
|
var Changeset = require('/easysync2_client').Changeset
|
||||||
|
var plugins = undefined;
|
||||||
|
try {
|
||||||
|
plugins = require('/plugins').plugins;
|
||||||
|
} catch (e) {
|
||||||
|
// silence
|
||||||
|
}
|
||||||
|
|
||||||
var linestylefilter = {};
|
var linestylefilter = {};
|
||||||
|
|
||||||
linestylefilter.ATTRIB_CLASSES = {
|
linestylefilter.ATTRIB_CLASSES = {
|
||||||
|
@ -350,3 +359,5 @@ linestylefilter.populateDomLine = function(textLine, aline, apool, domLineObj)
|
||||||
func = linestylefilter.getLineStyleFilter(text.length, aline, func, apool);
|
func = linestylefilter.getLineStyleFilter(text.length, aline, func, apool);
|
||||||
func(text, '');
|
func(text, '');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.linestylefilter = linestylefilter;
|
||||||
|
|
|
@ -23,12 +23,27 @@
|
||||||
/* global $, window */
|
/* global $, window */
|
||||||
|
|
||||||
var socket;
|
var socket;
|
||||||
var LineNumbersDisabled = false;
|
|
||||||
var noColors = false;
|
var settings = {};
|
||||||
var useMonospaceFontGlobal = false;
|
settings.LineNumbersDisabled = false;
|
||||||
var globalUserName = false;
|
settings.noColors = false;
|
||||||
var hideQRCode = false;
|
settings.useMonospaceFontGlobal = false;
|
||||||
var rtlIsTrue = false;
|
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()
|
$(document).ready(function()
|
||||||
{
|
{
|
||||||
|
@ -101,7 +116,7 @@ function getParams()
|
||||||
{
|
{
|
||||||
if(IsnoColors == "true")
|
if(IsnoColors == "true")
|
||||||
{
|
{
|
||||||
noColors = true;
|
settings.noColors = true;
|
||||||
$('#clearAuthorship').hide();
|
$('#clearAuthorship').hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,20 +139,20 @@ function getParams()
|
||||||
{
|
{
|
||||||
if(showLineNumbers == "false")
|
if(showLineNumbers == "false")
|
||||||
{
|
{
|
||||||
LineNumbersDisabled = true;
|
settings.LineNumbersDisabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(useMonospaceFont)
|
if(useMonospaceFont)
|
||||||
{
|
{
|
||||||
if(useMonospaceFont == "true")
|
if(useMonospaceFont == "true")
|
||||||
{
|
{
|
||||||
useMonospaceFontGlobal = true;
|
settings.useMonospaceFontGlobal = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(userName)
|
if(userName)
|
||||||
{
|
{
|
||||||
// If the username is set as a parameter we should set a global value that we can call once we have initiated the pad.
|
// If the username is set as a parameter we should set a global value that we can call once we have initiated the pad.
|
||||||
globalUserName = unescape(userName);
|
settings.globalUserName = unescape(userName);
|
||||||
}
|
}
|
||||||
if(hideQRCode)
|
if(hideQRCode)
|
||||||
{
|
{
|
||||||
|
@ -147,7 +162,7 @@ function getParams()
|
||||||
{
|
{
|
||||||
if(rtl == "true")
|
if(rtl == "true")
|
||||||
{
|
{
|
||||||
rtlIsTrue = true
|
settings.rtlIsTrue = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,7 +198,7 @@ function handshake()
|
||||||
//find out in which subfolder we are
|
//find out in which subfolder we are
|
||||||
var resource = loc.pathname.substr(1, loc.pathname.indexOf("/p/")) + "socket.io";
|
var resource = loc.pathname.substr(1, loc.pathname.indexOf("/p/")) + "socket.io";
|
||||||
//connect
|
//connect
|
||||||
socket = io.connect(url, {
|
socket = pad.socket = io.connect(url, {
|
||||||
resource: resource,
|
resource: resource,
|
||||||
'max reconnection attempts': 3
|
'max reconnection attempts': 3
|
||||||
});
|
});
|
||||||
|
@ -270,13 +285,13 @@ function handshake()
|
||||||
{
|
{
|
||||||
$("#editorloadingbox").html("<b>You need a password to access this pad</b><br>" +
|
$("#editorloadingbox").html("<b>You need a password to access this pad</b><br>" +
|
||||||
"<input id='passwordinput' type='password' name='password'>"+
|
"<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")
|
else if(obj.accessStatus == "wrongPassword")
|
||||||
{
|
{
|
||||||
$("#editorloadingbox").html("<b>You're password was wrong</b><br>" +
|
$("#editorloadingbox").html("<b>You're password was wrong</b><br>" +
|
||||||
"<input id='passwordinput' type='password' name='password'>"+
|
"<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>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,33 +313,33 @@ function handshake()
|
||||||
initalized = true;
|
initalized = true;
|
||||||
|
|
||||||
// If the LineNumbersDisabled value is set to true then we need to hide the Line Numbers
|
// If the LineNumbersDisabled value is set to true then we need to hide the Line Numbers
|
||||||
if (LineNumbersDisabled == true)
|
if (settings.LineNumbersDisabled == true)
|
||||||
{
|
{
|
||||||
pad.changeViewOption('showLineNumbers', false);
|
pad.changeViewOption('showLineNumbers', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the noColors value is set to true then we need to hide the backround colors on the ace spans
|
// If the noColors value is set to true then we need to hide the backround colors on the ace spans
|
||||||
if (noColors == true)
|
if (settings.noColors == true)
|
||||||
{
|
{
|
||||||
pad.changeViewOption('noColors', true);
|
pad.changeViewOption('noColors', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rtlIsTrue == true)
|
if (settings.rtlIsTrue == true)
|
||||||
{
|
{
|
||||||
pad.changeViewOption('rtl', true);
|
pad.changeViewOption('rtl', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the Monospacefont value is set to true then change it to monospace.
|
// If the Monospacefont value is set to true then change it to monospace.
|
||||||
if (useMonospaceFontGlobal == true)
|
if (settings.useMonospaceFontGlobal == true)
|
||||||
{
|
{
|
||||||
pad.changeViewOption('useMonospaceFont', true);
|
pad.changeViewOption('useMonospaceFont', true);
|
||||||
}
|
}
|
||||||
// if the globalUserName value is set we need to tell the server and the client about the new authorname
|
// if the globalUserName value is set we need to tell the server and the client about the new authorname
|
||||||
if (globalUserName !== false)
|
if (settings.globalUserName !== false)
|
||||||
{
|
{
|
||||||
pad.notifyChangeName(globalUserName); // Notifies the server
|
pad.notifyChangeName(settings.globalUserName); // Notifies the server
|
||||||
pad.myUserInfo.name = globalUserName;
|
pad.myUserInfo.name = settings.globalUserName;
|
||||||
$('#myusernameedit').attr({"value":globalUserName}); // Updates the current users UI
|
$('#myusernameedit').attr({"value":settings.globalUserName}); // Updates the current users UI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//This handles every Message after the clientVars
|
//This handles every Message after the clientVars
|
||||||
|
@ -411,7 +426,7 @@ var pad = {
|
||||||
pad.clientTimeOffset = new Date().getTime() - clientVars.serverTimestamp;
|
pad.clientTimeOffset = new Date().getTime() - clientVars.serverTimestamp;
|
||||||
|
|
||||||
//initialize the chat
|
//initialize the chat
|
||||||
chat.init();
|
chat.init(this);
|
||||||
pad.initTime = +(new Date());
|
pad.initTime = +(new Date());
|
||||||
pad.padOptions = clientVars.initialOptions;
|
pad.padOptions = clientVars.initialOptions;
|
||||||
|
|
||||||
|
@ -472,7 +487,7 @@ var pad = {
|
||||||
|
|
||||||
pad.collabClient = getCollabClient(padeditor.ace, clientVars.collab_client_vars, pad.myUserInfo, {
|
pad.collabClient = getCollabClient(padeditor.ace, clientVars.collab_client_vars, pad.myUserInfo, {
|
||||||
colorPalette: pad.getColorPalette()
|
colorPalette: pad.getColorPalette()
|
||||||
});
|
}, pad);
|
||||||
pad.collabClient.setOnUserJoin(pad.handleUserJoin);
|
pad.collabClient.setOnUserJoin(pad.handleUserJoin);
|
||||||
pad.collabClient.setOnUpdateUserInfo(pad.handleUserUpdate);
|
pad.collabClient.setOnUpdateUserInfo(pad.handleUserUpdate);
|
||||||
pad.collabClient.setOnUserLeave(pad.handleUserLeave);
|
pad.collabClient.setOnUserLeave(pad.handleUserLeave);
|
||||||
|
@ -951,3 +966,14 @@ var alertBar = (function()
|
||||||
};
|
};
|
||||||
return self;
|
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;
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var padmodals = require('/pad_modals').padmodals;
|
||||||
|
|
||||||
var padconnectionstatus = (function()
|
var padconnectionstatus = (function()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -85,3 +87,5 @@ var padconnectionstatus = (function()
|
||||||
};
|
};
|
||||||
return self;
|
return self;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
exports.padconnectionstatus = padconnectionstatus;
|
||||||
|
|
|
@ -85,9 +85,12 @@ var padcookie = (function()
|
||||||
var alreadyWarnedAboutNoCookies = false;
|
var alreadyWarnedAboutNoCookies = false;
|
||||||
var inited = false;
|
var inited = false;
|
||||||
|
|
||||||
|
var pad = undefined;
|
||||||
var self = {
|
var self = {
|
||||||
init: function(prefsToSet)
|
init: function(prefsToSet)
|
||||||
{
|
{
|
||||||
|
pad = require('/pad2').pad; // Sidestep circular dependency (should be injected).
|
||||||
|
|
||||||
var rawCookie = getRawCookie();
|
var rawCookie = getRawCookie();
|
||||||
if (rawCookie)
|
if (rawCookie)
|
||||||
{
|
{
|
||||||
|
@ -126,3 +129,5 @@ var padcookie = (function()
|
||||||
};
|
};
|
||||||
return self;
|
return self;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
exports.padcookie = padcookie;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var padutils = require('/pad_utils').padutils;
|
||||||
|
|
||||||
var paddocbar = (function()
|
var paddocbar = (function()
|
||||||
{
|
{
|
||||||
|
@ -113,11 +114,14 @@ var paddocbar = (function()
|
||||||
self.renderPassword();
|
self.renderPassword();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var pad = undefined;
|
||||||
var self = {
|
var self = {
|
||||||
title: null,
|
title: null,
|
||||||
password: null,
|
password: null,
|
||||||
init: function(opts)
|
init: function(opts)
|
||||||
{
|
{
|
||||||
|
pad = require('/pad2').pad; // Sidestep circular dependency (should be injected).
|
||||||
|
|
||||||
panels = {
|
panels = {
|
||||||
impexp: {
|
impexp: {
|
||||||
animator: getPanelOpenCloseAnimator("impexp", 160)
|
animator: getPanelOpenCloseAnimator("impexp", 160)
|
||||||
|
@ -444,6 +448,8 @@ var paddocbar = (function()
|
||||||
},
|
},
|
||||||
handleResizePage: function()
|
handleResizePage: function()
|
||||||
{
|
{
|
||||||
|
// Side-step circular reference. This should be injected.
|
||||||
|
var padsavedrevs = require('/pad_savedrevs').padsavedrevs;
|
||||||
padsavedrevs.handleResizePage();
|
padsavedrevs.handleResizePage();
|
||||||
},
|
},
|
||||||
hideLaterIfNoOtherInteraction: function()
|
hideLaterIfNoOtherInteraction: function()
|
||||||
|
@ -456,3 +462,5 @@ var paddocbar = (function()
|
||||||
};
|
};
|
||||||
return self;
|
return self;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
exports.paddocbar = paddocbar;
|
||||||
|
|
|
@ -20,6 +20,10 @@
|
||||||
* limitations under the License.
|
* 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()
|
var padeditbar = (function()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -230,3 +234,5 @@ var padeditbar = (function()
|
||||||
};
|
};
|
||||||
return self;
|
return self;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
exports.padeditbar = padeditbar;
|
||||||
|
|
|
@ -20,15 +20,23 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var padcookie = require('/pad_cookie').padcookie;
|
||||||
|
var padutils = require('/pad_utils').padutils;
|
||||||
|
|
||||||
var padeditor = (function()
|
var padeditor = (function()
|
||||||
{
|
{
|
||||||
|
var Ace2Editor = undefined;
|
||||||
|
var pad = undefined;
|
||||||
|
var settings = undefined;
|
||||||
var self = {
|
var self = {
|
||||||
ace: null,
|
ace: null,
|
||||||
// this is accessed directly from other files
|
// this is accessed directly from other files
|
||||||
viewZoom: 100,
|
viewZoom: 100,
|
||||||
init: function(readyFunc, initialViewOptions)
|
init: function(readyFunc, initialViewOptions)
|
||||||
{
|
{
|
||||||
|
Ace2Editor = require('/ace').Ace2Editor;
|
||||||
|
pad = require('/pad2').pad; // Sidestep circular dependency (should be injected).
|
||||||
|
settings = require('/pad2').settings;
|
||||||
|
|
||||||
function aceReady()
|
function aceReady()
|
||||||
{
|
{
|
||||||
|
@ -68,7 +76,7 @@ var padeditor = (function()
|
||||||
pad.changeViewOption('useMonospaceFont', $("#viewfontmenu").val() == 'monospace');
|
pad.changeViewOption('useMonospaceFont', $("#viewfontmenu").val() == 'monospace');
|
||||||
});
|
});
|
||||||
|
|
||||||
noColors = !noColors; // Inversed so we can pass it to showauthorcolors
|
settings.noColors = !settings.noColors; // Inversed so we can pass it to showauthorcolors
|
||||||
},
|
},
|
||||||
setViewOptions: function(newOptions)
|
setViewOptions: function(newOptions)
|
||||||
{
|
{
|
||||||
|
@ -93,9 +101,9 @@ var padeditor = (function()
|
||||||
self.ace.setProperty("textface", (v ? "monospace" : "Arial, sans-serif"));
|
self.ace.setProperty("textface", (v ? "monospace" : "Arial, sans-serif"));
|
||||||
$("#viewfontmenu").val(v ? "monospace" : "normal");
|
$("#viewfontmenu").val(v ? "monospace" : "normal");
|
||||||
|
|
||||||
self.ace.setProperty("showsauthorcolors", noColors);
|
self.ace.setProperty("showsauthorcolors", settings.noColors);
|
||||||
|
|
||||||
self.ace.setProperty("rtlIsTrue", rtlIsTrue);
|
self.ace.setProperty("rtlIsTrue", settings.rtlIsTrue);
|
||||||
},
|
},
|
||||||
initViewZoom: function()
|
initViewZoom: function()
|
||||||
{
|
{
|
||||||
|
@ -150,3 +158,5 @@ var padeditor = (function()
|
||||||
};
|
};
|
||||||
return self;
|
return self;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
exports.padeditor = padeditor;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var paddocbar = require('/pad_docbar').paddocbar;
|
||||||
|
|
||||||
var padimpexp = (function()
|
var padimpexp = (function()
|
||||||
{
|
{
|
||||||
|
@ -233,9 +234,16 @@ var padimpexp = (function()
|
||||||
}
|
}
|
||||||
|
|
||||||
/////
|
/////
|
||||||
|
var pad = undefined;
|
||||||
var self = {
|
var self = {
|
||||||
init: function()
|
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
|
//get /p/padname
|
||||||
var pad_root_path = new RegExp(/.*\/p\/[^\/]+/).exec(document.location.pathname)
|
var pad_root_path = new RegExp(/.*\/p\/[^\/]+/).exec(document.location.pathname)
|
||||||
//get http://example.com/p/padname
|
//get http://example.com/p/padname
|
||||||
|
@ -325,3 +333,5 @@ var padimpexp = (function()
|
||||||
};
|
};
|
||||||
return self;
|
return self;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
exports.padimpexp = padimpexp;
|
||||||
|
|
|
@ -20,6 +20,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var padutils = require('/pad_utils').padutils;
|
||||||
|
var paddocbar = require('/pad_docbar').paddocbar;
|
||||||
|
|
||||||
var padmodals = (function()
|
var padmodals = (function()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -70,9 +73,12 @@ var padmodals = (function()
|
||||||
clearShareBoxTo();
|
clearShareBoxTo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var pad = undefined;
|
||||||
var self = {
|
var self = {
|
||||||
init: function()
|
init: function()
|
||||||
{
|
{
|
||||||
|
pad = require('/pad2').pad; // Sidestep circular dependency (should be injected).
|
||||||
|
|
||||||
self.initFeedback();
|
self.initFeedback();
|
||||||
self.initShareBox();
|
self.initShareBox();
|
||||||
},
|
},
|
||||||
|
@ -364,3 +370,5 @@ var padmodals = (function()
|
||||||
};
|
};
|
||||||
return self;
|
return self;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
exports.padmodals = padmodals;
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var padutils = require('/pad_utils').padutils;
|
||||||
|
var paddocbar = require('/pad_docbar').paddocbar;
|
||||||
|
|
||||||
var padsavedrevs = (function()
|
var padsavedrevs = (function()
|
||||||
{
|
{
|
||||||
|
@ -39,7 +41,7 @@ var padsavedrevs = (function()
|
||||||
box.find(".srauthor").html("by " + padutils.escapeHtml(revisionInfo.savedBy));
|
box.find(".srauthor").html("by " + padutils.escapeHtml(revisionInfo.savedBy));
|
||||||
var viewLink = '/ep/pad/view/' + pad.getPadId() + '/' + revisionInfo.id;
|
var viewLink = '/ep/pad/view/' + pad.getPadId() + '/' + revisionInfo.id;
|
||||||
box.find(".srview").attr('href', viewLink);
|
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(".srrestore").attr('href', restoreLink);
|
||||||
box.find(".srname").click(function(evt)
|
box.find(".srname").click(function(evt)
|
||||||
{
|
{
|
||||||
|
@ -345,9 +347,11 @@ var padsavedrevs = (function()
|
||||||
$(document).unbind('mouseup', clearScrollRepeatTimer);
|
$(document).unbind('mouseup', clearScrollRepeatTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var pad = undefined;
|
||||||
var self = {
|
var self = {
|
||||||
init: function(initialRevisions)
|
init: function(initialRevisions)
|
||||||
{
|
{
|
||||||
|
pad = require('/pad2').pad; // Sidestep circular dependency (should be injected).
|
||||||
self.newRevisionList(initialRevisions, true);
|
self.newRevisionList(initialRevisions, true);
|
||||||
|
|
||||||
$("#savedrevs-savenow").click(function()
|
$("#savedrevs-savenow").click(function()
|
||||||
|
@ -518,3 +522,5 @@ var padsavedrevs = (function()
|
||||||
};
|
};
|
||||||
return self;
|
return self;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
exports.padsavedrevs = padsavedrevs;
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var padutils = require('/pad_utils').padutils;
|
||||||
|
|
||||||
var myUserInfo = {};
|
var myUserInfo = {};
|
||||||
|
|
||||||
var colorPickerOpen = false;
|
var colorPickerOpen = false;
|
||||||
|
@ -460,9 +462,12 @@ var paduserlist = (function()
|
||||||
return true;
|
return true;
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
var pad = undefined;
|
||||||
var self = {
|
var self = {
|
||||||
init: function(myInitialUserInfo)
|
init: function(myInitialUserInfo)
|
||||||
{
|
{
|
||||||
|
pad = require('/pad2').pad; // Sidestep circular dependency (should be injected).
|
||||||
|
|
||||||
self.setMyUserInfo(myInitialUserInfo);
|
self.setMyUserInfo(myInitialUserInfo);
|
||||||
|
|
||||||
$("#otheruserstable tr").remove();
|
$("#otheruserstable tr").remove();
|
||||||
|
@ -652,7 +657,7 @@ var paduserlist = (function()
|
||||||
if (box.length == 0)
|
if (box.length == 0)
|
||||||
{
|
{
|
||||||
// make guest prompt box
|
// 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);
|
$("#guestprompts").append(box);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -805,3 +810,5 @@ function showColorPicker()
|
||||||
$($("#colorpickerswatches li")[myUserInfo.colorId]).addClass("picked"); //seems weird
|
$($("#colorpickerswatches li")[myUserInfo.colorId]).addClass("picked"); //seems weird
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.paduserlist = paduserlist;
|
||||||
|
|
|
@ -34,6 +34,7 @@ var padutils = {
|
||||||
},
|
},
|
||||||
uniqueId: function()
|
uniqueId: function()
|
||||||
{
|
{
|
||||||
|
var pad = require('/pad2').pad; // Sidestep circular dependency
|
||||||
function encodeNum(n, width)
|
function encodeNum(n, width)
|
||||||
{
|
{
|
||||||
// returns string that is exactly 'width' chars, padding with zeros
|
// returns string that is exactly 'width' chars, padding with zeros
|
||||||
|
@ -226,6 +227,7 @@ var padutils = {
|
||||||
},
|
},
|
||||||
timediff: function(d)
|
timediff: function(d)
|
||||||
{
|
{
|
||||||
|
var pad = require('/pad2').pad; // Sidestep circular dependency
|
||||||
function format(n, word)
|
function format(n, word)
|
||||||
{
|
{
|
||||||
n = Math.round(n);
|
n = Math.round(n);
|
||||||
|
@ -486,3 +488,5 @@ window.onerror = function test (msg, url, linenumber)
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.padutils = padutils;
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
plugins = {
|
plugins = {
|
||||||
callHook: function(hookName, args)
|
callHook: function(hookName, args)
|
||||||
{
|
{
|
||||||
var hook = clientVars.hooks[hookName];
|
var global = (function () {return this}());
|
||||||
|
var hook = ((global.clientVars || {}).hooks || {})[hookName];
|
||||||
if (hook === undefined) return [];
|
if (hook === undefined) return [];
|
||||||
var res = [];
|
var res = [];
|
||||||
for (var i = 0, N = hook.length; i < N; i++)
|
for (var i = 0, N = hook.length; i < N; i++)
|
||||||
|
@ -30,3 +31,5 @@ plugins = {
|
||||||
}).join(sep || "");
|
}).join(sep || "");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.plugins = plugins;
|
||||||
|
|
|
@ -488,3 +488,5 @@ that is a string.
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.newSkipList = newSkipList;
|
||||||
|
|
|
@ -20,8 +20,10 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var Changeset = require('/easysync2').Changeset;
|
||||||
|
var extend = require('/ace2_common').extend;
|
||||||
|
|
||||||
undoModule = (function()
|
var undoModule = (function()
|
||||||
{
|
{
|
||||||
var stack = (function()
|
var stack = (function()
|
||||||
{
|
{
|
||||||
|
@ -329,3 +331,5 @@ undoModule = (function()
|
||||||
apool: null
|
apool: null
|
||||||
}; // apool is filled in by caller
|
}; // apool is filled in by caller
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
exports.undoModule = undoModule;
|
||||||
|
|
|
@ -384,3 +384,5 @@ function makeVirtualLineView(lineNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.makeVirtualLineView = makeVirtualLineView;
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
var clientVars = {};
|
var clientVars = {};
|
||||||
// ]]>
|
// ]]>
|
||||||
</script>
|
</script>
|
||||||
|
<script src="../static/js/require-kernel.js"></script>
|
||||||
<script src="../socket.io/socket.io.js"></script>
|
<script src="../socket.io/socket.io.js"></script>
|
||||||
<script src="../minified/pad.js"></script>
|
<script src="../minified/pad.js"></script>
|
||||||
<link href="../static/custom/pad.css" rel="stylesheet">
|
<link href="../static/custom/pad.css" rel="stylesheet">
|
||||||
|
@ -337,5 +338,13 @@
|
||||||
<input type="hidden" class="missedChanges" name="missedChanges"/>
|
<input type="hidden" class="missedChanges" name="missedChanges"/>
|
||||||
</form>
|
</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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
<link rel="stylesheet" href="../../static/css/timeslider.css">
|
<link rel="stylesheet" href="../../static/css/timeslider.css">
|
||||||
<style type="text/css" title="dynamicsyntax"></style>
|
<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="../../socket.io/socket.io.js"></script>
|
||||||
<script type="text/javascript" src="../../minified/timeslider.js"></script>
|
<script type="text/javascript" src="../../minified/timeslider.js"></script>
|
||||||
|
|
||||||
|
@ -19,6 +20,10 @@
|
||||||
// <![CDATA[
|
// <![CDATA[
|
||||||
var clientVars = {};
|
var clientVars = {};
|
||||||
|
|
||||||
|
/* TODO: These globals shouldn't exist. */
|
||||||
|
padeditbar = require('/pad_editbar').padeditbar;
|
||||||
|
padimpexp = require('/pad_impexp').padimpexp;
|
||||||
|
|
||||||
function createCookie(name,value,days)
|
function createCookie(name,value,days)
|
||||||
{
|
{
|
||||||
if (days) {
|
if (days) {
|
||||||
|
@ -141,9 +146,9 @@
|
||||||
clientVars = message.data;
|
clientVars = message.data;
|
||||||
|
|
||||||
//load all script that doesn't work without the clientVars
|
//load all script that doesn't work without the clientVars
|
||||||
loadBroadcastSliderJS();
|
require('/broadcast_slider').loadBroadcastSliderJS();
|
||||||
loadBroadcastRevisionsJS();
|
require('/broadcast_revisions').loadBroadcastRevisionsJS();
|
||||||
loadBroadcastJS();
|
require('/broadcast').loadBroadcastJS();
|
||||||
|
|
||||||
//initialize export ui
|
//initialize export ui
|
||||||
padimpexp.init();
|
padimpexp.init();
|
||||||
|
|
Loading…
Reference in New Issue