메테오와 채팅 앱을 만들고 있는데 스팸이 문제가 될 것이라고 생각합니다. 너무 빨리 댓글을 달면 (5 초에 3 번 이상) 대문자가 나타나는 Captcha를 통합하려고합니다. 내가 아래 자바 스크립트 코드가 있지만 어떻게 해야할지 모르겠다. Captcha를 화면의 어딘가에 팝업시킬 수 있습니까? 그렇다면 누구든지이 작업을 수행하는 방법을 알고 있습니까?사용자의 의견이 너무 빠른 경우 보안 문자 팝업?
자바 스크립트 :
// render all of our messages in the ui
Template.chatBox.helpers({
"messages": function() {
return chatCollection.find();
}
});
// get the value for handlerbar helper user
Template.chatMessage.helpers({
"user": function() {
if(this.userId == 'me') {
return this.userId;
} else if(this.userId) {
getUsername(this.userId);
return Session.get('user-' + this.userId);
} else {
return 'anonymous-' + this.subscriptionId;
}
}
});
// when Send Chat clicked at the message to the collection
Template.chatBox.events({
"click #send": function() {
if (Meteor.user() == null) {
alert("You must login to post");
return;
}
$('#messages').animate({"scrollTop": $('#messages')[0].scrollHeight}, "fast");
var message = $('#chat-message').val();
chatCollection.insert({
userId: 'me',
message: message
});
$('#chat-message').val('');
//add the message to the stream
chatStream.emit('chat', message);
},
"keypress #chat-message": function(e) {
if (Meteor.user() == null) {
alert("You must login to post");
return;
}
if (e.which == 13) {
$('#messages').animate({"scrollTop": $('#messages')[0].scrollHeight}, "fast");
console.log("you pressed enter");
e.preventDefault();
//repeat function from #send click event here
var message = $('#chat-message').val();
chatCollection.insert({
userId: 'me',
message: message
});
$('#chat-message').val('');
//add the message to the stream
chatStream.emit('chat', message);
}
}
});
chatStream.on('chat', function(message) {
chatCollection.insert({
userId: this.userId,
subscriptionId: this.subscriptionId,
message: message
});
});
Jquery를 사용하고 있습니까? –
나는 유성과 할 수 있다고 생각하지 않는다. – 5AMWE5T
시도해 보셨습니까? –