1
- import styled from '@emotion/styled'
2
- import styles from './BenchmarkEmail.styles'
1
+ /* eslint-disable camelcase */
3
2
import { Heading , SubHeading } from '@csssr/core-design'
4
3
import { PictureSmart } from '@csssr/csssr.images/dist/react'
4
+ import styled from '@emotion/styled'
5
+
6
+ import styles from './BenchmarkEmail.styles'
5
7
import TextField from './TextField'
6
8
7
9
const BenchmarkEmail = ( { className } ) => {
8
10
const isWindowContext = typeof window !== 'undefined'
9
11
10
12
function rmspaces ( x ) {
11
- var leftx = 0
12
- var rightx = x . length - 1
13
- while ( x . charAt ( leftx ) == ' ' ) {
13
+ let leftx = 0
14
+ let rightx = x . length - 1
15
+ while ( x . charAt ( leftx ) === ' ' ) {
14
16
leftx ++
15
17
}
16
- while ( x . charAt ( rightx ) == ' ' ) {
18
+ while ( x . charAt ( rightx ) === ' ' ) {
17
19
-- rightx
18
20
}
19
- var q = x . substr ( leftx , rightx - leftx + 1 )
20
- if ( leftx == x . length && rightx == - 1 ) {
21
+ let q = x . substr ( leftx , rightx - leftx + 1 )
22
+ if ( leftx === x . length && rightx = == - 1 ) {
21
23
q = ''
22
24
}
23
25
return q
24
26
}
25
27
function checkfield ( data ) {
26
- if ( rmspaces ( data ) == '' ) {
28
+ if ( rmspaces ( data ) === '' ) {
27
29
return false
28
30
} else {
29
31
return true
30
32
}
31
33
}
32
34
function isemail ( data ) {
33
- var flag = false
35
+ let flag = false
34
36
if (
35
- data . indexOf ( '@' , 0 ) == - 1 ||
36
- data . indexOf ( '\\' , 0 ) != - 1 ||
37
- data . indexOf ( '/' , 0 ) != - 1 ||
37
+ data . indexOf ( '@' , 0 ) === - 1 ||
38
+ data . indexOf ( '\\' , 0 ) !== - 1 ||
39
+ data . indexOf ( '/' , 0 ) !== - 1 ||
38
40
! checkfield ( data ) ||
39
- data . indexOf ( '.' , 0 ) == - 1 ||
40
- data . indexOf ( '@' ) == 0 ||
41
+ data . indexOf ( '.' , 0 ) === - 1 ||
42
+ data . indexOf ( '@' ) === 0 ||
41
43
data . lastIndexOf ( '.' ) < data . lastIndexOf ( '@' ) ||
42
- data . lastIndexOf ( '.' ) == data . length - 1 ||
43
- data . lastIndexOf ( '@' ) != data . indexOf ( '@' ) ||
44
- data . indexOf ( ',' , 0 ) != - 1 ||
45
- data . indexOf ( ':' , 0 ) != - 1 ||
46
- data . indexOf ( ';' , 0 ) != - 1
44
+ data . lastIndexOf ( '.' ) === data . length - 1 ||
45
+ data . lastIndexOf ( '@' ) !== data . indexOf ( '@' ) ||
46
+ data . indexOf ( ',' , 0 ) !== - 1 ||
47
+ data . indexOf ( ':' , 0 ) !== - 1 ||
48
+ data . indexOf ( ';' , 0 ) !== - 1
47
49
) {
48
50
return flag
49
51
} else {
50
- var temp = rmspaces ( data )
51
- if ( temp . indexOf ( ' ' , 0 ) != - 1 ) {
52
+ const temp = rmspaces ( data )
53
+ if ( temp . indexOf ( ' ' , 0 ) !== - 1 ) {
52
54
flag = true
53
55
}
54
- var e2 = temp . length - temp . lastIndexOf ( '.' ) - 1
55
- var i1 = temp . indexOf ( '@' )
56
- if ( temp . charAt ( i1 + 1 ) == '.' || e2 < 1 ) {
56
+ const e2 = temp . length - temp . lastIndexOf ( '.' ) - 1
57
+ const i1 = temp . indexOf ( '@' )
58
+ if ( temp . charAt ( i1 + 1 ) === '.' || e2 < 1 ) {
57
59
flag = true
58
60
}
59
61
return ! flag
60
62
}
61
63
}
62
64
63
65
function submit_LY6HHClick ( ) {
64
- var retVal = true
65
- var frm = isWindowContext && document . getElementById ( 'formbox_screen_subscribe_LY6HH' )
66
+ let retVal = true
67
+ let frm = isWindowContext && document . getElementById ( 'formbox_screen_subscribe_LY6HH' )
66
68
if ( ! isemail ( isWindowContext && document . getElementsByName ( 'fldemail_LY6HH' ) [ 0 ] . value ) ) {
67
69
alert ( 'Please enter the Email Address' )
68
70
isWindowContext && document . getElementsByName ( 'fldemail_LY6HH' ) [ 0 ] . classList . add ( 'error' )
69
71
retVal = false
70
72
}
71
- if ( retVal == true ) {
73
+ if ( retVal === true ) {
72
74
frm = '_LY6HH'
73
- var f = isWindowContext && document . createElement ( 'form' )
75
+ const f = isWindowContext && document . createElement ( 'form' )
74
76
f . setAttribute ( 'accept-charset' , 'UTF-8' )
75
77
f . setAttribute ( 'method' , 'post' )
76
78
f . setAttribute ( 'action' , 'https://lb.benchmarkemail.com//code/lbform' )
77
- var elms =
79
+ const elms =
78
80
isWindowContext && document . getElementsByName ( 'frmLB' + frm ) [ 0 ] . getElementsByTagName ( '*' )
79
- var ty = ''
80
- for ( var ei = 0 ; ei < elms . length ; ei ++ ) {
81
+ let ty = ''
82
+ for ( let ei = 0 ; ei < elms . length ; ei ++ ) {
81
83
ty = elms [ ei ] . type
82
84
if (
83
- ty == 'hidden' ||
84
- ty == 'text' ||
85
- ( ty == 'checkbox' && elms [ ei ] . checked ) ||
86
- ( ty == 'radio' && elms [ ei ] . checked ) ||
87
- ty == 'textarea' ||
88
- ty == 'select-one' ||
89
- ty == 'button'
85
+ ty === 'hidden' ||
86
+ ty === 'text' ||
87
+ ( ty === 'checkbox' && elms [ ei ] . checked ) ||
88
+ ( ty === 'radio' && elms [ ei ] . checked ) ||
89
+ ty === 'textarea' ||
90
+ ty === 'select-one' ||
91
+ ty === 'button'
90
92
) {
91
- var elm = elms [ ei ]
92
- if ( elm . id != '' ) {
93
- var i = document . createElement ( 'input' )
93
+ const elm = elms [ ei ]
94
+ if ( elm . id !== '' ) {
95
+ const i = document . createElement ( 'input' )
94
96
i . type = 'hidden'
95
97
i . name = elm . name . replace ( '_LY6HH' , '' )
96
98
i . id = elm . id
@@ -119,18 +121,18 @@ const BenchmarkEmail = ({ className }) => {
119
121
}
120
122
121
123
function debounce_LY6HH ( func , wait , immediate ) {
122
- var timeout
124
+ let timeout
123
125
124
126
return function ( ) {
125
- var context = this ,
126
- args = arguments
127
- var later = function ( ) {
127
+ const context = this
128
+ const args = arguments
129
+ const later = function ( ) {
128
130
timeout = null
129
131
if ( ! immediate ) {
130
132
func . apply ( context , args )
131
133
}
132
134
}
133
- var callNow = immediate && ! timeout
135
+ const callNow = immediate && ! timeout
134
136
clearTimeout ( timeout )
135
137
timeout = setTimeout ( later , wait )
136
138
if ( callNow ) {
@@ -139,7 +141,7 @@ const BenchmarkEmail = ({ className }) => {
139
141
}
140
142
}
141
143
142
- var hasVerticalCenter_LY6HH =
144
+ const hasVerticalCenter_LY6HH =
143
145
isWindowContext && document . getElementsByClassName ( 'position-centered' )
144
146
function verticalCenter_LY6HH ( element ) {
145
147
if ( element ) {
@@ -148,15 +150,15 @@ const BenchmarkEmail = ({ className }) => {
148
150
}
149
151
setTimeout ( function ( ) {
150
152
if ( hasVerticalCenter_LY6HH . length > 0 ) {
151
- var windowHeight = Math . max (
153
+ const windowHeight = Math . max (
152
154
isWindowContext && document . documentElement . clientHeight ,
153
155
window . innerHeight || 0 ,
154
156
)
155
- var formElement_LY6HH =
157
+ const formElement_LY6HH =
156
158
isWindowContext && document . getElementsByClassName ( 'formbox-editor_LY6HH' ) [ 0 ]
157
- var formHeight_LY6HH = formElement_LY6HH . clientHeight
159
+ const formHeight_LY6HH = formElement_LY6HH . clientHeight
158
160
if ( formHeight_LY6HH < windowHeight ) {
159
- var newPosition = 0
161
+ let newPosition = 0
160
162
newPosition = ( windowHeight - formHeight_LY6HH ) / 2
161
163
formElement_LY6HH . style . top = newPosition + 'px'
162
164
} else {
@@ -170,7 +172,7 @@ const BenchmarkEmail = ({ className }) => {
170
172
}
171
173
172
174
if ( hasVerticalCenter_LY6HH . length > 0 ) {
173
- var resizeEvent_LY6HH = debounce_LY6HH ( function ( ) {
175
+ const resizeEvent_LY6HH = debounce_LY6HH ( function ( ) {
174
176
verticalCenter_LY6HH ( )
175
177
} , 250 )
176
178
window . addEventListener ( 'resize' , resizeEvent_LY6HH )
@@ -236,6 +238,7 @@ const BenchmarkEmail = ({ className }) => {
236
238
/>
237
239
</ fieldset >
238
240
< fieldset className = "fieldset" >
241
+ { /* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */ }
239
242
< div
240
243
id = "btnSubmit_LY6HH"
241
244
className = "formbox-button_LY6HH"
0 commit comments