-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbioPage.html
179 lines (167 loc) · 6.07 KB
/
bioPage.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Profile</title>
<style>
.top-navbar {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 20px;
background-color: #333;
color: white;
width: 100%;
}
/* Main Content Styles */
.content-container {
display: flex;
justify-content: center;
align-items: flex-start;
margin: 20px auto;
width: 80%;
}
/* Profile Image Container */
.profile-container {
display: flex;
flex-direction: column;
align-items: center;
height: 300px;
width: 90%;
padding: 20px;
border: 2px solid #ccc;
border-radius: 10px;
background-color: white;
margin-right: 20px;
overflow: hidden;
}
.profile-container img {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 10px;
}
.id-card {
display: flex;
flex-direction: column;
justify-content: center;
width: 300px;
height: 300px;
border: 2px solid #ccc;
border-radius: 10px;
background-color: white;
padding: 20px;
box-sizing: border-box;
}
/* Summary Section */
.summary-container {
width: 80%;
margin: 20px auto;
border: 2px solid #ccc;
border-radius: 10px;
padding: 20px;
background-color: #f9f9f9;
}
/* Show More and Show Less Buttons */
.show-more-button, .show-less-button {
display: flex;
justify-content: center;
width: 100%;
border-radius: 5px;
cursor: pointer;
}
.show-more-button button, .show-less-button button {
padding: 10px 20px;
background-color: #fda92c;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
.show-more-button button:hover, .show-less-button button:hover {
background-color: #e8b471;
}
</style>
<link rel="stylesheet" href="/navbar.css">
<link rel="stylesheet" href="/main.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<!-- Navbar -->
<nav class="navbar">
<div class="navbar-left">
<a href="index.html">
<img class="navbar-img" src="logo.png" alt="Polipicker">
</a>
</div>
<div class="navbar-center">
<form class="search-bar" action="results.php">
<input id="searchInput" type="text" placeholder="Search politicians...">
<button type="submit">
<i class="fa fa-search"></i>
</button>
</form>
</div>
<div class="navbar-right">
<a href="profile.html">
<img id="pfp" class="navbar-img" src="profilePicDefault.png" alt="Account">
</a>
</div>
</nav>
<!-- Main content (Image and ID Card) -->
<div class="content-container">
<div class="profile-container">
<h1 id="politicianName">NAME</h1>
<img id="profile" src="" alt="Picture of [Name]">
<p id="description">Loading description...</p>
<button class="compare-button" onclick="window.location.href='compare.html'">Compare with another politician</button>
</div>
<div class="id-card">
<h2>Politician Information</h2>
<p><strong>Name:</strong> <span id="infoName">NAME</span></p>
<p><strong>Age:</strong> <span id="infoAge">AGE</span></p>
<p><strong>Political Affiliation:</strong> <span id="infoParty">PARTY</span></p>
<p><strong>Position Held:</strong> <span id="infoPosition">POSITION</span></p>
</div>
</div>
<!-- Summary Section -->
<div class="summary-container">
<h2>Summary of Policies</h2>
<p id="policySummary">Loading policy summary...</p> <!-- This is where the Google AI response will be loaded -->
</div>
<script>
const apiKey = "AIzaSyDqKJ7ZhvNSrEnUoTcpZU0ZCG_xQcXnymM"; // Use your own API key
async function summarizePoliticianPreferences(bio, keyIssues, politicianUrl) {
const response = await fetch('/summarize', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
bio: bio,
key_issues: keyIssues,
politician_url: politicianUrl
})
});
if (!response.ok) {
throw new Error('Failed to get the summary');
}
const data = await response.json();
return data.summary; // Return the summary
}
const userPreferences = "User preferences: This summary focuses on the politician's impact and policy effectiveness.";
const keyIssues = ["Climate Policy", "Gun Policy", "Healthcare", "Education"];
const politicianUrl = "https://en.wikipedia.org/wiki/Kamala_Harris";
summarizePoliticianPreferences(userPreferences, keyIssues, politicianUrl)
.then(summary => {
// Set the text content once
document.getElementById('policySummary').innerText = summary; // Set the text content once
})
.catch(error => {
console.error('Error:', error);
document.getElementById('policySummary').innerText = "Failed to load policy summary.";
});
</script>
</body>
</html>