barbass: шаблон и управляющий скрипт

parents
<html>
<head>
<meta charset="utf-8" />
<script src="etersoft_typos.js"></script>
</head>
<body>
<div id="e_typos_div" style="display:none;">
<table>
<a href="javascript:void(0)" onclick="e_typos_close()">Закрыть</a>
<tr>
<td>Введите капчу:</td>
<td>тут будет капча</td>
</tr>
<tr>
<td title="Не обязательное поле">Ваш email:</td>
<td><input type='email' name='e_typos_email' id='e_typos_email'></td>
</tr>
<tr>
<td colspan="2" align="center"><div id="e_typos_error" style="display:none;"></div></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="button" onclick="e_typos_post_data()" value="Отправить"></td>
</tr>
</table>
</div>
</br>
<p>Ехал грека через реку</p>
</body>
/* Плагин: сервис опечаток от компании Etersoft
* email: info@etersoft.ru
* автор: barbass@etersoft.ru
* дата: 2012-04-18
*/
window.document.onkeydown = function(e) {
if (e.ctrlKey==1 && e.keyCode == 69) {
e_typos_control_panel();
}
}
function e_typos_control_panel() {
if (document.getElementById("e_typos_div").style.display == "block") {
e_typos_close();
} else {
e_typos_div();
}
}
function e_typos_div() {
document.getElementById("e_typos_error").style.display = "none";
document.getElementById("e_typos_div").style.display = "block";
}
function e_typos_close() {
document.getElementById("e_typos_div").style.display = "none";
}
function e_typos_post_data() {
var this_url = window.location.href; //Текущая страница
var select_text = String(document.getSelection()); //Выделенный текст
var user_email = document.getElementById("e_typos_email").value;
if (user_email == '') {
user_email = "не указан";
}
if (select_text.length == 0) {
e_typos_error("red", "Вы ничего не выделили");
} else if (select_text.length <= 5) {
e_typos_error("red", "Выделенный текст слишком короток");
} else {
//Ajax-запрос
e_typos_error("green", "Ваш текст:"+select_text+"<br/>Спасибо за ваше внимание");
}
}
function e_typos_error(error, text) {
document.getElementById("e_typos_error").style.display = "block";
document.getElementById("e_typos_error").innerHTML = text;
document.getElementById("e_typos_error").style.color = error;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment