-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathindex.html
590 lines (516 loc) · 12.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
<!DOCTYPE html>
<html>
<head>
<title>LiveAddress API jQuery Plugin — TEST RUNNER</title>
<meta charset="utf-8">
<link href="//fonts.googleapis.com/css?family=Signika+Negative:300|Open+Sans:400,700,600,300,800" rel="stylesheet" type="text/css">
<script src="/lib/jquery-1_8_2.js"></script>
<script src="/src/jquery.liveaddress.js"></script>
<script>
var testRunnerVersion = "1.0.2"; // The version of this test runner page
var debug = true; // Toggle debug mode
var liveaddress = $.LiveAddress({
key: "YOUR-HTML-KEY", // Put your HTML key here
debug: debug // Show debug stuff
});
</script>
<style>
body {
font: 400 16px/1.5em 'Open Sans', 'Signika Negative', sans-serif;
padding: 15px 50px;
background: #F3F3F3;
text-shadow: 0 1px 0 #FFF;
min-width: 400px;
}
p a, form a, hgroup a {
color: #0077BB;
transition: color .25s linear;
-moz-transition: color .25s linear;
-webkit-transition: color .25s linear;
-o-transition: color .25s linear;
}
p a:hover, form a:hover, hgroup a:hover {
color: #119FF2;
}
.smarty-container a {
text-shadow: none;
}
h1, h2 {
text-align: center;
color: #222;
text-shadow: none;
}
hgroup {
background: #DDD;
padding: 1px 1px 5px;
margin-bottom: 50px;
position: relative;
border-radius: 10px;
}
#revision, #version {
font-size: 14px;
padding: 0 10px;
font-weight: 300;
}
#version {
position: absolute;
right: 0px;
}
h1 {
font: 600 45px/1em 'Open Sans', 'Helvetica Neue', sans-serif;
margin-bottom: 5px;
}
h2 {
font: 300 25px/1em 'Signika Negative';
}
h2 a {
text-decoration: none;
}
form {
border: 5px solid #AAA;
width: 350px;
background: #FFF;
margin-right: 25px;
margin-bottom: 25px;
float: left;
position: relative;
}
form header {
padding: 10px 15px 0;
background: #F0F0F0;
}
form header p {
margin: 0;
padding: 0;
font-size: 12px;
}
form header h3 {
font-weight: 300;
font-size: 27px;
margin: 0;
padding-bottom: 10px;
}
form table {
margin: 15px 10px;
font-size: 14px;
}
form table td {
padding: 5px;
}
form input[type=text],
form textarea {
padding: 5px 5px 3px;
font: 14px/1em 'Signika Negative', 'Helvetica Neue', sans-serif;
min-width: 165px;
outline: none;
}
form select {
outline: none;
}
form textarea {
min-height: 40px;
}
form input[type=submit],
form [type=image],
form button {
font-size: 16px;
}
.formNumber {
background: #40C7D6;
color: #FFF;
width: 25px;
height: 25px;
padding: 5px;
text-align: center;
border-radius: 20px;
position: absolute;
top: -15px;
right: -15px;
font-size: 14px;
box-shadow: 0 1px 2px #222;
}
.clear {
border: none;
background: none;
clear: both;
}
label {
cursor: pointer;
}
</style>
</head>
<body>
<hgroup>
<h1>LiveAddress API jQuery Plugin</h1>
<h2>Test Runner — by <a href="http://smartystreets.com/" target="_blank">SmartyStreets</a></h2>
<span id="revision">Revision: <script>document.write(testRunnerVersion);</script> / Debug mode: <script>document.write(debug ? "on" : "off");</script></span>
<span id="version">jQuery version: <script>document.write($.fn.jquery);</script> / Plugin version: <script>document.write(liveaddress.version);</script></span>
</hgroup>
<form id="happyPath">
<header>
<h3>Happy path</h3>
<p>The simplest, most traditional kind of address form</p>
</header>
<table>
<tr>
<td>Street address:</td>
<td><input type="text" name="street"></td>
</tr>
<tr>
<td>City:</td>
<td><input type="text" name="city"></td>
</tr>
<tr>
<td>State:</td>
<td><input type="text" name="state"></td>
</tr>
<tr>
<td>ZIP Code:</td>
<td><input type="text" name="zip"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit Form"></td>
</tr>
</table>
</form>
<form id="street2">
<header>
<h3>Street 2 Field</h3>
<p>Traditional address form containing a street line 2 field</p>
</header>
<table>
<tr>
<td>Street address:</td>
<td><input type="text" name="street"></td>
</tr>
<tr>
<td>Street line 2:</td>
<td><input type="text" name="streetTwo"></td>
</tr>
<tr>
<td>City:</td>
<td><input type="text" name="city"></td>
</tr>
<tr>
<td>State:</td>
<td><input type="text" name="state"></td>
</tr>
<tr>
<td>ZIP Code:</td>
<td><input type="text" name="zip"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit Form"></td>
</tr>
</table>
</form>
<form id="slap">
<header>
<h3>SLAP</h3>
<p>Single-Line (freeform) Address Processing: the whole address contained in one field</p>
</header>
<table>
<tr>
<td>Address:</td>
<td><textarea name="street_address"></textarea></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit Form"></td>
</tr>
</table>
</form>
<form id="twoSlap">
<header>
<h3>Two SLAP addresses</h3>
<p>One might be for shipping, the other might be for billing</p>
</header>
<table>
<tr>
<td>Billing address:</td>
<td><textarea name="billing-address"></textarea></td>
</tr>
<tr>
<td>Ship to:</td>
<td><textarea name="ship-address"></textarea></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit Form"></td>
</tr>
</table>
</form>
<hr class="clear">
<form id="twoAddresses">
<header>
<h3>Two addresses</h3>
<p>Likely, one would be a billing address, and the other would probably be shipping</p>
</header>
<table>
<tr>
<td>Street address:</td>
<td><input type="text" name="street"></td>
</tr>
<tr>
<td>City:</td>
<td><input type="text" name="city"></td>
</tr>
<tr>
<td>State:</td>
<td><input type="text" name="state"></td>
</tr>
<tr>
<td>ZIP Code:</td>
<td><input type="text" name="zip"></td>
</tr>
<tr>
<td colspan="2"><hr></td>
</tr>
<tr>
<td>Street address:</td>
<td><input type="text" name="street"></td>
</tr>
<tr>
<td>ZIP Code:</td>
<td><input type="text" name="zip"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit Form"></td>
</tr>
</table>
</form>
<form id="country">
<header>
<h3>Country field</h3>
<p>Non-US addresses should be allowed to pass thru freely</p>
</header>
<table>
<tr>
<td>Address:</td>
<td><input type="text" name="street"></td>
</tr>
<tr>
<td>City:</td>
<td><input type="text" name="town"></td>
</tr>
<tr>
<td>Province:</td>
<td><input type="text" name="province"></td>
</tr>
<tr>
<td>Postal Code:</td>
<td><input type="text" name="post-code"></td>
</tr>
<tr>
<td>Country:</td>
<td><select size="1" name="country" required="required" style="width: 85%;">
<option selected="selected" value="US">United States</option>
<option value="CA">Canada</option>
<option value="GB">United Kingdom</option>
</select>
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit Form"></td>
</tr>
</table>
</form>
<form id="incomplete">
<header>
<h3>Incomplete address</h3>
<p>When there's not enough information to verify an address, the fields shouldn't be mapped</p>
</header>
<table>
<tr>
<td>Street address:</td>
<td><input type="text" name="street"></td>
</tr>
<tr>
<td>City:</td>
<td><input type="text" name="city"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit Form"></td>
</tr>
</table>
</form>
<form id="onClick">
<header>
<h3>onclick Handler</h3>
<p>Submit button has an "onclick" attribute which should fire if the button is clicked</p>
</header>
<table>
<tr>
<td>Street address:</td>
<td><input type="text" name="street"></td>
</tr>
<tr>
<td>City:</td>
<td><input type="text" name="city"></td>
</tr>
<tr>
<td>State:</td>
<td><input type="text" name="state"></td>
</tr>
<tr>
<td>ZIP Code:</td>
<td><input type="text" name="zip"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit Form" onclick="alert('onclick handler; this should happen AFTER address verification')"></td>
</tr>
</table>
</form>
<hr class="clear">
<form id="similarFieldNames">
<header>
<h3>Similar field names</h3>
<p>Fields all contain the word "address" and not all fields should be mapped</p>
</header>
<table>
<tr>
<td>Company:</td>
<td><input type="text" name="address_company"></td>
</tr>
<tr>
<td>Street address:</td>
<td><input type="text" name="address_street1"></td>
</tr>
<tr>
<td>City:</td>
<td><input type="text" name="address_city"></td>
</tr>
<tr>
<td>State:</td>
<td><input type="text" name="address_state"></td>
</tr>
<tr>
<td>ZIP Code:</td>
<td><input type="text" name="address_zip"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit Form"></td>
</tr>
</table>
</form>
<form id="easyLabels">
<header>
<h3>Map using labels</h3>
<p>Fields contain vague or irrelevant names/IDs; use associated labels instead</p>
</header>
<table>
<tr>
<td><label for="fieldTest1">Street address:</label></td>
<td><input type="text" name="field[0]" id="fieldTest1"></td>
</tr>
<tr>
<td><label for="fieldTest2">City:</label></td>
<td><input type="text" name="field[1]" id="fieldTest2"></td>
</tr>
<tr>
<td><label for="fieldTest3">State:</label></td>
<td><input type="text" name="field[2]" id="fieldTest3"></td>
</tr>
<tr>
<td><label for="fieldTest4">ZIP Code:</label></td>
<td><input type="text" name="field[3]" id="fieldTest4"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit Form"></td>
</tr>
</table>
</form>
<form id="onSubmit" onsubmit="alert('onsubmit handler; this should happen AFTER address verification')">
<header>
<h3>onsubmit Handler</h3>
<p>Form has onsubmit="" attribute which should fire when form is submitted</p>
</header>
<table>
<tr>
<td>Street address:</td>
<td><input type="text" name="street"></td>
</tr>
<tr>
<td>City:</td>
<td><input type="text" name="city"></td>
</tr>
<tr>
<td>State:</td>
<td><input type="text" name="state"></td>
</tr>
<tr>
<td>ZIP Code:</td>
<td><input type="text" name="zip"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit Form"></td>
</tr>
</table>
</form>
<form id="twoHandlers" onsubmit="alert('onsubmit handler; this should happen AFTER address verification and the onclick handlers')">
<header>
<h3>Two handlers</h3>
<p>First the address should be verified, then the submit button's onclick handlers should fire, then the form's onsubmit handlers last</p>
</header>
<table>
<tr>
<td>Street address:</td>
<td><input type="text" name="street"></td>
</tr>
<tr>
<td>City:</td>
<td><input type="text" name="city"></td>
</tr>
<tr>
<td>State:</td>
<td><input type="text" name="state"></td>
</tr>
<tr>
<td>ZIP Code:</td>
<td><input type="text" name="zip"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit Form" onclick="alert('onclick handler; this should happen AFTER address verification and BEFORE onsubmit handlers')"></td>
</tr>
</table>
</form>
<hr class="clear">
<script>
$(function() {
// Prevent forms, by default, from leaving the page, so we can keep testing
$('form').submit(function(event) {
alert("Default form submit; actual POST prevented");
return suppress(event);
});
// Show the form index number so debug info can be connected to DOM elements visually
$('form').each(function(idx) {
$(this).append('<div class="formNumber">'+idx+'</div>');
});
});
// Enable this to prevent accidentally leaving the page
/*
window.onbeforeunload = function() {
return "Page is attempting to leave or reload";
};
*/
function suppress(event) {
if (!event) return false;
if (event.preventDefault) event.preventDefault();
if (event.stopPropagation) event.stopPropagation();
if (event.stopImmediatePropagation) event.stopImmediatePropagation();
if (event.cancelBubble) event.cancelBubble = true;
return false;
}
</script>
</body>
</html>