diff mbox series

Case when I can not unstage the hunk

Message ID 9994851539606820@myt5-f9d71769b752.qloud-c.yandex.net (mailing list archive)
State New, archived
Headers show
Series Case when I can not unstage the hunk | expand

Commit Message

Eugen Konkov Oct. 15, 2018, 12:33 p.m. UTC
Hi. 
Here is log:

git reset HEAD -p /home/kes/s/public/v2/js/contact_us.js
diff mbox series

Patch

diff --git a/public/v2/js/contact_us.js b/public/v2/js/contact_us.js
index e05be6d0..d429d291 100644
--- a/public/v2/js/contact_us.js
+++ b/public/v2/js/contact_us.js
@@ -1,7 +1,19 @@ 
+
+
+function captchaProcess( form ) {
+      var id =  $(form).find( 'textarea[name=g-recaptcha-response]' )
+        .attr( 'id' ).match( /\d+$/ );
+      if( id ){ id =  id[0] } else { id = 0 }
+      grecaptcha.reset( Number( id ) );
+      grecaptcha.execute( Number( id ) );
+      // When .execute is done this will trigger callback
+      // which is specified on g-recaptcha div element via data-callback attr
+}
+
+
 // FORM VALIDATION
-var validator;
 $(function(){
-  validator =  $('#contact_us-form').validate({
+  $('#contact_us-form').validate({
     rules: {
       name: {
         required: true,
Unstage this hunk [y,n,q,a,d,j,J,g,/,s,e,?]? s
Split into 3 hunks.
@@ -1 +1,14 @@ 
+
+
+function captchaProcess( form ) {
+      var id =  $(form).find( 'textarea[name=g-recaptcha-response]' )
+        .attr( 'id' ).match( /\d+$/ );
+      if( id ){ id =  id[0] } else { id = 0 }
+      grecaptcha.reset( Number( id ) );
+      grecaptcha.execute( Number( id ) );
+      // When .execute is done this will trigger callback
+      // which is specified on g-recaptcha div element via data-callback attr
+}
+
+
 // FORM VALIDATION
Unstage this hunk [y,n,q,a,d,j,J,g,/,e,?]? n
@@ -1,3 +14,2 @@ 
 // FORM VALIDATION
-var validator;
 $(function(){
Unstage this hunk [y,n,q,a,d,K,j,J,g,/,e,?]? y
@@ -3,5 +15,5 @@ 
 $(function(){
-  validator =  $('#contact_us-form').validate({
+  $('#contact_us-form').validate({
     rules: {
       name: {
         required: true,
Unstage this hunk [y,n,q,a,d,K,j,J,g,/,e,?]? y
@@ -47,12 +59,7 @@  $(function(){
       $(element).removeClass("error_inp");
     },
     submitHandler: function(form) {
-      var id =  $(form).find( 'textarea[name=g-recaptcha-response]' )
-        .attr( 'id' ).match( /\d+$/ );
-      if( id ){ id =  id[0] } else { id = 0 }
-      grecaptcha.execute( Number( id ) );
-      // When .execute is done this will trigger callback
-      // which is specified on g-recaptcha div element via data-callback attr
+      captchaProcess( form );
     }
   });
 });
Unstage this hunk [y,n,q,a,d,K,g,/,e,?]? n
error: patch failed: public/v2/js/contact_us.js:1
error: public/v2/js/contact_us.js: patch does not apply
diff --git a/public/v2/js/contact_us.js b/public/v2/js/contact_us.js
index e05be6d0..d429d291 100644
--- a/public/v2/js/contact_us.js
+++ b/public/v2/js/contact_us.js
@@ -1,7 +1,6 @@ 
 // FORM VALIDATION
-var validator;
 $(function(){
-  validator =  $('#contact_us-form').validate({
+  $('#contact_us-form').validate({
     rules: {
       name: {
         required: true,



DETAILS:

git diff -b -w --ignore-blank-lines /home/kes/s/public/v2/js/contact_us.js
diff --git a/public/v2/js/contact_us.js b/public/v2/js/contact_us.js
index d429d291..bd1f4ddd 100644
--- a/public/v2/js/contact_us.js
+++ b/public/v2/js/contact_us.js
@@ -1,10 +1,24 @@ 
 
+function show_validator_errors( xhr, validator ) {
+  if( xhr.status == 404 ) { return }
+
+  var res =  xhr.responseJSON;
+  // TODO: Display responseText if there is no responseJSON
+  if( !res ) { return };
+
+  var errors =  {};
+  // convert server response into validator format
+  for( var error in res.error.info ) {
+    errors[error] =  res.error.info[ error ][ 1 ] || 'Error';
+  }
+  validator.showErrors( errors );
+}
+
 
 function captchaProcess( form ) {
       var id =  $(form).find( 'textarea[name=g-recaptcha-response]' )
         .attr( 'id' ).match( /\d+$/ );
       if( id ){ id =  id[0] } else { id = 0 }
-      grecaptcha.reset( Number( id ) );
       grecaptcha.execute( Number( id ) );
       // When .execute is done this will trigger callback
       // which is specified on g-recaptcha div element via data-callback attr








git diff -b -w --ignore-blank-lines --staged /home/kes/s/public/v2/js/contact_us.js
diff --git a/public/v2/js/contact_us.js b/public/v2/js/contact_us.js
index e05be6d0..d429d291 100644
--- a/public/v2/js/contact_us.js
+++ b/public/v2/js/contact_us.js
@@ -1,7 +1,19 @@ 
+
+
+function captchaProcess( form ) {
+      var id =  $(form).find( 'textarea[name=g-recaptcha-response]' )
+        .attr( 'id' ).match( /\d+$/ );
+      if( id ){ id =  id[0] } else { id = 0 }
+      grecaptcha.reset( Number( id ) );
+      grecaptcha.execute( Number( id ) );
+      // When .execute is done this will trigger callback
+      // which is specified on g-recaptcha div element via data-callback attr
+}
+
+
 // FORM VALIDATION
-var validator;
 $(function(){
-  validator =  $('#contact_us-form').validate({
+  $('#contact_us-form').validate({
     rules: {
       name: {
         required: true,