function load_emo_data(elem_id, elem_type) { $.get( "/incl/ajax_load.php", {a: 'emo_get', elem_type: elem_type, elem_id: elem_id}, function (data) { change_chart(data); }, "json" ); } function show_emo_map(elem_id, elem_type) { $.get( "/incl/ajax_load.php", {a: 'emo_poll_block', elem_type: elem_type, elem_id: elem_id}, function (data) { if (data.error) { return; } $.msg({ autoUnblock : false, content : '
'+data.emo_map_content, afterBlock : function(){ load_emo_data(elem_id, elem_type); } }); }, "json" ); } function change_chart(data) { var vote_curious = parseInt(data.curious); var vote_indifferent = parseInt(data.indifferent); var vote_angry = parseInt(data.angry); var vote_happy = parseInt(data.happy); if ((vote_curious + vote_indifferent + vote_angry + vote_happy) == 0) { vote_curious = 1; vote_indifferent = 1; vote_angry = 1; vote_happy = 1; } var one_vote_perc = 100 / (vote_curious + vote_indifferent + vote_angry + vote_happy); vote_curious = vote_curious * one_vote_perc; vote_indifferent = vote_indifferent * one_vote_perc; vote_angry = vote_angry * one_vote_perc; vote_happy = vote_happy * one_vote_perc; $("#curious_perc").text(Math.round(parseInt(data.curious)*one_vote_perc)); $("#indifferent_perc").text(Math.round(parseInt(data.indifferent)*one_vote_perc)); $("#angry_perc").text(Math.round(parseInt(data.angry)*one_vote_perc)); $("#happy_perc").text(Math.round(parseInt(data.happy)*one_vote_perc)); $("#happy").css('width', vote_happy + '%'); $("#curious").css('width', vote_curious + '%'); $("#indifferent").css('width', vote_indifferent + '%'); $("#angry").css('width', vote_angry + '%'); } function poll(elem_id, type_emo, cookie_prefix, elem_type) { var ar_cookies=document.cookie.split(";"); for (i=0;i