-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frontend.js
162 lines (137 loc) · 4.73 KB
/
frontend.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
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
$( document ).ready(function() {
//open hyperlinks on the UI in the browser.
$(document).on('click', 'a[href^="http"]', function(event) {
event.preventDefault();
window.Electron.shell.openExternal(this.href);
});
//handle showing the modal on user click.
$('#modal_show').click(function() {
$('#modal1').modal('show')
});
$('#modal2_show').click(function() {
$('#modal2').modal('show')
});
$('#do_it_button').click(function(event) {
//run the facebook module
delete_fb_stuff = require('./delete_fb_stuff');
event.preventDefault();
var username = $("#username").val();
var password = $("#password").val();
var twofactor = $("#twofactor").val();
if (!username || !password || username == "" || password == "") {
alert("Username and password are required.");
return;
}
var categories = $("#categories").val();
if (!categories || categories =="") {
alert("You need to select some categories.");
return;
}
//categories = categories.join(" ");
var years = $("#years").val();
if (!years || years =="") {
alert("You need to select some years.");
return;
}
//years = years.join(" ");
var months = $("#months").val();
if (!months || months == "") {
alert("You need to select some months.");
return;
}
if (twofactor) {
var r = confirm("Two factor support in the application at this time is a bit rough, and may not work. You may be better off disabling two factor on your account, then trying to run this script. Are you sure you want to continue?");
if (r){
}
else {
return;
}
}
alert("Please do not click anywhere on the browser window that will pop up while the script is running. This will break the application. 😊");
$("#status").val("Running script...");
try {
var result = delete_fb_stuff.main(username,password,categories,years,months,twofactor).then(function(value) {
if (!value) {
$("#status").val("Fatal error running script!");
}
else {
alert(value.message);
$("#status").val(value.message);
}
});
}
catch(err) {
$("#status").val(err);
}
});
//the below code goes and builds up the select options.
var currentYear = (new Date()).getFullYear();
var years = [];
for (let i = 2004; i <= currentYear; i++) {
years.push(i.toString());
}
years.reverse();
//add years
for (var i = 0; i< years.length; i++) {
var x = document.getElementById("years");
var option = document.createElement("option");
option.text = years[i];
option.value = years[i];
x.add(option);
}
var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
//add months
for (var i = 0; i< months.length; i++) {
var x = document.getElementById("months");
var option = document.createElement("option");
option.text = months[i];
option.value = months[i];
x.add(option);
}
var categories = ["Posts",
"Posts You're Tagged In",
"Photos and Videos",
"Photos You're Tagged In",
"Others' Posts To Your Timeline",
"Hidden From Timeline",
"Likes and Reactions",
"Comments",
"Profile",
"Added Friends",
"Life Events",
"Songs You've Listened To",
"Articles You've Read",
"Movies and TV",
"Games",
"Books",
"Products You Wanted",
"Notes",
"Videos You've Watched",
"Following",
"Groups",
"Events",
"Polls",
"Search History",
"Saved",
"Apps"];
for (var i = 0; i< categories.length; i++) {
var x = document.getElementById("categories");
var option = document.createElement("option");
option.text = categories[i];
option.value = categories[i];
x.add(option);
}
$('select').selectpicker({actionsBox: true});
});
function selectAll(selectBox,selectAll) {
// have we been passed an ID
if (typeof selectBox == "string") {
selectBox = document.getElementById(selectBox);
}
// is the select box a multiple select box?
if (selectBox.type == "select-multiple") {
for (var i = 0; i < selectBox.options.length; i++) {
selectBox.options[i].selected = selectAll;
}
}
}