BBCode Neon com erros

3 participantes

Ver o tópico anterior Ver o tópico seguinte Ir para baixo

Tópico resolvido BBCode Neon com erros

Mensagem por Victor Monteiro 05.08.18 15:47

Detalhes da questão


Endereço do fórum: http://derby-family.forumeiros.com/
Versão do fórum: phpBB3

Descrição


Bem coloquei a opção neon em meu forum, porem ela nao funciona,ja tentei de varias maneiras
Segue os prints
BBCode Neon com erros BMLiPFP
O neon funciona na hora da edição, mas quando eu salvo aparece isso
BBCode Neon com erros U67Fm6u O neon some

Codigo que eu usei
Código:
/*
 *  Application: BBCode Neon
 *  Date: 14/10/2016
 *  Version: 1.114102916
 *  Copyright (c) 2016 Daemon <bestskins.forumeiros.com>
 *  This work is free. You can redistribute it and/or modify it
 */
$(function() {
    if (!$.sceditor) return;
 
    $.sceditor.plugins.bbcode.bbcode.set('neon', {
        tags: {
            font: {
                style: null
            }
        },
        quoteType: $.sceditor.BBCodeParser.QuoteType.never,
        format: function(element, content) {
            var rgbToHex = function(rgbStr) {
                var m;
                function toHex(n) {
                    n = parseInt(n,10);
                    if(isNaN(n))
                        return "00";
                        n = Math.max(0,Math.min(n,255)).toString(16);
                        return n.length<2 ? '0'+n : n;
                }
                // rgb(n,n,n);
                if((m = rgbStr.match(/rgb\((\d+),\s*?(\d+),\s*?(\d+)\)/i)))
                    return '#' + toHex(m[1]) + toHex(m[2]-0) + toHex(m[3]-0);
                    // expand shorthand
                    if((m = rgbStr.match(/#([0-f])([0-f])([0-f])\s*?$/i)))
                        return '#' + m[1] + m[1] + m[2] + m[2] + m[3] + m[3];
                        return rgbStr;
                    };
                    var color = element.css('color');
                    if(element[0].nodeName.toLowerCase() === "font" && element.attr('color'))
                        color = element.attr('color');
                        color = rgbToHex(color);
                        return '[neon=' + color + ']' + content + '[/neon]';
        },
        html: function(element, attrs, content) {
          return '<font style="color:' + attrs.defaultattr + ';text-shadow: 0px 0px 5px ' + attrs.defaultattr + '">' + content + '</font>';
        }
    });
 
    $.sceditor.command.set('neon', {
        _dropDown: function(editor, caller, callback) {
            var i, x, color, colors, genColor = {
                r: 255,
                g: 255,
                b: 255
            },
            content = $('<div />'),
            colorColumns = editor.opts.colors ? editor.opts.colors.split('|') : new Array(6),
            html = [],
            cmd = $.sceditor.command.get('neon');
            if (!cmd._htmlCache) {
                for (i = 0; i < colorColumns.length; ++i) {
                    colors = colorColumns[i] ? colorColumns[i].split(',') : new Array(37);
                    html.push('<div class="sceditor-color-column">');
                    for (x = 0; x < colors.length; ++x) {
                        color = colors[x] || "#" + genColor.r.toString(16) + genColor.g.toString(16) + genColor.b.toString(16);
                        html.push('<a href="#" class="sceditor-color-option" style="background-color: ' + color + '" data-color="' + color + '"></a>');
                        if (x % 6 === 0) {
                            genColor.g -= 51;
                            genColor.b = 255;
                            if (genColor.g < 51) {
                                genColor.g = "00"
                            }
                        } else genColor.b -= 51;
                        if (genColor.b < 51) {
                            genColor.b = "00"
                        }
                    }
                    html.push('</div>');
                    if (i % 1 === 0) {
                        genColor.r -= 51;
                        genColor.g = 255;
                        genColor.b = 255;
                        if (genColor.r < 51) {
                            genColor.r = "00"
                        }
                    } else {
                        genColor.g = 255;
                        genColor.b = 255;
                    }
                }
                cmd._htmlCache = html.join('');
            }
            content.append(cmd._htmlCache).find('a').click(function(e) {
                callback($(this).attr('data-color'));
                editor.closeDropDown(true);
                e.preventDefault();
            });
            editor.createDropDown(caller, "color-picker", content);
        },
        exec: function(caller) {
            var editor = this;
            $.sceditor.command.get('neon')._dropDown(editor, caller, function(color) {
                var before = '<font style="color: ' + color + ';text-shadow: 0px 0px 5px ' + color + '">',
                    end = '</font>';
                editor.wysiwygEditorInsertHtml(before, end)
            });
        },
        txtExec: function(caller) {
            var editor = this;
            $.sceditor.command.get('neon')._dropDown(editor, caller, function(color) {
                editor.insertText("[neon=" + color + "]", "[/neon]");
            });
        },
        tooltip: 'Neon'
    });
 
    toolbar = toolbar.replace(/quote/,'neon, quote');
 
    // Styles
    $('head').append(
    '<style type="text/css">' +
    '.sceditor-button-neon div {' +
    '  background:url(https://cdn2.iconfinder.com/data/icons/aspneticons_v1.0_Nov2006/color2_16x16.gif) !important}' +
    '  .sceditor-neon {' +
    '  width:auto;' +
    '  height:auto;' +
    '  overflow-y:auto;' +
    '}' +
    '.sceditor-neon-picker {' +
    '  padding: 0 !important;' +
    '}' +
    '.sceditor-neon-option {' +
    'border: 1px solid #fff;' +
    'display: block;' +
    'height: 10px;' +
    'overflow: hidden;' +
    'width: 10px;' +
    '}' +
    '</style>'
    );
});
Victor Monteiro

Victor Monteiro
****

Membro desde : 14/07/2018
Mensagens : 272
Pontos : 421

http://derby-family.forumeiros.com/

Ir para o topo Ir para baixo

Admineiro

Tópico resolvido Re: BBCode Neon com erros

Mensagem por tikky 05.08.18 15:56

Olá @Victor Monteiro,
Para que o seu código funcione você necessita usar mais, com revestimento em todas às páginas, este JS:
Código:
/*
 *  Application: Create New BBCode Tags
 *  Date: 18/05/2018
 *  Version: 1.321052018
 *  Copyright (c) 2018 Daemon <bestskins.forumeiros.com>
 *  This work is free. You can redistribute it and/or modify it
 */
(function() {
    BBParser = {
        initialize: function() {
            $(function() {
                BBParser.setupBBParser();
            });
        },
        add: [
            /*
            * Note: Add a comma at the end of each new entry
            * '{option}' corresponds to the optional tag title, and '{content}' correspond to the text between the tags
            */
 
            {
                tag: 'neon',
                close: true,
                replacement: '<font style="color: {option};text-shadow: 0px 0px 5px {option}">{content}</font>'
            }
 
            // Note: Do not add a comma at the end of the last entry
        ],
        // Do not change anything down
        validateTag: function(a) {
            if (!/^\w+$/.test(a)) throw new RangeError("You added an invalid tag: " + a);
        },
        replacers: function(a, b, c) {
            return (a || "").replace(/{option}/g, b || "").replace(/{content}/g, c || "");
        },
        optionReg: /.*?=("|'|)(.*?)\1\]/,
        parsedContent: function(a, b, c) {
            return a.replace(c ? RegExp("(\\[" + b.tag + "[^\\]]*\\])([\\s\\S]*?)\\[/" + b.tag + "]", "g" + (b.insensitive ? "i" : "")) : RegExp("\\[" + b.tag + "[^\\]]*\\]", "g" + (b.insensitive ? "i" : "")), function(d, e, f) {
                c || (e = d);
                e = BBParser.optionReg.test(e) ? e.replace(BBParser.optionReg, "$2") : b.defaultOption;
                if("undefined" !== typeof b.replace) {
                    d = c ? b.replace(e, f) : b.replace(e);
                    "string" === typeof d ? c ? f = d : e = d : d;
                    "object" === typeof d && (e = d.option || e, f = d.content || f);
                }
                return BBParser.replacers(b.replacement, e, f);
            });
        },
        setupBBParser: function() {
            var postContent = $(".entry-content, .blog_message");
            for (var i = 0, e;(e = postContent[i++]);) {
                for (var j in BBParser.add) {
                    var item = BBParser.add[j];
                    // Validating tag
                    BBParser.validateTag(item.tag);
                    e.innerHTML = BBParser.parsedContent(e.innerHTML, item, item.close);
                }
            }
        }
    };
    BBParser.initialize()
})();


Cordialmente,
pedxz
tikky

tikky
Admineiro
Admineiro

Membro desde : 13/01/2017
Mensagens : 7820
Pontos : 9063

Ir para o topo Ir para baixo

Tópico resolvido Re: BBCode Neon com erros

Mensagem por Victor Monteiro 05.08.18 16:01

Adicionei não funciona ainda...
Victor Monteiro

Victor Monteiro
****

Membro desde : 14/07/2018
Mensagens : 272
Pontos : 421

http://derby-family.forumeiros.com/

Ir para o topo Ir para baixo

Admineiro

Tópico resolvido Re: BBCode Neon com erros

Mensagem por tikky 05.08.18 16:03

Mude para
Código:
/*
 *  Application: Create New BBCode Tags
 *  Date: 18/05/2018
 *  Version: 1.321052018
 *  Copyright (c) 2018 Daemon <bestskins.forumeiros.com>
 *  This work is free. You can redistribute it and/or modify it
 */
(function() {
    BBParser = {
        initialize: function() {
            $(function() {
                BBParser.setupBBParser();
            });
        },
        add: [
            /*
            * Note: Add a comma at the end of each new entry
            * '{option}' corresponds to the optional tag title, and '{content}' correspond to the text between the tags
            */
 
            {
                tag: 'neon',
                close: true,
                replacement: '<font style="color: {option};text-shadow: 0px 0px 5px {option}">{content}</font>'
            }
 
            // Note: Do not add a comma at the end of the last entry
        ],
        // Do not change anything down
        validateTag: function(a) {
            if (!/^\w+$/.test(a)) throw new RangeError("You added an invalid tag: " + a);
        },
        replacers: function(a, b, c) {
            return (a || "").replace(/{option}/g, b || "").replace(/{content}/g, c || "");
        },
        optionReg: /.*?=("|'|)(.*?)\1\]/,
        parsedContent: function(a, b, c) {
            return a.replace(c ? RegExp("(\\[" + b.tag + "[^\\]]*\\])([\\s\\S]*?)\\[/" + b.tag + "]", "g" + (b.insensitive ? "i" : "")) : RegExp("\\[" + b.tag + "[^\\]]*\\]", "g" + (b.insensitive ? "i" : "")), function(d, e, f) {
                c || (e = d);
                e = BBParser.optionReg.test(e) ? e.replace(BBParser.optionReg, "$2") : b.defaultOption;
                if("undefined" !== typeof b.replace) {
                    d = c ? b.replace(e, f) : b.replace(e);
                    "string" === typeof d ? c ? f = d : e = d : d;
                    "object" === typeof d && (e = d.option || e, f = d.content || f);
                }
                return BBParser.replacers(b.replacement, e, f);
            });
        },
        setupBBParser: function() {
            var postContent = $(".postbody .content");
            for (var i = 0, e;(e = postContent[i++]);) {
                for (var j in BBParser.add) {
                    var item = BBParser.add[j];
                    // Validating tag
                    BBParser.validateTag(item.tag);
                    e.innerHTML = BBParser.parsedContent(e.innerHTML, item, item.close);
                }
            }
        }
    };
    BBParser.initialize()
})();
tikky

tikky
Admineiro
Admineiro

Membro desde : 13/01/2017
Mensagens : 7820
Pontos : 9063

Ir para o topo Ir para baixo

Tópico resolvido Re: BBCode Neon com erros

Mensagem por Victor Monteiro 05.08.18 16:03

Sim muda isso no novo javascript?
Victor Monteiro

Victor Monteiro
****

Membro desde : 14/07/2018
Mensagens : 272
Pontos : 421

http://derby-family.forumeiros.com/

Ir para o topo Ir para baixo

Admineiro

Tópico resolvido Re: BBCode Neon com erros

Mensagem por tikky 05.08.18 16:04

No JS que eu passei em cima, é um novo JS, não misture com o do Neon
tikky

tikky
Admineiro
Admineiro

Membro desde : 13/01/2017
Mensagens : 7820
Pontos : 9063

Ir para o topo Ir para baixo

Tópico resolvido Re: BBCode Neon com erros

Mensagem por Victor Monteiro 05.08.18 16:07

Ok fiz tudo certinho, persiste
BBCode Neon com erros CMLc2nx
O mesmo so esta funcionando na parte de edição do topico

enquanto eu salvo so aparece isso
BBCode Neon com erros JJWYE4B
e com um espaçamento maior do que o da edição
Victor Monteiro

Victor Monteiro
****

Membro desde : 14/07/2018
Mensagens : 272
Pontos : 421

http://derby-family.forumeiros.com/

Ir para o topo Ir para baixo

Admineiro

Tópico resolvido Re: BBCode Neon com erros

Mensagem por tikky 05.08.18 16:19

Remova os dois scripts, vamos refazer o processo:
1. Script do Neon
Crie uma nova página JavaScript com revestimento em todas às páginas:
Código:
/*
 *  Application: BBCode Neon
 *  Date: 14/10/2016
 *  Version: 1.114102916
 *  Copyright (c) 2016 Daemon <bestskins.forumeiros.com>
 *  This work is free. You can redistribute it and/or modify it
 */
$(function() {
    if (!$.sceditor) return;
 
    $.sceditor.plugins.bbcode.bbcode.set('neon', {
        tags: {
            font: {
                style: null
            }
        },
        quoteType: $.sceditor.BBCodeParser.QuoteType.never,
        format: function(element, content) {
            var rgbToHex = function(rgbStr) {
                var m;
                function toHex(n) {
                    n = parseInt(n,10);
                    if(isNaN(n))
                        return "00";
                        n = Math.max(0,Math.min(n,255)).toString(16);
                        return n.length<2 ? '0'+n : n;
                }
                // rgb(n,n,n);
                if((m = rgbStr.match(/rgb\((\d+),\s*?(\d+),\s*?(\d+)\)/i)))
                    return '#' + toHex(m[1]) + toHex(m[2]-0) + toHex(m[3]-0);
                    // expand shorthand
                    if((m = rgbStr.match(/#([0-f])([0-f])([0-f])\s*?$/i)))
                        return '#' + m[1] + m[1] + m[2] + m[2] + m[3] + m[3];
                        return rgbStr;
                    };
                    var color = element.css('color');
                    if(element[0].nodeName.toLowerCase() === "font" && element.attr('color'))
                        color = element.attr('color');
                        color = rgbToHex(color);
                        return '[neon=' + color + ']' + content + '[/neon]';
        },
        html: function(element, attrs, content) {
          return '<font style="color:' + attrs.defaultattr + ';text-shadow: 0px 0px 5px ' + attrs.defaultattr + '">' + content + '</font>';
        }
    });
 
    $.sceditor.command.set('neon', {
        _dropDown: function(editor, caller, callback) {
            var i, x, color, colors, genColor = {
                r: 255,
                g: 255,
                b: 255
            },
            content = $('<div />'),
            colorColumns = editor.opts.colors ? editor.opts.colors.split('|') : new Array(6),
            html = [],
            cmd = $.sceditor.command.get('neon');
            if (!cmd._htmlCache) {
                for (i = 0; i < colorColumns.length; ++i) {
                    colors = colorColumns[i] ? colorColumns[i].split(',') : new Array(37);
                    html.push('<div class="sceditor-color-column">');
                    for (x = 0; x < colors.length; ++x) {
                        color = colors[x] || "#" + genColor.r.toString(16) + genColor.g.toString(16) + genColor.b.toString(16);
                        html.push('<a href="#" class="sceditor-color-option" style="background-color: ' + color + '" data-color="' + color + '"></a>');
                        if (x % 6 === 0) {
                            genColor.g -= 51;
                            genColor.b = 255;
                            if (genColor.g < 51) {
                                genColor.g = "00"
                            }
                        } else genColor.b -= 51;
                        if (genColor.b < 51) {
                            genColor.b = "00"
                        }
                    }
                    html.push('</div>');
                    if (i % 1 === 0) {
                        genColor.r -= 51;
                        genColor.g = 255;
                        genColor.b = 255;
                        if (genColor.r < 51) {
                            genColor.r = "00"
                        }
                    } else {
                        genColor.g = 255;
                        genColor.b = 255;
                    }
                }
                cmd._htmlCache = html.join('');
            }
            content.append(cmd._htmlCache).find('a').click(function(e) {
                callback($(this).attr('data-color'));
                editor.closeDropDown(true);
                e.preventDefault();
            });
            editor.createDropDown(caller, "color-picker", content);
        },
        exec: function(caller) {
            var editor = this;
            $.sceditor.command.get('neon')._dropDown(editor, caller, function(color) {
                var before = '<font style="color: ' + color + ';text-shadow: 0px 0px 5px ' + color + '">',
                    end = '</font>';
                editor.wysiwygEditorInsertHtml(before, end)
            });
        },
        txtExec: function(caller) {
            var editor = this;
            $.sceditor.command.get('neon')._dropDown(editor, caller, function(color) {
                editor.insertText("[neon=" + color + "]", "[/neon]");
            });
        },
        tooltip: 'Neon'
    });
 
    toolbar = toolbar.replace(/quote/,'neon, quote');
 
    // Styles
    $('head').append(
    '<style type="text/css">' +
    '.sceditor-button-neon div {' +
    '  background:url(https://cdn2.iconfinder.com/data/icons/aspneticons_v1.0_Nov2006/color2_16x16.gif) !important}' +
    '  .sceditor-neon {' +
    '  width:auto;' +
    '  height:auto;' +
    '  overflow-y:auto;' +
    '}' +
    '.sceditor-neon-picker {' +
    '  padding: 0 !important;' +
    '}' +
    '.sceditor-neon-option {' +
    'border: 1px solid #fff;' +
    'display: block;' +
    'height: 10px;' +
    'overflow: hidden;' +
    'width: 10px;' +
    '}' +
    '</style>'
    );
});

2. Script do BBCode
Crie uma nova página JavaScript com revestimento em todas às páginas:
Código:
/*
 *  Application: Create New BBCode Tags
 *  Date: 18/05/2018
 *  Version: 1.321052018
 *  Copyright (c) 2018 Daemon <bestskins.forumeiros.com>
 *  This work is free. You can redistribute it and/or modify it
 */
(function() {
    BBParser = {
        initialize: function() {
            $(function() {
                BBParser.setupBBParser();
            });
        },
        add: [
            /*
            * Note: Add a comma at the end of each new entry
            * '{option}' corresponds to the optional tag title, and '{content}' correspond to the text between the tags
            */
 
            {
                tag: 'neon',
                close: true,
                replacement: '<font style="color: {option};text-shadow: 0px 0px 5px {option}">{content}</font>'
            }
 
            // Note: Do not add a comma at the end of the last entry
        ],
        // Do not change anything down
        validateTag: function(a) {
            if (!/^\w+$/.test(a)) throw new RangeError("You added an invalid tag: " + a);
        },
        replacers: function(a, b, c) {
            return (a || "").replace(/{option}/g, b || "").replace(/{content}/g, c || "");
        },
        optionReg: /.*?=("|'|)(.*?)\1\]/,
        parsedContent: function(a, b, c) {
            return a.replace(c ? RegExp("(\\[" + b.tag + "[^\\]]*\\])([\\s\\S]*?)\\[/" + b.tag + "]", "g" + (b.insensitive ? "i" : "")) : RegExp("\\[" + b.tag + "[^\\]]*\\]", "g" + (b.insensitive ? "i" : "")), function(d, e, f) {
                c || (e = d);
                e = BBParser.optionReg.test(e) ? e.replace(BBParser.optionReg, "$2") : b.defaultOption;
                if("undefined" !== typeof b.replace) {
                    d = c ? b.replace(e, f) : b.replace(e);
                    "string" === typeof d ? c ? f = d : e = d : d;
                    "object" === typeof d && (e = d.option || e, f = d.content || f);
                }
                return BBParser.replacers(b.replacement, e, f);
            });
        },
        setupBBParser: function() {
            var postContent = $(".postbody .content");
            for (var i = 0, e;(e = postContent[i++]);) {
                for (var j in BBParser.add) {
                    var item = BBParser.add[j];
                    // Validating tag
                    BBParser.validateTag(item.tag);
                    e.innerHTML = BBParser.parsedContent(e.innerHTML, item, item.close);
                }
            }
        }
    };
    BBParser.initialize()
})();


se o erro persistir diga-me um tópico onde o efeito está a ser usado!
tikky

tikky
Admineiro
Admineiro

Membro desde : 13/01/2017
Mensagens : 7820
Pontos : 9063

Ir para o topo Ir para baixo

Tópico resolvido Re: BBCode Neon com erros

Mensagem por Victor Monteiro 05.08.18 16:25

Oloko
agr funcionou obrigadao msm
um bug amigo, so funciona quando eu crio um novo topico, se eu tentar editar nao funcionar
Victor Monteiro

Victor Monteiro
****

Membro desde : 14/07/2018
Mensagens : 272
Pontos : 421

http://derby-family.forumeiros.com/

Ir para o topo Ir para baixo

Admineiro

Tópico resolvido Re: BBCode Neon com erros

Mensagem por tikky 05.08.18 16:32

Tens como demostrar isso, com prints? Do meu fórum teste está a funcionar á 100% Muito feliz
tikky

tikky
Admineiro
Admineiro

Membro desde : 13/01/2017
Mensagens : 7820
Pontos : 9063

Ir para o topo Ir para baixo

Membro Entusiasta

Tópico resolvido Re: BBCode Neon com erros

Mensagem por RafaelS. 08.08.18 6:12

Tópico resolvido


Tópico marcado como resolvido pela equipe por abandono do autor.
RafaelS.

RafaelS.
Membro Entusiasta
Membro Entusiasta

Membro desde : 26/04/2014
Mensagens : 5746
Pontos : 7156

http://techmais.forumeiros.com/

Ir para o topo Ir para baixo

Ver o tópico anterior Ver o tópico seguinte Ir para o topo

- Tópicos semelhantes

Permissões neste sub-fórum
Não podes responder a tópicos