Test Setup Failed
Push — master ( 51607c...6b8ca8 )
by Paul
03:43
created

assets/scripts/recaptcha.js   A

Size

Lines of Code 1

Duplication

Duplicated Lines 1
Ratio 100 %

Importance

Changes 0
Metric Value
dl 1
loc 1
rs 10
c 0
b 0
f 0
noi 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
// jshint unused:false
2
var glsr_render_recaptcha = function() {
3
	var id;
4
	var recaptchaEl;
5
	[].forEach.call( document.querySelectorAll( '.glsr-submit-review-form' ), function( formEl ) {
6
		formEl.onsubmit = null;
7
		recaptchaEl = formEl.querySelector( '.glsr-recaptcha-holder' );
8
		if( !recaptchaEl )return;
9
		recaptchaEl.innerHTML = '';
10
		id = grecaptcha.render( recaptchaEl, {
11
			callback: function( token ) {
12
				GLSR.submitForm( token );
13
			},
14
			'expired-callback': function() {
15
				grecaptcha.reset( id );
16
			},
17
		}, true );
18
		// recaptchaEl.setAttribute( 'data-id', id );
19
	});
20
};
21