Following tye's suggestion, I've put up this little piece of javascript code for making the life of Friars and above a little easier. This is my first javascript snippet (besides alert ('Hello, World!');) and I thing it's pretty good looking. I just would like to get rid of that 6 repeated <br>s.

When you select either "Add code tags" or "Add readmore tags", the proper message is included in the text box, and it's marked read only. In the case of "Retitle" or "Reap", the text "Retitle: " or "Reap: " is automatically added to the textbox, and the user is expected to fill in some further details (like the new title or the reason to reap a node), or enter other completely different reason (ie, the radio buttons are not a contract). In case the user selects "Other", the textbox is emptied.

This "Other" and the original checkbox "Consider node" serve the same purpose, more or less. The radio button can be safely eliminated from the form, or the original checkbox can be hidden for consistency ("I want only radio buttons!").

It's "tested" in Mozilla 1.7.12, IE 6.0 (winxp) and IE 5.0 (win98). "tested" ~~ "all buttons work as expected", I actually used it a couple of times in Mozilla. After all, once the desired text is in the textbox, the rest is the same as before ("It should work"™). There are were a couple of additional features in the works, waiting to get some testing.

Special thanks to jdporter and Corion for their kindness and support.

Update: Incorporated that nice refactoring by Corion. Added hue_mangle_text(). Now, a consideration with a text of "Reap: " (with a space and no explanation) will be changed to "Reap: empty" so considerating empty nodes for reaping becomes a matter of using just the mouse. If you add a number ("Reap: 42"), it will be promoted to a link ("Reap: duplicate of [id://42]"). || Added some improvements by ikegami. || Added three more options per Arunbear request; they are commented to show how easily you can have exactly the options you want. The "Reparent" option changes numbers into links too.

<script language="Javascript"> // plagiarized from Corion++ ;^) function $(name) { return document.getElementById (name); } { var form; // approval nodelet form var cb; // consideration checkbox function hue_disable() { form.considerreason.readOnly = true; } function hue_enable() { form.considerreason.readOnly = false; } function hue_set_code() { hue_disable(); form.considerreason.value = 'Add code tags'; } function hue_set_readmore() { hue_disable(); form.considerreason.value = 'Add readmore tags'; } function hue_set_retitle() { hue_enable(); form.considerreason.value = 'Retitle: '; form.considerreason.focus(); } function hue_set_reap() { hue_enable(); form.considerreason.value = 'Reap: '; form.considerreason.focus(); } function hue_set_moveto() { hue_enable(); form.considerreason.value = 'Move to: '; form.considerreason.focus(); } function hue_set_reparent() { hue_enable(); form.considerreason.value = 'Reparent under: '; } function hue_set_restore() { hue_disable(); form.considerreason.value = 'Restore content'; form.considerreason.focus(); } function hue_set_other() { hue_enable(); form.considerreason.value = ''; form.considerreason.focus(); } function hue_mangle_text() { if (form.considerreason.value.match (/^Reap: $/)) { form.considerreason.value = 'Reap: empty node'; } if (form.considerreason.value.match (/^Reap: (\d+)$/)) { form.considerreason.value = 'Reap: duplicate of `[id://' + Reg +Exp.$1 + '`]'; } if (form.considerreason.value.match (/^Reparent under: (\d+)$/)) { form.considerreason.value = 'Reparent under: `[id://' + RegExp +.$1 + '`]'; } } function hue_create_radio(value, callback) { var input = document.createElement ('input'); input.name = 'hue_reason'; input.value = value; input.type = 'radio'; input.onclick = callback; return input; } function hue_create_input(value, visual, callback) { var input = hue_create_radio (value, callback); var text = document.createTextNode (visual); var br = document.createElement ('br'); return `[ input, text, br `]; } function hue_add_elems() { var approval_nodelet = $('nodelet_body_row_Approval_Nodelet'); if (!approval_nodelet) { return; } form = approval_nodelet.getElementsByTagName ('td')`[0`].getElemen +tsByTagName ('form')`[0`]; form.onsubmit = hue_mangle_text(); var checkbox = $('considerit'); if (!checkbox) { return; } var to_insert = `[ hue_create_input ('code', 'Add code tags', hue_set_ +code), hue_create_input ('readmore', 'Add readmore tags', hue_set_ +readmore), hue_create_input ('retitle', 'Retitle', hue_set_ +retitle), hue_create_input ('reap', 'Reap duplicate/empty', hue_set_ +reap), // hue_create_input ('moveto', 'Move', hue_set +_moveto), // hue_create_input ('reparent', 'Reparent', hue_set +_reparent), // hue_create_input ('restore', 'Restore content', hue_se +t_restore), hue_create_input ('other', 'Other', hue_set_ +other), `]; for (var i = to_insert.length; i--; ) { var arr = to_insert`[i`]; for (var j = arr.length; j--; ) { form.insertBefore (arr`[j`], checkbox.nextSibling); }; } form.insertBefore (document.createElement ('br'), checkbox.nextSib +ling); } hue_add_elems(); } </script>

--
David Serrano


In reply to Free nodelet hack: Consideration shortcuts by Hue-Bond

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.