barbass: поправки стилей/офрмлений, переименование функций

parent df61ad83
......@@ -13,7 +13,7 @@
font-size: 15px;
background-color: #DDDDDD;
padding: 0px 2px 2px 2px;
width:300px;
width:350px;
border-radius: 10px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
text-align: center;
......@@ -57,14 +57,14 @@
<div id="e_typos_div">
<p>Выделите текст и нажмите кнопку "Отправить"</p>
<p>
<nobr>email: <input type="email" id="e_typos_email" name="e_typos_email" class="idle" onblur="this.className='idle'" onfocus="this.className='activeField'" size='19' maxlength="50" placeholder="my@email.com" /></nobr>
<nobr>e-mail: <input type="email" id="e_typos_email" name="e_typos_email" class="idle" onblur="this.className='idle'" onfocus="this.className='activeField'" size='19' maxlength="50" placeholder="my@email.com" /></nobr>
<nobr>Комментарий: <input type="text" id="e_typos_comment" name="e_typos_comment" class="idle" onblur="this.className='idle'" onfocus="this.className='activeField'" size='19' maxlength="50" placeholder="Должна быть буква..."/></nobr>
</p>
<p id="e_typos_error" class="e_typos_error"></p>
<p id="e_typos_error" class="e_typos_error" style="border:1px solid"></p>
<input type="button" value="Отправить" class="idle" onblur="this.className='idle'" onmouseup="this.className='idle'" onmousedown="this.className='activeButton'" onclick=" e_typos_post_data();" />
<input type="button" value="Закрыть" class="idle" onblur="this.className='idle'" onmouseup="this.className='idle'" onmousedown="this.className='activeButton'" onclick="e_typos_close();" />
<input type="button" value="Отправить" class="idle" onblur="this.className='idle'" onmouseup="this.className='idle'" onmousedown="this.className='activeButton'" onclick="ETY_post_data();" />
<input type="button" value="Закрыть" class="idle" onblur="this.className='idle'" onmouseup="this.className='idle'" onmousedown="this.className='activeButton'" onclick="ETY_close();" />
</div>
<div style='white-space: pre;'>
......
......@@ -5,23 +5,23 @@
*/
//////////////////////////////////////////////////////
var etersoft_typos_time = 0; //время последнего запроса
var ety_time = 0; //время последнего запроса
window.document.onkeydown = function(e) {
if (e.ctrlKey==1 && e.keyCode == 13) {
e_typos_control_panel();
ETY_control_panel();
}
}
function e_typos_control_panel() {
function ETY_control_panel() {
if (document.getElementById("e_typos_div").style.display == "block") {
e_typos_close();
ETY_close();
} else {
e_typos_div();
ETY_div();
}
}
function e_typos_div() {
function ETY_div() {
//Определяем на какой позиции X, Y всплывет элемент
var top = window.pageYOffset + window.innerHeight/3;
var left = window.pageXOffset + window.innerWidth/3;
......@@ -34,11 +34,11 @@ function e_typos_div() {
document.getElementById("e_typos_div").style.display = "block";
}
function e_typos_close() {
function ETY_close() {
document.getElementById("e_typos_div").style.display = "none";
}
function e_typos_post_data() {
function ETY_post_data() {
var this_url = window.location.href; //Текущая страница
var select_text = String(window.getSelection()).trim(); //Выделенный текст
var user_email = document.getElementById("e_typos_email").value.trim().substr(0, 50);
......@@ -46,7 +46,7 @@ function e_typos_post_data() {
user_email = "";
} else {
if (!/^([a-z0-9_-]+\.)*[a-z0-9_-]+@[a-z0-9_-]+(\.[a-z0-9_-]+)*\.[a-z]{2,4}$/.test(user_email)) {
e_typos_error("red", "email некорректен");
ETY_error("red", "e-mail некорректен");
return false;
}
}
......@@ -56,37 +56,37 @@ function e_typos_post_data() {
}
if (select_text.length == 0) {
e_typos_error("red", "Вы ничего не выделили");
ETY_error("red", "Вы ничего не выделили");
} else if (select_text.length < 5) {
e_typos_error("red", "Выделенный текст слишком короток");
ETY_error("red", "Выделенный текст слишком короток");
} else if (select_text.length > 30) {
e_typos_error("red", "Выделенный текст слишком длинный");
ETY_error("red", "Выделенный текст слишком длинный");
} else {
//Ajax-запрос
ajax_query("http://barbass.pubsandbox.eterhost.ru/typos/server.php"+"?url="+this_url+"&email="+user_email+"&comment="+user_comment+"&error_text="+select_text);
ETY_ajax_query("http://barbass.pubsandbox.eterhost.ru/typos/server.php"+"?url="+this_url+"&email="+user_email+"&comment="+user_comment+"&error_text="+select_text);
}
}
//Отправка запроса
function ajax_query(url) {
e_typos_error("black", "Идет отправка данных...");
function ETY_ajax_query(url) {
ETY_error("black", "Идет отправка данных...");
var XHR = window.XDomainRequest || window.XMLHttpRequest;
request = new XHR;//new XMLHttpRequest();
request = new XHR;
//Если не поддерживаются кроссдоменные запросы
if (request.withCredentials == undefined) {
e_typos_error("red", "Ваш браузер не может отправить данные");
ETY_error("red", "Ваш браузер не может отправить данные");
return false;
}
var result = timer();
var result = ETY_timer();
if (result == 0) {
e_typos_error("red", "Не отправляйте данные часто");
ETY_error("red", "Не отправляйте данные часто");
return false;
} else {
etersoft_typos_time = this_time();
set_storage("etersoft_typos/"+window.location.hostname+"", etersoft_typos_time);
ety_time = ETY_this_time();
ETY_set_storage("etersoft_typos/"+window.location.hostname+"", ety_time);
}
request.open("POST", url, true);
......@@ -94,66 +94,68 @@ function ajax_query(url) {
var data = request.responseText;
switch (data) {
case '10robot':
e_typos_error("red", "Есть подозрения что вы робот");
ETY_error("red", "Есть подозрения что вы робот");
break;
case '10dataerror':
e_typos_error("red", "Данные некорректны");
ETY_error("red", "Данные некорректны");
break;
case '10siteerror':
e_typos_error("red", "Данный сайт не поддерживается");
ETY_error("red", "Данный сайт не поддерживается");
break;
case '10emailerror':
e_typos_error("red", "Сервер не смог отправить письмо");
ETY_error("red", "Сервер не смог отправить письмо");
break;
case '10win':
e_typos_error("green", "Спасибо за ваше внимание");
window.setTimeout('e_typos_close()', 2000);
ETY_error("green", "Спасибо за ваше внимание");
window.setTimeout('ETY_close()', 2000);
break;
case '10inserterror':
e_typos_error("red", "Ошибка добавления данных");
ETY_error("red", "Ошибка добавления данных");
break;
case '10servererror':
e_typos_error("red", "На сервере произошла ошибка");
ETY_error("red", "На сервере произошла ошибка");
break;
default:
e_typos_error("red", "На сервере произошла ошибка");
ETY_error("red", "На сервере произошла ошибка");
break;
}
}
request.onerror = function() {
e_typos_error("red", "Ошибка отправки данных. Повторите позже");
etersoft_typos_time = 0;
ETY_error("red", "Ошибка отправки данных. Повторите позже");
ETY_time = 0;
}
request.send();
}
function e_typos_error(error, text) {
function ETY_error(color, text) {
document.getElementById("e_typos_error").style.display = "block";
document.getElementById("e_typos_error").innerHTML = text;
document.getElementById("e_typos_error").style.color = error;
document.getElementById("e_typos_error").style.color = color;
document.getElementById("e_typos_error").style.borderColor = color;
}
function timer() {
var sec = this_time();
var time_s = get_storage("etersoft_typos/"+window.location.hostname+"");
function ETY_timer() {
var sec = ETY_this_time();
var time_s = ETY_get_storage("etersoft_typos/"+window.location.hostname+"");
if (time_s != 0) {
etersoft_typos_time = time_s;
ety_time = time_s;
}
if (this_time() - parseFloat(etersoft_typos_time) < 60000) {
if (ETY_this_time() - parseFloat(ety_time) < 60000) {
return 0;
} else {
return 1;
}
}
function this_time() {
function ETY_this_time() {
var day = new Date();
var sec = day.getTime();
return sec;
}
function get_storage(key) {
function ETY_get_storage(key) {
if (window['localStorage'] != null) {
if (!localStorage.getItem(key+"")) {
return 0;
......@@ -166,7 +168,7 @@ function get_storage(key) {
}
}
function set_storage(key, data) {
function ETY_set_storage(key, data) {
if (window['localStorage'] != null) {
localStorage.setItem(key+"", data);
}
......
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