From 9c5abd9b54138693098850212263d253c0b0024b Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Tue, 18 Jul 2017 04:46:26 +0000 Subject: [PATCH] Add defaultchannel query parameter to embed to set default embed channel --- webapp/titanembeds/static/js/embed.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/webapp/titanembeds/static/js/embed.js b/webapp/titanembeds/static/js/embed.js index 3f590e3..e71e02d 100644 --- a/webapp/titanembeds/static/js/embed.js +++ b/webapp/titanembeds/static/js/embed.js @@ -273,16 +273,32 @@ if (guildobj === undefined) { var guild = query_guild(); guild.done(function(data) { + switch_to_default_channel(data.channels); prepare_guild(data); $('#loginmodal').modal('close'); unlock_login_fields(); }); } else { + switch_to_default_channel(guildobj.channels); prepare_guild(guildobj); $('#loginmodal').modal('close'); unlock_login_fields(); } } + + function switch_to_default_channel(guildchannels) { + var defaultChannel = getParameterByName("defaultchannel"); + if (!defaultChannel) { + return; + } + for (var i = 0; i < guildchannels.length; i++) { + if (guildchannels[i].channel.id == defaultChannel) { + selected_channel = defaultChannel; + debugger; + return; + } + } + } function prepare_guild(guildobj) { emoji_store = guildobj.emojis;