Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Voting inside longer subthreads with jump marks

by LanX (Saint)
on Jul 18, 2021 at 21:57 UTC ( [id://11135142]=monkdiscuss: print w/replies, xml ) Need Help??

For discussion (and as reminder to myself)

Voting inside longer sub-threads with many posts is easy, you select ++ or -- and hit return.

But the request will return at the very beginning of the page and you need to scroll again to were you started.

actually there are anchors allowing to return from where you voted, like

?node_id=11135115#11135141

one only needs to isolate the ID from the radio's name <input type="radio" name="vote__11135141" value="-1">

Minor complication is that one can vote on multiple nodes at the same time, identifying the one where the request was triggered might require some JS trickery.

update

In hindsight, implementing to vote with an AJAX request might be the better approach tho. It wouldn't require to reload the whole page and fiddling with the current vote mechanism.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re: Voting inside longer subthreads with jump marks
by Your Mother (Archbishop) on Jul 18, 2021 at 22:50 UTC

    I am using ajax voting, and have been for quite awhile now. The issue is, it’s like a lot of personal code: barely enough to do what I want—requires a local webserver which would not be relevant if the code were hosted—and not written with an eye toward cleanliness or testing or good error trapping or… It also requires da Inkster’s formatting stuff.

    I can open it up to you if you want to look at it. I have been meaning to do a writeup of it all to post but like so many of these things, describing the code clearly and carefully is harder than writing the code and it would probably lead me to do a bunch of fixes I don’t really need just to share something less embarrassing. :P

    I guess I’ll just post it. Of all the things I should be embarrassed about, it probably doesn’t crack the top 100. Maybe tonight.

      We talked about this in the past.

      Did you use the standard action which returns the whole page again or did you find a lightweight interface for this?

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        I didn’t try to dig into any alternate endpoints that might exist on the site. I just smooth over what it does normally and return the whole page to the JS and let it parse/use it.

Re: Voting inside longer subthreads with jump marks
by Your Mother (Archbishop) on Jul 19, 2021 at 00:25 UTC
Re: Voting inside longer subthreads with jump marks
by shmem (Chancellor) on Jul 18, 2021 at 23:32 UTC

    Oh nice... that would only require a tiny update on that ol' javascript stuff.

    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: monkdiscuss [id://11135142]
Approved by davies
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-23 18:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found