-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
246 lines (209 loc) · 9.87 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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>malTrackerGo</title>
<script>
window.$ = window.jQuery = require('jquery');
</script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>
<link href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet">
<script src="node_modules/jquery-tags-input/src/jquery.tagsinput.js"></script>
<link rel="stylesheet" type="text/css" href="node_modules/jquery-tags-input/src/jquery.tagsinput.css" />
<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nunito:400,700">
<script src="scripts/jscolor.js"></script>
<script src="scripts/functions.js"></script>
<link rel="stylesheet" href="default.css" />
<script type="text/javascript">
// require dependencies
const fs = require('fs'); // File systems
const util = require('util');
const path = require('path');
const request = require("request");
const parseString = require('xml2js').parseString;
const RSSCombiner = require('./scripts/rsscombine');
const readFile = util.promisify(fs.readFile);
const Parser = require('rss-parser');
const remote = require('electron').remote;
// setup global variables
var pathSet = path.join(__dirname, 'settings.txt'); // Path to the settings file
var setFull = null;
var setStatuses = null;
var setColors = null;
// cpl, w, ptw, oh, d, re-w,
var statusFilter = [false, false, false, false, false, false];
var statusTexts = ["Completed ", "Watching ", "Plan to Watch ", "On-hold ", "Dropped ", ""];
var feedSize = 15;
var firstColor = "";
var secondColor = "";
var i = null;
var loaded = false;
var animeScores = [];
var interval = 5000;
var fileWrite = "";
// document ready setup
$(document).ready(function() {
// setup close button event handler
document.getElementById("btnClose").addEventListener("click", function(e) {
const window = remote.getCurrentWindow();
window.close();
});
// setup tag input
$('#tagsFriends').tagsInput({
onChange: function() {
if (loaded) {
setTimeout(function() {
document.getElementById("btnLoad").click();
}, 100);
}
}
});
$("#tagsFriends_tag").attr("data-default", "Add a user");
// load data from file
getData().then(data => {
setFull = data.split("\n");
setStatuses = setFull[0].split(",");
setColors = setFull[1].split(",");
for (var i = 0; i < statusFilter.length; i++) {
if (setStatuses[i] == "true") {
statusFilter[i] = true;
} else {
statusFilter[i] = false;
}
}
firstColor = setColors[0];
secondColor = setColors[1];
feedSize = parseInt(setFull[2].split(",")[0]);
$('#tagsFriends').importTags(setFull[3]);
// once data is loaded, apply settings from file and render page
applySettings(firstColor, secondColor, statusFilter[0], statusFilter[1], statusFilter[2], statusFilter[3], statusFilter[4], statusFilter[5], feedSize);
loaded = true;
});
// setup feedsize slider
$("#feedSize").slider({
min: 5,
max: 100,
step: 5,
slide: function(event, ui) {
$('#sliderDisplay').html(ui.value);
}
});
// code for auto pull feed
var timer;
// resets the timer
function refresh() {
clearTimeout(timer);
timer = setTimeout(function() {
if ($('#divTable').css('display') == 'none') {
document.getElementById("btnLoad").click();
}
refresh();
}, interval);
};
// creates the timer
timer = setTimeout(function() {
if ($('#divTable').css('display') == 'none') {
document.getElementById("btnLoad").click();
}
}, interval);
// calls reset timer function if user is active
$(document).on('keypress, click, mousemove', refresh);
// setup settings button
document.getElementById("btnSettings").addEventListener("click", function() {
$('#cpl').prop('checked', statusFilter[0]);
$('#w').prop('checked', statusFilter[1]);
$('#ptw').prop('checked', statusFilter[2]);
$('#oh').prop('checked', statusFilter[3]);
$('#d').prop('checked', statusFilter[4]);
$('#r').prop('checked', statusFilter[5]);
document.getElementById("color1").jscolor.fromString(firstColor.split("#")[1]);
document.getElementById("color2").jscolor.fromString(secondColor.split("#")[1]);
$("#feedSize").slider("value", feedSize);
$('#sliderDisplay').html(feedSize);
document.body.style.overflow = "hidden";
document.getElementById("content").style.webkitFilter = "blur(2px) brightness(80%)";
$(".modal").show('clip', {}, 200);
});
// setup swap button
document.getElementById("btnTable").addEventListener("click", function() {
if ($('#divTable').css('display') == 'none') { // if we are on the main rss display
$("#display").hide(0, function() {
$("#divTable").show(0, function() {
document.getElementById("btnLoad").click();
fixGradient();
});
});
} else { // we are on the table
$("#divTable").hide(0, function() {
$("#display").show(0, function() {
fixGradient();
});
});
}
});
// setup close modal
document.getElementById("settingsModal").addEventListener("click", function(e) {
if (e.target !== this) {
return;
}
document.body.style.overflow = "scroll";
document.getElementsByTagName("html")[0].style.background = "linear-gradient(to bottom right,#" + firstColor.split("#")[1] + ",#" + secondColor.split("#")[1] + ")";
document.getElementById("content").style.webkitFilter = "blur(0px) brightness(100%)";
$(".modal").hide('clip', {}, 200);
});
});
</script>
</head>
<body>
<!-- draggable title bar -->
<div class="buffer"></div>
<!-- main content -->
<div id="content">
<form>
<input name="tags" id="tagsFriends" value="Badtz13,PanDoes,Fandango86,crazyawesome" />
</form>
<div class="rightButtons">
<button id="btnLoad" onclick="loadContent($('form').serialize())"><i class="fas fa-sync-alt"></i></button>
<button style="display:none" id="btnTable"><i class="fas fa-table"></i></button>
<button id="btnSettings"><i class="fas fa-cog"></i></button>
<button id="btnClose"><i class="fas fa-times"></i></button>
</div>
<div id="display">
</div>
<div id="divTable" style="display:none;">
<table id="dataTable">
<tbody></tbody>
</table>
</div>
</div>
<!-- modal code -->
<div id="settingsModal" style="display:none" class="modal">
<div class="modalContent modal">
<p class="modalHeader">Settings</p>
<div class="modalLabel" id="backgroundLabel">Background Color</div>
<input type="text" id="color1" class="jscolor {onFineChange:'previewColors()'}" />
<input type="text" id="color2" class="jscolor {onFineChange:'previewColors()'}" />
<div class="checkboxContainer">
<div class="modalLabel" id="checkBoxLabel">Feed Filters</div>
<input type="checkbox" id="cpl" class="checkbox" />
<p class="label">Completed</p>
<input type="checkbox" id="w" class="checkbox" />
<p class="label">Watching</p>
<input type="checkbox" id="ptw" class="checkbox" />
<p class="label"> Plan to watch</p>
<input type="checkbox" id="oh" class="checkbox" />
<p class="label">On hold</p>
<input type="checkbox" id="d" class="checkbox" />
<p class="label">Dropped</p>
<input type="checkbox" id="r" class="checkbox" />
<p class="label">Rewatching</p>
</div>
<div id="feedSize"></div>
<button id="settingsSubmit" onclick="applySettings($('#color1').val(),$('#color2').val(),$('#cpl').prop('checked'),$('#w').prop('checked'),$('#ptw').prop('checked'),$('#oh').prop('checked'),$('#d').prop('checked'),$('#r').prop('checked'),$('#feedSize').slider('option','value'))">Save</button>
<div class="modalLabel" id="feedSizeLabel">Feed Size</div>
<div id="sliderDisplay"></div>
</div>
</div>
</body>
</html>