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'); var $run = $('h1, h3, .options, a');
$('li[contenteditable]').click(function(e) { $('li[contenteditable]').click(function(e) {
if($(this).html() == 'عدد وارد کنید') $(this).html(' '); if($(this).html() == 'عدد وارد کنید') $(this).html(' ');
}) });
$('li[contenteditable]').on('keydown', function(e) { $('li[contenteditable]').on('keydown', function(e) {
if(e.keyCode !== 8 && isNaN(+e.key)) return e.preventDefault(); if(e.keyCode !== 8 && isNaN(+e.key)) return e.preventDefault();
}) });
$('li[contenteditable]').on('keyup', function(e) { $('li[contenteditable]').on('keyup', function(e) {
$(this).data('val', /\d*/.exec($(this).html())); $(this).data('val', /\d*/.exec($(this).html()));
}) });
$('a').click(function(e) { $('a[href="#"]').click(function(e) {
e.preventDefault(); e.preventDefault();
var $this = $(this); var $this = $(this);
@ -21,13 +23,13 @@ $('a').click(function(e) {
$.ajax({ $.ajax({
url: url, url: url,
success: success success: success
}) });
}) });
$('li').click(function() { $('li').click(function() {
$(this).parent().find('li').removeClass('active'); $(this).parent().find('li').removeClass('active');
$(this).addClass('active'); $(this).addClass('active');
}) });
function success(ipsum) { function success(ipsum) {
$('a').removeClass('running'); $('a').removeClass('running');
@ -38,4 +40,11 @@ function success(ipsum) {
var selection = window.getSelection(); var selection = window.getSelection();
selection.removeAllRanges(); selection.removeAllRanges();
selection.addRange(range); selection.addRange(range);
socket.emit('counter', ipsum);
} }
socket.emit('counter');
socket.on('counter', function(count) {
$('#count').text(count);
});