Add Counter #2
@ -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,21 +23,28 @@ $('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');
|
||||||
$('.modal').html(ipsum);
|
$('.modal').html(ipsum);
|
||||||
|
|
||||||
var range = document.createRange();
|
var range = document.createRange();
|
||||||
range.selectNodeContents($('.modal')[0]);
|
range.selectNodeContents($('.modal')[0]);
|
||||||
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);
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user