MediaWiki:Resources/landingpage.js: Difference between revisions

From Donate
Jump to navigation Jump to search
Content deleted Content added
Pgehres (WMF) (talk | contribs)
creating page with JS from Template:Lp-layout-default
 
Pgehres (WMF) (talk | contribs)
adding getQuerystring function from Template:2012FR/Form-template-whereyourdonation
Line 8: Line 8:
} );
} );
} );
} );

function getQuerystring( key ) {
key = key.replace( /[\[]/, '\\\[' ).replace( /[\]]/, '\\\]' );
var regex = new RegExp( '[\\?&]' + key + '=([a-zA-Z0-9\_\-]*)' );
var qs = regex.exec( window.location.search );
return qs == null ? '' : qs[1];
}

</script>
</script>
</html>
</html>

Revision as of 18:43, 22 March 2012

<html>
<script type="text/javascript">
$( document ).ready( function () {
  // Disable submitting form with return key
  $( 'form' ).bind( 'keypress', function(e) {
    var code = ( e.keyCode ? e.keyCode : e.which );
    if ( code == 13 ) return false;
  } );
} );

function getQuerystring( key ) {
  key = key.replace( /[\[]/, '\\\[' ).replace( /[\]]/, '\\\]' );
  var regex = new RegExp( '[\\?&]' + key + '=([a-zA-Z0-9\_\-]*)' );
  var qs = regex.exec( window.location.search );
  return qs == null ? '' : qs[1];
}

</script>
</html>