Add Counter #2

Closed
amovah wants to merge 6 commits from master into master
Showing only changes of commit d66e046a1c - Show all commits

View File

@ -1,17 +1,19 @@
var socket = io();
var $run = $('h1, h3, .options, a');
$('li[contenteditable]').click(function(e) {
if($(this).html() == 'عدد وارد کنید') $(this).html(' ');
})
});
$('li[contenteditable]').on('keydown', function(e) {
if(e.keyCode !== 8 && isNaN(+e.key)) return e.preventDefault();
})
});
$('li[contenteditable]').on('keyup', function(e) {
$(this).data('val', /\d*/.exec($(this).html()));
})
});
$('a').click(function(e) {
$('a[href="#"]').click(function(e) {
e.preventDefault();
var $this = $(this);
@ -21,21 +23,28 @@ $('a').click(function(e) {
$.ajax({
url: url,
success: success
})
})
});
});
$('li').click(function() {
$(this).parent().find('li').removeClass('active');
$(this).addClass('active');
})
});
function success(ipsum) {
$('a').removeClass('running');
$('.modal').html(ipsum);
var range = document.createRange();
range.selectNodeContents($('.modal')[0]);
var selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
socket.emit('counter', ipsum);
}
socket.emit('counter');
socket.on('counter', function(count) {
$('#count').text(count);
});