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 Tue 3 Nov 2020 - 21:27

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 Fri 6 Nov 2020 - 12:15; 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 Tue 3 Nov 2020 - 21:44

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 : 19369
Reputation : 2006
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 Wed 4 Nov 2020 - 21:14

@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 Wed 4 Nov 2020 - 23:16

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 : 19369
Reputation : 2006
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 Thu 5 Nov 2020 - 12:18

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 Thu 5 Nov 2020 - 13:15

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 Thu 5 Nov 2020 - 21:29

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 : 922
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 Fri 6 Nov 2020 - 10:59

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 : 2545
Reputation : 118
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 Fri 6 Nov 2020 - 12:16

@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 Fri 6 Nov 2020 - 13:21

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