function f() { console.log(2) }
(function() {
var f;
f(); // f локальная и сейчас undefined
f = function() { console.log(1) } // и только тут в нее пишется ссылка на функцию
})();
f();
function f() { console.log(2) }
(function() {
f(); // f функция из родительского скоупа
f = function() { console.log(1) } // а тут она просто перезаписывается
})();
f();
$(function () {
$('[data-toggle="ajax"]').on('submit', function (e) {
e.preventDefault();
let $form = $(this);
let $formLoading = $('.ajax-form__loading', $form);
let $button = $('[type="submit"]', $form);
let data = $form.serialize();
let action = $form.data('action') || $form.attr('action');
let method = $form.attr('method');
let response = $form.data('response') || 'html';
console.log('Response type: ', response);
$button.attr('disabled', true);
$formLoading.addClass('show');
$form.trigger('beforeSend');
$.ajax({
url : action,
type : method,
data : data,
dataType: response
}).then(function (data) {
console.log('success', arguments);
$formLoading.removeClass('show');
$button.attr('disabled', false);
$form.trigger('success', [data]);
}).fail(function () {
console.log('error', arguments);
$formLoading.removeClass('show');
$button.attr('disabled', false);
$form.trigger('error');
});
});
});
function increase() {
value += step;
if (max < Infinity && value > max) value = max;
$inp.val(value);
}
function decrease() {
value -= step;
if (value < min) value = min;
$inp.val(value);
}
function repeatIncrease() {
repeatTimeout = setTimeout(function () {
repeatInterval = setInterval(increase, SPIN_INTERVAL);
}, SPIN_DELAY);
}
function repeatDecrease() {
repeatTimeout = setTimeout(function () {
repeatInterval = setInterval(decrease, SPIN_INTERVAL);
}, SPIN_DELAY);
}
$el.on('click', '.spin__button_increase', increase);
$el.on('click', '.spin__button_decrease', decrease);
$el.on('mousedown', '.spin__button_increase', repeatIncrease);
$el.on('mousedown', '.spin__button_decrease', repeatDecrease);
$el.on('mouseup mouseleave', '.spin__button', () => {
clearTimeout(repeatTimeout);
clearInterval(repeatInterval);
});
function myFunc(a) {
return a * a * 15;
}
(function () {
function myFunc2(a) {
return a * a * 15;
}
})();
var fname=url.replace(/.+\//,"");
fname = 'd:\\path\\to\\file\\' + fname;
wget -P d:\path http://site.com/file.rar