XF 2.1 Can't build my addon...

Jaxel

Well-known member
I'm having problems building my Discord addon for release.
Code:
In ReleaseBuilder.php line 324:

  Unexpected error while minifying JS: Syntax errors encountered while compiling:  Parse error. primary expression expected
This is with XF2.1. My JS files have not changed from the previous version, which had no errors.
 
Here is my JS:

Code:
var EWRdiscord = window.EWRdiscord || {};

!function($, window, document)
{
    // ################################## --- ###########################################
    
    EWRdiscord.Botcheck = XF.Element.newHandler(
    {
        $target: null,
        token: null,
        
        init: function()
        {
            $target = this.$target;
            token = $target.data('token');
        
            $target.on('click', $target, $.proxy(this, 'click'));
        },
        
        click: function(e)
        {
            var sequence = 0;
            var socket = new WebSocket("wss://gateway.discord.gg/?encoding=json&v=6");
            
            socket.onopen = function() { console.log("Discord: Websocket OPEN"); },
            socket.onerror = function(err) { console.error(err); },
            socket.onclose = function(err) { console.error(err); },
            socket.onmessage = function(msg)
            {
                try
                {
                    var data = JSON.parse(msg.data);
                    sequence = data.s;
                    
                    if (data.op == "10")
                    {
                        $target.addClass('button--cta');
                        $target.find('.button-text').text('CONNECTED');
                        console.log('Discord: Sending handshake');
                        
                        socket.send(JSON.stringify({
                            op: 2,
                            d:
                            {
                                token: token,
                                properties:
                                {
                                    $browser: "DiscordBot (8wayrunBot, v2)"
                                },
                                large_threshold: 50
                            }
                        })),
                        setInterval(function()
                        {
                            $target.find('.button-text').text('HEARTBEAT');
                            console.log('Discord: Sending heartbeat ('+sequence+')');
                            
                            socket.send(JSON.stringify(
                            {
                                op: 1,
                                d: sequence
                            }));
                        }, data.d.heartbeat_interval);
                    }
                }
                catch (err)
                {
                    $target.removeClass('button--cta');
                    $target.find('.button-text').text('ERROR');
                    console.error(err);
                }
            };
        },
    });
    
    // ################################## --- ###########################################

    XF.Element.register('discord-botcheck', 'EWRdiscord.Botcheck');
}
(window.jQuery, window, document);
 
Having the same issue with another JS file:

Code:
In functions.php line 304:

  json_decode error: Syntax error

Code:
var EWRrio = window.EWRrio || {};

!function($, window, document)
{
    // ################################## --- ###########################################
    
    EWRrio.ResizeVideo = XF.Element.newHandler(
    {
        init: function()
        {
            this.$target.on('click', '.rio-resize-small', $.proxy(this, 'small'));
            this.$target.on('click', '.rio-resize-medium', $.proxy(this, 'medium'));
            this.$target.on('click', '.rio-resize-large', $.proxy(this, 'large'));
            this.$target.on('click', '.rio-resize-popout', $.proxy(this, 'popout'));
        },
        
        small: function(e)
        {
            $('body').removeClass('rio-cinema');
            $('.rio-embed>div').attr('class', 'rio-embed-small');
            document.cookie = "xf_EWRrio_layout=small; max-age=31536000; path=/";
        },
        
        medium: function(e)
        {
            $('body').removeClass('rio-cinema');
            $('.rio-embed>div').attr('class', 'rio-embed-medium');
            document.cookie = "xf_EWRrio_layout=medium; max-age=31536000; path=/";
        },
        
        large: function(e)
        {
            $('body').addClass('rio-cinema');
            $('.rio-embed>div').attr('class', 'rio-embed-large');
        },
        
        popout: function(e)
        {
            e.preventDefault();
            
            var video = $('.rio-video').html();
            var win = window.open($(e.currentTarget).attr('href'), '_blank',
                'width=800,height=450,toolbar=no,scrollbars=no,menubar=no,resizable=yes');
            win.focus();
            
            $('.rio-embed>div').addClass('rio-embed-popped');
            $('.rio-video').html('');
            
            var winTimer = window.setInterval(function()
            {
                if (win.closed !== false)
                {
                    window.clearInterval(winTimer);
                    $('.rio-embed>div').removeClass('rio-embed-popped');
                    $('.rio-video').html(video);
                }
            }, 200);
        },
    });
    
    // ################################## --- ###########################################
    
    EWRrio.MultiPopout = XF.Element.newHandler(
    {
        init: function()
        {
            this.$target.on('click', $.proxy(this, 'popout'));
        },
        
        popout: function(e)
        {
            e.preventDefault();
            
            var win = window.open($(e.currentTarget).attr('href'), '_blank',
                'width=1280,height=720,toolbar=no,scrollbars=no,menubar=no,resizable=yes');
            win.focus();
        },
    });
    
    EWRrio.MultiViewer = XF.Element.newHandler(
    {
        init: function()
        {
            this.$target.on('click', '.rio-multi-open', $.proxy(this, 'open'));
            this.$target.on('click', '.rio-multi-close', $.proxy(this, 'close'));
            this.$target.on('click', '.rio-multi-share', $.proxy(this, 'share'));
            EWRrio.CheckActives();
        },
        
        open: function(e)
        {
            e.preventDefault();
            
            var $item = $(e.currentTarget),
                id = $item.data('id');
            
            $('.rio-multi-large').removeClass('rio-multi-large').addClass('rio-multi-small');
            $('#video_'+id).removeClass('rio-multi-small').addClass('rio-multi-large');
            $('#name_'+id).trigger('click');
        },
        
        close: function(e)
        {
            e.preventDefault();
            
            var $item = $(e.currentTarget),
                id = $item.data('id');
            
            $('#name_'+id).remove();
            $('#pane_'+id).remove();
            $('#video_'+id).remove();
            EWRrio.CheckActives();
        },
        
        share: function(e)
        {
            e.preventDefault();
            
            var channels = [];
            
            $('.rio-multi-tabs .tabs-tab').each(function()
            {
                channels.push($(this).data('key'));
            });
            
            prompt("SHARE URL", $('#TabNames').data('url') + '?q=' + channels.join(';'));
        },
    });
    
    EWRrio.MultiAdder = XF.Element.newHandler(
    {
        init: function()
        {
            this.$target.on('ajax-submit:response', $.proxy(this, 'response'));
        },
        
        response: function(e, data)
        {
            e.preventDefault();
            
            if (data.html.content)
            {
                var html = data.html.content.split('#####');

                $(html[0]).appendTo('#TabNames');
                $(html[1]).appendTo('#TabPanes');
                $(html[2]).appendTo('#TabVideos');
                
                EWRrio.CheckActives();
                $('.rio-multi-tabs .tabs-tab').off('click');
                $('.rio-multi-tabs .tabs-tab').on('click', EWRrio.FocusActive);
                XF.hideOverlays();
            }
        },
    });
    
    EWRrio.MultiTabs = XF.Element.newHandler(
    {
        init: function()
        {
            $('.rio-multi-tabs .tabs-tab').on('click', EWRrio.FocusActive);
            EWRrio.CheckActives();
        },
    });
    
    EWRrio.FocusActive = function()
    {
        $('.rio-multi-tabs .tabs-tab').removeClass('is-active');
        $('.rio-multi-panes .tabs-pane').removeClass('is-active');
        
        $(this).addClass('is-active');
        $($(this).data('pane')).addClass('is-active');
    }
    
    EWRrio.CheckActives = function()
    {
        if (!$('.rio-multi-large').length && $('.rio-multi-small').length)
        {
            $('.rio-multi-hidden').removeClass('rio-multi-hidden');
            $('.rio-multi-small:first').removeClass('rio-multi-small').addClass('rio-multi-large');
        }
        
        if (!$('.rio-multi-tabs .tabs-tab.is-active').length)
        {
            $('.rio-multi-tabs .tabs-tab:first').addClass('is-active');
            $('.rio-multi-panes .tabs-pane:first').addClass('is-active');
        }
    }
    
    // ################################## --- ###########################################

    XF.Element.register('rio-resize-video', 'EWRrio.ResizeVideo');
    
    XF.Element.register('rio-multi-popout', 'EWRrio.MultiPopout');
    XF.Element.register('rio-multi-viewer', 'EWRrio.MultiViewer');
    XF.Element.register('rio-multi-adder', 'EWRrio.MultiAdder');
    XF.Element.register('rio-multi-tabs', 'EWRrio.MultiTabs');
}
(window.jQuery, window, document);
 
Okay, I figured out the issue with my EWRdiscord JS... its related to this bug:


However, I can't figure out the issue with my EWRrio JS. That issue still remains.
 
Back
Top Bottom