Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

jQuery Customizations to Enhance the PerlMonks Experience

by aaron_baugher (Curate)
on Jun 28, 2015 at 01:57 UTC ( [id://1132306]=monkdiscuss: print w/replies, xml ) Need Help??

A while back I got tired of scrolling back to the top of a post after reading it and deciding to vote on it, so I wrote a little Javascript/jQuery to move the buttons to the bottom of a reply. I insert it in the page using a Chromium extension called Personalized Web, but you can use any browser plugin/extension that does the same thing, or insert it using the Free Nodelet Settings as jdporter said here. I've added some other features to it, and thought I'd share it in case others can get some use from it.

The code has four parts:

  1. This one line adds a [vote!] button for each post, so I don't have to scroll to the bottom of the page when I'm ready to submit my votes.
  2. This moves the vote buttons for each reply to the bottom of the reply, so they're accessible when you've read to the bottom of the reply.
  3. This does the same with the vote buttons for the main post at the top of the page.
  4. (This one may be controversial, so use it or delete it as you like.) I tend to find Anonymous Monk replies, let's say, less useful than non-Anonymous Monk replies, so I thought I'd like to hide them but make it easy to see them in case I want to for context. This hides the reply itself, shrinks the header a bit, changes its background color to make it stand out, and makes it clickable. Clicking on it toggles the visibility of the reply, so I can click to see it and then click it back out of the way.

If you like it, use it however you like. If you have any questions or suggestions, please share them.

<script src="//code.jquery.com/jquery-1.11.3.min.js"></script> <script type="text/javascript"> jQuery(document).ready(function(){ // 1. add vote button next to each set of voting radio buttons jQuery('div.reputation center').append('<input style="margin-left: +20px" type="submit" name="sexisgreat" value="vote!" />'); // 2. move vote buttons for replies jQuery('td.reply-body').not('td.adjunct-links').each(function(){ var $m = $(this).children().first(); var $t = $m.html(); $m.remove(); $(this).append('<div class="reputation">'+$t+'</div>'); }); // 3. move vote buttons for main post var $m = $('div.reputation').first(); var $t = $m.html(); jQuery('div.doctext').append($t); // different classes depending +on jQuery('div.notetext').append($t); // whether top of thread $m.remove(); // 4. hide and de-emphasize Anonymous Monk replies var $anon = jQuery('span.attribution:contains("Anonymous Monk")'). +parents('tr.reply'); $anon.css({'font-size':'50%','background-color':'#dd7'}); $anon.next().hide(); $anon.click(function(e){ e.preventDefault(); jQuery(this).next().toggle(); }); }); </script>

Aaron B.
Available for small or large Perl jobs and *nix system administration; see my home node.

Replies are listed 'Best First'.
Re: jQuery Customizations to Enhance the PerlMonks Experience
by GrandFather (Saint) on Jun 28, 2015 at 02:17 UTC

    I use a little css to move the Vote! button to the top left of the browser window:

    <style type="text/css"> input[name="sexisgreat"] { position: fixed; top: 0px; left: 0px; z-index:1; padding: 5px; border: 2px solid red; } </style >

    Seems a little less heavy handed than pulling in a whole pile of jQuery cruft.

    Perl is the programming world's equivalent of English

      Nice, that's definitely a lighter way to keep that button handy.

      Aaron B.
      Available for small or large Perl jobs and *nix system administration; see my home node.

Log In?
Username:
Password:

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

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

    No recent polls found