The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Java script Select all code stopped working

5 posters

Go down

Solved Java script Select all code stopped working

Post by smurfavr November 3rd 2020, 9:27 pm

Java script Select all code stopped working. What can the problem come from?
Java script Select all code stopped working OTHiVzR

Code:
function selectCode(a){a=$(a).closest("dl").find(".cont_code,code")[0];if(window.getSelection){var c=window.getSelection();if(c.setBaseAndExtent)c.setBaseAndExtent(a,0,a,a.innerText.length-1);else{window.opera&&a.innerHTML.substring(a.innerHTML.length-4)=="<BR>"&&(a.innerHTML+=" ");var b=document.createRange();b.selectNodeContents(a);c.removeAllRanges();c.addRange(b)}}else document.getSelection?(c=document.getSelection(),b=document.createRange(),b.selectNodeContents(a),
        c.removeAllRanges(),c.addRange(b)):document.selection&&(b=document.body.createTextRange(),b.moveToElementText(a),b.select())}
       
      $(function(){
            $("dl.codebox:not(.spoiler,.hidecode)  > dd.code, dl.codebox:not(.spoiler,.hidecode)  > dd > code").closest("dl").find('dt').append('<span onClick="selectCode(this)" class="selectCode">
КОПИРАЙ&nbsp;&nbsp;КОДА</span>');
        });


Last edited by smurfavr on November 6th 2020, 12:15 pm; edited 1 time in total
smurfavr
smurfavr
Active Poster

Male Posts : 1881
Reputation : 22
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Solved Re: Java script Select all code stopped working

Post by Ape November 3rd 2020, 9:44 pm

if you turn off the falling leaves dose the code work again ?


Java script Select all code stopped working Left1212Java script Select all code stopped working Center11Java script Select all code stopped working Right112
Java script Select all code stopped working Ape_b110
Java script Select all code stopped working Ape1010
Ape
Ape
Administrator
Administrator

Male Posts : 19449
Reputation : 2011
Language : fluent in dork / mumbojumbo & English haha

http://chatworld.forumotion.co.uk/

Back to top Go down

Solved Re: Java script Select all code stopped working

Post by smurfavr November 4th 2020, 9:14 pm

@Ape I stopped the falling leaves, but the problem still exists.
smurfavr
smurfavr
Active Poster

Male Posts : 1881
Reputation : 22
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Solved Re: Java script Select all code stopped working

Post by Ape November 4th 2020, 11:16 pm

Thank you for you reply @smurfavr I have ran some tests and everything looks to be ok our end

Can you please turn off your JavaScripts and then see if the problem is still there ?

I am asking this as it looks like it is only your forum that has the problem after I done tests on 6 other sites and on this support forum and can't reproduce the problem.


Java script Select all code stopped working Left1212Java script Select all code stopped working Center11Java script Select all code stopped working Right112
Java script Select all code stopped working Ape_b110
Java script Select all code stopped working Ape1010
Ape
Ape
Administrator
Administrator

Male Posts : 19449
Reputation : 2011
Language : fluent in dork / mumbojumbo & English haha

http://chatworld.forumotion.co.uk/

Back to top Go down

Solved Re: Java script Select all code stopped working

Post by smurfavr November 5th 2020, 12:18 pm

Excluding the java script, the codes stop and the text copy code and I can't tell if it works.
smurfavr
smurfavr
Active Poster

Male Posts : 1881
Reputation : 22
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Solved Re: Java script Select all code stopped working

Post by TheCrow November 5th 2020, 1:15 pm

What he meant is leave only the Select Code Javascript enabled and turning off the rest of the Javascripts.


Java script Select all code stopped working Thecro10
Forum of the Forums

Forumotion Rules | Tips & Tricks |
FAQ | Did you forget your password?



*** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
No support via PM!
TheCrow
TheCrow
Manager
Manager

Male Posts : 6916
Reputation : 795
Language : Greek, English

https://www.inforumgr.com

Back to top Go down

Solved Re: Java script Select all code stopped working

Post by tikky November 5th 2020, 9:29 pm

Hello @smurfavr,

Change your code to:
Code:
/* global Clipboard, jQuery*/
(function($) {
 
    $(function() {
 
        $('.post .code').each(function() {
 
            var $copy = $('<a>', {
                'class': 'fa-code-copy-button',
                'title': 'Copiar',
                'role': 'button',
                'text': 'КОПИРАЙ КОДА'
            }).css('float', 'right');
 
            $copy.prependTo($(this).parents('.codebox').not('.spoiler').find('dt'));
        });
 
        $.getScript('https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.7.1/clipboard.min.js', function() {
            new Clipboard('.fa-code-copy-button', {
                target: function(trigger) {
                    return $(trigger).parents('.codebox').find('.cont_code').get(0);
                }
            });
        });
 
    });
}(jQuery));
Your current code has an error and it's old :/ AND it probably stopped working due to a browser update
tikky
tikky
Forumember

Posts : 923
Reputation : 160
Language : 🇵🇹

https://www.forumotion.com/create-forum/modernbb

TonnyKamper likes this post

Back to top Go down

Solved Re: Java script Select all code stopped working

Post by Jucarese November 6th 2020, 10:59 am

This also works and does not depend on any external address, which can fail.

Code:
function selectCode(e) {
        var doc = document
            , text = $(e).closest("dl").find(".cont_code,code").get(0)
            , range, selection
        ;
        if (doc.body.createTextRange) {
            range = document.body.createTextRange();
            range.moveToElementText(text);
            range.select();
        } else if (window.getSelection) {
            selection = window.getSelection();       
            range = document.createRange();
            range.selectNodeContents(text);
            selection.removeAllRanges();
            selection.addRange(range);
        }
    };
    $(function(){$("dl.codebox:not(.spoiler,.hidecode)  > dd.code, dl.codebox:not(.spoiler,.hidecode)  > dd > code").closest("dl").find('dt').append('<span onClick="selectCode(this)" class="selectCode">Select all</span>')});
Jucarese
Jucarese
Hyperactive

Male Posts : 2558
Reputation : 121
Language : spanish
Location : SSF Admin

http://asistencia.foroactivo.com/u23082

TonnyKamper likes this post

Back to top Go down

Solved Re: Java script Select all code stopped working

Post by smurfavr November 6th 2020, 12:16 pm

@pedxz, @jucarese, Thank you both codes work.
smurfavr
smurfavr
Active Poster

Male Posts : 1881
Reputation : 22
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Solved Re: Java script Select all code stopped working

Post by TheCrow November 6th 2020, 1:21 pm

Problem solved & topic archived.
Please read our forum rules: ESF General Rules


Java script Select all code stopped working Thecro10
Forum of the Forums

Forumotion Rules | Tips & Tricks |
FAQ | Did you forget your password?



*** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
No support via PM!
TheCrow
TheCrow
Manager
Manager

Male Posts : 6916
Reputation : 795
Language : Greek, English

https://www.inforumgr.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum