-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.html
121 lines (107 loc) · 3.71 KB
/
home.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>News Headlines Visualization</title>
<style>
#visualizationContainer {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
}
iframe {
margin: 10px;
width: calc(33% - 20px);
/* Adjust the width percentage as needed */
max-width: 400px;
/* Maximum width to prevent distortion */
height: auto;
}
.btn-container {
display: flex;
justify-content: center;
margin-top: 20px;
}
button {
margin: 5px;
padding: 8px 12px;
background-color: #007bff;
color: white;
border: none;
cursor: pointer;
}
.btn-container button {
display: inline-block;
/* Ensure the "CLEAR" button is displayed inline */
}
</style>
</head>
<body>
<h1>News, Languages and Sentiment</h1>
<div class="intro" contenteditable="true">
<h3>Your Quick Introduction Here</h3>
</div>
<div class="sources" contenteditable="true">
<h3>Sources:</h3>
<ul>
<li>Source 1</li>
<li>Source 2</li>
<li>Source 3</li>
</ul>
</div>
<!-- <div>
<button onclick="loadVisualization('5zkma')">Chinese</button>
<button onclick="loadVisualization('sb07L')">Arabic</button>
<button onclick="loadVisualization('1vL1d')">Russian</button>
<button onclick="loadAllVisualizations(['5zkma', 'sb07L', '1vL1d'])">ALL</button>
</div>
<div id="visualizationContainer"></div>
<div class="btn-container">
<button onclick="clearVisualizations()">CLEAR</button>
</div> -->
<div class="super-div">
<div class="btn-container">
<button onclick="loadVisualization('5zkma')">Chinese</button>
<button onclick="loadVisualization('sb07L')">Arabic</button>
<button onclick="loadVisualization('1vL1d')">Russian</button>
<button onclick="loadAllVisualizations(['5zkma', 'sb07L', '1vL1d'])">ALL</button>
<button onclick="clearVisualizations()">CLEAR</button>
</div>
<div id="visualizationContainer"></div>
</div>
<script>
function loadVisualization(chartId) {
const container = document.getElementById('visualizationContainer');
const iframe = document.createElement('iframe');
iframe.title = 'News Sentiment Visualization';
iframe.setAttribute('aria-label', 'Bar Chart');
iframe.id = `datawrapper-chart-${chartId}`;
iframe.src = `https://datawrapper.dwcdn.net/${chartId}/1/`;
iframe.scrolling = 'no';
iframe.frameBorder = 0;
iframe.style.height = '495px'; // Adjust height as needed
container.appendChild(iframe);
// Auto-adjust height of the iframe based on content
window.addEventListener('message', (event) => {
if (event.data['datawrapper-height']) {
const height = event.data['datawrapper-height'][chartId] + 'px';
iframe.style.height = height;
}
});
}
function loadAllVisualizations(chartIds) {
const container = document.getElementById('visualizationContainer');
container.innerHTML = ''; // Clear previous visualizations if any
chartIds.forEach((chartId) => {
loadVisualization(chartId);
});
}
function clearVisualizations() {
const container = document.getElementById('visualizationContainer');
container.innerHTML = ''; // Clear all visualizations
}
</script>
</body>
</html>