Putting the 'role' back in role-playing games since 2002.
Donate to Codex
Good Old Games
  • Welcome to rpgcodex.net, a site dedicated to discussing computer based role-playing games in a free and open fashion. We're less strict than other forums, but please refer to the rules.

    "This message is awaiting moderator approval": All new users must pass through our moderation queue before they will be able to post normally. Until your account has "passed" your posts will only be visible to yourself (and moderators) until they are approved. Give us a week to get around to approving / deleting / ignoring your mundane opinion on crap before hassling us about it. Once you have passed the moderation period (think of it as a test), you will be able to post normally, just like all the other retards.

Polls need next-gen

Jigawatt

Arcane
Joined
Aug 13, 2009
Messages
3,409
Location
in a desert, walking along in the sand
Refreshing the page to vote in/view results of polls is turning prestigious RPGCodex into the laughing stock of the internet. I demand some javascript for viewing results, and AJAX for voting. Chop chop
 

King Crispy

Too bad I have no queen.
Patron
Staff Member
Joined
Feb 16, 2008
Messages
1,876,687
Location
Future Wasteland
Strap Yourselves In
Goblin2_L.jpg


antidas2.jpg


Goblin2_L.jpg


antidas2.jpg


Goblin2_L.jpg


antidas2.jpg
 

Jigawatt

Arcane
Joined
Aug 13, 2009
Messages
3,409
Location
in a desert, walking along in the sand
Alright, here's the patch

In the file viewtopic_poll_ballot.tpl
(I worked off the codex copy of this file)

Code:
Line 1:
//Add
<script type="text/javascript">
	function viewResult() {
		document.getElementById("pollresultsjs").style.display = "table-row-group";
		document.getElementById("pollballotjs").style.display = "none";
	}
</script>
<tbody id="pollballotjs">

Lines 10-11:
//Replace
<td><input type="radio" name="vote_id" value="{poll_option.POLL_OPTION_ID}" />&nbsp;</td>
<td><span class="gen">{poll_option.POLL_OPTION_CAPTION}</span></td>
//With
<td><input type="radio" name="vote_id" value="{poll_optionb.POLL_OPTION_ID}" />&nbsp;</td>
<td><span class="gen">{poll_optionb.POLL_OPTION_CAPTION}</span></td>
//Only change is poll_option classname changed to poll_optionb

Line 23:
//Replace the segment
<a href="{U_VIEW_RESULTS}" class="gensmall">{L_VIEW_RESULTS}</a>
//With
<a href="{U_VIEW_RESULTS}" class="gensmall" onclick="viewResult(); return false;" </a>

End of file:
//Add
</tbody>

<tbody id="pollresultsjs" style="display:none;">
	{POLL_JS}
</tbody>

In viewtopic.php
(Didn't have codex copy for this, obviously)
Assume that the line for the comment 'Does this topic contain a poll?' is 677

Code:
Line 724
//Comment out the if statement and open bracket 
if ( $user_voted || ...

Line 770
//Comment out the close bracket for the if statement

Line 771
//Replace
else
//With
if (!( $user_voted || $view_result || $poll_expired || !$is_auth['auth_vote'] || $forum_topic_data['topic_status'] == TOPIC_LOCKED ))
//ie the inverse of the commented out if statement above

Line 775-776
//Add
'polljs' => 'viewtopic_poll_result.tpl'
//to the array

Line 786
//Replace
"poll_option"
//With
"poll_optionb"

Line 801 (before the if close bracket)
//Add
$template->assign_var_from_handle('POLL_JS', 'polljs');

That will create a nice little javascript based switch to see the results of a poll. People without javascript will see no change to the existing functionality. There's probably a way to expand on this to provide AJAX voting but because of the weird way phpBB constructs pages I don't think there's an easy way to recalculate the graph after voting.

Happy new year, motherfucker
 

DarkUnderlord

Professional Throne Sitter
Staff Member
Joined
Jun 18, 2002
Messages
28,357
It worked. Just had to correct the view results link.
 

Jigawatt

Arcane
Joined
Aug 13, 2009
Messages
3,409
Location
in a desert, walking along in the sand
Cool, just got to see it in action. It would be more useful to have ajax for the voting because that's where the most annoying page reload is. From having a quick look there isn't going to be an easy way to get it going because the graph would have to be rebuilt and the template engine doesn't seem to be set up for it. Shame really.
 

As an Amazon Associate, rpgcodex.net earns from qualifying purchases.
Back
Top Bottom