-
Notifications
You must be signed in to change notification settings - Fork 0
/
TargetAddress.js
executable file
·108 lines (94 loc) · 3.75 KB
/
TargetAddress.js
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
$( document ).ready(function(){
var myDebug = false;
$("#address-choices .row:first a span").click(function(){
if(myDebug)
console.debug("js loaded properly");
var json = prompt("please paste address here");
setTimeout(function(){
populate(json);
},2000);
});
function populateCCInfo(){
if(myDebug)console.debug("cc pop code");
}
function populate(json){
if(myDebug)
console.debug("populate();");
var customer = JSON.parse(json);
var nameArray = customer.name.split(" ");
var lastName = nameArray[nameArray.length-1];
var firstName = customer.name.substr(0, customer.name.indexOf(lastName)-1);
if(myDebug)console.debug("starting population");
if(myDebug)console.debug(firstName + " " + lastName);
$("#firstName").val(firstName);
$("#lastName").val(lastName);
$("#address1").val(customer.street);
$("#city").val(customer.city);
$("#zipCode").val(customer.zip);
$("#phone1").val(customer.phone);
var state;
if(customer.state.length>2){
state = getStateCode(customer.state);
} else {
state = customer.state.toUpperCase();
}
$("#state").val(state);
}
function getStateCode(longState){
var longStateTemp = longState.toLowerCase();
if(myDebug)console.debug("state to be coded: " + longStateTemp);
switch (longStateTemp)
{
case 'alabama' : return "AL";
case 'alaska': return 'AK';
case 'arizona': return 'AZ';
case 'arkansas': return 'AR';
case 'california':return 'CA';
case 'colorado': return 'CO';
case 'conecticut':return 'CT';
case 'delware':return 'DE';
case 'florida':return 'FL';
case 'georgia': return 'GA';
case 'hawaii': return 'HI';
case 'idaho': return 'ID';
case 'illinois': return "IL";
case 'indiana': return 'IN';
case 'iowa': return 'IA';
case 'kansas':return 'KA';
case 'kentucky': return 'KY';
case 'louisiana': return "LA";
case 'maine': return 'ME';
case 'maryland': return "MD";
case 'massachusetts': return 'MA';
case 'michigan': return 'MI';
case 'minnesota': return 'MN';
case 'mississippi': return 'MS';
case 'missouri': return 'MO';
case 'montana': return 'MT';
case 'nebraska': return 'NE';
case 'nevada': return 'NV';
case 'new hampshire': return 'NH';
case 'new jersey': return 'NJ';
case 'new mexico': return 'NM';
case 'new york': return "NY";
case 'north carolina': return 'NC';
case 'north dakota': return 'ND';
case 'ohio':return "OH";
case 'oklahoma': return 'OK';
case 'oregon': return "OR";
case 'pennsylvania': return 'PA';
case 'rhode island': return 'RI';
case 'south carolina': return 'SC';
case 'south dakota': return 'SD';
case 'tennessee': return 'TN';
case 'texas': return 'TX';
case 'utah': return 'UT';
case 'vermont': return 'VT';
case 'virginia': return 'VA';
case 'washington': return 'WA';
case 'west virginia': return 'WV';
case 'wisconsin': return 'WI';
case 'wyoming': return 'WY';
}
}
});