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
febd52d8
Commit
febd52d8
authored
May 01, 2012
by
Владислав Большаков
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
barbass: делаем объект
parent
78c3d39b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
184 additions
and
4 deletions
+184
-4
default.php
default.php
+4
-4
etersoft_typos2.js
etersoft_typos2.js
+180
-0
No files found.
default.php
View file @
febd52d8
...
...
@@ -63,9 +63,9 @@
<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=
"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>
<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;'
>
</br>
...
...
@@ -369,5 +369,5 @@ hgfgjhfgm,hgfhnfghnlfghlgfhgflhfghklgfhkghkgfhkgfkhhjkgfhklfghjh
h gjhfgm,hgfhnfghnlfghlgfhgflhfghklgfhkghkgfhkgfkhhjkgfhklfghjh
fg
<br>
gjhfgm,hg
</div>
<script
src=
"etersoft_typos.js"
></script>
<script
src=
"etersoft_typos
2
.js"
></script>
</body>
etersoft_typos2.js
0 → 100644
View file @
febd52d8
/* Плагин: сервис опечаток от компании Etersoft
* email: info@etersoft.ru
* автор: barbass@etersoft.ru
* дата: 2012-04-18
*/
//////////////////////////////////////////////////////
window
.
document
.
onkeydown
=
function
(
e
)
{
if
(
e
.
ctrlKey
==
1
&&
e
.
keyCode
==
13
)
{
ETY
.
control_panel
();
}
}
var
ETY
=
{
time
:
0
,
//время последнего запроса
server_url
:
"http://barbass.pubsandbox.eterhost.ru/typos/server2.php"
,
control_panel
:
function
()
{
if
(
document
.
getElementById
(
"e_typos_div"
).
style
.
display
==
"block"
)
{
this
.
close
();
}
else
{
this
.
div
();
}
},
div
:
function
()
{
//Определяем на какой позиции X, Y всплывет элемент
var
top
=
window
.
pageYOffset
+
window
.
innerHeight
/
3
;
var
left
=
window
.
pageXOffset
+
window
.
innerWidth
/
3
;
document
.
getElementById
(
"e_typos_div"
).
style
.
top
=
top
+
"px"
;
document
.
getElementById
(
"e_typos_div"
).
style
.
left
=
left
+
"px"
;
document
.
getElementById
(
"e_typos_error"
).
style
.
display
=
"none"
;
document
.
getElementById
(
"e_typos_comment"
).
value
=
""
;
document
.
getElementById
(
"e_typos_div"
).
style
.
display
=
"block"
;
},
close
:
function
()
{
document
.
getElementById
(
"e_typos_div"
).
style
.
display
=
"none"
;
},
post_data
:
function
()
{
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
);
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
))
{
this
.
error
(
"red"
,
"e-mail некорректен"
);
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
)
{
this
.
error
(
"red"
,
"Вы ничего не выделили"
);
}
else
if
(
select_text
.
length
<
5
)
{
this
.
error
(
"red"
,
"Выделенный текст слишком короток"
);
}
else
if
(
select_text
.
length
>
30
)
{
this
.
error
(
"red"
,
"Выделенный текст слишком длинный"
);
}
else
{
//Ajax-запрос
this
.
ajax_query
(
this
.
server_url
+
"?url="
+
this_url
+
"&email="
+
user_email
+
"&comment="
+
user_comment
+
"&error_text="
+
select_text
);
}
},
//Отправка запроса
ajax_query
:
function
(
url
)
{
this
.
error
(
"black"
,
"Идет отправка данных..."
);
var
XHR
=
window
.
XDomainRequest
||
window
.
XMLHttpRequest
;
request
=
new
XHR
;
//Если не поддерживаются кроссдоменные запросы
if
(
request
.
withCredentials
==
undefined
)
{
this
.
error
(
"red"
,
"Ваш браузер не может отправить данные"
);
return
false
;
}
var
result
=
this
.
timer
();
if
(
result
==
0
)
{
this
.
error
(
"red"
,
"Не отправляйте данные часто"
);
return
false
;
}
else
{
this
.
time
=
this
.
now_time
();
this
.
set_storage
(
"etersoft_typos/"
+
window
.
location
.
hostname
+
""
,
this
.
time
);
}
request
.
open
(
"POST"
,
url
,
true
);
request
.
onload
=
function
()
{
var
data
=
request
.
responseText
;
switch
(
data
)
{
case
'10robot'
:
ETY
.
error
(
"red"
,
"Есть подозрения что вы робот"
);
break
;
case
'10dataerror'
:
ETY
.
error
(
"red"
,
"Данные некорректны"
);
break
;
case
'10siteerror'
:
ETY
.
error
(
"red"
,
"Данный сайт не поддерживается"
);
break
;
case
'10emailerror'
:
ETY
.
error
(
"red"
,
"Сервер не смог отправить письмо"
);
break
;
case
'10win'
:
ETY
.
error
(
"green"
,
"Спасибо за ваше внимание"
);
window
.
setTimeout
(
'ETY.close()'
,
2000
);
break
;
case
'10inserterror'
:
ETY
.
error
(
"red"
,
"Ошибка добавления данных"
);
break
;
case
'10servererror'
:
ETY
.
error
(
"red"
,
"На сервере произошла ошибка"
);
break
;
default
:
ETY
.
error
(
"red"
,
"На сервере произошла ошибка"
);
break
;
}
}
request
.
onerror
=
function
()
{
ETY
.
error
(
"red"
,
"Ошибка отправки данных. Повторите позже"
);
this
.
time
=
0
;
}
request
.
send
();
},
error
:
function
(
color
,
text
)
{
document
.
getElementById
(
"e_typos_error"
).
style
.
display
=
"block"
;
document
.
getElementById
(
"e_typos_error"
).
innerHTML
=
text
;
document
.
getElementById
(
"e_typos_error"
).
style
.
color
=
color
;
document
.
getElementById
(
"e_typos_error"
).
style
.
borderColor
=
color
;
},
timer
:
function
()
{
var
sec
=
this
.
now_time
();
var
time_s
=
this
.
get_storage
(
"etersoft_typos/"
+
window
.
location
.
hostname
+
""
);
if
(
time_s
!=
0
)
{
this
.
time
=
time_s
;
}
if
(
this
.
now_time
()
-
parseFloat
(
this
.
time
)
<
60000
)
{
return
0
;
}
else
{
return
1
;
}
},
now_time
:
function
()
{
var
day
=
new
Date
();
var
sec
=
day
.
getTime
();
return
sec
;
},
get_storage
:
function
(
key
)
{
if
(
window
[
'localStorage'
]
!=
null
)
{
if
(
!
localStorage
.
getItem
(
key
+
""
))
{
return
0
;
}
else
{
var
data
=
localStorage
.
getItem
(
key
+
""
);
return
data
;
}
}
else
{
return
0
;
}
},
set_storage
:
function
(
key
,
data
)
{
if
(
window
[
'localStorage'
]
!=
null
)
{
localStorage
.
setItem
(
key
+
""
,
data
);
}
}
}
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