vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 5.x Template Modifications (https://vborg.vbsupport.ru/forumdisplay.php?f=259)
-   -   BB Code Enhancements - Copy Code to Clipboard for CODE/HTML/PHP BBCode (https://vborg.vbsupport.ru/showthread.php?t=329287)

TheDigitalCouch 07-20-2022 09:00 PM

Copy Code to Clipboard for CODE/HTML/PHP BBCode
 
1 Attachment(s)
vBulletin 4 Creator: BCP_Hung
vBulletin 4 Mod Link: https://vbulletin.org/forum/showthre...ight=copy+code
Javascript Fix: Raptor

Working with vB 5.6.9

About:

This modification adds a "Copy Code" box that will select all of the code within the box, as well as automatically copy to clipboard.

The vB4 mod did not automatically copy the code, which I've fixed in this version.

Installation

Copy and paste the following javascript code at the bottom of your head_include template:
AdminCP -> Styles -> Style Manager -> Edit Templates -> head_include
Code:

<script type="text/javascript">
    function selectAll(a)
    {
        var e  = a.parentNode.parentNode.getElementsByTagName('code')[0];
        if  (window.getSelection)
        {
            var s = window.getSelection();
 
                var r = document.createRange();
                r.selectNodeContents(e);
                s.removeAllRanges();
                s.addRange(r);
                document.execCommand('copy')
                               
        }
        else if (document.getSelection)
        {
            var s = document.getSelection();
            var r = document.createRange();
            r.selectNodeContents(e);
            s.removeAllRanges();
            s.addRange(r);
        }
        else if  (document.selection)
        {
            var r = document.body.createTextRange();
            r.moveToElementText(e);
            r.select();
        }
    }
</script>

Save.

For CODE BBCode:

Navigate to AdminCP -> Styles -> Style Manager -> Edit Templates -> bbcode_code

Find:
Code:

{vb:rawphrase code}:
Replace with:
Code:

{vb:rawphrase code}:&nbsp;<input type="button" value="{vb:rawphrase select_code}" onclick="selectAll(this); return false;">
Find:
Code:

{vb:raw code}
Replace with:
Code:

<code>{vb:raw code}</code>
Save.

For HTML BBCode:

Navigate to AdminCP -> Styles -> Style Manager -> Edit Templates -> bbcode_html

Find:
Code:

{vb:rawphrase html_code}:
Replace with:
Code:

{vb:rawphrase html_code}:&nbsp;<input type="button" value="{vb:rawphrase select_code}" onclick="selectAll(this); return false;">
Find:
Code:

{vb:raw code}
Replace with:
Code:

<code>{vb:raw code}</code>
Save.

For PHP BBCode:

Navigate to AdminCP -> Styles -> Style Manager -> Edit Templates -> bbcode_php

Find:
Code:

{vb:rawphrase php_code}:
Replace with:
Code:

{vb:rawphrase php_code}:&nbsp;<input type="button" value="{vb:rawphrase select_code}" onclick="selectAll(this); return false;">
Find:
Code:

{vb:raw code}
Replace with:
Code:

<code>{vb:raw code}</code>
Save.

Then add the following to your css_additional.css:
Code:

.bbcode_container .bbcode_description {
    background: #777;
    font-weight: 8;
    padding: 5px;
}
.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button {
    font-size: 10px;
    font-weight: 7;
    float: right;
    margin-right: 5px;
}

Save.

You may need to make some adjustments.
Enjoy!


All times are GMT. The time now is 10:04 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01030 seconds
  • Memory Usage 1,726KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (14)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (1)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete