-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.js
executable file
·123 lines (106 loc) · 3.34 KB
/
profile.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// Profile Javascript File
// Helper functions~~~~~~~~~~
function formatUsPhone(phone) {
var phoneTest = new RegExp(/^((\+1)|1)? ?\(?(\d{3})\)?[ .-]?(\d{3})[ .-]?(\d{4})( ?(ext\.? ?|x)(\d*))?$/);
phone = phone.trim();
var results = phoneTest.exec(phone);
if (results !== null && results.length > 8) {
return "(" + results[3] + ") " + results[4] + "-" + results[5] + (typeof results[8] !== "undefined" ? " x" + results[8] : "");
} else {
return phone;
}
}
// Geolocation for Map~~~~~~~~~~
var geocoder = new google.maps.Geocoder();
var address;
var latitude;
var longitude;
function initMap() {
var location = {lat: latitude, lng: longitude};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 16,
center: location
});
var marker = new google.maps.Marker({
position: location,
map: map
});
}
// Vue.js Code~~~~~~~~~~~
var portfolio = new Vue({
el: '#portfolioPics',
data: {
pic1: 'samp1.jpeg',
pic2: 'samp2.jpg',
pic3: 'samp3.png'
}
})
$(document).ready(function()
{
reqEmail = window.location.href.split("?")[1].split("=")[1];
// AWS ~~~~~~~~~
// Configure AWS SDK for JavaScript for LAMBDA
AWS.config.region = 'us-west-2'; // Region
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'us-west-2:01df0e0c-6be5-46cd-b277-f60d4e3021a0',
});
// Prepare to call Lambda function
var lambda = new AWS.Lambda({region: 'us-west-1', apiVersion: '2015-03-31'});
var pullParams = {
FunctionName : 'accountInfo',
InvocationType : 'RequestResponse',
LogType : 'None',
Payload: '{"email" : "' + reqEmail + '", "action" : "query"}'
};
var pullResults;
lambda.invoke(pullParams, function(error, data) {
if (error) {
prompt(error);
} else {
pullResults = JSON.parse(data.Payload).Items[0];
console.log(pullResults);
var profileInfo = new Vue({
el: '#providerInfo',
data: {
name: pullResults.name,
address: pullResults.address,
number: formatUsPhone(pullResults.phonenumber),
service: pullResults.serviceType,
profilePic: 'tempprofile.png'
}
})
address = pullResults.address;
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
latitude = results[0].geometry.location.lat();
longitude = results[0].geometry.location.lng();
initMap();
}
});
if (pullResults.dynamicAvailable == '1') {
$('#settingAvailable').text('Yes');
$('#settingAvailable').removeClass('label-danger');
$('#settingAvailable').addClass('label-success');
} else if (pullResults.dynamicAvailable == '0') {
$('#settingAvailable').text('No');
$('#settingAvailable').removeClass('label-success');
$('#settingAvailable').addClass('label-danger');
}
}
});
}
);
/*
// REVIEW SYSTEM
var rating = new Vue({
el: '#rating',
data: {
emoji: '4.png',
e1: '1.png',
e2: '2.png',
e3: '3.png',
e4: '4.png',
e5: '5.png'
}
})
*/