mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-26 10:26:15 -04:00
Merge pull request #667 from fourplusone/feature/cleaner_code
Removing unused code - All looks good, some minor tweeks are probably worthwhile in the future.
This commit is contained in:
commit
c70d88eedc
15 changed files with 30 additions and 1083 deletions
|
@ -883,15 +883,6 @@ down on the page in IE. Strange but it works! */
|
|||
line-height: 18px;
|
||||
padding: 2px;
|
||||
}
|
||||
#sharebox-send {
|
||||
float: right;
|
||||
background-repeat: no-repeat;
|
||||
background-image: url(static/img/sharebox4.gif);
|
||||
display: block;
|
||||
width: 87px;
|
||||
height: 22px;
|
||||
background-position: -383px -289px;
|
||||
}
|
||||
#viewbarcontents {
|
||||
display: none
|
||||
}
|
||||
|
@ -903,9 +894,7 @@ down on the page in IE. Strange but it works! */
|
|||
line-height: 20px;
|
||||
width: auto;
|
||||
}
|
||||
#viewzoommenu {
|
||||
width: 65px
|
||||
}
|
||||
|
||||
#bottomarea {
|
||||
height: 28px;
|
||||
overflow: hidden;
|
||||
|
@ -949,17 +938,7 @@ down on the page in IE. Strange but it works! */
|
|||
.sidebarchecked {
|
||||
background-position: -1px -67px
|
||||
}
|
||||
#feedbackbutton {
|
||||
display: block;
|
||||
position: absolute;
|
||||
width: 68px;
|
||||
height: 0;
|
||||
padding-top: 17px;
|
||||
overflow: hidden;
|
||||
background: url(static/img/bottomareagfx.gif);
|
||||
top: 5px;
|
||||
right: 220px;
|
||||
}
|
||||
|
||||
#modaloverlay {
|
||||
z-index: 500;
|
||||
display: none;
|
||||
|
|
|
@ -245,14 +245,6 @@ require.setGlobalKeyPath("require");\n\
|
|||
iframeHTML: iframeHTML
|
||||
});
|
||||
|
||||
// For compatability's sake transform in and out.
|
||||
for (var i = 0, ii = iframeHTML.length; i < ii; i++) {
|
||||
iframeHTML[i] = JSON.stringify(iframeHTML[i]);
|
||||
}
|
||||
for (var i = 0, ii = iframeHTML.length; i < ii; i++) {
|
||||
iframeHTML[i] = JSON.parse(iframeHTML[i]);
|
||||
}
|
||||
|
||||
// calls to these functions ($$INCLUDE_...) are replaced when this file is processed
|
||||
// and compressed, putting the compressed code from the named file directly into the
|
||||
// source here.
|
||||
|
|
|
@ -166,12 +166,10 @@ function Ace2Inner(){
|
|||
}
|
||||
|
||||
var dynamicCSS = null;
|
||||
var dynamicCSSTop = null;
|
||||
|
||||
function initDynamicCSS()
|
||||
{
|
||||
dynamicCSS = makeCSSManager("dynamicsyntax");
|
||||
dynamicCSSTop = makeCSSManager("dynamicsyntax", true);
|
||||
}
|
||||
|
||||
var changesetTracker = makeChangesetTracker(scheduler, rep.apool, {
|
||||
|
@ -214,7 +212,6 @@ function Ace2Inner(){
|
|||
if (dynamicCSS)
|
||||
{
|
||||
dynamicCSS.removeSelectorStyle(getAuthorColorClassSelector(getAuthorClassName(author)));
|
||||
dynamicCSSTop.removeSelectorStyle(getAuthorColorClassSelector(getAuthorClassName(author)));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -232,23 +229,18 @@ function Ace2Inner(){
|
|||
|
||||
var authorStyle = dynamicCSS.selectorStyle(getAuthorColorClassSelector(
|
||||
getAuthorClassName(author)));
|
||||
var authorStyleTop = dynamicCSSTop.selectorStyle(getAuthorColorClassSelector(
|
||||
getAuthorClassName(author)));
|
||||
var anchorStyle = dynamicCSS.selectorStyle(getAuthorColorClassSelector(
|
||||
getAuthorClassName(author))+' > a')
|
||||
|
||||
// author color
|
||||
authorStyle.backgroundColor = bgcolor;
|
||||
authorStyleTop.backgroundColor = bgcolor;
|
||||
|
||||
// text contrast
|
||||
if(colorutils.luminosity(colorutils.css2triple(bgcolor)) < 0.5)
|
||||
{
|
||||
authorStyle.color = '#ffffff';
|
||||
authorStyleTop.color = '#ffffff';
|
||||
}else{
|
||||
authorStyle.color = null;
|
||||
authorStyleTop.color = null;
|
||||
}
|
||||
|
||||
// anchor text contrast
|
||||
|
@ -3749,24 +3741,6 @@ function Ace2Inner(){
|
|||
setSelection(selection);
|
||||
}
|
||||
|
||||
function getRepHTML()
|
||||
{
|
||||
return _.map(rep.lines.slice(), function(entry)
|
||||
{
|
||||
var text = entry.text;
|
||||
var content;
|
||||
if (text.length === 0)
|
||||
{
|
||||
content = '<span style="color: #aaa">--</span>';
|
||||
}
|
||||
else
|
||||
{
|
||||
content = htmlPrettyEscape(text);
|
||||
}
|
||||
return '<div><code>' + content + '</div></code>';
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function nodeMaxIndex(nd)
|
||||
{
|
||||
if (isNodeText(nd)) return nd.nodeValue.length;
|
||||
|
|
|
@ -189,95 +189,15 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
|||
|
||||
function setUpSocket()
|
||||
{
|
||||
//oldSocketId = String(Math.floor(Math.random()*1e12));
|
||||
//socketId = String(Math.floor(Math.random()*1e12));
|
||||
/*socket = new io.Socket();
|
||||
socket.connect();*/
|
||||
|
||||
//socket.on('connect', function(){
|
||||
hiccupCount = 0;
|
||||
setChannelState("CONNECTED");
|
||||
/*var msg = { type:"CLIENT_READY", roomType:'padpage',
|
||||
roomName:'padpage/'+globalPadId,
|
||||
data: {
|
||||
lastRev:rev,
|
||||
userInfo:userSet[userId],
|
||||
stats: getStats() } };
|
||||
if (oldSocketId) {
|
||||
msg.data.isReconnectOf = oldSocketId;
|
||||
msg.data.isCommitPending = (state == "COMMITTING");
|
||||
}
|
||||
sendMessage(msg);*/
|
||||
doDeferredActions();
|
||||
|
||||
initialStartConnectTime = +new Date();
|
||||
// });
|
||||
/*socket.on('message', function(obj){
|
||||
if(window.console)
|
||||
console.log(obj);
|
||||
handleMessageFromServer(obj);
|
||||
});*/
|
||||
|
||||
/*var success = false;
|
||||
callCatchingErrors("setUpSocket", function() {
|
||||
appLevelDisconnectReason = null;
|
||||
|
||||
var oldSocketId = socketId;
|
||||
socketId = String(Math.floor(Math.random()*1e12));
|
||||
socket = new WebSocket(socketId);
|
||||
socket.onmessage = wrapRecordingErrors("socket.onmessage", handleMessageFromServer);
|
||||
socket.onclosed = wrapRecordingErrors("socket.onclosed", handleSocketClosed);
|
||||
socket.onopen = wrapRecordingErrors("socket.onopen", function() {
|
||||
hiccupCount = 0;
|
||||
setChannelState("CONNECTED");
|
||||
var msg = { type:"CLIENT_READY", roomType:'padpage',
|
||||
roomName:'padpage/'+globalPadId,
|
||||
data: {
|
||||
lastRev:rev,
|
||||
userInfo:userSet[userId],
|
||||
stats: getStats() } };
|
||||
if (oldSocketId) {
|
||||
msg.data.isReconnectOf = oldSocketId;
|
||||
msg.data.isCommitPending = (state == "COMMITTING");
|
||||
}
|
||||
sendMessage(msg);
|
||||
doDeferredActions();
|
||||
});
|
||||
socket.onhiccup = wrapRecordingErrors("socket.onhiccup", handleCometHiccup);
|
||||
socket.onlogmessage = dmesg;
|
||||
socket.connect();
|
||||
success = true;
|
||||
});
|
||||
if (success) {
|
||||
initialStartConnectTime = +new Date();
|
||||
}
|
||||
else {
|
||||
abandonConnection("initsocketfail");
|
||||
}*/
|
||||
}
|
||||
|
||||
var hiccupCount = 0;
|
||||
|
||||
function handleCometHiccup(params)
|
||||
{
|
||||
dmesg("HICCUP (connected:" + ( !! params.connected) + ")");
|
||||
var connectedNow = params.connected;
|
||||
if (!connectedNow)
|
||||
{
|
||||
hiccupCount++;
|
||||
// skip first "cut off from server" notification
|
||||
if (hiccupCount > 1)
|
||||
{
|
||||
setChannelState("RECONNECTING");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hiccupCount = 0;
|
||||
setChannelState("CONNECTED");
|
||||
}
|
||||
}
|
||||
|
||||
function sendMessage(msg)
|
||||
{
|
||||
getSocket().json.send(
|
||||
|
@ -382,13 +302,11 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
|||
{
|
||||
userSet[id] = userInfo;
|
||||
callbacks.onUpdateUserInfo(userInfo);
|
||||
dmesgUsers();
|
||||
}
|
||||
else
|
||||
{
|
||||
userSet[id] = userInfo;
|
||||
callbacks.onUserJoin(userInfo);
|
||||
dmesgUsers();
|
||||
}
|
||||
tellAceActiveAuthorInfo(userInfo);
|
||||
}
|
||||
|
@ -401,7 +319,6 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
|||
delete userSet[userInfo.userId];
|
||||
fadeAceAuthorInfo(userInfo);
|
||||
callbacks.onUserLeave(userInfo);
|
||||
dmesgUsers();
|
||||
}
|
||||
}
|
||||
else if (msg.type == "DISCONNECT_REASON")
|
||||
|
@ -485,11 +402,6 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
|||
}
|
||||
}
|
||||
|
||||
function dmesgUsers()
|
||||
{
|
||||
//pad.dmesg($.map(getConnectedUsers(), function(u) { return u.userId.slice(-2); }).join(','));
|
||||
}
|
||||
|
||||
function setChannelState(newChannelState, moreInfo)
|
||||
{
|
||||
if (newChannelState != channelState)
|
||||
|
@ -678,29 +590,4 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
|||
return self;
|
||||
}
|
||||
|
||||
function selectElementContents(elem)
|
||||
{
|
||||
if ($.browser.msie)
|
||||
{
|
||||
var range = document.body.createTextRange();
|
||||
range.moveToElementText(elem);
|
||||
range.select();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (window.getSelection)
|
||||
{
|
||||
var browserSelection = window.getSelection();
|
||||
if (browserSelection)
|
||||
{
|
||||
var range = document.createRange();
|
||||
range.selectNodeContents(elem);
|
||||
browserSelection.removeAllRanges();
|
||||
browserSelection.addRange(range);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.getCollabClient = getCollabClient;
|
||||
exports.selectElementContents = selectElementContents;
|
||||
|
|
|
@ -20,15 +20,12 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
function makeCSSManager(emptyStylesheetTitle, top)
|
||||
function makeCSSManager(emptyStylesheetTitle)
|
||||
{
|
||||
|
||||
function getSheetByTitle(title, top)
|
||||
function getSheetByTitle(title)
|
||||
{
|
||||
if(top)
|
||||
var allSheets = window.parent.parent.document.styleSheets;
|
||||
else
|
||||
var allSheets = document.styleSheets;
|
||||
var allSheets = document.styleSheets;
|
||||
|
||||
for (var i = 0; i < allSheets.length; i++)
|
||||
{
|
||||
|
@ -40,21 +37,8 @@ function makeCSSManager(emptyStylesheetTitle, top)
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*function getSheetTagByTitle(title) {
|
||||
var allStyleTags = document.getElementsByTagName("style");
|
||||
for(var i=0;i<allStyleTags.length;i++) {
|
||||
var t = allStyleTags[i];
|
||||
if (t.title == title) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}*/
|
||||
|
||||
var browserSheet = getSheetByTitle(emptyStylesheetTitle, top);
|
||||
//var browserTag = getSheetTagByTitle(emptyStylesheetTitle);
|
||||
|
||||
|
||||
var browserSheet = getSheetByTitle(emptyStylesheetTitle);
|
||||
|
||||
function browserRules()
|
||||
{
|
||||
|
|
|
@ -30,7 +30,6 @@ require('./jquery');
|
|||
require('./farbtastic');
|
||||
require('./excanvas');
|
||||
JSON = require('./json2');
|
||||
require('./undo-xpopup');
|
||||
|
||||
var chat = require('./chat').chat;
|
||||
var getCollabClient = require('./collab_client').getCollabClient;
|
||||
|
|
|
@ -58,7 +58,6 @@ var padeditor = (function()
|
|||
self.setViewOptions(initialViewOptions);
|
||||
|
||||
// view bar
|
||||
self.initViewZoom();
|
||||
$("#viewbarcontents").show();
|
||||
},
|
||||
initViewOptions: function()
|
||||
|
@ -106,36 +105,6 @@ var padeditor = (function()
|
|||
self.ace.setProperty("textface", (v ? "monospace" : "Arial, sans-serif"));
|
||||
$("#viewfontmenu").val(v ? "monospace" : "normal");
|
||||
},
|
||||
initViewZoom: function()
|
||||
{
|
||||
var viewZoom = Number(padcookie.getPref('viewZoom'));
|
||||
if ((!viewZoom) || isNaN(viewZoom))
|
||||
{
|
||||
viewZoom = 100;
|
||||
}
|
||||
self.setViewZoom(viewZoom);
|
||||
$("#viewzoommenu").change(function(evt)
|
||||
{
|
||||
// strip initial 'z' from val
|
||||
self.setViewZoom(Number($("#viewzoommenu").val().substring(1)));
|
||||
});
|
||||
},
|
||||
setViewZoom: function(percent)
|
||||
{
|
||||
if (!(percent >= 50 && percent <= 1000))
|
||||
{
|
||||
// percent is out of sane range or NaN (which fails comparisons)
|
||||
return;
|
||||
}
|
||||
|
||||
self.viewZoom = percent;
|
||||
$("#viewzoommenu").val('z' + percent);
|
||||
|
||||
var baseSize = 13;
|
||||
self.ace.setProperty('textsize', Math.round(baseSize * self.viewZoom / 100));
|
||||
|
||||
padcookie.setPref('viewZoom', percent);
|
||||
},
|
||||
dispose: function()
|
||||
{
|
||||
if (self.ace)
|
||||
|
|
|
@ -19,166 +19,16 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
var padutils = require('./pad_utils').padutils;
|
||||
var paddocbar = require('./pad_docbar').paddocbar;
|
||||
|
||||
var padmodals = (function()
|
||||
{
|
||||
|
||||
/*var clearFeedbackEmail = function() {};
|
||||
function clearFeedback() {
|
||||
clearFeedbackEmail();
|
||||
$("#feedbackbox-message").val('');
|
||||
}
|
||||
|
||||
var sendingFeedback = false;
|
||||
function setSendingFeedback(v) {
|
||||
v = !! v;
|
||||
if (sendingFeedback != v) {
|
||||
sendingFeedback = v;
|
||||
if (v) {
|
||||
$("#feedbackbox-send").css('opacity', 0.75);
|
||||
}
|
||||
else {
|
||||
$("#feedbackbox-send").css('opacity', 1);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
var sendingInvite = false;
|
||||
|
||||
function setSendingInvite(v)
|
||||
{
|
||||
v = !! v;
|
||||
if (sendingInvite != v)
|
||||
{
|
||||
sendingInvite = v;
|
||||
if (v)
|
||||
{
|
||||
$(".sharebox-send").css('opacity', 0.75);
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#sharebox-send").css('opacity', 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var clearShareBoxTo = function()
|
||||
{};
|
||||
|
||||
function clearShareBox()
|
||||
{
|
||||
clearShareBoxTo();
|
||||
}
|
||||
|
||||
var pad = undefined;
|
||||
var self = {
|
||||
init: function(_pad)
|
||||
{
|
||||
pad = _pad;
|
||||
|
||||
self.initFeedback();
|
||||
self.initShareBox();
|
||||
},
|
||||
initFeedback: function()
|
||||
{
|
||||
/*var emailField = $("#feedbackbox-email");
|
||||
clearFeedbackEmail =
|
||||
padutils.makeFieldLabeledWhenEmpty(emailField, '(your email address)').clear;
|
||||
clearFeedback();*/
|
||||
|
||||
$("#feedbackbox-hide").click(function()
|
||||
{
|
||||
self.hideModal();
|
||||
});
|
||||
/*$("#feedbackbox-send").click(function() {
|
||||
self.sendFeedbackEmail();
|
||||
});*/
|
||||
|
||||
$("#feedbackbutton").click(function()
|
||||
{
|
||||
self.showFeedback();
|
||||
});
|
||||
},
|
||||
initShareBox: function()
|
||||
{
|
||||
$("#sharebutton").click(function()
|
||||
{
|
||||
self.showShareBox();
|
||||
});
|
||||
$("#sharebox-hide").click(function()
|
||||
{
|
||||
self.hideModal();
|
||||
});
|
||||
$("#sharebox-send").click(function()
|
||||
{
|
||||
self.sendInvite();
|
||||
});
|
||||
|
||||
$("#sharebox-url").click(function()
|
||||
{
|
||||
$("#sharebox-url").focus().select();
|
||||
});
|
||||
|
||||
clearShareBoxTo = padutils.makeFieldLabeledWhenEmpty($("#sharebox-to"), "(email addresses)").clear;
|
||||
clearShareBox();
|
||||
|
||||
$("#sharebox-subject").val(self.getDefaultShareBoxSubjectForName(pad.getUserName()));
|
||||
$("#sharebox-message").val(self.getDefaultShareBoxMessageForName(pad.getUserName()));
|
||||
|
||||
$("#sharebox-stripe .setsecurity").click(function()
|
||||
{
|
||||
self.hideModal();
|
||||
paddocbar.setShownPanel('security');
|
||||
});
|
||||
},
|
||||
getDefaultShareBoxMessageForName: function(name)
|
||||
{
|
||||
return (name || "Somebody") + " has shared an EtherPad document with you." + "\n\n" + "View it here:\n\n" + padutils.escapeHtml($(".sharebox-url").val() + "\n");
|
||||
},
|
||||
getDefaultShareBoxSubjectForName: function(name)
|
||||
{
|
||||
return (name || "Somebody") + " invited you to an EtherPad document";
|
||||
},
|
||||
relayoutWithBottom: function(px)
|
||||
{
|
||||
$("#modaloverlay").height(px);
|
||||
$("#sharebox").css('left', Math.floor(($(window).width() - $("#sharebox").outerWidth()) / 2));
|
||||
$("#feedbackbox").css('left', Math.floor(($(window).width() - $("#feedbackbox").outerWidth()) / 2));
|
||||
},
|
||||
showFeedback: function()
|
||||
{
|
||||
self.showModal("#feedbackbox");
|
||||
},
|
||||
showShareBox: function()
|
||||
{
|
||||
// when showing the dialog, if it still says "Somebody" invited you
|
||||
// then we fill in the updated username if there is one;
|
||||
// otherwise, we don't touch it, perhaps the user is happy with it
|
||||
var msgbox = $("#sharebox-message");
|
||||
if (msgbox.val() == self.getDefaultShareBoxMessageForName(null))
|
||||
{
|
||||
msgbox.val(self.getDefaultShareBoxMessageForName(pad.getUserName()));
|
||||
}
|
||||
var subjBox = $("#sharebox-subject");
|
||||
if (subjBox.val() == self.getDefaultShareBoxSubjectForName(null))
|
||||
{
|
||||
subjBox.val(self.getDefaultShareBoxSubjectForName(pad.getUserName()));
|
||||
}
|
||||
|
||||
if (pad.isPadPublic())
|
||||
{
|
||||
$("#sharebox-stripe").get(0).className = 'sharebox-stripe-public';
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#sharebox-stripe").get(0).className = 'sharebox-stripe-private';
|
||||
}
|
||||
|
||||
self.showModal("#sharebox", 500);
|
||||
$("#sharebox-url").focus().select();
|
||||
},
|
||||
showModal: function(modalId, duration)
|
||||
{
|
||||
|
@ -218,155 +68,6 @@ var padmodals = (function()
|
|||
$("#modaloverlay").hide();
|
||||
});
|
||||
},
|
||||
hideFeedbackLaterIfNoOtherInteraction: function()
|
||||
{
|
||||
return padutils.getCancellableAction('hide-feedbackbox', function()
|
||||
{
|
||||
self.hideModal();
|
||||
});
|
||||
},
|
||||
hideShareboxLaterIfNoOtherInteraction: function()
|
||||
{
|
||||
return padutils.getCancellableAction('hide-sharebox', function()
|
||||
{
|
||||
self.hideModal();
|
||||
});
|
||||
},
|
||||
/* sendFeedbackEmail: function() {
|
||||
if (sendingFeedback) {
|
||||
return;
|
||||
}
|
||||
var message = $("#feedbackbox-message").val();
|
||||
if (! message) {
|
||||
return;
|
||||
}
|
||||
var email = ($("#feedbackbox-email").hasClass('editempty') ? '' :
|
||||
$("#feedbackbox-email").val());
|
||||
var padId = pad.getPadId();
|
||||
var username = pad.getUserName();
|
||||
setSendingFeedback(true);
|
||||
$("#feedbackbox-response").html("Sending...").get(0).className = '';
|
||||
$("#feedbackbox-response").show();
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/ep/pad/feedback',
|
||||
data: {
|
||||
feedback: message,
|
||||
padId: padId,
|
||||
username: username,
|
||||
email: email
|
||||
},
|
||||
success: success,
|
||||
error: error
|
||||
});
|
||||
var hideCall = self.hideFeedbackLaterIfNoOtherInteraction();
|
||||
function success(msg) {
|
||||
setSendingFeedback(false);
|
||||
clearFeedback();
|
||||
$("#feedbackbox-response").html("Thanks for your feedback").get(0).className = 'goodresponse';
|
||||
$("#feedbackbox-response").show();
|
||||
window.setTimeout(function() {
|
||||
$("#feedbackbox-response").fadeOut('slow', function() {
|
||||
hideCall();
|
||||
});
|
||||
}, 1500);
|
||||
}
|
||||
function error(e) {
|
||||
setSendingFeedback(false);
|
||||
$("#feedbackbox-response").html("Could not send feedback. Please email us at feedback"+"@"+"etherpad.com instead.").get(0).className = 'badresponse';
|
||||
$("#feedbackbox-response").show();
|
||||
}
|
||||
},*/
|
||||
sendInvite: function()
|
||||
{
|
||||
if (sendingInvite)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!pad.isFullyConnected())
|
||||
{
|
||||
displayErrorMessage("Error: Connection to the server is down or flaky.");
|
||||
return;
|
||||
}
|
||||
var message = $("#sharebox-message").val();
|
||||
if (!message)
|
||||
{
|
||||
displayErrorMessage("Please enter a message body before sending.");
|
||||
return;
|
||||
}
|
||||
var emails = ($("#sharebox-to").hasClass('editempty') ? '' : $("#sharebox-to").val()) || '';
|
||||
// find runs of characters that aren't obviously non-email punctuation
|
||||
var emailArray = emails.match(/[^\s,:;<>\"\'\/\(\)\[\]{}]+/g) || [];
|
||||
if (emailArray.length == 0)
|
||||
{
|
||||
displayErrorMessage('Please enter at least one "To:" address.');
|
||||
$("#sharebox-to").focus().select();
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < emailArray.length; i++)
|
||||
{
|
||||
var addr = emailArray[i];
|
||||
if (!addr.match(/^[\w\.\_\+\-]+\@[\w\_\-]+\.[\w\_\-\.]+$/))
|
||||
{
|
||||
displayErrorMessage('"' + padutils.escapeHtml(addr) + '" does not appear to be a valid email address.');
|
||||
return;
|
||||
}
|
||||
}
|
||||
var subject = $("#sharebox-subject").val();
|
||||
if (!subject)
|
||||
{
|
||||
subject = self.getDefaultShareBoxSubjectForName(pad.getUserName());
|
||||
$("#sharebox-subject").val(subject); // force the default subject
|
||||
}
|
||||
|
||||
var padId = pad.getPadId();
|
||||
var username = pad.getUserName();
|
||||
setSendingInvite(true);
|
||||
$("#sharebox-response").html("Sending...").get(0).className = '';
|
||||
$("#sharebox-response").show();
|
||||
$.ajax(
|
||||
{
|
||||
type: 'post',
|
||||
url: '/ep/pad/emailinvite',
|
||||
data: {
|
||||
message: message,
|
||||
toEmails: emailArray.join(','),
|
||||
subject: subject,
|
||||
username: username,
|
||||
padId: padId
|
||||
},
|
||||
success: success,
|
||||
error: error
|
||||
});
|
||||
var hideCall = self.hideShareboxLaterIfNoOtherInteraction();
|
||||
|
||||
function success(msg)
|
||||
{
|
||||
setSendingInvite(false);
|
||||
$("#sharebox-response").html("Email invitation sent!").get(0).className = 'goodresponse';
|
||||
$("#sharebox-response").show();
|
||||
window.setTimeout(function()
|
||||
{
|
||||
$("#sharebox-response").fadeOut('slow', function()
|
||||
{
|
||||
hideCall();
|
||||
});
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
function error(e)
|
||||
{
|
||||
setSendingFeedback(false);
|
||||
$("#sharebox-response").html("An error occurred; no email was sent.").get(0).className = 'badresponse';
|
||||
$("#sharebox-response").show();
|
||||
}
|
||||
|
||||
function displayErrorMessage(msgHtml)
|
||||
{
|
||||
$("#sharebox-response").html(msgHtml).get(0).className = 'badresponse';
|
||||
$("#sharebox-response").show();
|
||||
}
|
||||
}
|
||||
};
|
||||
return self;
|
||||
}());
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
// assigns to the global `$` and augments it with plugins.
|
||||
require('./jquery');
|
||||
JSON = require('./json2');
|
||||
require('./undo-xpopup');
|
||||
|
||||
var createCookie = require('./pad_utils').createCookie;
|
||||
var readCookie = require('./pad_utils').readCookie;
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
/**
|
||||
* This code is mostly from the old Etherpad. Please help us to comment this code.
|
||||
* This helps other people to understand this code better and helps them to improve it.
|
||||
* TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
if (window._orig_windowOpen)
|
||||
{
|
||||
window.open = _orig_windowOpen;
|
||||
}
|
||||
if (window._orig_windowSetTimeout)
|
||||
{
|
||||
window.setTimeout = _orig_windowSetTimeout;
|
||||
}
|
||||
if (window._orig_windowSetInterval)
|
||||
{
|
||||
window.setInterval = _orig_windowSetInterval;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue