diff --git a/spa/ajax.py b/spa/ajax.py index a33ef97..fc2209f 100644 --- a/spa/ajax.py +++ b/spa/ajax.py @@ -100,6 +100,7 @@ def get_mix_stream_url(request, mix_id): request.session['play_count'] = 1 mix = Mix.objects.get(pk=mix_id) + mix.add_play(request.user) data = { 'stream_url': mix.get_stream_path(), 'description': mix.description, diff --git a/static/js/app/dss.bootstrapper.js b/static/js/app/dss.bootstrapper.js index 2949867..c12a5b5 100644 --- a/static/js/app/dss.bootstrapper.js +++ b/static/js/app/dss.bootstrapper.js @@ -9,8 +9,8 @@ requirejs.config({ marionette: 'libs/backbone/backbone.marionette', 'backbone.wreqr': 'libs/backbone/backbone.wreqr', ich: 'libs/ICanHaz', + bootstrap: 'libs/bootstrap/bootstrap', underscore: 'libs/backbone/underscore', - backgrid: 'libs/backgrid/backgrid', text: 'libs/text', templates: '/templates', app: 'app/appv2', diff --git a/static/js/app/lib/utils.coffee b/static/js/app/lib/utils.coffee new file mode 100644 index 0000000..d9a2c2e --- /dev/null +++ b/static/js/app/lib/utils.coffee @@ -0,0 +1,23 @@ +define['jquery', 'bootstrap'] +($, bootstrap) -> + class Utils + + modal: (url) -> + if url.indexOf("#") is 0 + $(url).modal "open" + else + $.get(url,(data) -> + $("
" + data + "
").modal().on "hidden", -> + $(this).remove() + + ).success -> + $("input:text:visible:first").focus() + true + checkPlayCount: -> + if document.cookie.indexOf("sessionId") + $.getJSON "/ajax/session_play_count", (data) -> + com.podnoms.utils.modal "tpl/PlayCountLoginAlert" if (data.play_count isnt 0) and (data.play_count % 1) is 0 + true + + Utils + diff --git a/static/js/com.podnoms.utils.js b/static/js/com.podnoms.utils.js index 9347fe4..6c73076 100644 --- a/static/js/com.podnoms.utils.js +++ b/static/js/com.podnoms.utils.js @@ -9,7 +9,6 @@ if (!com) var com = {}; if (!com.podnoms) com.podnoms = {}; - com.podnoms.utils = { // Asynchronously load templates located in separate .html files loadTemplate: function (views, callback) { @@ -108,8 +107,8 @@ com.podnoms.utils = { checkPlayCount: function () { if (document.cookie.indexOf('sessionId')) { $.getJSON('/ajax/session_play_count', function (data) { - if ((data.play_count != 0) && (data.play_count % 5) == 0) { - com.podnoms.utils.showAlert('tpl/PlayCountLoginAlert'); + if ((data.play_count != 0) && (data.play_count % 1) == 0) { + com.podnoms.utils.modal('tpl/PlayCountLoginAlert'); } }); } diff --git a/templates/base.html b/templates/base.html index c555a97..0824b54 100644 --- a/templates/base.html +++ b/templates/base.html @@ -65,7 +65,6 @@ - {% endcompress %}