Jump to content

Recommended Posts

Posted

Miren tengo un problema en la web y es que quiero poner un limite de tiempo para el sistema de votacion; Explico mejor,  un usuario puede votar las veces que quiere en un mismo dia y al menos para evitar eso me gustaria ponerle un tiempo de 4 o 5 horas para poder votar de nuevo 

 

 

aqui el code

 

 

$(document).ready(function(){
// ajax setup
$.ajaxSetup({
url: 'ajaxvote.php',
type: 'POST',
cache: 'true'
});
 
// any voting button (up/down) clicked event
$('.vote').click(function(){
var self = $(this); // cache $this
var action = self.data('action'); // grab action data up/down 
var parent = self.parent().parent(); // grab grand parent .item
var postid = parent.data('postid'); // grab post id from data-postid
var score = parent.data('score'); // grab score form data-score
 
// only works where is no disabled class
if (!parent.hasClass('.enabled')) {
// vote up action
if (action == 'up') {
// increase vote score and color to orange
parent.find('.vote-score').html(++score).css({'color':'green'});
// change vote up button color to orange
self.css({'color':'orange'});
// send ajax request with post id & action
$.ajax({data: {'postid' : postid, 'action' : 'up'}});
}
// voting down action
else if (action == 'down'){
// decrease vote score and color to red
parent.find('.vote-score').html(--score).css({'color':'red'});
// change vote up button color to red
self.css({'color':'red'});
// send ajax request
$.ajax({data: {'postid' : postid, 'action' : 'down'}});
};
 
// add disabled class with .item
parent.addClass('.disabled');
};
});
});
Posted

Se me ocurre creando una nueva tabla en la base de datos, y que al realizar el voto dicho valor se modifique a 1 por ejemplo, y con un cronjob cada 4 o 5 horas hacer una alteración de todos a 0 nuevamente.

 

Eso se me ocurre, estoy seguro que no es lo más acertado pero meh.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

This site uses cookies to enhance your browsing experience and provide relevant content. By continuing to browse, you agree to our We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. and Terms of Use. For more information on how we protect your data, please check our Privacy Policy.