jQuery(function() {
jQuery("#gallerydiv table.form-table").each(function(item) { //the table with gallery fields (hack to add to it with js, sorry)
var row = this.insertRow(this.rows.length);
var cell = row.insertCell(0);
cell.align = "left";
cell.vAlign = "top";
cell.innerHTML = "Gallery Voting Options";
var cell = row.insertCell(1);
cell.colSpan = 3;
var str = "";
str += " Enable voting for this gallery
";
str += " Only allow logged in users to vote
";
str += " Only allow 1 vote per person (IP or userid is used to stop multiple)
";
str += " Allow users to see results
";
str += "Rating Type: ";
cell.innerHTML = str;
row = this.insertRow(this.rows.length);
cell = row.insertCell(0);
cell.align = "left";
cell.vAlign = "top";
cell.innerHTML = "Current Votes";
cell = row.insertCell(1);
cell.colSpan = 3;
if(voting_type == 3) { //likes
str = nggv_num_likes+' ';
str += nggv_num_likes == 1 ? 'Vote ' : 'Votes ';
//str += nggv_num_dislikes+' ';
//str += nggv_num_dislikes == 1 ? 'Dislike' : 'Dislikes';
str += " ("+nggv_num_votes+" votes cast)";
}else{
str = nggv_avg+" / 10 ("+nggv_num_votes+" votes cast)";
}
cell.innerHTML = str;
jQuery("a#nggv_more_results").click(function() { //button click to open more detail on the voting
tb_show("", "#TB_inline?width=640&height=300&inlineId=nggvShowList&modal=true", false); //thick box seems to be included, so lets use it :)
jQuery.get(nggv_more_url, 'gid='+nggv_gid, function(data, status) {
if(status == 'success') {
var start = data.indexOf("") + 33; //find the start of the outputting by the ajax url (stupid wordpress and poor buffering options blah blah)
eval(data.substr(start)); //the array of voters gets echoed out at the ajax url
if(nggv_votes_list.length > 0) {
//todo, paginate results (pseudo even, with hidden divs etc)?
var bgcol;
var html = '
Date | '; html += 'Vote (out 10) | ';
html += 'User Name (if logged in) | ';
html += 'IP | '; html += ''+nggv_votes_list[i][1]+' | '; if(parseInt(nggv_voting_type) == 3) { html += ''+(nggv_votes_list[i][0] == 100 ? 'Like' : 'Dislike')+' | '; }else{ html += ''+(Math.round(nggv_votes_list[i][0]) / 10)+' | '; } html += ''+nggv_votes_list[i][3][1]+' | '; html += ''+nggv_votes_list[i][2]+' | '; html += ''; } html += '
Date | '; html += 'Vote (out 10) | ';
html += 'User Name (if logged in) | ';
html += 'IP | '; html += ''+nggv_votes_list[i][1]+' | '; if(parseInt(nggv_voting_type) == 3) { html += ''+(nggv_votes_list[i][0] == 100 ? 'Like' : 'Dislike d>'; }else{ html += ' | '+(Math.round(nggv_votes_list[i][0]) / 10)+' | '; } html += ''+nggv_votes_list[i][3][1]+' | '; html += ''+nggv_votes_list[i][2]+' | '; html += ''; } html += '