mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-28 11:26:16 -04:00
The Big Rewrite to AMD format - had to do lots of them at once
This commit is contained in:
parent
2472cd365e
commit
250b8928bd
20 changed files with 4582 additions and 4448 deletions
|
@ -22,7 +22,7 @@
|
||||||
var ERR = require("async-stacktrace");
|
var ERR = require("async-stacktrace");
|
||||||
var db = require("./DB").db;
|
var db = require("./DB").db;
|
||||||
var customError = require("../utils/customError");
|
var customError = require("../utils/customError");
|
||||||
var randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString;
|
var randomString = require('ep_etherpad-lite/static/js/random_utils').randomString;
|
||||||
|
|
||||||
exports.getColorPalette = function(){
|
exports.getColorPalette = function(){
|
||||||
return ["#ffc7c7", "#fff1c7", "#e3ffc7", "#c7ffd5", "#c7ffff", "#c7d5ff", "#e3c7ff", "#ffc7f1", "#ff8f8f", "#ffe38f", "#c7ff8f", "#8fffab", "#8fffff", "#8fabff", "#c78fff", "#ff8fe3", "#d97979", "#d9c179", "#a9d979", "#79d991", "#79d9d9", "#7991d9", "#a979d9", "#d979c1", "#d9a9a9", "#d9cda9", "#c1d9a9", "#a9d9b5", "#a9d9d9", "#a9b5d9", "#c1a9d9", "#d9a9cd", "#4c9c82", "#12d1ad", "#2d8e80", "#7485c3", "#a091c7", "#3185ab", "#6818b4", "#e6e76d", "#a42c64", "#f386e5", "#4ecc0c", "#c0c236", "#693224", "#b5de6a", "#9b88fd", "#358f9b", "#496d2f", "#e267fe", "#d23056", "#1a1a64", "#5aa335", "#d722bb", "#86dc6c", "#b5a714", "#955b6a", "#9f2985", "#4b81c8", "#3d6a5b", "#434e16", "#d16084", "#af6a0e", "#8c8bd8"];
|
return ["#ffc7c7", "#fff1c7", "#e3ffc7", "#c7ffd5", "#c7ffff", "#c7d5ff", "#e3c7ff", "#ffc7f1", "#ff8f8f", "#ffe38f", "#c7ff8f", "#8fffab", "#8fffff", "#8fabff", "#c78fff", "#ff8fe3", "#d97979", "#d9c179", "#a9d979", "#79d991", "#79d9d9", "#7991d9", "#a979d9", "#d979c1", "#d9a9a9", "#d9cda9", "#c1d9a9", "#a9d9b5", "#a9d9d9", "#a9b5d9", "#c1a9d9", "#d9a9cd", "#4c9c82", "#12d1ad", "#2d8e80", "#7485c3", "#a091c7", "#3185ab", "#6818b4", "#e6e76d", "#a42c64", "#f386e5", "#4ecc0c", "#c0c236", "#693224", "#b5de6a", "#9b88fd", "#358f9b", "#496d2f", "#e267fe", "#d23056", "#1a1a64", "#5aa335", "#d722bb", "#86dc6c", "#b5a714", "#955b6a", "#9f2985", "#4b81c8", "#3d6a5b", "#434e16", "#d16084", "#af6a0e", "#8c8bd8"];
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
var ERR = require("async-stacktrace");
|
var ERR = require("async-stacktrace");
|
||||||
var customError = require("../utils/customError");
|
var customError = require("../utils/customError");
|
||||||
var randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString;
|
var randomString = require('ep_etherpad-lite/static/js/random_utils').randomString;
|
||||||
var db = require("./DB").db;
|
var db = require("./DB").db;
|
||||||
var async = require("async");
|
var async = require("async");
|
||||||
var padManager = require("./PadManager");
|
var padManager = require("./PadManager");
|
||||||
|
|
|
@ -22,11 +22,17 @@
|
||||||
|
|
||||||
// These parameters were global, now they are injected. A reference to the
|
// These parameters were global, now they are injected. A reference to the
|
||||||
// Timeslider controller would probably be more appropriate.
|
// Timeslider controller would probably be more appropriate.
|
||||||
var _ = require('./underscore');
|
|
||||||
var padmodals = require('./pad_modals').padmodals;
|
|
||||||
|
|
||||||
function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded)
|
define([
|
||||||
{
|
'ep_etherpad-lite/static/js/pad_modals',
|
||||||
|
'underscore'
|
||||||
|
], function(padModalsModule, _) {
|
||||||
|
var exports = {};
|
||||||
|
|
||||||
|
var padmodals = padModalsModule.padmodals;
|
||||||
|
|
||||||
|
function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded)
|
||||||
|
{
|
||||||
var BroadcastSlider;
|
var BroadcastSlider;
|
||||||
|
|
||||||
// Hack to ensure timeslider i18n values are in
|
// Hack to ensure timeslider i18n values are in
|
||||||
|
@ -497,6 +503,9 @@ function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded)
|
||||||
})
|
})
|
||||||
|
|
||||||
return BroadcastSlider;
|
return BroadcastSlider;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.loadBroadcastSliderJS = loadBroadcastSliderJS;
|
exports.loadBroadcastSliderJS = loadBroadcastSliderJS;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -14,14 +14,22 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var padutils = require('./pad_utils').padutils;
|
define([
|
||||||
var padcookie = require('./pad_cookie').padcookie;
|
'ep_etherpad-lite/static/js/pad_utils',
|
||||||
var Tinycon = require('tinycon/tinycon');
|
'ep_etherpad-lite/static/js/pad_cookie',
|
||||||
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
'ep_etherpad-lite/static/js/pad_editor',
|
||||||
var padeditor = require('./pad_editor').padeditor;
|
'ep_etherpad-lite/static/js/pluginfw/hooks',
|
||||||
|
], function (padUtilsModule, padCookieModule, padEditorModule, hooks) {
|
||||||
|
var exports = {};
|
||||||
|
|
||||||
var chat = (function()
|
var padutils = padUtilsModule.padutils;
|
||||||
{
|
var padcookie = padCookieModule.padcookie;
|
||||||
|
var padeditor = padEditorModule.padeditor;
|
||||||
|
|
||||||
|
var Tinycon = window.requireKernel('tinycon/tinycon');
|
||||||
|
|
||||||
|
var chat = (function()
|
||||||
|
{
|
||||||
var isStuck = false;
|
var isStuck = false;
|
||||||
var userAndChat = false;
|
var userAndChat = false;
|
||||||
var gotInitialMessages = false;
|
var gotInitialMessages = false;
|
||||||
|
@ -265,7 +273,9 @@ var chat = (function()
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
exports.chat = chat;
|
exports.chat = chat;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -20,21 +20,26 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var chat = require('./chat').chat;
|
define([
|
||||||
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
'ep_etherpad-lite/static/js/pluginfw/hooks',
|
||||||
|
'ep_etherpad-lite/static/js/chat'
|
||||||
|
], function(hooks, chatModule) {
|
||||||
|
var exports = {};
|
||||||
|
|
||||||
// Dependency fill on init. This exists for `pad.socket` only.
|
var chat = chatModule.chat;
|
||||||
// TODO: bind directly to the socket.
|
|
||||||
var pad = undefined;
|
// Dependency fill on init. This exists for `pad.socket` only.
|
||||||
function getSocket() {
|
// TODO: bind directly to the socket.
|
||||||
|
var pad = undefined;
|
||||||
|
function getSocket() {
|
||||||
return pad && pad.socket;
|
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, _pad)
|
function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
||||||
{
|
{
|
||||||
var editor = ace2editor;
|
var editor = ace2editor;
|
||||||
pad = _pad; // Inject pad to avoid a circular dependency.
|
pad = _pad; // Inject pad to avoid a circular dependency.
|
||||||
|
|
||||||
|
@ -655,6 +660,9 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
||||||
|
|
||||||
$(document).ready(setUpSocket);
|
$(document).ready(setUpSocket);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getCollabClient = getCollabClient;
|
exports.getCollabClient = getCollabClient;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -22,35 +22,53 @@
|
||||||
|
|
||||||
/* global $, window */
|
/* global $, window */
|
||||||
|
|
||||||
var socket;
|
define([
|
||||||
|
'ep_etherpad-lite/static/js/rjquery',
|
||||||
|
'ep_etherpad-lite/static/js/pluginfw/hooks',
|
||||||
|
'ep_etherpad-lite/static/js/pad_utils',
|
||||||
|
'ep_etherpad-lite/static/js/chat',
|
||||||
|
'ep_etherpad-lite/static/js/pad_cookie',
|
||||||
|
'ep_etherpad-lite/static/js/pad_editbar',
|
||||||
|
'ep_etherpad-lite/static/js/pad_editor',
|
||||||
|
'ep_etherpad-lite/static/js/pad_savedrevs',
|
||||||
|
'ep_etherpad-lite/static/js/pad_userlist',
|
||||||
|
'ep_etherpad-lite/static/js/pad_modals',
|
||||||
|
'ep_etherpad-lite/static/js/collab_client',
|
||||||
|
'ep_etherpad-lite/static/js/pad_connectionstatus'
|
||||||
|
], function($, hooks, padUtilsMod, chatMod, padCookieMod, padEditbarMod, padEditorMod, padsavedrevs, padUserListMod, padModalsMod, collabClientMod, padConnectionStatusMod) {
|
||||||
|
var exports = {};
|
||||||
|
|
||||||
// These jQuery things should create local references, but for now `require()`
|
var socket;
|
||||||
// assigns to the global `$` and augments it with plugins.
|
|
||||||
require('./jquery');
|
|
||||||
require('./farbtastic');
|
|
||||||
require('./excanvas');
|
|
||||||
JSON = require('./json2');
|
|
||||||
|
|
||||||
var chat = require('./chat').chat;
|
window.requireKernel('./farbtastic');
|
||||||
var getCollabClient = require('./collab_client').getCollabClient;
|
window.requireKernel('./excanvas');
|
||||||
var padconnectionstatus = require('./pad_connectionstatus').padconnectionstatus;
|
JSON = window.requireKernel('./json2');
|
||||||
var padcookie = require('./pad_cookie').padcookie;
|
|
||||||
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');
|
|
||||||
var paduserlist = require('./pad_userlist').paduserlist;
|
|
||||||
var padutils = require('./pad_utils').padutils;
|
|
||||||
var colorutils = require('./colorutils').colorutils;
|
|
||||||
var createCookie = require('./pad_utils').createCookie;
|
|
||||||
var readCookie = require('./pad_utils').readCookie;
|
|
||||||
var randomString = require('./pad_utils').randomString;
|
|
||||||
var gritter = require('./gritter').gritter;
|
|
||||||
|
|
||||||
var receivedClientVars = false;
|
var chat = chatMod.chat;
|
||||||
|
var getCollabClient = collabClientMod.getCollabClient;
|
||||||
|
var padconnectionstatus = padConnectionStatusMod.padconnectionstatus;
|
||||||
|
var padcookie = padCookieMod.padcookie;
|
||||||
|
var padeditbar = padEditbarMod.padeditbar;
|
||||||
|
var padeditor = padEditorMod.padeditor;
|
||||||
|
var padimpexp = window.requireKernel('./pad_impexp').padimpexp;
|
||||||
|
var padmodals = padModalsMod.padmodals;
|
||||||
|
var paduserlist = padUserListMod.paduserlist;
|
||||||
|
var padutils = padUtilsMod.padutils;
|
||||||
|
var colorutils = window.requireKernel('./colorutils').colorutils;
|
||||||
|
var createCookie = padUtilsMod.createCookie;
|
||||||
|
var readCookie = padUtilsMod.readCookie;
|
||||||
|
var randomString = padUtilsMod.randomString;
|
||||||
|
var gritter = window.requireKernel('./gritter').gritter;
|
||||||
|
|
||||||
function createCookie(name, value, days, path){ /* Warning Internet Explorer doesn't use this it uses the one from pad_utils.js */
|
var receivedClientVars = false;
|
||||||
|
|
||||||
|
$.extend($.gritter.options, {
|
||||||
|
position: 'bottom-right', // defaults to 'top-right' but can be 'bottom-left', 'bottom-right', 'top-left', 'top-right' (added in 1.7.1)
|
||||||
|
fade: false, // dont fade, too jerky on mobile
|
||||||
|
time: 6000 // hang on the screen for...
|
||||||
|
});
|
||||||
|
|
||||||
|
function createCookie(name, value, days, path){ /* Warning Internet Explorer doesn't use this it uses the one from pad_utils.js */
|
||||||
if (days)
|
if (days)
|
||||||
{
|
{
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
|
@ -72,10 +90,10 @@ function createCookie(name, value, days, path){ /* Warning Internet Explorer doe
|
||||||
else{
|
else{
|
||||||
document.cookie = name + "=" + value + expires + "; path=" + path;
|
document.cookie = name + "=" + value + expires + "; path=" + path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function readCookie(name)
|
function readCookie(name)
|
||||||
{
|
{
|
||||||
var nameEQ = name + "=";
|
var nameEQ = name + "=";
|
||||||
var ca = document.cookie.split(';');
|
var ca = document.cookie.split(';');
|
||||||
for (var i = 0; i < ca.length; i++)
|
for (var i = 0; i < ca.length; i++)
|
||||||
|
@ -85,28 +103,15 @@ function readCookie(name)
|
||||||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
|
|
||||||
function randomString()
|
|
||||||
{
|
|
||||||
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
||||||
var string_length = 20;
|
|
||||||
var randomstring = '';
|
|
||||||
for (var i = 0; i < string_length; i++)
|
|
||||||
{
|
|
||||||
var rnum = Math.floor(Math.random() * chars.length);
|
|
||||||
randomstring += chars.substring(rnum, rnum + 1);
|
|
||||||
}
|
}
|
||||||
return "t." + randomstring;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This array represents all GET-parameters which can be used to change a setting.
|
// This array represents all GET-parameters which can be used to change a setting.
|
||||||
// name: the parameter-name, eg `?noColors=true` => `noColors`
|
// name: the parameter-name, eg `?noColors=true` => `noColors`
|
||||||
// checkVal: the callback is only executed when
|
// checkVal: the callback is only executed when
|
||||||
// * the parameter was supplied and matches checkVal
|
// * the parameter was supplied and matches checkVal
|
||||||
// * the parameter was supplied and checkVal is null
|
// * the parameter was supplied and checkVal is null
|
||||||
// callback: the function to call when all above succeeds, `val` is the value supplied by the user
|
// callback: the function to call when all above succeeds, `val` is the value supplied by the user
|
||||||
var getParameters = [
|
var getParameters = [
|
||||||
{ name: "noColors", checkVal: "true", callback: function(val) { settings.noColors = true; $('#clearAuthorship').hide(); } },
|
{ name: "noColors", checkVal: "true", callback: function(val) { settings.noColors = true; $('#clearAuthorship').hide(); } },
|
||||||
{ name: "showControls", checkVal: "false", callback: function(val) { $('#editbar').addClass('hideControlsEditbar'); $('#editorcontainer').addClass('hideControlsEditor'); } },
|
{ name: "showControls", checkVal: "false", callback: function(val) { $('#editbar').addClass('hideControlsEditbar'); $('#editorcontainer').addClass('hideControlsEditor'); } },
|
||||||
{ name: "showChat", checkVal: "false", callback: function(val) { $('#chaticon').hide(); } },
|
{ name: "showChat", checkVal: "false", callback: function(val) { $('#chaticon').hide(); } },
|
||||||
|
@ -120,10 +125,10 @@ var getParameters = [
|
||||||
{ name: "alwaysShowChat", checkVal: "true", callback: function(val) { chat.stickToScreen(); } },
|
{ name: "alwaysShowChat", checkVal: "true", callback: function(val) { chat.stickToScreen(); } },
|
||||||
{ name: "chatAndUsers", checkVal: "true", callback: function(val) { chat.chatAndUsers(); } },
|
{ name: "chatAndUsers", checkVal: "true", callback: function(val) { chat.chatAndUsers(); } },
|
||||||
{ name: "lang", checkVal: null, callback: function(val) { window.html10n.localize([val, 'en']); } }
|
{ name: "lang", checkVal: null, callback: function(val) { window.html10n.localize([val, 'en']); } }
|
||||||
];
|
];
|
||||||
|
|
||||||
function getParams()
|
function getParams()
|
||||||
{
|
{
|
||||||
var params = getUrlVars()
|
var params = getUrlVars()
|
||||||
|
|
||||||
for(var i = 0; i < getParameters.length; i++)
|
for(var i = 0; i < getParameters.length; i++)
|
||||||
|
@ -136,10 +141,10 @@ function getParams()
|
||||||
setting.callback(value);
|
setting.callback(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUrlVars()
|
function getUrlVars()
|
||||||
{
|
{
|
||||||
var vars = [], hash;
|
var vars = [], hash;
|
||||||
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
||||||
for(var i = 0; i < hashes.length; i++)
|
for(var i = 0; i < hashes.length; i++)
|
||||||
|
@ -149,19 +154,19 @@ function getUrlVars()
|
||||||
vars[hash[0]] = hash[1];
|
vars[hash[0]] = hash[1];
|
||||||
}
|
}
|
||||||
return vars;
|
return vars;
|
||||||
}
|
}
|
||||||
|
|
||||||
function savePassword()
|
function savePassword()
|
||||||
{
|
{
|
||||||
//set the password cookie
|
//set the password cookie
|
||||||
createCookie("password",$("#passwordinput").val(),null,document.location.pathname);
|
createCookie("password",$("#passwordinput").val(),null,document.location.pathname);
|
||||||
//reload
|
//reload
|
||||||
document.location=document.location;
|
document.location=document.location;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendClientReady(isReconnect, messageType)
|
function sendClientReady(isReconnect, messageType)
|
||||||
{
|
{
|
||||||
messageType = typeof messageType !== 'undefined' ? messageType : 'CLIENT_READY';
|
messageType = typeof messageType !== 'undefined' ? messageType : 'CLIENT_READY';
|
||||||
var padId = document.location.pathname.substring(document.location.pathname.lastIndexOf("/") + 1);
|
var padId = document.location.pathname.substring(document.location.pathname.lastIndexOf("/") + 1);
|
||||||
padId = decodeURIComponent(padId); // unescape neccesary due to Safari and Opera interpretation of spaces
|
padId = decodeURIComponent(padId); // unescape neccesary due to Safari and Opera interpretation of spaces
|
||||||
|
@ -201,10 +206,10 @@ function sendClientReady(isReconnect, messageType)
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.json.send(msg);
|
socket.json.send(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handshake()
|
function handshake()
|
||||||
{
|
{
|
||||||
var loc = document.location;
|
var loc = document.location;
|
||||||
//get the correct port
|
//get the correct port
|
||||||
var port = loc.port == "" ? (loc.protocol == "https:" ? 443 : 80) : loc.port;
|
var port = loc.port == "" ? (loc.protocol == "https:" ? 443 : 80) : loc.port;
|
||||||
|
@ -261,7 +266,7 @@ function handshake()
|
||||||
if(obj.accessStatus)
|
if(obj.accessStatus)
|
||||||
{
|
{
|
||||||
if(!receivedClientVars){
|
if(!receivedClientVars){
|
||||||
$('.passForm').submit(require(module.id).savePassword);
|
$('.passForm').submit(window.requireKernel(module.id).savePassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(obj.accessStatus == "deny")
|
if(obj.accessStatus == "deny")
|
||||||
|
@ -376,15 +381,9 @@ function handshake()
|
||||||
$('#readonlyinput').on('click',function(){
|
$('#readonlyinput').on('click',function(){
|
||||||
padeditbar.setEmbedLinks();
|
padeditbar.setEmbedLinks();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$.extend($.gritter.options, {
|
var pad = {
|
||||||
position: 'bottom-right', // defaults to 'top-right' but can be 'bottom-left', 'bottom-right', 'top-left', 'top-right' (added in 1.7.1)
|
|
||||||
fade: false, // dont fade, too jerky on mobile
|
|
||||||
time: 6000 // hang on the screen for...
|
|
||||||
});
|
|
||||||
|
|
||||||
var pad = {
|
|
||||||
// don't access these directly from outside this file, except
|
// don't access these directly from outside this file, except
|
||||||
// for debugging
|
// for debugging
|
||||||
collabClient: null,
|
collabClient: null,
|
||||||
|
@ -897,10 +896,10 @@ var pad = {
|
||||||
pad.collabClient.addHistoricalAuthors(data);
|
pad.collabClient.addHistoricalAuthors(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var alertBar = (function()
|
var alertBar = (function()
|
||||||
{
|
{
|
||||||
|
|
||||||
var animator = padutils.makeShowHideAnimator(arriveAtAnimationState, false, 25, 400);
|
var animator = padutils.makeShowHideAnimator(arriveAtAnimationState, false, 25, 400);
|
||||||
|
|
||||||
|
@ -940,36 +939,34 @@ var alertBar = (function()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return self;
|
return self;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
var hooks = undefined;
|
function init() {
|
||||||
|
|
||||||
function init() {
|
|
||||||
requirejs(['ep_etherpad-lite/static/js/pluginfw/hooks'], function (h) {
|
|
||||||
hooks = h;
|
|
||||||
return pad.init();
|
return pad.init();
|
||||||
});
|
}
|
||||||
}
|
|
||||||
|
|
||||||
var settings = {
|
var settings = {
|
||||||
LineNumbersDisabled: false
|
LineNumbersDisabled: false
|
||||||
, noColors: false
|
, noColors: false
|
||||||
, useMonospaceFontGlobal: false
|
, useMonospaceFontGlobal: false
|
||||||
, globalUserName: false
|
, globalUserName: false
|
||||||
, globalUserColor: false
|
, globalUserColor: false
|
||||||
, rtlIsTrue: false
|
, rtlIsTrue: false
|
||||||
};
|
};
|
||||||
|
|
||||||
pad.settings = settings;
|
pad.settings = settings;
|
||||||
exports.baseURL = '';
|
exports.baseURL = '';
|
||||||
exports.settings = settings;
|
exports.settings = settings;
|
||||||
exports.createCookie = createCookie;
|
exports.createCookie = createCookie;
|
||||||
exports.readCookie = readCookie;
|
exports.readCookie = readCookie;
|
||||||
exports.randomString = randomString;
|
exports.randomString = randomString;
|
||||||
exports.getParams = getParams;
|
exports.getParams = getParams;
|
||||||
exports.getUrlVars = getUrlVars;
|
exports.getUrlVars = getUrlVars;
|
||||||
exports.savePassword = savePassword;
|
exports.savePassword = savePassword;
|
||||||
exports.handshake = handshake;
|
exports.handshake = handshake;
|
||||||
exports.pad = pad;
|
exports.pad = pad;
|
||||||
exports.init = init;
|
exports.init = init;
|
||||||
exports.alertBar = alertBar;
|
exports.alertBar = alertBar;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -20,10 +20,15 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var padmodals = require('./pad_modals').padmodals;
|
define([
|
||||||
|
'ep_etherpad-lite/static/js/pad_modals'
|
||||||
|
], function(padModalsModule) {
|
||||||
|
var exports = {};
|
||||||
|
|
||||||
var padconnectionstatus = (function()
|
var padmodals = padModalsModule.padmodals;
|
||||||
{
|
|
||||||
|
var padconnectionstatus = (function()
|
||||||
|
{
|
||||||
|
|
||||||
var status = {
|
var status = {
|
||||||
what: 'connecting'
|
what: 'connecting'
|
||||||
|
@ -83,6 +88,9 @@ var padconnectionstatus = (function()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return self;
|
return self;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
exports.padconnectionstatus = padconnectionstatus;
|
exports.padconnectionstatus = padconnectionstatus;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -21,8 +21,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
var padcookie = (function()
|
define([], function () {
|
||||||
{
|
var exports = {};
|
||||||
|
var padcookie = (function()
|
||||||
|
{
|
||||||
function getRawCookie()
|
function getRawCookie()
|
||||||
{
|
{
|
||||||
// returns null if can't get cookie text
|
// returns null if can't get cookie text
|
||||||
|
@ -128,6 +130,9 @@ var padcookie = (function()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return self;
|
return self;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
exports.padcookie = padcookie;
|
exports.padcookie = padcookie;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -20,45 +20,51 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
define([
|
||||||
var padutils = require('./pad_utils').padutils;
|
'ep_etherpad-lite/static/js/pluginfw/hooks',
|
||||||
var padeditor = require('./pad_editor').padeditor;
|
'ep_etherpad-lite/static/js/pad_utils',
|
||||||
var padsavedrevs = require('./pad_savedrevs');
|
'ep_etherpad-lite/static/js/pad_editor',
|
||||||
|
'ep_etherpad-lite/static/js/pad_savedrevs'
|
||||||
|
], function(hooks, padUtilsModule, padEditorModule, padsavedrevs) {
|
||||||
|
var exports = {};
|
||||||
|
|
||||||
var ToolbarItem = function (element) {
|
var padutils = padUtilsModule.padutils;
|
||||||
|
var padeditor = padEditorModule.padeditor;
|
||||||
|
|
||||||
|
var ToolbarItem = function (element) {
|
||||||
this.$el = element;
|
this.$el = element;
|
||||||
};
|
};
|
||||||
|
|
||||||
ToolbarItem.prototype.getCommand = function () {
|
ToolbarItem.prototype.getCommand = function () {
|
||||||
return this.$el.attr("data-key");
|
return this.$el.attr("data-key");
|
||||||
};
|
};
|
||||||
|
|
||||||
ToolbarItem.prototype.getValue = function () {
|
ToolbarItem.prototype.getValue = function () {
|
||||||
if (this.isSelect()) {
|
if (this.isSelect()) {
|
||||||
return this.$el.find("select").val();
|
return this.$el.find("select").val();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ToolbarItem.prototype.setValue = function (val) {
|
ToolbarItem.prototype.setValue = function (val) {
|
||||||
if (this.isSelect()) {
|
if (this.isSelect()) {
|
||||||
return this.$el.find("select").val(val);
|
return this.$el.find("select").val(val);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
ToolbarItem.prototype.getType = function () {
|
ToolbarItem.prototype.getType = function () {
|
||||||
return this.$el.attr("data-type");
|
return this.$el.attr("data-type");
|
||||||
};
|
};
|
||||||
|
|
||||||
ToolbarItem.prototype.isSelect = function () {
|
ToolbarItem.prototype.isSelect = function () {
|
||||||
return this.getType() == "select";
|
return this.getType() == "select";
|
||||||
};
|
};
|
||||||
|
|
||||||
ToolbarItem.prototype.isButton = function () {
|
ToolbarItem.prototype.isButton = function () {
|
||||||
return this.getType() == "button";
|
return this.getType() == "button";
|
||||||
};
|
};
|
||||||
|
|
||||||
ToolbarItem.prototype.bind = function (callback) {
|
ToolbarItem.prototype.bind = function (callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (self.isButton()) {
|
if (self.isButton()) {
|
||||||
|
@ -73,11 +79,11 @@ ToolbarItem.prototype.bind = function (callback) {
|
||||||
callback(self.getCommand(), self);
|
callback(self.getCommand(), self);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var padeditbar = (function()
|
var padeditbar = (function()
|
||||||
{
|
{
|
||||||
|
|
||||||
var syncAnimation = (function()
|
var syncAnimation = (function()
|
||||||
{
|
{
|
||||||
|
@ -173,7 +179,7 @@ var padeditbar = (function()
|
||||||
},
|
},
|
||||||
isEnabled: function()
|
isEnabled: function()
|
||||||
{
|
{
|
||||||
// return !$("#editbar").hasClass('disabledtoolbar');
|
// return !$("#editbar").hasClass('disabledtoolbar');
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
disable: function()
|
disable: function()
|
||||||
|
@ -476,6 +482,9 @@ var padeditbar = (function()
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
exports.padeditbar = padeditbar;
|
exports.padeditbar = padeditbar;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -20,11 +20,17 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var padcookie = require('./pad_cookie').padcookie;
|
define([
|
||||||
var padutils = require('./pad_utils').padutils;
|
'ep_etherpad-lite/static/js/pad_cookie',
|
||||||
|
'ep_etherpad-lite/static/js/pad_utils'
|
||||||
|
], function (padCookieModule, padUtilsModule) {
|
||||||
|
exports = {};
|
||||||
|
|
||||||
var padeditor = (function()
|
var padcookie = padCookieModule.padcookie;
|
||||||
{
|
var padutils = padUtilsModule.padutils;
|
||||||
|
|
||||||
|
var padeditor = (function()
|
||||||
|
{
|
||||||
var Ace2Editor = undefined;
|
var Ace2Editor = undefined;
|
||||||
var pad = undefined;
|
var pad = undefined;
|
||||||
var settings = undefined;
|
var settings = undefined;
|
||||||
|
@ -217,6 +223,9 @@ var padeditor = (function()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return self;
|
return self;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
exports.padeditor = padeditor;
|
exports.padeditor = padeditor;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -20,10 +20,15 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var padeditbar = require('./pad_editbar').padeditbar;
|
define([
|
||||||
|
'ep_etherpad-lite/static/js/pad_editbar'
|
||||||
|
], function (padEditbarModule) {
|
||||||
|
var exports = {};
|
||||||
|
|
||||||
var padmodals = (function()
|
var padeditbar = padEditbarModule.padeditbar;
|
||||||
{
|
|
||||||
|
var padmodals = (function()
|
||||||
|
{
|
||||||
var pad = undefined;
|
var pad = undefined;
|
||||||
var self = {
|
var self = {
|
||||||
init: function(_pad)
|
init: function(_pad)
|
||||||
|
@ -46,6 +51,9 @@ var padmodals = (function()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return self;
|
return self;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
exports.padmodals = padmodals;
|
exports.padmodals = padmodals;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -14,9 +14,11 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var pad;
|
define([], function() {
|
||||||
|
var exports = {};
|
||||||
|
var pad;
|
||||||
|
|
||||||
exports.saveNow = function(){
|
exports.saveNow = function(){
|
||||||
pad.collabClient.sendMessage({"type": "SAVE_REVISION"});
|
pad.collabClient.sendMessage({"type": "SAVE_REVISION"});
|
||||||
$.gritter.add({
|
$.gritter.add({
|
||||||
// (string | mandatory) the heading of the notification
|
// (string | mandatory) the heading of the notification
|
||||||
|
@ -28,8 +30,11 @@ exports.saveNow = function(){
|
||||||
// (int | optional) the time you want it to be alive for before fading out
|
// (int | optional) the time you want it to be alive for before fading out
|
||||||
time: '2000'
|
time: '2000'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.init = function(_pad){
|
exports.init = function(_pad){
|
||||||
pad = _pad;
|
pad = _pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -20,18 +20,23 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var padutils = require('./pad_utils').padutils;
|
define([
|
||||||
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
'ep_etherpad-lite/static/js/pad_utils',
|
||||||
|
'ep_etherpad-lite/static/js/pluginfw/hooks'
|
||||||
|
], function(padUtilsModule, hooks) {
|
||||||
|
var exports = {};
|
||||||
|
|
||||||
var myUserInfo = {};
|
var padutils = padUtilsModule.padutils;
|
||||||
|
|
||||||
var colorPickerOpen = false;
|
var myUserInfo = {};
|
||||||
var colorPickerSetup = false;
|
|
||||||
var previousColorId = 0;
|
var colorPickerOpen = false;
|
||||||
|
var colorPickerSetup = false;
|
||||||
|
var previousColorId = 0;
|
||||||
|
|
||||||
|
|
||||||
var paduserlist = (function()
|
var paduserlist = (function()
|
||||||
{
|
{
|
||||||
|
|
||||||
var rowManager = (function()
|
var rowManager = (function()
|
||||||
{
|
{
|
||||||
|
@ -764,16 +769,16 @@ var paduserlist = (function()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return self;
|
return self;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
function getColorPickerSwatchIndex(jnode)
|
function getColorPickerSwatchIndex(jnode)
|
||||||
{
|
{
|
||||||
// return Number(jnode.get(0).className.match(/\bn([0-9]+)\b/)[1])-1;
|
// return Number(jnode.get(0).className.match(/\bn([0-9]+)\b/)[1])-1;
|
||||||
return $("#colorpickerswatches li").index(jnode);
|
return $("#colorpickerswatches li").index(jnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeColorPicker(accept)
|
function closeColorPicker(accept)
|
||||||
{
|
{
|
||||||
if (accept)
|
if (accept)
|
||||||
{
|
{
|
||||||
var newColor = $("#mycolorpickerpreview").css("background-color");
|
var newColor = $("#mycolorpickerpreview").css("background-color");
|
||||||
|
@ -799,10 +804,10 @@ function closeColorPicker(accept)
|
||||||
|
|
||||||
colorPickerOpen = false;
|
colorPickerOpen = false;
|
||||||
$("#mycolorpicker").fadeOut("fast");
|
$("#mycolorpicker").fadeOut("fast");
|
||||||
}
|
}
|
||||||
|
|
||||||
function showColorPicker()
|
function showColorPicker()
|
||||||
{
|
{
|
||||||
previousColorId = myUserInfo.colorId;
|
previousColorId = myUserInfo.colorId;
|
||||||
|
|
||||||
if (!colorPickerOpen)
|
if (!colorPickerOpen)
|
||||||
|
@ -841,6 +846,9 @@ function showColorPicker()
|
||||||
$("#colorpickerswatches li").removeClass('picked');
|
$("#colorpickerswatches li").removeClass('picked');
|
||||||
$($("#colorpickerswatches li")[myUserInfo.colorId]).addClass("picked"); //seems weird
|
$($("#colorpickerswatches li")[myUserInfo.colorId]).addClass("picked"); //seems weird
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.paduserlist = paduserlist;
|
exports.paduserlist = paduserlist;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -20,26 +20,12 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var Security = require('./security');
|
define(['ep_etherpad-lite/static/js/pad', 'ep_etherpad-lite/static/js/random_utils'], function(padModule, random_utils) {
|
||||||
|
var exports = {};
|
||||||
|
|
||||||
/**
|
var Security = window.requireKernel('./security');
|
||||||
* Generates a random String with the given length. Is needed to generate the Author, Group, readonly, session Ids
|
|
||||||
*/
|
|
||||||
|
|
||||||
function randomString(len)
|
function createCookie(name, value, days, path){ /* Used by IE */
|
||||||
{
|
|
||||||
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
||||||
var randomstring = '';
|
|
||||||
len = len || 20
|
|
||||||
for (var i = 0; i < len; i++)
|
|
||||||
{
|
|
||||||
var rnum = Math.floor(Math.random() * chars.length);
|
|
||||||
randomstring += chars.substring(rnum, rnum + 1);
|
|
||||||
}
|
|
||||||
return randomstring;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createCookie(name, value, days, path){ /* Used by IE */
|
|
||||||
if (days)
|
if (days)
|
||||||
{
|
{
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
|
@ -62,10 +48,10 @@ function createCookie(name, value, days, path){ /* Used by IE */
|
||||||
document.cookie = name + "=" + value + expires + "; path=" + path;
|
document.cookie = name + "=" + value + expires + "; path=" + path;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function readCookie(name)
|
function readCookie(name)
|
||||||
{
|
{
|
||||||
var nameEQ = name + "=";
|
var nameEQ = name + "=";
|
||||||
var ca = document.cookie.split(';');
|
var ca = document.cookie.split(';');
|
||||||
for (var i = 0; i < ca.length; i++)
|
for (var i = 0; i < ca.length; i++)
|
||||||
|
@ -75,16 +61,16 @@ function readCookie(name)
|
||||||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var padutils = {
|
var padutils = {
|
||||||
escapeHtml: function(x)
|
escapeHtml: function(x)
|
||||||
{
|
{
|
||||||
return Security.escapeHTML(String(x));
|
return Security.escapeHTML(String(x));
|
||||||
},
|
},
|
||||||
uniqueId: function()
|
uniqueId: function()
|
||||||
{
|
{
|
||||||
var pad = require('./pad').pad; // Sidestep circular dependency
|
var pad = padModule.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
|
||||||
|
@ -259,7 +245,7 @@ var padutils = {
|
||||||
},
|
},
|
||||||
timediff: function(d)
|
timediff: function(d)
|
||||||
{
|
{
|
||||||
var pad = require('./pad').pad; // Sidestep circular dependency
|
var pad = padModule.pad; // Sidestep circular dependency
|
||||||
function format(n, word)
|
function format(n, word)
|
||||||
{
|
{
|
||||||
n = Math.round(n);
|
n = Math.round(n);
|
||||||
|
@ -507,14 +493,14 @@ var padutils = {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var globalExceptionHandler = undefined;
|
var globalExceptionHandler = undefined;
|
||||||
function setupGlobalExceptionHandler() {
|
function setupGlobalExceptionHandler() {
|
||||||
if (!globalExceptionHandler) {
|
if (!globalExceptionHandler) {
|
||||||
globalExceptionHandler = function test (msg, url, linenumber)
|
globalExceptionHandler = function test (msg, url, linenumber)
|
||||||
{
|
{
|
||||||
var errorId = randomString(20);
|
var errorId = random_utils.randomString(20);
|
||||||
var userAgent = padutils.escapeHtml(navigator.userAgent);
|
var userAgent = padutils.escapeHtml(navigator.userAgent);
|
||||||
if ($("#editorloadingbox").attr("display") != "none"){
|
if ($("#editorloadingbox").attr("display") != "none"){
|
||||||
//show javascript errors to the user
|
//show javascript errors to the user
|
||||||
|
@ -535,13 +521,16 @@ function setupGlobalExceptionHandler() {
|
||||||
};
|
};
|
||||||
window.onerror = globalExceptionHandler;
|
window.onerror = globalExceptionHandler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
padutils.setupGlobalExceptionHandler = setupGlobalExceptionHandler;
|
padutils.setupGlobalExceptionHandler = setupGlobalExceptionHandler;
|
||||||
|
|
||||||
padutils.binarySearch = require('./ace2_common').binarySearch;
|
padutils.binarySearch = require('./ace2_common').binarySearch;
|
||||||
|
|
||||||
exports.randomString = randomString;
|
exports.randomString = random_utils.randomString;
|
||||||
exports.createCookie = createCookie;
|
exports.createCookie = createCookie;
|
||||||
exports.readCookie = readCookie;
|
exports.readCookie = readCookie;
|
||||||
exports.padutils = padutils;
|
exports.padutils = padutils;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -82,6 +82,7 @@ exports.loadModule = function(path, cb) {
|
||||||
cb(require(path));
|
cb(require(path));
|
||||||
console.warn("Module uses old CommonJS format: " + path);
|
console.warn("Module uses old CommonJS format: " + path);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.warn("Error loading CommonJS module: " + path + "\n" + e.toString());
|
||||||
requirejs([path], cb);
|
requirejs([path], cb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
44
src/static/js/random_utils.js
Normal file
44
src/static/js/random_utils.js
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/**
|
||||||
|
* Copyright 2009 Google Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS-IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function defineRandomUtils(exports) {
|
||||||
|
if (exports == undefined) exports = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a random String with the given length. Is needed to generate the Author, Group, readonly, session Ids
|
||||||
|
*/
|
||||||
|
exports.randomString = function(len)
|
||||||
|
{
|
||||||
|
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||||
|
var randomstring = '';
|
||||||
|
len = len || 20
|
||||||
|
for (var i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
var rnum = Math.floor(Math.random() * chars.length);
|
||||||
|
randomstring += chars.substring(rnum, rnum + 1);
|
||||||
|
}
|
||||||
|
return randomstring;
|
||||||
|
}
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (typeof(define) != 'undefined' && define.amd != undefined && typeof(exports) == 'undefined') {
|
||||||
|
define([], defineRandomUtils);
|
||||||
|
} else {
|
||||||
|
defineRandomUtils(exports);
|
||||||
|
}
|
|
@ -3,5 +3,7 @@
|
||||||
*/
|
*/
|
||||||
define.amd.jQuery = true;
|
define.amd.jQuery = true;
|
||||||
define(["ep_etherpad-lite/static/js/jquery"], function (dummy) {
|
define(["ep_etherpad-lite/static/js/jquery"], function (dummy) {
|
||||||
return window.$.noConflict(true);
|
return window.$;
|
||||||
|
// Loading jQuery extensions won't work if you use noConflict :/
|
||||||
|
// return window.$.noConflict(true);
|
||||||
});
|
});
|
||||||
|
|
|
@ -22,17 +22,24 @@
|
||||||
|
|
||||||
// These jQuery things should create local references, but for now `require()`
|
// These jQuery things should create local references, but for now `require()`
|
||||||
// assigns to the global `$` and augments it with plugins.
|
// assigns to the global `$` and augments it with plugins.
|
||||||
require('./jquery');
|
|
||||||
JSON = require('./json2');
|
|
||||||
|
|
||||||
var createCookie = require('./pad_utils').createCookie;
|
define([
|
||||||
var readCookie = require('./pad_utils').readCookie;
|
'ep_etherpad-lite/static/js/rjquery',
|
||||||
var randomString = require('./pad_utils').randomString;
|
'ep_etherpad-lite/static/js/pluginfw/hooks',
|
||||||
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
'ep_etherpad-lite/static/js/pad_utils',
|
||||||
|
'ep_etherpad-lite/static/js/broadcast_slider'
|
||||||
|
], function($, hooks, padUtilsMod, broadcastSliderMod) {
|
||||||
|
var exports = {};
|
||||||
|
|
||||||
var token, padId, export_links;
|
JSON = window.requireKernel('./json2');
|
||||||
|
|
||||||
function init() {
|
var createCookie = padUtilsMod.createCookie;
|
||||||
|
var readCookie = padUtilsMod.readCookie;
|
||||||
|
var randomString = padUtilsMod.randomString;
|
||||||
|
|
||||||
|
var token, padId, export_links;
|
||||||
|
|
||||||
|
function init() {
|
||||||
$(document).ready(function ()
|
$(document).ready(function ()
|
||||||
{
|
{
|
||||||
// start the custom js
|
// start the custom js
|
||||||
|
@ -105,11 +112,11 @@ function init() {
|
||||||
|
|
||||||
hooks.aCallAll("postTimesliderInit");
|
hooks.aCallAll("postTimesliderInit");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//sends a message over the socket
|
//sends a message over the socket
|
||||||
function sendSocketMsg(type, data)
|
function sendSocketMsg(type, data)
|
||||||
{
|
{
|
||||||
var sessionID = decodeURIComponent(readCookie("sessionID"));
|
var sessionID = decodeURIComponent(readCookie("sessionID"));
|
||||||
var password = readCookie("password");
|
var password = readCookie("password");
|
||||||
|
|
||||||
|
@ -123,18 +130,18 @@ function sendSocketMsg(type, data)
|
||||||
"protocolVersion": 2};
|
"protocolVersion": 2};
|
||||||
|
|
||||||
socket.json.send(msg);
|
socket.json.send(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
var fireWhenAllScriptsAreLoaded = [];
|
var fireWhenAllScriptsAreLoaded = [];
|
||||||
|
|
||||||
var changesetLoader;
|
var changesetLoader;
|
||||||
function handleClientVars(message)
|
function handleClientVars(message)
|
||||||
{
|
{
|
||||||
//save the client Vars
|
//save the client Vars
|
||||||
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
|
||||||
BroadcastSlider = require('./broadcast_slider').loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded);
|
BroadcastSlider = broadcastSliderMod.loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded);
|
||||||
require('./broadcast_revisions').loadBroadcastRevisionsJS();
|
require('./broadcast_revisions').loadBroadcastRevisionsJS();
|
||||||
changesetLoader = require('./broadcast').loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, BroadcastSlider);
|
changesetLoader = require('./broadcast').loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, BroadcastSlider);
|
||||||
|
|
||||||
|
@ -185,11 +192,14 @@ function handleClientVars(message)
|
||||||
if(font === "serif") setFont("MS Serif");
|
if(font === "serif") setFont("MS Serif");
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setFont(font){
|
function setFont(font){
|
||||||
$('#padcontent').css("font-family", font);
|
$('#padcontent').css("font-family", font);
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.baseURL = '';
|
exports.baseURL = '';
|
||||||
exports.init = init;
|
exports.init = init;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -370,10 +370,6 @@
|
||||||
|
|
||||||
<script type="text/javascript" src="../static/plugins/requirejs/require.js"></script>
|
<script type="text/javascript" src="../static/plugins/requirejs/require.js"></script>
|
||||||
|
|
||||||
<!-- Include base packages manually (this help with debugging) -->
|
|
||||||
<!-- script type="text/javascript" src="../javascripts/lib/ep_etherpad-lite/static/js/pad.js?callback=require.define"></script>
|
|
||||||
<script type="text/javascript" src="../javascripts/lib/ep_etherpad-lite/static/js/ace2_common.js?callback=require.define"></script -->
|
|
||||||
|
|
||||||
<% e.begin_block("customScripts"); %>
|
<% e.begin_block("customScripts"); %>
|
||||||
<script type="text/javascript" src="../static/custom/pad.js"></script>
|
<script type="text/javascript" src="../static/custom/pad.js"></script>
|
||||||
<% e.end_block(); %>
|
<% e.end_block(); %>
|
||||||
|
@ -402,8 +398,11 @@
|
||||||
[
|
[
|
||||||
'ep_etherpad-lite/static/js/rjquery',
|
'ep_etherpad-lite/static/js/rjquery',
|
||||||
'ep_etherpad-lite/static/js/pluginfw/client_plugins',
|
'ep_etherpad-lite/static/js/pluginfw/client_plugins',
|
||||||
'ep_etherpad-lite/static/js/pluginfw/hooks'
|
'ep_etherpad-lite/static/js/pluginfw/hooks',
|
||||||
], function ($, plugins, hooks) {
|
'ep_etherpad-lite/static/js/pad',
|
||||||
|
'ep_etherpad-lite/static/js/chat',
|
||||||
|
'ep_etherpad-lite/static/js/pad_editbar',
|
||||||
|
], function ($, plugins, hooks, padMod, chatMod, padEditbarMod) {
|
||||||
window.$ = $; // Expose jQuery #HACK
|
window.$ = $; // Expose jQuery #HACK
|
||||||
window.jQuery = $;
|
window.jQuery = $;
|
||||||
|
|
||||||
|
@ -421,16 +420,15 @@
|
||||||
hooks.aCallAll('documentReady');
|
hooks.aCallAll('documentReady');
|
||||||
});
|
});
|
||||||
|
|
||||||
var pad = require('ep_etherpad-lite/static/js/pad');
|
padMod.baseURL = baseURL;
|
||||||
pad.baseURL = baseURL;
|
padMod.init();
|
||||||
pad.init();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/* TODO: These globals shouldn't exist. */
|
/* TODO: These globals shouldn't exist. */
|
||||||
pad = require('ep_etherpad-lite/static/js/pad').pad;
|
pad = padMod.pad;
|
||||||
chat = require('ep_etherpad-lite/static/js/chat').chat;
|
chat = chatMod.chat;
|
||||||
padeditbar = require('ep_etherpad-lite/static/js/pad_editbar').padeditbar;
|
padeditbar = padEditbarMod.padeditbar;
|
||||||
padimpexp = require('ep_etherpad-lite/static/js/pad_impexp').padimpexp;
|
padimpexp = window.requireKernel('ep_etherpad-lite/static/js/pad_impexp').padimpexp;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}());
|
}());
|
||||||
|
|
|
@ -222,9 +222,7 @@
|
||||||
<script type="text/javascript" src="../../static/js/require-kernel.js"></script>
|
<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>
|
||||||
|
|
||||||
<!-- Include base packages manually (this help with debugging) -->
|
<script type="text/javascript" src="../static/plugins/requirejs/require.js"></script>
|
||||||
<script type="text/javascript" src="../../javascripts/lib/ep_etherpad-lite/static/js/timeslider.js?callback=require.define"></script>
|
|
||||||
<script type="text/javascript" src="../../javascripts/lib/ep_etherpad-lite/static/js/ace2_common.js?callback=require.define"></script>
|
|
||||||
|
|
||||||
<script type="text/javascript" src="../../static/custom/timeslider.js"></script>
|
<script type="text/javascript" src="../../static/custom/timeslider.js"></script>
|
||||||
|
|
||||||
|
@ -243,31 +241,47 @@
|
||||||
require.setLibraryURI(baseURL + "javascripts/lib");
|
require.setLibraryURI(baseURL + "javascripts/lib");
|
||||||
require.setGlobalKeyPath("require");
|
require.setGlobalKeyPath("require");
|
||||||
|
|
||||||
$ = jQuery = require('ep_etherpad-lite/static/js/rjquery').jQuery; // Expose jQuery #HACK
|
window.requireKernel = require;
|
||||||
browser = require('ep_etherpad-lite/static/js/browser').browser;
|
|
||||||
|
requirejs.config({
|
||||||
|
baseUrl: baseURL + "static/plugins",
|
||||||
|
paths: {'underscore': baseURL + "static/plugins/underscore/underscore"},
|
||||||
|
});
|
||||||
|
|
||||||
|
requirejs([
|
||||||
|
'ep_etherpad-lite/static/js/rjquery',
|
||||||
|
'ep_etherpad-lite/static/js/pluginfw/client_plugins',
|
||||||
|
'ep_etherpad-lite/static/js/pluginfw/hooks'
|
||||||
|
'ep_etherpad-lite/static/js/pad_editbar',
|
||||||
|
'ep_etherpad-lite/static/js/browser',
|
||||||
|
'ep_etherpad-lite/static/js/timeslider'
|
||||||
|
], function ($, plugins, hooks, padEditbarMod, browserMod, timesliderMod) {
|
||||||
|
window.$ = $; // Expose jQuery #HACK
|
||||||
|
window.jQuery = $;
|
||||||
|
|
||||||
|
browser = browserMod.browser;
|
||||||
|
|
||||||
if ((!browser.msie) && (!(browser.mozilla && browser.version.indexOf("1.8.") == 0))) {
|
if ((!browser.msie) && (!(browser.mozilla && browser.version.indexOf("1.8.") == 0))) {
|
||||||
document.domain = document.domain; // for comet
|
document.domain = document.domain; // for comet
|
||||||
}
|
}
|
||||||
|
|
||||||
var plugins = require('ep_etherpad-lite/static/js/pluginfw/client_plugins');
|
|
||||||
var socket = require('ep_etherpad-lite/static/js/timeslider').socket;
|
var socket = timesliderMod.socket;
|
||||||
BroadcastSlider = require('ep_etherpad-lite/static/js/timeslider').BroadcastSlider;
|
BroadcastSlider = timesliderMod.BroadcastSlider;
|
||||||
plugins.baseURL = baseURL;
|
plugins.baseURL = baseURL;
|
||||||
|
|
||||||
plugins.update(function () {
|
plugins.update(function () {
|
||||||
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
|
||||||
hooks.plugins = plugins;
|
hooks.plugins = plugins;
|
||||||
|
|
||||||
var timeslider = require('ep_etherpad-lite/static/js/timeslider')
|
timesliderMod.baseURL = baseURL;
|
||||||
timeslider.baseURL = baseURL;
|
timesliderMod.init();
|
||||||
timeslider.init();
|
|
||||||
|
|
||||||
/* TODO: These globals shouldn't exist. */
|
/* TODO: These globals shouldn't exist. */
|
||||||
padeditbar = require('ep_etherpad-lite/static/js/pad_editbar').padeditbar;
|
padeditbar = padEditbarMod.padeditbar;
|
||||||
padimpexp = require('ep_etherpad-lite/static/js/pad_impexp').padimpexp;
|
padimpexp = window.requireKernel('ep_etherpad-lite/static/js/pad_impexp').padimpexp;
|
||||||
|
|
||||||
padeditbar.init()
|
padeditbar.init();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue