r57834 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57833‎ | r57834 | r57835 >
Date:20:35, 16 October 2009
Author:diana
Status:deferred
Tags:
Comment:
add javascript error checking, change some data reporting handling
Modified paths:
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js (added) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js
@@ -0,0 +1,40 @@
 2+//<![CDATA[
 3+
 4+function validate_form( form )
 5+{
 6+ var msg = [ 'email address', 'first name', 'last name', 'street address', 'city', 'state', 'zip code', 'credit card number', 'the CVV from the back of your card' ];
 7+
 8+ var fields = ["email","fname","lname","street","city","state","zip","card_num","cvv"],
 9+ numFields = fields.length,
 10+ i,
 11+ output = '';
 12+
 13+
 14+ for (i = 0; i < numFields; i++) {
 15+ if (document.getElementById(fields[i]).value == "")
 16+ {
 17+ output += 'Please include a value for ' + msg[i] + '.\r\n';
 18+ }
 19+
 20+ }
 21+
 22+ // validate email address
 23+ var apos=form.email.value.indexOf("@");
 24+ var dotpos=form.email.value.lastIndexOf(".");
 25+
 26+ if (apos<1||dotpos-apos<2)
 27+ {
 28+ output += "Please include a valid email address";
 29+ }
 30+
 31+ if (output)
 32+ {
 33+ alert(output);
 34+ return false;
 35+ }
 36+
 37+ return true;
 38+
 39+}
 40+
 41+//]]>
\ No newline at end of file
Property changes on: trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js
___________________________________________________________________
Name: svn:eol-style
142 + native
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
@@ -14,6 +14,8 @@
1515 $wgParser->disableCache();
1616
1717 $this->setHeaders();
 18+
 19+ $wgOut->addHeadItem('validatescript', '<script type="text/javascript" language="javascript" src="/extensions/DonationInterface/payflowpro_gateway/validate_input.js"></script>');
1820
1921 //create token if one doesn't already exist
2022 $token = $wgUser->editToken('mrxc877668DwQQ');
@@ -151,13 +153,13 @@
152154
153155 //Form
154156 $form .= XML::openElement('div', array('id' => 'mw-creditcard-form')) .
155 - XML::openElement('form', array('name' => "payment", 'method' => "post", 'action' => "")) .
 157+ XML::openElement('form', array('name' => "payment", 'method' => "post", 'action' => "", 'onsubmit' => 'return validate_form(this)')) .
156158 XML::element('legend', array('class' => 'mw-creditcard-amount'), wfMsg( 'pfp-amount-legend' ) .$data['amount']) .
157159 XML::hidden('amount', $data['amount']);
158160
159161 $donorInput = array(
160162 XML::inputLabel(wfMsg( 'pfp-donor-email' ), "email", "email", "30", $data['email'], array('maxlength' => "150")),
161 - XML::inputLabel(wfMsg( 'pfp-donor-fname' ), "fname", "fname", "20", $data['fname'], array('maxlength' => "35")),
 163+ XML::inputLabel(wfMsg( 'pfp-donor-fname' ), "fname", "fname", "20", $data['fname'], array('maxlength' => "35", 'class' => 'required')),
162164 XML::inputLabel(wfMsg( 'pfp-donor-mname' ), "mname", "mname", "20", $data['mname'], array('maxlength' => "35")),
163165 XML::inputLabel(wfMsg( 'pfp-donor-lname' ), "lname", "lname", "20", $data['lname'], array('maxlength' => "35")),
164166 XML::inputLabel(wfMsg( 'pfp-donor-street' ), "street", "street", "30", $data['street'], array('maxlength' => "100")),
@@ -565,7 +567,7 @@
566568 // include response message
567569 $transaction['response'] = $responseMsg;
568570 // include date
569 - $transaction['date'] = date('r');
 571+ $transaction['date'] = time();
570572 // send both the country as text and the three digit ISO code
571573 $transaction['country_name'] = $countries[$data['country']];
572574 $transaction['country_code'] = $data['country'];

Status & tagging log