This repository has been archived by the owner on Jul 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoptions.js
273 lines (272 loc) · 12.8 KB
/
options.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
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
// Options array, getters and setters
var opt = {
options: {
global: {
form_validation: { defaultVal: true, showInOptions: true, dispText: "Validation des formulaires avec ctrl+entrée" },
bbcode_shortcuts: { defaultVal: true, showInOptions: true, dispText: "Raccourcis BBCodes avec ctrl" },
allow_frame_css: { defaultVal: false, showInOptions: true, dispText: "Laisser le CSS positionner les fenêtres GKSi" },
real_upload: { defaultVal: false, showInOptions: true, dispText: "Afficher les stats réelles (UP/DL/Ratio) dans l'entête" },
buffer: { defaultVal: true, showInOptions: true, dispText: "Afficher le buffer en mouseover sur les statistiques" },
search_buttons: { defaultVal: false, showInOptions: true, dispText: "Transformer les loupes en boutons dans les champs de recherche de l'entête" },
check_episodes: { defaultVal: false, showInOptions: true, dispText: "Vérifier la présence de nouveaux épisodes toutes les 2 heures" },
options_section: { defaultVal: false, showInOptions: false }
},
endless_scrolling : {
endless_scrolling: { defaultVal: true, showInOptions: true, dispText: "Endless scrolling sur les pages compatibles", sub_options: {
main: { defaultVal: true, showInOptions: true, dispText: "Page d'accueil", tooltip: "https://gks.gs/" },
browse: { defaultVal: true, showInOptions: true, dispText: "Torrents : Parcourir", tooltip: "https://gks.gs/browse/" },
sphinx: { defaultVal: true, showInOptions: true, dispText: "Torrents : Recherche", tooltip: "https://gks.gs/sphinx/" },
viewforum: { defaultVal: true, showInOptions: true, dispText: "Forums : Liste des topics", tooltip: "https://gks.gs/forums.php?action=viewforum" },
viewtopic: { defaultVal: true, showInOptions: true, dispText: "Forums : Lecture de topic", tooltip: "https://gks.gs/forums.php?action=viewtopic" },
forum_search:{ defaultVal: true, showInOptions: true, dispText: "Forums : Recherche", tooltip: "https://gks.gs/forums.php?action=search" },
snatched: { defaultVal: true, showInOptions: true, dispText: "Snatched : Liste", tooltip: "https://gks.gs/m/peers/snatched" },
history_up: { defaultVal: true, showInOptions: true, dispText: "Historique : Uploads", tooltip: "/my/history/<id_user>/uploads" },
logs: { defaultVal: true, showInOptions: true, dispText: "Logs : Liste", tooltip: "https://gks.gs/logs/" },
req: { defaultVal: true, showInOptions: true, dispText: "Requests : Liste", tooltip: "https://gks.gs/req/" },
images: { defaultVal: true, showInOptions: true, dispText: "Images : Liste", tooltip: "https://gks.gs/m/images/" },
uploads: { defaultVal: true, showInOptions: true, dispText: "Uploads : Liste", tooltip: "https://gks.gs/m/uploads/" },
peers: { defaultVal: true, showInOptions: true, dispText: "Peers : Liste", tooltip: "https://gks.gs/m/peers/" },
dupecheck: { defaultVal: true, showInOptions: true, dispText: "Dupecheck : Liste", tooltip: "https://gks.gs/dupecheck/" },
reseed: { defaultVal: true, showInOptions: true, dispText: "Reseed : Liste", tooltip: "https://gks.gs/reseed.php" }
} },
adapt_url: { defaultVal: true, showInOptions: true, dispText: "Adapter l'url en fonction de la page vue avec l'ES", parent: "endless_scrolling" },
pagination_rewrite: { defaultVal: false, showInOptions: true, dispText: "Adapter la pagination en fonction de la page vue avec l'ES", parent: "adapt_url", indicateParent: true },
pause_scrolling: { defaultVal: false, showInOptions: true, dispText: "Pauser l'ES lorsqu'arrivé en fond de page", parent: "endless_scrolling" },
button_style: { defaultVal: 'LordVal', showInOptions: true, type: "select", choices: ['LordVal', 'Classic'], dispText: "Style des icônes" }
},
torrent_list: {
imdb_suggest: { defaultVal: true, showInOptions: true, dispText: "Suggestions de recherche grâce à IMDB" },
imdb_auto_add: { defaultVal: false, showInOptions: true, dispText: "Ajouter le résultat de la meilleure correspondance IMDB", parent: "imdb_suggest", indicateParent: true },
filter_fl: { defaultVal: 0, showInOptions: false },
filter_scene: { defaultVal: 0, showInOptions: false },
auto_refresh: { defaultVal: false, showInOptions: false },
auto_refresh_color: { defaultVal: "#ffa500", showInOptions: true, type: "text", width: 5, regex: /^#[0-9A-Fa-f]{3}$|^#[0-9A-Fa-f]{6}$/, dispText: "Couleur (hexa) de la mise en avant des lignes lors de l'auto-refresh" },
age_column: { defaultVal: false, showInOptions: true, dispText: "Ajout d'une colonne d'age du torrent" },
autoget_column: { defaultVal: false, showInOptions: true, dispText: "Colonne de boutons d'ajout direct à l'autoget" },
bookmark_column: { defaultVal: false, showInOptions: true, dispText: "Colonne de boutons d'ajout direct aux bookmarks" },
nfo_column: { defaultVal: false, showInOptions: true, dispText: "Colonne de liens vers le NFO" },
torrent_marker: { defaultVal: false, showInOptions: false },
t_marker_button: { defaultVal: true, showInOptions: true, dispText: "Afficher les boutons torrent marker/finder" },
direct_comments: { defaultVal: false, showInOptions: true, dispText: "Afficher les commentaires au survol" },
preview: { defaultVal: false, showInOptions: true, dispText: "Afficher un apercu de la fiche torrent au survol" },
filter_string: { defaultVal: true, showInOptions: true, dispText: "Afficher un champ de filtrage par chaîne de caractères" },
},
snatched: {
filter_deleted: { defaultVal: 2, showInOptions: false },
filter_seed: { defaultVal: 0, showInOption: false },
filter_complete: { defaultVal: 0, showInOption: false },
filter_hnr: { defaultVal: 0, showInOption: false }
},
twits: {
twit_auto_complete: { defaultVal: true, showInOptions: true, dispText: "Auto-complétion des twits" },
twit_color: { defaultVal: true, showInOptions: true, dispText: "Coloration et lien automatique sur les twits" }
},
pins: {
filter_expensive: { defaultVal: false, showInOptions: true, dispText: "Cacher les pin's trop chers" },
filter_bought: { defaultVal: false, showInOptions: true, dispText: "Cacher les pin's déjà achetés" },
sort_price: { defaultVal: false, showInOptions: true, dispText: "Trier les pins par prix" }
},
forums: {
hidable_sigs: { defaultVal: false, showInOptions: true, dispText: "Rendre les signatures masquables" },
hide_signatures: { defaultVal: false, showInOptions: true, dispText: "Cacher les signatures par défaut", parent: "hidable_sigs", indicateParent: true },
scroll_correction: { defaultVal: false, showInOptions: true, dispText: "Corriger le scrolling " },
duplicate_markread: { defaultVal: false, showInOptions: true, dispText: "Copie le 'Marquer les sujets lus' en haut de page" }
},
torrent: {
quick_comment: { defaultVal: true, showInOptions: true, dispText: "Afficher la boite de commentaire rapide sur les fiches torrent" },
comment_mp_title: { defaultVal: "[Torrent #%id_torrent%] Commentaires désactivés", showInOptions: false },
comment_mp_text: { defaultVal: "Salutations !\n\nIl semblerait qu'un des torrents que vous avez posté n'accepte pas les commentaires :\n[url=%url_torrent%]%titre_torrent%[/url]\n\nSerait-il possible d'y remédier ?\n[url=https://gks.gs/m/account/paranoia]Réglage de la paranoïa[/url]\n\nMerci :)", showInOptions: false }
},
badges: {
progress: { defaultVal: false, showInOptions: true, dispText: "Afficher la progression sous les badges" },
show_img: { defaultVal: false, showInOptions: true, dispText: "Afficher toutes les images des badges" },
show_tip: { defaultVal: false, showInOptions: true, dispText: "Afficher toutes les infobulles des badges" }
},
logs: {
auto_refresh: { defaultVal: false, showInOptions: false },
uploads_filter: { defaultVal: false, showInOptions: false },
delete_filter: { defaultVal: false, showInOptions: false },
edit_filter: { defaultVal: false, showInOptions: false },
request_filter: { defaultVal: false, showInOptions: false },
request_fill_filter:{ defaultVal: false, showInOptions: false },
summary_edit_filter:{ defaultVal: false, showInOptions: false },
summary_new_filter: { defaultVal: false, showInOptions: false }
},
aura: {
ag_column: { defaultVal: true, showInOptions: true, dispText: "Colonne de rentabilité torrent A/Go" }
},
peers: {
filtering_active: { defaultVal: false, showInOptions: false }
},
bookmark: {
delete_get: { defaultVal: true, showInOptions: false }
}
},
// Returns value for module(m) & option(o)
get: function(m, o) {
return this.options[m][o].val;
},
// Returns value for module(m) & option(o) & sub option(s)
sub_get: function(m, o, s) {
return this.options[m][o].sub_options[s].val;
},
// Sets value(v) for module(m) & option(o)
set: function(m, o, v) {
this.options[m][o].val = v;
this.save(m);
},
// Sets value(v) for module(m) & option(o) & sub option(s)
sub_set: function(m, o, s, v) {
this.options[m][o].sub_options[s].val = v;
this.save(m);
},
// Sets on change callback(c) for module(m) & option(o)
setCallback: function(m, o, c) {
this.options[m][o].callback = c;
},
// Appends pure nammed(name) data to module(m) & option(o)
setData: function(m, o, name, data) {
this.options[m][o][name] = data;
},
// Sends to storage
save: function(m) {
utils.storage.set(m, this.options[m]);
},
// Populate all options values by extracting from storage or default value
load: function(callback) {
var requiredCallbacks = 0;
$.each(this.options, function(m, opts) { requiredCallbacks++; });
$.each(this.options, function(m, opts) {
utils.storage.get(m, function(obj) {
var values = obj[m], legValues;
if(!values) {
legValues = utils.storage.legacy.get(m);
if(legValues) {
values = legValues;
}
}
$.each(opts, function(o, v) {
opt.options[m][o].val = (values && values[o] !== undefined ? values[o] : v.defaultVal);
if(v.sub_options) {
$.each(v.sub_options, function(s_o, s_v) {
opt.options[m][o].sub_options[s_o].val = (values && values[o + '_' + s_o] !== undefined ? values[o + '_' + s_o] : s_v.defaultVal);
});
}
});
if(legValues) {
opt.save(m);
utils.storage.legacy.rm(m);
}
if(--requiredCallbacks === 0) {
callback();
}
});
});
},
exportAll: function() {
var tempStore = {};
$.each(this.options, function(m, opts) {
tempStore[m] = {};
$.each(opts, function(o, v) {
tempStore[m][o] = v.val;
if(v.sub_options) {
$.each(v.sub_options, function(s_o, s_v) {
tempStore[m][o + '_' + s_o] = s_v.val;
});
}
});
});
return tempStore;
},
importAll: function(obj) {
$.each(this.options, function(m, opts) {
$.each(opts, function(o, v) {
opt.options[m][o].val = (obj[m] && obj[m][o] !== undefined ? obj[m][o] : v.defaultVal);
if(v.sub_options) {
$.each(v.sub_options, function(s_o, s_v) {
opt.options[m][o].sub_options[s_o].val = (obj[m] && obj[m][o + '_' + s_o] !== undefined ? obj[m][o + '_' + s_o] : s_v.defaultVal);
});
}
});
opt.save(m);
});
}
};
var gData = {
data: {
badges: {},
real_stats: {
real_upload: 0,
real_download: 0,
real_buffer: 0,
real_ratio: 0,
real_snatched: 0,
max_snatched_pages: 0,
last_check: 0
},
bookmarks: {
torrents: [],
bookmarkIds: {},
last_check: 0
},
episodes: {
shows_list: {},
shows_list_size: 0,
global_conf: {},
episodes: {},
episodes_size: 0,
hasUnseenData: false,
last_display: 0,
last_check: new Date().getTime()
}
},
setFresh: function(m) {
this.set(m, "last_check", new Date().getTime());
},
set: function(m, o, v) {
this.data[m][o] = v;
this.save(m);
},
get: function(m, o) {
return this.data[m][o];
},
save: function(m) {
utils.storage.data_set(m, this.data[m]);
},
load: function(callback) {
var requiredCallbacks = 0;
$.each(this.data, function(m, data) { requiredCallbacks++; });
$.each(this.data, function(m, data) {
utils.storage.data_get(m, function(obj) {
var values = obj[m], legValues;
if(!values) {
legValues = utils.storage.legacy.data_get(m);
if(legValues) {
values = legValues;
}
}
$.each(data, function(o, v) {
gData.data[m][o] = (values && values[o] !== undefined ? values[o] : v);
});
if(legValues) {
gData.save(m);
utils.storage.legacy.data_rm(m);
}
if(--requiredCallbacks === 0) {
callback();
}
});
});
},
exportAll: function() {
return this.data;
},
importAll: function(obj) {
$.each(this.data, function(m, data) {
$.each(data, function(o, v) {
gData.data[m][o] = (obj[m] && obj[m][o] !== undefined ? obj[m][o] : v);
});
gData.save(m);
});
}
};