Adding Select All for [code] BBcode

Adding Select All for [code] BBcode 1.1 Stable

No permission to download
Sbenny updated Adding Select All for [code] BBcode with a new update entry:

Adding Select All for [code] BBcode v1.1

A simple but effective way to select all the content within a code bbcode in your forum.

Please note: this doesn't add a "select all" button like you're probably used to see, but it adds a simple functionality to your mouse (or your thumbs) so that each time you click (or tap) inside a code box, it'll automatically select all the text into it.

How to:
Download the attached file, and replace it with your existing bb_code_tag_code file in your template(s).

Alternatively, follow these...

Read the rest of this update entry...
 
Stable version released:

- Javascript code optimized in order to load faster and with less queries.
- Bug fixes (you can now select each code block separately).

No more bugs so far.
 
My next project: SOCIAL PROFILES

jDKCi2noSKek0d1oPG3TGQ.jpeg
 
@ozzy47 Are you a lawyer? Look at your work please!
@Sbenny , use please;
JavaScript:
function selectElementContents(el)
{
    // Copy textarea, pre, div, etc.
    if (document.body.createTextRange) {
        // IE
        var textRange = document.body.createTextRange();
        textRange.moveToElementText(el);
        textRange.select();
        textRange.execCommand("Copy");     
    }
    else if (window.getSelection && document.createRange) {
        // non-IE
        var range = document.createRange();
        range.selectNodeContents(el);
        var sel = window.getSelection();
        sel.removeAllRanges();
        sel.addRange(range);
        try { 
            var successful = document.execCommand('copy'); 
            var msg = successful ? 'successful' : 'unsuccessful'; 
            console.log('Copy command was ' + msg); 
        } catch(err) { 
            console.log('Oops, unable to copy'); 
        }
    }
} // end function selectElementContents(el)

function make_copy_button(el)
{
    var copy_btn = document.createElement('input');
    copy_btn.type = "button";
    el.parentNode.insertBefore(copy_btn, el.nextSibling);
    copy_btn.onclick = function() { selectElementContents(el); };
    
    if (document.queryCommandSupported("copy") || parseInt(navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)[2]) >= 42)
    {
        // Copy works with IE 4+, Chrome 42+, Firefox 41+, Opera 29+
        copy_btn.value = "Copy to Clipboard";
    }   
    else
    {
        // Select only for Safari and older Chrome, Firefox and Opera
        copy_btn.value = "Select All (then press CTRL+C to Copy)";
    }
}

make_copy_button(document.getElementById("IDUSE"));
The above code is automatically copied.
 
Last edited:
It should be as simple as assigning a onClick function to a "Select All" button using my javascript code instead of automatically selecting and copying without the need of clicking any buttons like I did instead, as it better fitted my needs.
 
Back
Top Bottom