Can it handle someone voting twice (nulling the first vote)? What about pages where the first half of the page is votes for one round, and the second half of the page is votes for the next round; does it total the entire page, or from a start/end point?
And out of sheer curiosity, any chance I could see the javascript code string?
If you look at the code Ack posted, it actually retrieves most of the code from a separate pastebin paste that I made. If you want to actually see how it works, you'll probably want to see it
on pastebin.
It handles people voting twice on the same page (and counts the later vote), and then lists who has voted on that page. If someone votes twice over two separate pages, it won't discount the first, but it allows Ack to easily discount them manually by clicking an "×" button next to the person's name on the first vote page, or he could just subtract it from the total (it puts a neat breakdown next to each vote tally).
If there's an end (or even many vote ends) to a vote on one page, it'll separate the tallying into distinct groups, and list who voted in each vote (each person is separated by a comma, each vote is separated by a semi-colon, or if you're looking at the tallies it stores it in an HTML table, allowing the data to be easily copied over to an excel document). It detects vote endings by "Vote is CLOSED", so in theory it'll count votes between that and the "Voting is OPEN" part as counting to the
next vote instead. Maybe I should change that, but then it'd just be discounting extra votes. I'm not sure it actually matters that much.
Yes, yes and yes.
Code:
javascript:var minVoteWeight = 1; /*Their lowest vote can be 1*/ var maxVoteWeight = 6; /*Their highest vote can be 6*/ var stories = ["Alea Iacta Est", "All Alone", "Bait & Switch", "Confrontation II", "Danny & Taylor", "Hostage Situation", "I, Panacea", "Junior Hero", "Meet the Heberts", "MirrorVerse", "Nemesis", "NSW", "One More Trigger", "Really Bad End", "Recoil", "Security!", "Slippery Slope", "Trump Card", "War Games", "Wyvern"]; /*A list of stories, so it knows which to count*/ var splitter = "Ack"; /*Your username, so it checks for posts from you*/ var splitterContains = "Voting is CLOSED"; /*A post must contain this to mean the end of a vote*/ void($.getScript("https://pastebin.com/raw.php?i=BjSdjs7J"));
It should, in theory, work for a variety of different vote threads, provided it includes a vote in the following format:
If the "Vote Title" is stored within the "stories" array (defaults to Ack's current one if it's not specified before the script is loaded), or a if version of the title is present instead (i.e. one with punctuation stripped, & changed to an "and", and capitalisation ignored (i.e. "security" matches "Security!" and vice-versa)), it'll add the number (provided it's between "minVoteWeight" and "maxVoteWeight") to the totals and list who voted for which story, and how much weight they put into it. People can't use the same vote count for multiple stories (i.e. "[X] Security! - 1" and "[X] One More Trigger - 1" in the same vote will end up rejecting the "One More Trigger" vote as a duplicate) nor multiple vote counts for a single story (i.e. "[X] Security! - 5" and "[X] Security! - 4" in the same vote will reject the 4). It will reject vote titles which don't fit that pattern (such as "[X] Aftermath" without a vote count, or "[X] Aftermath 5", seeing as there isn't a "-" there), but should work even if all spacing is gone (e.g. "[X]security-1" should still match), and also if the font is different. When you run it, it automatically removes all quotes and code blocks from the DOM to prevent it from counting any text within there (I probably could've done this in a neater way, but you can just reload to have them reappear), and it only counts votes that have "[X]" at the start of the line (ignoring spaces). If you write " [X] Security - 1", it'll still count it, but it shouldn't count "t[X] Security - 1".
There might be a couple of mistakes? I don't think so, seeing as I tested it on a couple of pages of votes already and it got the same totals as he got separately, and I've already tested it on weird votes (e.g. "[X]security-1"), so... Hopefully that'll be fine?
So... if you have sub-votes (like I think QQBot supported? "-[X]" being treated as a sub-vote?), it won't count them, I'm afraid. You could, however, just put a "1" in the title of the vote or something (i.e. "[X] Vote - 5" and "[X] 1Subvote - 4") if you want them to be sorted differently. For it to work properly on other vote threads, it might require a bit of a rework or extra settings, and I've currently only tested it on this thread, not others, nor other websites (such as SpaceBattles).
I hope I've explained this well enough? I might have missed some bits though, so if you need clarification, feel free to ask.