152
| <![CDATA[<script>
var url = '/poll';
jQ = jQuery.noConflict();
// jQ.noConflict();
jQ(function() {
configureCaptcha();
refreshCaptcha();
var rating = jQ( ".divRating" );
var sendRating = jQ( "#sendRating" );
rating.popup({
position:'bottom left'
});
rating.hover(function() {
jQ('.iconCustom').transition('jiggle');
});
rating.click(function() {
sendRating.addClass("disabled");
jQ('#modalRating').modal({
onVisible: function () {
rating.popup({
position:'bottom left'
});
}
}).modal('show');
jQ('.iconCustom').transition('jiggle');
});
sendRating.click(function() {
var result = parseInt(jQ('.captchaV1').text())+ parseInt(jQ('.captchaV2').text());
if(parseInt(result) === parseInt(jQ('input.resultCaptcha').val())){
// console.log(jQ('#ratingForm').rating('get rating'));
sendEvaluation(url);
}else
jQ('.iconCustom').transition('jiggle');
});
});
function refreshCaptcha() {
jQ('.refreshCaptcha').click(function() {
a = Math.ceil(Math.random() * 10);
b = Math.ceil(Math.random() * 10);
c = jQ('input.resultCaptcha').val('');
jQ('.captchaV1').text(a);
jQ('.captchaV2').text(b);
jQ('input.resultCaptcha').focus();
jQ('#sendRating').addClass("disabled");
});
}
function configureCaptcha() {
jQ('input.resultCaptcha').on('input',function(e){
var result = parseInt(jQ('.captchaV1').text())+ parseInt(jQ('.captchaV2').text());
// console.log(result);
// console.log(jQ('input.resultCaptcha').val());
if(parseInt(result) === parseInt(jQ('input.resultCaptcha').val())){
jQ('#sendRating').removeClass("disabled");
}else{
jQ('#sendRating').addClass("disabled");
}
});
jQ('#ratingForm').rating({
initialRating: 3,
maxRating: 5
});
var a = Math.ceil(Math.random() * 10);
var b = Math.ceil(Math.random() * 10);
jQ('.captchaV1').text(a);
jQ('.captchaV2').text(b);
}
function sendEvaluation(url) {
var resultCaptcha = parseInt(jQ('.captchaV1').text()) + parseInt(jQ('.captchaV2').text());
var validateCaptcha = jQ('input.resultCaptcha').val();
var ratingValue = jQ('#ratingForm').rating('get rating');
var data = {operation: "saveEvaluation",
ratingValue: ratingValue,
resultCaptcha: resultCaptcha,
validateCaptcha: validateCaptcha
};
jQ.post(url, data, function (res) {
// console.log(res);
if(res.indexOf("success") >= 0){
jQ('#modalRating').modal('hide');
jQ('div.divRating')
.popup({
delay: {
hide: 900
},
position : 'right center',
target : 'div.divRating',
title : 'Avaliação!',
content : 'Sua avaliação foi registrada, Obrigado!'
}).popup('show');
}else{
jQ('#modalRating').modal('hide');
jQ('div.divRating')
.popup({
delay: {
hide: 900
},
position : 'right center',
target : 'div.divRating',
title : 'Avaliação incorreta!',
content : 'Avaliação não foi registrada!'
}).popup('show');
}
});
}
</script>]]>
|