Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
retypos-webclient
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eterfund
retypos-webclient
Commits
a6e4e527
Commit
a6e4e527
authored
Apr 19, 2012
by
Владислав Большаков
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
barbass: ajax-запрос, оформление, принимащий файл
parent
88b9d60e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
18 deletions
+103
-18
2.php
2.php
+28
-0
default.php
default.php
+17
-11
etersoft_typos.js
etersoft_typos.js
+58
-7
No files found.
2.php
0 → 100644
View file @
a6e4e527
<?php
$email
=
$_REQUEST
[
'email'
];
$url
=
$_REQUEST
[
'url'
];
$comment
=
$_REQUEST
[
'comment'
];
$error_text
=
$_REQUEST
[
'error_text'
];
echo
(
$error_text
);
$mas_url
=
parse_url
(
$url
);
//Достаем номер сайта ?нужно ли? и емайлы полльзователей
$query
=
"SELECT s.id AS site, u.email AS email
FROM sites AS s
JOIN users AS u
JOIN responsible AS r ON r.id_site = s.id
WHERE site = '"
.
$mas_url
[
"host"
]
.
"' AND r.status = 1"
;
$id_site
=
2
;
$id_user
=
1
;
$message_email
=
"Сайт: "
.
$mas_url
[
"host"
]
.
"<br/>"
;
$message_email
.=
"Ссылка: <a href=
$url
>нажмите</a><br/>"
;
$message_email
.=
"Текст с опечаткой: "
.
$error_text
.
"<br/>"
;
$message_email
.=
"email пользователя:"
.
$email
.
"<br/>"
;
$message_email
.=
"Комментарий пользователя: "
.
$comment
.
"<br/>"
;
$query2
=
"INSERT INTO messages VALUES('NULL',
$id_site
,
$url
,
$error_text
,
$email
,
$comment
,DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s'),0)"
;
$query3
=
"INSERT INTO message_perl VALUES('NULL',
$id_user
,
$message_email
)"
;
?>
default.php
View file @
a6e4e527
<html>
<head>
<meta
charset=
"utf-8"
/>
<
script
src=
"etersoft_typos.js"
></script
>
<
!--<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>
<body>
<!--draggable="true"-->
<div
id=
"e_typos_div"
style=
"display:none; position:fixed; top:center; left:40%; background-color:#DDDDDD; border-radius:10px 10px 10px 10px; box-shadow:1px -1px 7px rgba(0, 0, 0, 0.5); width:300px; font-size:15px;"
>
<!--<div style="text-align:right"><a href="javascript:void(0)" onclick="e_typos_close()">Закрыть</a></div>-->
<table
style=
"text-align:center;"
style=
"width:200px; font-size: 15px;"
>
<tr>
<td>
Введите капчу:
</td>
<td>
тут будет капча
</td>
<td
colspan=
"2"
align=
"center"
>
Выделите текст и нажмите кнопку "Отправить"
</td>
</tr>
<tr>
<td
title=
"Не обязательное поле"
>
Ваш email:
</td>
<td><input
type=
'email'
name=
'e_typos_email'
id=
'e_typos_email'
></td>
<td><input
type=
'email'
name=
'e_typos_email'
id=
'e_typos_email'
size=
"19"
maxlength=
"50"
></td>
</tr>
<tr>
<td
title=
"Не обязательное поле"
>
Комментарий:
</td>
<td><input
type=
'text'
name=
'e_typos_comment'
id=
'e_typos_comment'
size=
"19"
maxlength=
"50"
></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>
<td
colspan=
"2"
align=
"center"
><input
type=
"button"
onclick=
"e_typos_post_data()"
value=
"Отправить"
><
input
type=
"button"
onclick=
"e_typos_close()"
value=
"Отмена"
><
/td>
</tr>
</table>
</div>
</br>
<p>
Ехал грека через реку
</p>
<p>
Ехал грека через реку. Не будет мира вне власти моей. Я тучка, тучка, тучка, я вовсе не медведь
</p>
Нажмите Ctrl+Enter
<!--<script src="etersoft_typos.js"></script>-->
<script
src=
"etersoft_typos.js"
></script>
</body>
etersoft_typos.js
View file @
a6e4e527
...
...
@@ -3,9 +3,16 @@
* автор: barbass@etersoft.ru
* дата: 2012-04-18
*/
/*
el = document.getElementById("e_typos_div")
document.addEventListener('dragstart', function (e) {
e.dataTransfer.effectAllowed = 'copy'; // only dropEffect='copy' will be dropable
e.dataTransfer.setData('Text', this.id); // required otherwise doesn't work
}, true);
*/
//////////////////////////////////////////////////////
window
.
document
.
onkeydown
=
function
(
e
)
{
if
(
e
.
ctrlKey
==
1
&&
e
.
keyCode
==
69
)
{
if
(
e
.
ctrlKey
==
1
&&
e
.
keyCode
==
13
)
{
e_typos_control_panel
();
}
}
...
...
@@ -28,24 +35,68 @@ function e_typos_close() {
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
;
var
select_text
=
String
(
document
.
getSelection
())
.
trim
()
;
//Выделенный текст
var
user_email
=
document
.
getElementById
(
"e_typos_email"
).
value
.
trim
()
;
if
(
user_email
==
''
)
{
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 некорректен."
);
return
false
;
}
}
var
user_comment
=
document
.
getElementById
(
"e_typos_comment"
).
value
.
trim
().
substr
(
0
,
50
);
if
(
user_comment
==
''
)
{
user_comment
=
"Пользователь не оставил комментарий"
;
}
if
(
select_text
.
length
==
0
)
{
e_typos_error
(
"red"
,
"Вы ничего не выделили"
);
}
else
if
(
select_text
.
length
<
=
5
)
{
}
else
if
(
select_text
.
length
<
5
)
{
e_typos_error
(
"red"
,
"Выделенный текст слишком короток"
);
}
else
if
(
select_text
.
length
>
30
)
{
e_typos_error
(
"red"
,
"Выделенный текст слишком длинный"
);
}
else
{
//Ajax-запрос
e_typos_error
(
"green"
,
"Ваш текст:"
+
select_text
+
"<br/>Спасибо за ваше внимание"
);
var
mas
=
new
Object
();
var
mas2
=
new
Array
();
mas
[
"url"
]
=
this_url
;
mas
[
"email"
]
=
user_email
;
mas
[
"comment"
]
=
user_comment
;
mas
[
"error_text"
]
=
select_text
;
mas2
[
0
]
=
"url"
;
mas2
[
1
]
=
"email"
;
mas2
[
2
]
=
"comment"
;
mas2
[
3
]
=
"error_text"
;
ajax_query
(
"http://barbass.pubsandbox.eterhost.ru/typos2/2.php"
+
"?url="
+
this_url
+
"&email="
+
user_email
+
"&comment="
+
user_comment
+
"&error_text="
+
select_text
);
}
}
//Отправка запроса
function
ajax_query
(
url
)
{
var
XHR
=
window
.
XDomainRequest
||
window
.
XMLHttpRequest
;
request
=
new
XHR
;
//new XMLHttpRequest();
request
.
open
(
"POST"
,
url
,
true
);
request
.
onload
=
function
()
{
e_typos_error
(
"green"
,
"Ваш текст:"
+
request
.
responseText
+
"<br/>Спасибо за ваше внимание"
);
}
request
.
onerror
=
function
()
{
e_typos_error
(
"red"
,
"Ошибка отправки данных. Повторите позже"
);
}
//request.onreadystatechange = response_server(request);
request
.
send
();
}
//Обработка ответа от сервера
function
response_server
(
request
)
{
if
(
request
.
onreadystatechange
==
4
)
{
e_typos_error
(
"green"
,
"Ваш текст:"
+
select_text
+
"<br/>Спасибо за ваше внимание"
);
alert
(
request
.
responseText
);
}
}
function
e_typos_error
(
error
,
text
)
{
document
.
getElementById
(
"e_typos_error"
).
style
.
display
=
"block"
;
document
.
getElementById
(
"e_typos_error"
).
innerHTML
=
text
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment