diff --git a/public/src/app.js b/public/src/app.js index daf8fb2427..8327fe3af3 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -114,6 +114,17 @@ var socket, }); }); + socket.on('event:banned', function() { + app.alert({ + title: 'Banned', + message: 'You are banned you will be logged out!', + type: 'warning', + timeout: 1000 + }); + + setTimeout(app.logout, 1000); + }); + app.enter_room('global'); } }, @@ -121,6 +132,14 @@ var socket, }); } + app.logout = function() { + $.post(RELATIVE_PATH + '/logout', { + _csrf: $('#csrf_token').val() + }, function() { + window.location = RELATIVE_PATH + '/'; + }); + } + // takes a string like 1000 and returns 1,000 app.addCommas = function (text) { return text.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,"); diff --git a/public/src/forum/footer.js b/public/src/forum/footer.js index 4c05432027..45cc71312c 100644 --- a/public/src/forum/footer.js +++ b/public/src/forum/footer.js @@ -67,15 +67,7 @@ if (data['username']) userLabel.find('span').html(data['username']); - $('#logout-link').on('click', function() { - var csrf_token = $('#csrf_token').val(); - - $.post(RELATIVE_PATH + '/logout', { - _csrf: csrf_token - }, function() { - window.location = RELATIVE_PATH + '/'; - }); - }); + $('#logout-link').on('click', app.logout); } } else { $('#search-button').hide(); diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl index d5c3309234..fd59734c00 100644 --- a/public/templates/topic.tpl +++ b/public/templates/topic.tpl @@ -63,7 +63,7 @@ - +