Abspeichern des Namen funktioniert
This commit is contained in:
parent
eda1e4d82e
commit
f103b057aa
5
includes/.htaccess
Executable file
5
includes/.htaccess
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
## Default .htaccess file
|
||||||
|
# Displaying PHP errors
|
||||||
|
php_flag display_errors on
|
||||||
|
php_value error_reporting 6143
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,52 +1,56 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class CommentBlockAPI extends ApiBase {
|
class CommentBlockAPI extends ApiBase {
|
||||||
|
|
||||||
public function execute() {
|
public function execute() {
|
||||||
// Do nothing when the database is in read-only mode
|
// Do nothing when the database is in read-only mode
|
||||||
if ( wfReadOnly() ) {
|
if ( wfReadOnly() ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load user_name and user_id for person we want to block from the comment it originated from
|
// Load user_name and user_id for person we want to block from the comment it originated from
|
||||||
$dbr = wfGetDB( DB_SLAVE );
|
$dbr = wfGetDB( DB_SLAVE );
|
||||||
$s = $dbr->selectRow(
|
$s = $dbr->selectRow(
|
||||||
'Comments',
|
'Comments',
|
||||||
array( 'comment_username', 'comment_user_id' ),
|
array( 'comment_username', 'comment_user_id' ),
|
||||||
array( 'CommentID' => $this->getMain()->getVal( 'commentID' ) ),
|
array( 'CommentID' => $this->getMain()->getVal( 'commentID' ) ),
|
||||||
__METHOD__
|
__METHOD__
|
||||||
);
|
);
|
||||||
if ( $s !== false ) {
|
if ( $s !== false ) {
|
||||||
$userID = $s->comment_user_id;
|
$userID = $s->comment_user_id;
|
||||||
$username = $s->comment_username;
|
$username = $s->comment_username;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommentFunctions::blockUser( $this->getUser(), $userID, $username );
|
CommentFunctions::blockUser( $this->getUser(), $userID, $username );
|
||||||
|
|
||||||
if ( class_exists( 'UserStatsTrack' ) ) {
|
if ( class_exists( 'UserStatsTrack' ) ) {
|
||||||
$stats = new UserStatsTrack( $userID, $username );
|
$stats = new UserStatsTrack( $userID, $username );
|
||||||
$stats->incStatField( 'comment_ignored' );
|
$stats->incStatField( 'comment_ignored' );
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->getResult();
|
$result = $this->getResult();
|
||||||
$result->addValue( $this->getModuleName(), 'ok', 'ok' );
|
$result->addValue( $this->getModuleName(), 'ok', 'ok' );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function needsToken() {
|
public function needsToken() {
|
||||||
return 'csrf';
|
return 'csrf';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isWriteMode() {
|
public function isWriteMode() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAllowedParams() {
|
public function getAllowedParams() {
|
||||||
return array(
|
return array(
|
||||||
'commentID' => array(
|
'commentID' => array(
|
||||||
ApiBase::PARAM_REQUIRED => true,
|
ApiBase::PARAM_REQUIRED => true,
|
||||||
ApiBase::PARAM_TYPE => 'integer'
|
ApiBase::PARAM_TYPE => 'integer'
|
||||||
)
|
),
|
||||||
);
|
'UsernameKOK' => array(
|
||||||
}
|
ApiBase::PARAM_REQUIRED => false,
|
||||||
}
|
ApiBase::PARAM_TYPE => 'string'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,73 +1,79 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class CommentSubmitAPI extends ApiBase {
|
class CommentSubmitAPI extends ApiBase {
|
||||||
|
|
||||||
public function execute() {
|
public function execute() {
|
||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
// Blocked users cannot submit new comments, and neither can those users
|
// Blocked users cannot submit new comments, and neither can those users
|
||||||
// without the necessary privileges. Also prevent obvious cross-site request
|
// without the necessary privileges. Also prevent obvious cross-site request
|
||||||
// forgeries (CSRF)
|
// forgeries (CSRF)
|
||||||
if (
|
if (
|
||||||
$user->isBlocked() ||
|
$user->isBlocked() ||
|
||||||
!$user->isAllowed( 'comment' ) ||
|
!$user->isAllowed( 'comment' ) ||
|
||||||
wfReadOnly()
|
wfReadOnly()
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$commentText = $this->getMain()->getVal( 'commentText' );
|
$commentText = $this->getMain()->getVal( 'commentText' );
|
||||||
|
|
||||||
if ( $commentText != '' ) {
|
if ( $commentText != '' ) {
|
||||||
// To protect against spam, it's necessary to check the supplied text
|
// To protect against spam, it's necessary to check the supplied text
|
||||||
// against spam filters (but comment admins are allowed to bypass the
|
// against spam filters (but comment admins are allowed to bypass the
|
||||||
// spam filters)
|
// spam filters)
|
||||||
if ( !$user->isAllowed( 'commentadmin' ) && CommentFunctions::isSpam( $commentText ) ) {
|
if ( !$user->isAllowed( 'commentadmin' ) && CommentFunctions::isSpam( $commentText ) ) {
|
||||||
$this->dieUsage( wfMessage( 'comments-is-spam' )->plain(), 'comments-is-spam' );
|
$this->dieUsage( wfMessage( 'comments-is-spam' )->plain(), 'comments-is-spam' );
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the comment contains links but the user isn't allowed to post
|
// If the comment contains links but the user isn't allowed to post
|
||||||
// links, reject the submission
|
// links, reject the submission
|
||||||
if ( !$user->isAllowed( 'commentlinks' ) && CommentFunctions::haveLinks( $commentText ) ) {
|
if ( !$user->isAllowed( 'commentlinks' ) && CommentFunctions::haveLinks( $commentText ) ) {
|
||||||
$this->dieUsage( wfMessage( 'comments-links-are-forbidden' )->plain(), 'comments-links-are-forbidden' );
|
$this->dieUsage( wfMessage( 'comments-links-are-forbidden' )->plain(), 'comments-links-are-forbidden' );
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = new CommentsPage( $this->getMain()->getVal( 'pageID' ), $this->getContext() );
|
$page = new CommentsPage( $this->getMain()->getVal( 'pageID' ), $this->getContext() );
|
||||||
|
|
||||||
Comment::add( $commentText, $page, $user, $this->getMain()->getVal( 'parentID' ) );
|
Comment::add( $commentText, $page, $user, $this->getMain()->getVal( 'parentID' ) );
|
||||||
|
|
||||||
if ( class_exists( 'UserStatsTrack' ) ) {
|
if ( class_exists( 'UserStatsTrack' ) ) {
|
||||||
$stats = new UserStatsTrack( $user->getID(), $user->getName() );
|
$stats = new UserStatsTrack( $user->getID(), $user->getName() );
|
||||||
$stats->incStatField( 'comment' );
|
$stats->incStatField( 'comment' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->getResult();
|
$kok_username = $this->getMain()->getVal( 'UsernameKOK' );
|
||||||
$result->addValue( $this->getModuleName(), 'ok', 'ok' );
|
|
||||||
return true;
|
$result = $this->getResult();
|
||||||
}
|
$result->addValue( $this->getModuleName(), 'ok', 'ok' );
|
||||||
|
return true;
|
||||||
public function needsToken() {
|
}
|
||||||
return 'csrf';
|
|
||||||
}
|
public function needsToken() {
|
||||||
|
return 'csrf';
|
||||||
public function isWriteMode() {
|
}
|
||||||
return true;
|
|
||||||
}
|
public function isWriteMode() {
|
||||||
|
return true;
|
||||||
public function getAllowedParams() {
|
}
|
||||||
return array(
|
|
||||||
'pageID' => array(
|
public function getAllowedParams() {
|
||||||
ApiBase::PARAM_REQUIRED => true,
|
return array(
|
||||||
ApiBase::PARAM_TYPE => 'integer'
|
'pageID' => array(
|
||||||
),
|
ApiBase::PARAM_REQUIRED => true,
|
||||||
'parentID' => array(
|
ApiBase::PARAM_TYPE => 'integer'
|
||||||
ApiBase::PARAM_REQUIRED => false,
|
),
|
||||||
ApiBase::PARAM_TYPE => 'integer'
|
'parentID' => array(
|
||||||
),
|
ApiBase::PARAM_REQUIRED => false,
|
||||||
'commentText' => array(
|
ApiBase::PARAM_TYPE => 'integer'
|
||||||
ApiBase::PARAM_REQUIRED => true,
|
),
|
||||||
ApiBase::PARAM_TYPE => 'string'
|
'commentText' => array(
|
||||||
)
|
ApiBase::PARAM_REQUIRED => true,
|
||||||
);
|
ApiBase::PARAM_TYPE => 'string'
|
||||||
}
|
),
|
||||||
}
|
'UsernameKOK' => array(
|
||||||
|
ApiBase::PARAM_REQUIRED => false,
|
||||||
|
ApiBase::PARAM_TYPE => 'string'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,347 +1,358 @@
|
|||||||
/**
|
/**
|
||||||
* JavaScript for the Comments extension.
|
* JavaScript for the Comments extension.
|
||||||
* Rewritten by Jack Phoenix <jack@countervandalism.net> to be more
|
* Rewritten by Jack Phoenix <jack@countervandalism.net> to be more
|
||||||
* object-oriented.
|
* object-oriented.
|
||||||
*
|
*
|
||||||
* @file
|
* @file
|
||||||
* @date 6 December 2013
|
* @date 6 December 2013
|
||||||
*/
|
*/
|
||||||
( function ( $, mw ) {
|
( function ( $, mw ) {
|
||||||
var Comment = {
|
var Comment = {
|
||||||
submitted: 0,
|
submitted: 0,
|
||||||
isBusy: false,
|
isBusy: false,
|
||||||
timer: '', // has to have an initial value...
|
timer: '', // has to have an initial value...
|
||||||
updateDelay: 7000,
|
updateDelay: 7000,
|
||||||
LatestCommentID: '',
|
LatestCommentID: '',
|
||||||
CurLatestCommentID: '',
|
CurLatestCommentID: '',
|
||||||
pause: 0,
|
pause: 0,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When a comment's author is ignored, "Show Comment" link will be
|
* When a comment's author is ignored, "Show Comment" link will be
|
||||||
* presented to the user.
|
* presented to the user.
|
||||||
* If the user clicks on it, this function is called to show the hidden
|
* If the user clicks on it, this function is called to show the hidden
|
||||||
* comment.
|
* comment.
|
||||||
*/
|
*/
|
||||||
show: function( id ) {
|
show: function( id ) {
|
||||||
$( '#ignore-' + id ).hide( 300 );
|
$( '#ignore-' + id ).hide( 300 );
|
||||||
$( '#comment-' + id ).show( 300 );
|
$( '#comment-' + id ).show( 300 );
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is called whenever a user clicks on the "block" image to
|
* This function is called whenever a user clicks on the "block" image to
|
||||||
* block another user's comments.
|
* block another user's comments.
|
||||||
*
|
*
|
||||||
* @param username String: name of the user whose comments we want to block
|
* @param username String: name of the user whose comments we want to block
|
||||||
* @param userID Integer: user ID number of the user whose comments we
|
* @param userID Integer: user ID number of the user whose comments we
|
||||||
* want to block (or 0 for anonymous users)
|
* want to block (or 0 for anonymous users)
|
||||||
* @param commentID Integer: comment ID number
|
* @param commentID Integer: comment ID number
|
||||||
*/
|
*/
|
||||||
blockUser: function( username, userID, commentID ) {
|
blockUser: function( username, userID, commentID ) {
|
||||||
var message;
|
var message;
|
||||||
|
|
||||||
// Display a different message depending on whether we're blocking an
|
// Display a different message depending on whether we're blocking an
|
||||||
// anonymous user or a registered one.
|
// anonymous user or a registered one.
|
||||||
if ( !userID || userID === 0 ) {
|
if ( !userID || userID === 0 ) {
|
||||||
message = mw.msg( 'comments-block-warning-anon' );
|
message = mw.msg( 'comments-block-warning-anon' );
|
||||||
} else {
|
} else {
|
||||||
message = mw.msg( 'comments-block-warning-user', username );
|
message = mw.msg( 'comments-block-warning-user', username );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( window.confirm( message ) ) {
|
if ( window.confirm( message ) ) {
|
||||||
( new mw.Api() ).postWithToken( 'csrf', {
|
( new mw.Api() ).postWithToken( 'csrf', {
|
||||||
action: 'commentblock',
|
action: 'commentblock',
|
||||||
commentID: commentID
|
commentID: commentID
|
||||||
} ).done( function( response ) {
|
} ).done( function( response ) {
|
||||||
if ( response.commentblock.ok ) {
|
if ( response.commentblock.ok ) {
|
||||||
$( 'a.comments-block-user[data-comments-user-id=' + userID + ']' )
|
$( 'a.comments-block-user[data-comments-user-id=' + userID + ']' )
|
||||||
.parents( '.c-item' ).hide( 300 )
|
.parents( '.c-item' ).hide( 300 )
|
||||||
.prev().show( 300 );
|
.prev().show( 300 );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is called whenever a user clicks on the "Delete Comment"
|
* This function is called whenever a user clicks on the "Delete Comment"
|
||||||
* link to delete a comment.
|
* link to delete a comment.
|
||||||
*
|
*
|
||||||
* @param commentID Integer: comment ID number
|
* @param commentID Integer: comment ID number
|
||||||
*/
|
*/
|
||||||
deleteComment: function( commentID ) {
|
deleteComment: function( commentID ) {
|
||||||
if ( window.confirm( mw.msg( 'comments-delete-warning' ) ) ) {
|
if ( window.confirm( mw.msg( 'comments-delete-warning' ) ) ) {
|
||||||
( new mw.Api() ).postWithToken( 'csrf', {
|
( new mw.Api() ).postWithToken( 'csrf', {
|
||||||
action: 'commentdelete',
|
action: 'commentdelete',
|
||||||
commentID: commentID
|
commentID: commentID
|
||||||
} ).done( function( response ) {
|
} ).done( function( response ) {
|
||||||
if ( response.commentdelete.ok ) {
|
if ( response.commentdelete.ok ) {
|
||||||
$( '#comment-' + commentID ).hide( 2000 );
|
$( '#comment-' + commentID ).hide( 2000 );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vote for a comment.
|
* Vote for a comment.
|
||||||
*
|
*
|
||||||
* @param commentID Integer: comment ID number
|
* @param commentID Integer: comment ID number
|
||||||
* @param voteValue Integer: vote value
|
* @param voteValue Integer: vote value
|
||||||
*/
|
*/
|
||||||
vote: function( commentID, voteValue ) {
|
vote: function( commentID, voteValue ) {
|
||||||
( new mw.Api() ).postWithToken( 'csrf', {
|
( new mw.Api() ).postWithToken( 'csrf', {
|
||||||
action: 'commentvote',
|
action: 'commentvote',
|
||||||
commentID: commentID,
|
commentID: commentID,
|
||||||
voteValue: voteValue
|
voteValue: voteValue
|
||||||
} ).done( function( response ) {
|
} ).done( function( response ) {
|
||||||
$( '#comment-' + commentID + ' .c-score' )
|
$( '#comment-' + commentID + ' .c-score' )
|
||||||
.html( response.commentvote.html ) // this will still be escaped
|
.html( response.commentvote.html ) // this will still be escaped
|
||||||
.html( $( '#comment-' + commentID + ' .c-score' ).text() ); // unescape
|
.html( $( '#comment-' + commentID + ' .c-score' ).text() ); // unescape
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param pageID Integer: page ID
|
* @param pageID Integer: page ID
|
||||||
* @param order Sorting order
|
* @param order Sorting order
|
||||||
* @param end Scroll to bottom after?
|
* @param end Scroll to bottom after?
|
||||||
* @param cpage Integer: comment page number (used for pagination)
|
* @param cpage Integer: comment page number (used for pagination)
|
||||||
*/
|
*/
|
||||||
viewComments: function( pageID, order, end, cpage ) {
|
viewComments: function( pageID, order, end, cpage ) {
|
||||||
document.commentForm.cpage.value = cpage;
|
document.commentForm.cpage.value = cpage;
|
||||||
document.getElementById( 'allcomments' ).innerHTML = mw.msg( 'comments-loading' ) + '<br /><br />';
|
document.getElementById( 'allcomments' ).innerHTML = mw.msg( 'comments-loading' ) + '<br /><br />';
|
||||||
|
|
||||||
$.ajax( {
|
$.ajax( {
|
||||||
url: mw.config.get( 'wgScriptPath' ) + '/api.php',
|
url: mw.config.get( 'wgScriptPath' ) + '/api.php',
|
||||||
data: { 'action': 'commentlist', 'format': 'json', 'pageID': pageID, 'order': order, 'pagerPage': cpage },
|
data: { 'action': 'commentlist', 'format': 'json', 'pageID': pageID, 'order': order, 'pagerPage': cpage },
|
||||||
cache: false
|
cache: false
|
||||||
} ).done( function( response ) {
|
} ).done( function( response ) {
|
||||||
document.getElementById( 'allcomments' ).innerHTML = response.commentlist.html;
|
document.getElementById( 'allcomments' ).innerHTML = response.commentlist.html;
|
||||||
Comment.submitted = 0;
|
Comment.submitted = 0;
|
||||||
if ( end ) {
|
if ( end ) {
|
||||||
window.location.hash = 'end';
|
window.location.hash = 'end';
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Submit a new comment.
|
* Submit a new comment.
|
||||||
*/
|
*/
|
||||||
submit: function() {
|
submit: function() {
|
||||||
if ( Comment.submitted === 0 ) {
|
if ( Comment.submitted === 0 ) {
|
||||||
Comment.submitted = 1;
|
Comment.submitted = 1;
|
||||||
|
|
||||||
var pageID = document.commentForm.pageId.value;
|
var pageID = document.commentForm.pageId.value;
|
||||||
var parentID;
|
var parentID;
|
||||||
if ( !document.commentForm.commentParentId.value ) {
|
if ( !document.commentForm.commentParentId.value ) {
|
||||||
parentID = 0;
|
parentID = 0;
|
||||||
} else {
|
} else {
|
||||||
parentID = document.commentForm.commentParentId.value;
|
parentID = document.commentForm.commentParentId.value;
|
||||||
}
|
}
|
||||||
var commentText = document.commentForm.commentText.value;
|
var commentText = document.commentForm.commentText.value;
|
||||||
|
/* ## START ## 27.09.2017 von Bernhard Linz: Prüfen ob txt_username einen Wert enthält. wenn nicht, ignorieren */
|
||||||
( new mw.Api() ).postWithToken( 'csrf', {
|
var UsernameKOK;
|
||||||
action: 'commentsubmit',
|
if (document.getElementById('txt_username')) {
|
||||||
pageID: pageID,
|
// UsernameKOK = document.commentform.txt_username.value; /* Wert aus txt_username in die Variable übergeben, welche später an Comments_AjaxFunctions.php übergeben wird */
|
||||||
parentID: parentID,
|
UsernameKOK = document.getElementById('txt_username').value;
|
||||||
commentText: commentText
|
} else {
|
||||||
} ).done( function( response ) {
|
UsernameKOK = "none"; /* Wenn Feld nicht existiert Variable auf "none" setzen */
|
||||||
if ( response.commentsubmit && response.commentsubmit.ok ) {
|
}
|
||||||
document.commentForm.commentText.value = '';
|
commentText = commentText + "#START#" + UsernameKOK + "#ENDE#";
|
||||||
var end = 1;
|
//window.alert( UsernameKOK );
|
||||||
if ( mw.config.get( 'wgCommentsSortDescending' ) ) {
|
/* ## ENDE ## 27.09.2017 von Bernhard Linz */
|
||||||
end = 0;
|
( new mw.Api() ).postWithToken( 'csrf', {
|
||||||
}
|
action: 'commentsubmit',
|
||||||
Comment.viewComments( document.commentForm.pageId.value, 0, end, document.commentForm.cpage.value );
|
pageID: pageID,
|
||||||
} else {
|
parentID: parentID,
|
||||||
window.alert( response.error.info );
|
commentText: commentText
|
||||||
Comment.submitted = 0;
|
//UsernameKOK: UsernameKOK
|
||||||
}
|
} ).done( function( response ) {
|
||||||
} );
|
if ( response.commentsubmit && response.commentsubmit.ok ) {
|
||||||
|
document.commentForm.commentText.value = '';
|
||||||
Comment.cancelReply();
|
var end = 1;
|
||||||
}
|
if ( mw.config.get( 'wgCommentsSortDescending' ) ) {
|
||||||
},
|
end = 0;
|
||||||
|
}
|
||||||
/**
|
Comment.viewComments( document.commentForm.pageId.value, 0, end, document.commentForm.cpage.value );
|
||||||
* Toggle comment auto-refreshing on or off
|
} else {
|
||||||
*
|
window.alert( response.error.info );
|
||||||
* @param status
|
Comment.submitted = 0;
|
||||||
*/
|
}
|
||||||
toggleLiveComments: function( status ) {
|
} );
|
||||||
if ( status ) {
|
|
||||||
Comment.pause = 0;
|
Comment.cancelReply();
|
||||||
} else {
|
}
|
||||||
Comment.pause = 1;
|
},
|
||||||
}
|
|
||||||
var msg;
|
/**
|
||||||
if ( status ) {
|
* Toggle comment auto-refreshing on or off
|
||||||
msg = mw.msg( 'comments-auto-refresher-pause' );
|
*
|
||||||
} else {
|
* @param status
|
||||||
msg = mw.msg( 'comments-auto-refresher-enable' );
|
*/
|
||||||
}
|
toggleLiveComments: function( status ) {
|
||||||
|
if ( status ) {
|
||||||
$( 'body' ).on( 'click', 'div#spy a', function() {
|
Comment.pause = 0;
|
||||||
Comment.toggleLiveComments( ( status ) ? 0 : 1 );
|
} else {
|
||||||
} );
|
Comment.pause = 1;
|
||||||
$( 'div#spy a' ).css( 'font-size', '10px' ).text( msg );
|
}
|
||||||
|
var msg;
|
||||||
if ( !Comment.pause ) {
|
if ( status ) {
|
||||||
Comment.LatestCommentID = document.commentForm.lastCommentId.value;
|
msg = mw.msg( 'comments-auto-refresher-pause' );
|
||||||
Comment.timer = setTimeout(
|
} else {
|
||||||
function() { Comment.checkUpdate(); },
|
msg = mw.msg( 'comments-auto-refresher-enable' );
|
||||||
Comment.updateDelay
|
}
|
||||||
);
|
|
||||||
}
|
$( 'body' ).on( 'click', 'div#spy a', function() {
|
||||||
},
|
Comment.toggleLiveComments( ( status ) ? 0 : 1 );
|
||||||
|
} );
|
||||||
checkUpdate: function() {
|
$( 'div#spy a' ).css( 'font-size', '10px' ).text( msg );
|
||||||
if ( Comment.isBusy ) {
|
|
||||||
return;
|
if ( !Comment.pause ) {
|
||||||
}
|
Comment.LatestCommentID = document.commentForm.lastCommentId.value;
|
||||||
var pageID = document.commentForm.pageId.value;
|
Comment.timer = setTimeout(
|
||||||
|
function() { Comment.checkUpdate(); },
|
||||||
$.ajax( {
|
Comment.updateDelay
|
||||||
url: mw.config.get( 'wgScriptPath' ) + '/api.php',
|
);
|
||||||
data: { 'action': 'commentlatestid', 'format': 'json', 'pageID': pageID },
|
}
|
||||||
cache: false
|
},
|
||||||
} ).done( function( response ) {
|
|
||||||
if ( response.commentlatestid.id ) {
|
checkUpdate: function() {
|
||||||
// Get last new ID
|
if ( Comment.isBusy ) {
|
||||||
Comment.CurLatestCommentID = response.commentlatestid.id;
|
return;
|
||||||
if ( Comment.CurLatestCommentID !== Comment.LatestCommentID ) {
|
}
|
||||||
Comment.viewComments( document.commentForm.pageId.value, 0, 1, document.commentForm.cpage.value );
|
var pageID = document.commentForm.pageId.value;
|
||||||
Comment.LatestCommentID = Comment.CurLatestCommentID;
|
|
||||||
}
|
$.ajax( {
|
||||||
}
|
url: mw.config.get( 'wgScriptPath' ) + '/api.php',
|
||||||
|
data: { 'action': 'commentlatestid', 'format': 'json', 'pageID': pageID },
|
||||||
Comment.isBusy = false;
|
cache: false
|
||||||
if ( !Comment.pause ) {
|
} ).done( function( response ) {
|
||||||
clearTimeout( Comment.timer );
|
if ( response.commentlatestid.id ) {
|
||||||
Comment.timer = setTimeout(
|
// Get last new ID
|
||||||
function() { Comment.checkUpdate(); },
|
Comment.CurLatestCommentID = response.commentlatestid.id;
|
||||||
Comment.updateDelay
|
if ( Comment.CurLatestCommentID !== Comment.LatestCommentID ) {
|
||||||
);
|
Comment.viewComments( document.commentForm.pageId.value, 0, 1, document.commentForm.cpage.value );
|
||||||
}
|
Comment.LatestCommentID = Comment.CurLatestCommentID;
|
||||||
} );
|
}
|
||||||
|
}
|
||||||
Comment.isBusy = true;
|
|
||||||
return false;
|
Comment.isBusy = false;
|
||||||
},
|
if ( !Comment.pause ) {
|
||||||
|
clearTimeout( Comment.timer );
|
||||||
/**
|
Comment.timer = setTimeout(
|
||||||
* Show the "reply to user X" form
|
function() { Comment.checkUpdate(); },
|
||||||
*
|
Comment.updateDelay
|
||||||
* @param parentId Integer: parent comment (the one we're replying to) ID
|
);
|
||||||
* @param poster String: name of the person whom we're replying to
|
}
|
||||||
* @param posterGender String: gender of the person whom we're replying to
|
} );
|
||||||
*/
|
|
||||||
reply: function( parentId, poster, posterGender ) {
|
Comment.isBusy = true;
|
||||||
$( '#replyto' ).text(
|
return false;
|
||||||
mw.msg( 'comments-reply-to', poster, posterGender ) + ' ('
|
},
|
||||||
);
|
|
||||||
$( '<a>', {
|
/**
|
||||||
class: 'comments-cancel-reply-link',
|
* Show the "reply to user X" form
|
||||||
style: 'cursor:pointer',
|
*
|
||||||
text: mw.msg( 'comments-cancel-reply' )
|
* @param parentId Integer: parent comment (the one we're replying to) ID
|
||||||
} ).appendTo( '#replyto' );
|
* @param poster String: name of the person whom we're replying to
|
||||||
$( '#replyto' ).append( ') <br />' );
|
* @param posterGender String: gender of the person whom we're replying to
|
||||||
|
*/
|
||||||
document.commentForm.commentParentId.value = parentId;
|
reply: function( parentId, poster, posterGender ) {
|
||||||
},
|
$( '#replyto' ).text(
|
||||||
|
mw.msg( 'comments-reply-to', poster, posterGender ) + ' ('
|
||||||
cancelReply: function() {
|
);
|
||||||
document.getElementById( 'replyto' ).innerHTML = '';
|
$( '<a>', {
|
||||||
document.commentForm.commentParentId.value = '';
|
class: 'comments-cancel-reply-link',
|
||||||
}
|
style: 'cursor:pointer',
|
||||||
};
|
text: mw.msg( 'comments-cancel-reply' )
|
||||||
|
} ).appendTo( '#replyto' );
|
||||||
$( function() {
|
$( '#replyto' ).append( ') <br />' );
|
||||||
// Important note: these are all using $( 'body' ) as the selector
|
|
||||||
// instead of the class/ID/whatever so that they work after viewComments()
|
document.commentForm.commentParentId.value = parentId;
|
||||||
// has been called (i.e. so that "Delete comment", reply, etc. links
|
},
|
||||||
// continue working after you've submitted a comment yourself)
|
|
||||||
|
cancelReply: function() {
|
||||||
// "Sort by X" feature
|
document.getElementById( 'replyto' ).innerHTML = '';
|
||||||
$( 'body' ).on( 'change', 'select[name="TheOrder"]', function() {
|
document.commentForm.commentParentId.value = '';
|
||||||
Comment.viewComments(
|
}
|
||||||
mw.config.get( 'wgArticleId' ), // or we could use $( 'input[name="pid"]' ).val(), too
|
};
|
||||||
$( this ).val(),
|
|
||||||
0,
|
$( function() {
|
||||||
document.commentForm.cpage.value
|
// Important note: these are all using $( 'body' ) as the selector
|
||||||
);
|
// instead of the class/ID/whatever so that they work after viewComments()
|
||||||
} )
|
// has been called (i.e. so that "Delete comment", reply, etc. links
|
||||||
|
// continue working after you've submitted a comment yourself)
|
||||||
// Comment auto-refresher
|
|
||||||
.on( 'click', 'div#spy a', function() {
|
// "Sort by X" feature
|
||||||
Comment.toggleLiveComments( 1 );
|
$( 'body' ).on( 'change', 'select[name="TheOrder"]', function() {
|
||||||
} )
|
Comment.viewComments(
|
||||||
|
mw.config.get( 'wgArticleId' ), // or we could use $( 'input[name="pid"]' ).val(), too
|
||||||
// Voting links
|
$( this ).val(),
|
||||||
.on( 'click', 'a#comment-vote-link', function() {
|
0,
|
||||||
var that = $( this );
|
document.commentForm.cpage.value
|
||||||
Comment.vote(
|
);
|
||||||
that.data( 'comment-id' ),
|
} )
|
||||||
that.data( 'vote-type' )
|
|
||||||
);
|
// Comment auto-refresher
|
||||||
} )
|
.on( 'click', 'div#spy a', function() {
|
||||||
|
Comment.toggleLiveComments( 1 );
|
||||||
// "Block this user" links
|
} )
|
||||||
.on( 'click', 'a.comments-block-user', function() {
|
|
||||||
var that = $( this );
|
// Voting links
|
||||||
Comment.blockUser(
|
.on( 'click', 'a#comment-vote-link', function() {
|
||||||
that.data( 'comments-safe-username' ),
|
var that = $( this );
|
||||||
that.data( 'comments-user-id' ),
|
Comment.vote(
|
||||||
that.data( 'comments-comment-id' )
|
that.data( 'comment-id' ),
|
||||||
);
|
that.data( 'vote-type' )
|
||||||
} )
|
);
|
||||||
|
} )
|
||||||
// "Delete Comment" links
|
|
||||||
.on( 'click', 'a.comment-delete-link', function() {
|
// "Block this user" links
|
||||||
Comment.deleteComment( $( this ).data( 'comment-id' ) );
|
.on( 'click', 'a.comments-block-user', function() {
|
||||||
} )
|
var that = $( this );
|
||||||
|
Comment.blockUser(
|
||||||
// "Show this hidden comment" -- comments made by people on the user's
|
that.data( 'comments-safe-username' ),
|
||||||
// personal block list
|
that.data( 'comments-user-id' ),
|
||||||
.on( 'click', 'div.c-ignored-links a', function() {
|
that.data( 'comments-comment-id' )
|
||||||
Comment.show( $( this ).data( 'comment-id' ) );
|
);
|
||||||
} )
|
} )
|
||||||
|
|
||||||
// Reply links
|
// "Delete Comment" links
|
||||||
.on( 'click', 'a.comments-reply-to', function() {
|
.on( 'click', 'a.comment-delete-link', function() {
|
||||||
Comment.reply(
|
Comment.deleteComment( $( this ).data( 'comment-id' ) );
|
||||||
$( this ).data( 'comment-id' ),
|
} )
|
||||||
$( this ).data( 'comments-safe-username' ),
|
|
||||||
$( this ).data( 'comments-user-gender' )
|
// "Show this hidden comment" -- comments made by people on the user's
|
||||||
);
|
// personal block list
|
||||||
} )
|
.on( 'click', 'div.c-ignored-links a', function() {
|
||||||
|
Comment.show( $( this ).data( 'comment-id' ) );
|
||||||
// "Reply to <username>" links
|
} )
|
||||||
.on( 'click', 'a.comments-cancel-reply-link', function() {
|
|
||||||
Comment.cancelReply();
|
// Reply links
|
||||||
} )
|
.on( 'click', 'a.comments-reply-to', function() {
|
||||||
|
Comment.reply(
|
||||||
// Handle clicks on the submit button (previously this was an onclick attr)
|
$( this ).data( 'comment-id' ),
|
||||||
.on( 'click', 'div.c-form-button input[type="button"]', function() {
|
$( this ).data( 'comments-safe-username' ),
|
||||||
Comment.submit();
|
$( this ).data( 'comments-user-gender' )
|
||||||
} )
|
);
|
||||||
|
} )
|
||||||
// Change page
|
|
||||||
.on( 'click', 'li.c-pager-item a.c-pager-link', function() {
|
// "Reply to <username>" links
|
||||||
var ord = 0,
|
.on( 'click', 'a.comments-cancel-reply-link', function() {
|
||||||
commentsBody = $( this ).parents( 'div.comments-body:first' );
|
Comment.cancelReply();
|
||||||
|
} )
|
||||||
if ( commentsBody.length > 0 ) {
|
|
||||||
var ordCrtl = commentsBody.first().find( 'select[name="TheOrder"]:first' );
|
// Handle clicks on the submit button (previously this was an onclick attr)
|
||||||
if ( ordCrtl.length > 0 ) {
|
.on( 'click', 'div.c-form-button input[type="button"]', function() {
|
||||||
ord = ordCrtl.val();
|
Comment.submit();
|
||||||
}
|
} )
|
||||||
}
|
|
||||||
|
// Change page
|
||||||
Comment.viewComments(
|
.on( 'click', 'li.c-pager-item a.c-pager-link', function() {
|
||||||
mw.config.get( 'wgArticleId' ), // or we could use $( 'input[name="pid"]' ).val(), too
|
var ord = 0,
|
||||||
ord,
|
commentsBody = $( this ).parents( 'div.comments-body:first' );
|
||||||
0,
|
|
||||||
$( this ).data( 'cpage' )
|
if ( commentsBody.length > 0 ) {
|
||||||
);
|
var ordCrtl = commentsBody.first().find( 'select[name="TheOrder"]:first' );
|
||||||
} );
|
if ( ordCrtl.length > 0 ) {
|
||||||
} );
|
ord = ordCrtl.val();
|
||||||
|
}
|
||||||
}( jQuery, mediaWiki ) );
|
}
|
||||||
|
|
||||||
|
Comment.viewComments(
|
||||||
|
mw.config.get( 'wgArticleId' ), // or we could use $( 'input[name="pid"]' ).val(), too
|
||||||
|
ord,
|
||||||
|
0,
|
||||||
|
$( this ).data( 'cpage' )
|
||||||
|
);
|
||||||
|
} );
|
||||||
|
} );
|
||||||
|
|
||||||
|
}( jQuery, mediaWiki ) );
|
||||||
|
Loading…
Reference in New Issue
Block a user