-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
205 lines (146 loc) · 4.45 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
button, .aButton {
cursor: pointer;
color: #fff;
background-color: #007bff;
border-color: #007bff;
box-shadow: 0 .5rem 1rem rgba(0,0,0,.15)!important;
display: inline-block;
font-weight: 400;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
border: 1px solid transparent;
padding: .375rem .75rem;
font-size: 1rem;
line-height: 1.5;
border-radius: .25rem;
transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}
.loading {
position: absolute;
top: 0;
opacity: .5;
}
.hidden {
display: none;
}
/* Safari */
@-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body>
<div>
<p>
<h1>Paste your code here:</h1>
</p>
<textarea id="information" rows="10" cols="100">
</textarea>
<div class="hidden loading"><img src="images/loading.gif" alt=""></div>
</div>
<button onclick="myFunction()">Download Calendar CVS</button>
<a href="/birthdays-fromFB/readme.docx" class="aButton">Read-more</a>
<script>
function myFunction() {
var myVar;
document.querySelector('.loading').classList.remove('hidden');
myVar = setTimeout(getBirthdays, 2000);
}
function getBirthdays(){
let information = document.getElementById('information').value;
let infoElement = document.createElement("div");
infoElement.innerHTML = information;
infoElement.style.display="none";
document.body.appendChild(infoElement);
let aTags = document.querySelectorAll("a");
var table = document.createElement('table');
table.innerHTML=`<tr>
<td>Subject</td>
<td>Start date</td>
<td>All Day Event</td></tr>`;
for (var i = 0; i < aTags.length; i++) {
let attribute = aTags[i].getAttribute("data-tooltip-content");
let startLength;
if(attribute!=null){
textAttribute =attribute;
for (let j = 0; j < attribute.length; j++) {
if(textAttribute[j]=="(") {
startLength=j+2;
break;
}
}
let name = attribute.substr(0,startLength-2);
let birthDayFinal="";
let birthDayMid="";
let birthDay = attribute.substring(startLength-1,attribute.length-1);
for (let z = 0; z < birthDay.length; z++) {
if(birthDay[z]=="."||birthDay[z]=="-") {
birthDayMid="/"
}
else {
birthDayMid=birthDay[z];
}
birthDayFinal+=birthDayMid;
}
table.innerHTML+="<tr><td>Birthday: "+name+"</td><td>"+birthDayFinal+"/2020</td><td>true</td></tr>";
}
}
table.style.display="none";
document.body.appendChild(table);
// Export CSV
function download_csv(csv, filename) {
var csvFile;
var downloadLink;
// CSV FILE
csvFile = new Blob(["\uFEFF"+csv], {
type: 'text/csv; charset=utf-18'
}); // Format UTF
// Download link
downloadLink = document.createElement("a");
// File name
downloadLink.download = filename;
// We have to create a link to the file
downloadLink.href = window.URL.createObjectURL(csvFile);
// Make sure that the link is not displayed
downloadLink.style.display = "none";
// Add the link to your DOM
document.body.appendChild(downloadLink);
// Lanzamos
downloadLink.click();
}
function export_table_to_csv(html, filename) {
var csv = [];
var rows = document.querySelectorAll("table tr");
for (var i = 0; i < rows.length; i++) {
var row = [], cols = rows[i].querySelectorAll("td");
for (var j = 0; j < cols.length; j++) {
row.push(cols[j].innerText);
}
csv.push(row.join(","));
}
// Download CSV
download_csv(csv.join("\n"), filename);
}
var html = document.querySelector("table").outerHTML;
export_table_to_csv(html, "table.csv");
document.querySelector('.loading').classList.add('hidden');
}
</script>
</body>
</html>