making DiscussionViewer testable, removing some inconsistency
This commit is contained in:
parent
928215dc5e
commit
d80c2f83fa
1 changed files with 37 additions and 31 deletions
|
@ -2090,11 +2090,9 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
* (view) Shows discussion thread and handles replies
|
* (view) Shows discussion thread and handles replies
|
||||||
*
|
*
|
||||||
* @name DiscussionViewer
|
* @name DiscussionViewer
|
||||||
* @param {object} window
|
|
||||||
* @param {object} document
|
|
||||||
* @class
|
* @class
|
||||||
*/
|
*/
|
||||||
var DiscussionViewer = (function (window, document) {
|
var DiscussionViewer = (function () {
|
||||||
var me = {};
|
var me = {};
|
||||||
|
|
||||||
var $commentTail,
|
var $commentTail,
|
||||||
|
@ -2286,10 +2284,10 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
* removes the old discussion and prepares everything for creating a new
|
* removes the old discussion and prepares everything for creating a new
|
||||||
* one.
|
* one.
|
||||||
*
|
*
|
||||||
* @name DiscussionViewer.prepareNewDisucssion
|
* @name DiscussionViewer.prepareNewDiscussion
|
||||||
* @function
|
* @function
|
||||||
*/
|
*/
|
||||||
me.prepareNewDisucssion = function()
|
me.prepareNewDiscussion = function()
|
||||||
{
|
{
|
||||||
$commentContainer.html('');
|
$commentContainer.html('');
|
||||||
$discussion.addClass('hidden');
|
$discussion.addClass('hidden');
|
||||||
|
@ -2299,18 +2297,39 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the user put into the reply form
|
* returns the users message from the reply form
|
||||||
*
|
*
|
||||||
* @name DiscussionViewer.getReplyData
|
* @name DiscussionViewer.getReplyMessage
|
||||||
* @function
|
* @function
|
||||||
* @return {array}
|
* @return {String}
|
||||||
*/
|
*/
|
||||||
me.getReplyData = function()
|
me.getReplyMessage = function()
|
||||||
{
|
{
|
||||||
return [
|
return $replyMessage.val();
|
||||||
$replyMessage.val(),
|
}
|
||||||
$replyNickname.val()
|
|
||||||
];
|
/**
|
||||||
|
* returns the users nickname (if any) from the reply form
|
||||||
|
*
|
||||||
|
* @name DiscussionViewer.getReplyNickname
|
||||||
|
* @function
|
||||||
|
* @return {String}
|
||||||
|
*/
|
||||||
|
me.getReplyNickname = function()
|
||||||
|
{
|
||||||
|
return $replyNickname.val();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the id of the parent comment the user is replying to
|
||||||
|
*
|
||||||
|
* @name DiscussionViewer.getReplyCommentId
|
||||||
|
* @function
|
||||||
|
* @return {int|undefined}
|
||||||
|
*/
|
||||||
|
me.getReplyCommentId = function()
|
||||||
|
{
|
||||||
|
return replyCommentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2345,18 +2364,6 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
UiHelper.scrollTo($comment, 100, 'swing', highlightComment);
|
UiHelper.scrollTo($comment, 100, 'swing', highlightComment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* returns the id of the parent comment the user is replying to
|
|
||||||
*
|
|
||||||
* @name DiscussionViewer.getReplyCommentId
|
|
||||||
* @function
|
|
||||||
* @return {int|undefined}
|
|
||||||
*/
|
|
||||||
me.getReplyCommentId = function()
|
|
||||||
{
|
|
||||||
return replyCommentId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initiate
|
* initiate
|
||||||
*
|
*
|
||||||
|
@ -2376,7 +2383,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return me;
|
return me;
|
||||||
})(window, document);
|
})();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage top (navigation) bar
|
* Manage top (navigation) bar
|
||||||
|
@ -3361,10 +3368,9 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
TopNav.hideAllButtons();
|
TopNav.hideAllButtons();
|
||||||
Alert.showLoading('Sending comment…', 0, 'cloud-upload');
|
Alert.showLoading('Sending comment…', 0, 'cloud-upload');
|
||||||
|
|
||||||
// get data, note that "var [x, y] = " structures aren't supported in all JS environments
|
// get data
|
||||||
var replyData = DiscussionViewer.getReplyData(),
|
var plainText = DiscussionViewer.getReplyMessage(),
|
||||||
plainText = replyData[0],
|
nickname = DiscussionViewer.getReplyNickname(),
|
||||||
nickname = replyData[1],
|
|
||||||
parentid = DiscussionViewer.getReplyCommentId();
|
parentid = DiscussionViewer.getReplyCommentId();
|
||||||
|
|
||||||
// do not send if there is no data
|
// do not send if there is no data
|
||||||
|
@ -3661,7 +3667,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
function decryptComments(paste, key, password)
|
function decryptComments(paste, key, password)
|
||||||
{
|
{
|
||||||
// remove potentially previous discussion
|
// remove potentially previous discussion
|
||||||
DiscussionViewer.prepareNewDisucssion();
|
DiscussionViewer.prepareNewDiscussion();
|
||||||
|
|
||||||
// iterate over comments
|
// iterate over comments
|
||||||
for (var i = 0; i < paste.comments.length; ++i) {
|
for (var i = 0; i < paste.comments.length; ++i) {
|
||||||
|
|
Loading…
Reference in a new issue