Как сделать так, чтобы сообщение отправлялось и при нажатии ctrl+enter
Вот скрипт:
Code
function haveFiles() {
var f = false;
$("input.uplFileFl").each(function() {
if ($(this).val()) f = true;
});
return f
}
document.addform.onsubmit = function() {
var namewnd = "w" + Math.floor(Math.random() * 999);
_uWnd.alert('<img src="/.s/img/wd/3/ajax.gif" border="0" alt="Загрузка">', 'Загрузка', {
name: namewnd,
w: 250,
h: 80,
tm: 0
});
$("#frF16").attr("disabled", true);
if (haveFiles()) {
_uPostForm($("form[name='addform']"), {
success: function(dt) {
parseResult(dt, namewnd);
}
})
} else {
$.post("/forum", $("form[name='addform']").serialize(), function(dt) {
parseResult(dt, namewnd)
})
};
return false;
};
function parseResult(dt, namewnd) {
var err = $("#frM2", dt).text(),
thmurl = $("a:first", dt).attr("href");
if (err) {
_uWnd.content(namewnd, '<center>' + err + '</center>');
_uWnd.setTitle(namewnd, 'Ошибка');
$("#frF16").attr("disabled", false);
setTimeout(function() {
_uWnd.close(namewnd)
}, 2000);
} else if ($(dt).text().indexOf("Ответ добавлен") > -1) {
$("textarea#message").val("");
$("form[name='addform'] input:file").val("");
_uWnd.content(namewnd, '<center>Добавлено</center>');
_uWnd.setTitle(namewnd, 'Успех');
$("#frF16").attr("disabled", false);
setTimeout(function() {
_uWnd.close(namewnd)
}, 2000);
setTimeout(function() {
$(".gDivRight:first").load(thmurl + "?" + Math.floor(Math.random() * 9999) + " .gDivRight:first");
setPnt(thmurl);
}, 50);
} else {
_uWnd.content(namewnd, 'Во время отправки произошла ошибка');
_uWnd.setTitle(namewnd, 'Не удалось');
$("#frF16").attr("disabled", false);
setTimeout(function() {
_uWnd.close(namewnd)
}, 2000);
}
};