Wrap embed js in anonymous function

This commit is contained in:
Jeremy Zhang 2017-04-13 00:42:32 +00:00
parent 56dc12fcc2
commit a0003388ae
2 changed files with 430 additions and 425 deletions

View File

@ -5,6 +5,7 @@
/* global bot_client_id */
/* global moment */
(function () {
var logintimer; // timer to keep track of user inactivity after hitting login
var fetchtimeout; // fetch routine timer
var last_message_id; // last message tracked
@ -140,6 +141,9 @@ function fill_channels(channels) {
if (chan.read) {
var rendered = Mustache.render(template, {"channelid": chan.channel.id, "channelname": chan.channel.name});
$("#channels-list").append(rendered);
$("#channel-" + chan.channel.id.toString()).click({"channel_id": chan.channel.id.toString()}, function(event) {
select_channel(event.data.channel_id);
});
if (chan.channel.id == selected_channel) {
if (chan.write) {
$("#messagebox").prop('disabled', false);
@ -410,7 +414,7 @@ $("#custom_username_field").keyup(function(event){
Materialize.toast('Illegal username provided! Only alphanumeric, spaces, dashes, and underscores allowed in usernames.', 10000);
}
unlock_login_fields();
})
});
}
}
});
@ -439,7 +443,7 @@ $("#messagebox").keyup(function(event){
});
funct.always(function() {
$("#messagebox").attr('readonly', false);
})
});
}
});
@ -457,3 +461,4 @@ $('#members-btn').sideNav({
draggable: true // Choose whether you can drag to open on touch screens
}
);
})();

View File

@ -109,7 +109,7 @@
{% raw %}
<script id="mustache_channellistings" type="text/template">
<li><a class="waves-effect truncate" id="channel-{{channelid}}" onclick='select_channel("{{channelid}}");'><span class="channel-hash">#</span> {{channelname}}</a></li>
<li><a class="waves-effect truncate" id="channel-{{channelid}}"><span class="channel-hash">#</span> {{channelname}}</a></li>
</script>
<script id="mustache_authedusers" type="text/template">
@ -126,8 +126,8 @@
{% endraw %}
<script>
var guild_id = "{{ guild_id }}";
var bot_client_id = "{{ client_id }}";
const guild_id = "{{ guild_id }}";
const bot_client_id = "{{ client_id }}";
</script>
<script type="text/javascript" src="{{ url_for('static', filename='js/embed.js') }}"></script>