commit
351b516359
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -79,6 +79,11 @@ 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");
|
||||||
|
@ -112,28 +117,13 @@ async.waterfall([
|
||||||
//serve static files
|
//serve static files
|
||||||
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 +168,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 +252,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 +261,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 +287,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 +306,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 +318,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 +378,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 +385,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 +392,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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,6 +32,10 @@ var gzip = require('gzip');
|
||||||
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,19 +44,19 @@ 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];
|
||||||
} else {
|
} else {
|
||||||
throw new Error("there is no profile for creating " + name);
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
var rootPath = path.normalize(__dirname + "/../../" );
|
res.header("Content-Type","text/javascript");
|
||||||
|
|
||||||
//minifying is enabled
|
//minifying is enabled
|
||||||
if(settings.minify)
|
if(settings.minify)
|
||||||
|
@ -65,7 +69,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 +108,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 +133,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;
|
||||||
|
@ -158,7 +162,7 @@ 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)
|
fs.readFile(ROOT_DIR + filename, "utf-8", function(err, data)
|
||||||
{
|
{
|
||||||
if(ERR(err, callback)) return;
|
if(ERR(err, callback)) return;
|
||||||
|
|
||||||
|
@ -207,7 +211,7 @@ exports.minifyJS = function(req, res, jsFilename)
|
||||||
//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)
|
||||||
|
@ -221,7 +225,7 @@ exports.minifyJS = function(req, res, jsFilename)
|
||||||
|
|
||||||
if(ERR(err, callback)) return;
|
if(ERR(err, callback)) return;
|
||||||
|
|
||||||
fs.writeFile(rootPath + "var/minified_" + jsFilename + ".gz", compressedResult, callback);
|
fs.writeFile(CACHE_DIR + "minified_" + jsFilename + ".gz", compressedResult, callback);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//skip this step on windows
|
//skip this step on windows
|
||||||
|
@ -245,12 +249,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 +268,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;
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -30,7 +30,6 @@ Ace2Editor.registry = {
|
||||||
|
|
||||||
function Ace2Editor()
|
function Ace2Editor()
|
||||||
{
|
{
|
||||||
var thisFunctionsName = "Ace2Editor";
|
|
||||||
var ace2 = Ace2Editor;
|
var ace2 = Ace2Editor;
|
||||||
|
|
||||||
var editor = {};
|
var editor = {};
|
||||||
|
@ -323,6 +322,10 @@ function Ace2Editor()
|
||||||
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); }';
|
||||||
|
|
||||||
|
|
|
@ -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],
|
||||||
|
|
|
@ -25,12 +25,20 @@ $(window).bind("load", function()
|
||||||
getCollabClient.windowLoaded = true;
|
getCollabClient.windowLoaded = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 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 +89,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 +119,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 +303,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 +345,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 +450,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",
|
||||||
|
|
|
@ -23,12 +23,14 @@
|
||||||
/* 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;
|
||||||
|
|
||||||
$(document).ready(function()
|
$(document).ready(function()
|
||||||
{
|
{
|
||||||
|
@ -101,7 +103,7 @@ function getParams()
|
||||||
{
|
{
|
||||||
if(IsnoColors == "true")
|
if(IsnoColors == "true")
|
||||||
{
|
{
|
||||||
noColors = true;
|
settings.noColors = true;
|
||||||
$('#clearAuthorship').hide();
|
$('#clearAuthorship').hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,20 +126,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 +149,7 @@ function getParams()
|
||||||
{
|
{
|
||||||
if(rtl == "true")
|
if(rtl == "true")
|
||||||
{
|
{
|
||||||
rtlIsTrue = true
|
settings.rtlIsTrue = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,7 +185,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
|
||||||
});
|
});
|
||||||
|
@ -298,33 +300,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
|
||||||
|
@ -472,7 +474,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);
|
||||||
|
|
|
@ -68,7 +68,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 +93,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()
|
||||||
{
|
{
|
||||||
|
|
|
@ -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++)
|
||||||
|
|
Loading…
Reference in New Issue