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,8 +22,14 @@
|
||||||
|
|
||||||
// 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;
|
define([
|
||||||
|
'ep_etherpad-lite/static/js/pad_modals',
|
||||||
|
'underscore'
|
||||||
|
], function(padModalsModule, _) {
|
||||||
|
var exports = {};
|
||||||
|
|
||||||
|
var padmodals = padModalsModule.padmodals;
|
||||||
|
|
||||||
function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded)
|
function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded)
|
||||||
{
|
{
|
||||||
|
@ -500,3 +506,6 @@ function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.loadBroadcastSliderJS = loadBroadcastSliderJS;
|
exports.loadBroadcastSliderJS = loadBroadcastSliderJS;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -14,11 +14,19 @@
|
||||||
* 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 padutils = padUtilsModule.padutils;
|
||||||
|
var padcookie = padCookieModule.padcookie;
|
||||||
|
var padeditor = padEditorModule.padeditor;
|
||||||
|
|
||||||
|
var Tinycon = window.requireKernel('tinycon/tinycon');
|
||||||
|
|
||||||
var chat = (function()
|
var chat = (function()
|
||||||
{
|
{
|
||||||
|
@ -269,3 +277,5 @@ var chat = (function()
|
||||||
|
|
||||||
exports.chat = chat;
|
exports.chat = chat;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -20,8 +20,13 @@
|
||||||
* 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 = {};
|
||||||
|
|
||||||
|
var chat = chatModule.chat;
|
||||||
|
|
||||||
// Dependency fill on init. This exists for `pad.socket` only.
|
// Dependency fill on init. This exists for `pad.socket` only.
|
||||||
// TODO: bind directly to the socket.
|
// TODO: bind directly to the socket.
|
||||||
|
@ -658,3 +663,6 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getCollabClient = getCollabClient;
|
exports.getCollabClient = getCollabClient;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -22,34 +22,52 @@
|
||||||
|
|
||||||
/* global $, window */
|
/* global $, window */
|
||||||
|
|
||||||
|
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 = {};
|
||||||
|
|
||||||
var socket;
|
var socket;
|
||||||
|
|
||||||
// These jQuery things should create local references, but for now `require()`
|
window.requireKernel('./farbtastic');
|
||||||
// assigns to the global `$` and augments it with plugins.
|
window.requireKernel('./excanvas');
|
||||||
require('./jquery');
|
JSON = window.requireKernel('./json2');
|
||||||
require('./farbtastic');
|
|
||||||
require('./excanvas');
|
|
||||||
JSON = require('./json2');
|
|
||||||
|
|
||||||
var chat = require('./chat').chat;
|
var chat = chatMod.chat;
|
||||||
var getCollabClient = require('./collab_client').getCollabClient;
|
var getCollabClient = collabClientMod.getCollabClient;
|
||||||
var padconnectionstatus = require('./pad_connectionstatus').padconnectionstatus;
|
var padconnectionstatus = padConnectionStatusMod.padconnectionstatus;
|
||||||
var padcookie = require('./pad_cookie').padcookie;
|
var padcookie = padCookieMod.padcookie;
|
||||||
var padeditbar = require('./pad_editbar').padeditbar;
|
var padeditbar = padEditbarMod.padeditbar;
|
||||||
var padeditor = require('./pad_editor').padeditor;
|
var padeditor = padEditorMod.padeditor;
|
||||||
var padimpexp = require('./pad_impexp').padimpexp;
|
var padimpexp = window.requireKernel('./pad_impexp').padimpexp;
|
||||||
var padmodals = require('./pad_modals').padmodals;
|
var padmodals = padModalsMod.padmodals;
|
||||||
var padsavedrevs = require('./pad_savedrevs');
|
var paduserlist = padUserListMod.paduserlist;
|
||||||
var paduserlist = require('./pad_userlist').paduserlist;
|
var padutils = padUtilsMod.padutils;
|
||||||
var padutils = require('./pad_utils').padutils;
|
var colorutils = window.requireKernel('./colorutils').colorutils;
|
||||||
var colorutils = require('./colorutils').colorutils;
|
var createCookie = padUtilsMod.createCookie;
|
||||||
var createCookie = require('./pad_utils').createCookie;
|
var readCookie = padUtilsMod.readCookie;
|
||||||
var readCookie = require('./pad_utils').readCookie;
|
var randomString = padUtilsMod.randomString;
|
||||||
var randomString = require('./pad_utils').randomString;
|
var gritter = window.requireKernel('./gritter').gritter;
|
||||||
var gritter = require('./gritter').gritter;
|
|
||||||
|
|
||||||
var receivedClientVars = false;
|
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 */
|
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)
|
||||||
{
|
{
|
||||||
|
@ -87,19 +105,6 @@ function readCookie(name)
|
||||||
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
|
||||||
|
@ -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")
|
||||||
|
@ -378,12 +383,6 @@ function handshake()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$.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...
|
|
||||||
});
|
|
||||||
|
|
||||||
var pad = {
|
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
|
||||||
|
@ -942,13 +941,8 @@ 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 = {
|
||||||
|
@ -973,3 +967,6 @@ exports.handshake = handshake;
|
||||||
exports.pad = pad;
|
exports.pad = pad;
|
||||||
exports.init = init;
|
exports.init = init;
|
||||||
exports.alertBar = alertBar;
|
exports.alertBar = alertBar;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -20,7 +20,12 @@
|
||||||
* 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 padmodals = padModalsModule.padmodals;
|
||||||
|
|
||||||
var padconnectionstatus = (function()
|
var padconnectionstatus = (function()
|
||||||
{
|
{
|
||||||
|
@ -86,3 +91,6 @@ var padconnectionstatus = (function()
|
||||||
}());
|
}());
|
||||||
|
|
||||||
exports.padconnectionstatus = padconnectionstatus;
|
exports.padconnectionstatus = padconnectionstatus;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
define([], function () {
|
||||||
|
var exports = {};
|
||||||
var padcookie = (function()
|
var padcookie = (function()
|
||||||
{
|
{
|
||||||
function getRawCookie()
|
function getRawCookie()
|
||||||
|
@ -131,3 +133,6 @@ var padcookie = (function()
|
||||||
}());
|
}());
|
||||||
|
|
||||||
exports.padcookie = padcookie;
|
exports.padcookie = padcookie;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -20,10 +20,16 @@
|
||||||
* 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 padutils = padUtilsModule.padutils;
|
||||||
|
var padeditor = padEditorModule.padeditor;
|
||||||
|
|
||||||
var ToolbarItem = function (element) {
|
var ToolbarItem = function (element) {
|
||||||
this.$el = element;
|
this.$el = element;
|
||||||
|
@ -479,3 +485,6 @@ var padeditbar = (function()
|
||||||
}());
|
}());
|
||||||
|
|
||||||
exports.padeditbar = padeditbar;
|
exports.padeditbar = padeditbar;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -20,8 +20,14 @@
|
||||||
* 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 padcookie = padCookieModule.padcookie;
|
||||||
|
var padutils = padUtilsModule.padutils;
|
||||||
|
|
||||||
var padeditor = (function()
|
var padeditor = (function()
|
||||||
{
|
{
|
||||||
|
@ -220,3 +226,6 @@ var padeditor = (function()
|
||||||
}());
|
}());
|
||||||
|
|
||||||
exports.padeditor = padeditor;
|
exports.padeditor = padeditor;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -20,7 +20,12 @@
|
||||||
* 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 padeditbar = padEditbarModule.padeditbar;
|
||||||
|
|
||||||
var padmodals = (function()
|
var padmodals = (function()
|
||||||
{
|
{
|
||||||
|
@ -49,3 +54,6 @@ var padmodals = (function()
|
||||||
}());
|
}());
|
||||||
|
|
||||||
exports.padmodals = padmodals;
|
exports.padmodals = padmodals;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
define([], function() {
|
||||||
|
var exports = {};
|
||||||
var pad;
|
var pad;
|
||||||
|
|
||||||
exports.saveNow = function(){
|
exports.saveNow = function(){
|
||||||
|
@ -33,3 +35,6 @@ exports.saveNow = function(){
|
||||||
exports.init = function(_pad){
|
exports.init = function(_pad){
|
||||||
pad = _pad;
|
pad = _pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -20,8 +20,13 @@
|
||||||
* 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 padutils = padUtilsModule.padutils;
|
||||||
|
|
||||||
var myUserInfo = {};
|
var myUserInfo = {};
|
||||||
|
|
||||||
|
@ -844,3 +849,6 @@ function showColorPicker()
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.paduserlist = paduserlist;
|
exports.paduserlist = paduserlist;
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
|
|
|
@ -20,24 +20,10 @@
|
||||||
* 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)
|
|
||||||
{
|
|
||||||
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 */
|
function createCookie(name, value, days, path){ /* Used by IE */
|
||||||
if (days)
|
if (days)
|
||||||
|
@ -84,7 +70,7 @@ var padutils = {
|
||||||
},
|
},
|
||||||
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);
|
||||||
|
@ -514,7 +500,7 @@ 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
|
||||||
|
@ -541,7 +527,10 @@ 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,13 +22,20 @@
|
||||||
|
|
||||||
// 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 = {};
|
||||||
|
|
||||||
|
JSON = window.requireKernel('./json2');
|
||||||
|
|
||||||
|
var createCookie = padUtilsMod.createCookie;
|
||||||
|
var readCookie = padUtilsMod.readCookie;
|
||||||
|
var randomString = padUtilsMod.randomString;
|
||||||
|
|
||||||
var token, padId, export_links;
|
var token, padId, export_links;
|
||||||
|
|
||||||
|
@ -134,7 +141,7 @@ function handleClientVars(message)
|
||||||
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);
|
||||||
|
|
||||||
|
@ -193,3 +200,6 @@ function setFont(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