-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathoptions.js
232 lines (203 loc) · 7.03 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
// Récupération d'une référence vers la backgroundpage
bkg = chrome.extension.getBackgroundPage();
// Chargement google analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', bkg.AnalyticsHelper.gaAccount]);
_gaq.push(['_trackPageview']);
bkg.AnalyticsHelper.gaLoad(document);
jQuery(document).ready(function($){
// Définition du bouton email
var email = (function(){
coded = "49vVNJ@y36Ws4sWA.4VN"
key = "bP3Oc7k8xzM2dnm0oWZplqEw4SKf1UDBr6NeVCTAshItiLYyjQu5vXHJFRGag9"
shift = coded.length
output = ""
for (i = 0; i < coded.length; i++) {
if (key.indexOf(coded.charAt(i)) == -1) {
ltr = coded.charAt(i)
output += (ltr)
} else {
ltr = (key.indexOf(coded.charAt(i)) - shift + key.length) % key.length
output += (key.charAt(ltr))
}
}
return output;
})();
$('#contact-link').attr('href', 'mailto:'+email).find('span').html(email);
// Affichage version
$('#cpau_version_label').html(chrome.runtime.getManifest().version);
// Initialisation de l'état du formulaire
OptionFormManager.init();
// Enregistrement lors du changement de format
$('#formats input[type=radio]').change(function(e){
localStorage["format"] = $(this).val();
OptionFormManager.init();
});
// Changement format html
$('#format_html_advanced input[type=radio]').change(function(e){
localStorage["anchor"] = $(this).val();
OptionFormManager.init();
});
// Changement row format (custom)
$('#format_custom_advanced>textarea').change(function(e){
localStorage["format_custom_advanced"] = $(this).val();
OptionFormManager.init();
});
// Intelligent paste
$('#intelligent_paste').change(function(e){
localStorage["intelligent_paste"] = $(this).prop("checked");
OptionFormManager.init();
});
// Copy tabs from all windows
$('#walk_all_windows').change(function(e){
localStorage["walk_all_windows"] = $(this).prop("checked");
OptionFormManager.init();
});
// Highlighted only
$('#highlighted_tab_only').change(function(e){
localStorage["highlighted_tab_only"] = $(this).prop("checked");
OptionFormManager.init();
});
// Default action
$('#default_action').change(function(e){
localStorage["default_action"] = $(this).val();
OptionFormManager.init();
});
// MIME type
$('#mime').change(function(e){
localStorage["mime"] = $(this).val();
OptionFormManager.init();
});
// Reset
$('#reset_settings').click(function(e){
_gaq.push(['_trackEvent', 'Internal link', 'Reset settings']);
OptionFormManager.optionsReset();
});
// Copyright
var currentYear = new Date().getFullYear();
if( $('#copyright-year-footer').text() < currentYear ){
$('#copyright-year-footer').text(currentYear);
}
// Lien vers la page chrome://extensions/
$('.open-link-via-chrome-api').click(function(e){
e.preventDefault();
e.stopImmediatePropagation();
var href = $(this).attr('href');
if (href == undefined) {
return;
}
var gaAction = $(this).data('galinkid') || $(this).attr('id') || $(this).text() || 'Unset';
_gaq.push(['_trackEvent', 'Internal link', gaAction, href]);
if ($(this).hasClass('on-new-tab')) {
chrome.tabs.create({url: href});
} else {
chrome.tabs.update({url: href});
}
});
// Affichage notification nouvelle version dans la page d'option
if (bkg.UpdateManager.recentUpdate()) {
var content = "<h3>New version recently installed : " + chrome.runtime.getManifest().version + "</h3>"
+ "Check the " + '<a href="http://finalclap.github.io/CopyAllUrl_Chrome/" data-galinkid="changelog recent update">' + "changelog</a> to see what's new !<br>"
+ "<em>This notice will go off automatically</em>";
$('#recently-updated').html(content).show();
}
// Tracking events
$('.hero-unit .paypal-donate form').click(function(e){
e.stopImmediatePropagation();
_gaq.push(['_trackEvent', 'Donate', 'Paypal', 'Header']);
});
$('#donate-paypal form').click(function(e){
e.stopImmediatePropagation();
_gaq.push(['_trackEvent', 'Donate', 'Paypal', 'About']);
});
$('#donate-flattr a').click(function(e){
e.stopImmediatePropagation();
_gaq.push(['_trackEvent', 'Donate', 'Flattr', 'About']);
});
$('#donate-bitcoin img').click(function(e){
e.stopImmediatePropagation();
_gaq.push(['_trackEvent', 'Donate', 'Bitcoin', 'About']);
});
$('#contact-link').click(function(e){
e.stopImmediatePropagation();
_gaq.push(['_trackEvent', 'Internal link', 'Email']);
});
$('a').click(function(e){
var href = $(this).attr('href');
try {
if (!href.match(/^\s*http/i)) {
return;
}
} catch(ex) {
return;
}
e.stopImmediatePropagation();
var gaAction = $(this).data('galinkid') || $(this).attr('id') || $(this).text() || 'Unset';
_gaq.push(['_trackEvent', 'External link', gaAction, href]);
});
});
/**
* Objet de gestion du formulaire d'options
*/
var OptionFormManager = {
/**
* Init form from localStorage (saved settings)
*/
init: function(){
var format = localStorage['format'] ? localStorage['format'] : 'text';
var anchor = localStorage['anchor'] ? localStorage['anchor'] : 'url';
var format_custom_advanced = localStorage['format_custom_advanced'] ? localStorage['format_custom_advanced'] : '';
var intelligent_paste = localStorage['intelligent_paste'] == "true" ? true : false;
var walk_all_windows = localStorage['walk_all_windows'] == "true" ? true : false;
var highlighted_tab_only = localStorage['highlighted_tab_only'] == "true" ? true : false;
var default_action = localStorage['default_action'] ? localStorage['default_action'] : "menu";
var mime = localStorage['mime'] ? localStorage['mime'] : 'plaintext';
// Coche Format
this.cocherFormat(format);
// Coche Anchor
jQuery('#format_html_advanced input[type=radio]').attr('checked', false);
jQuery('#format_html_anchor_' + anchor).attr('checked', true);
// Restaure template custom
jQuery('#format_custom_advanced>textarea').val(format_custom_advanced);
// Panneaux avancés
$('#format_html_advanced').hide();
$('#format_custom_advanced').hide();
if( format == 'html' ){
$('#format_html_advanced').show();
}
if( format == 'custom' ){
$('#format_custom_advanced').show();
}
// Coche Intelligent paste
jQuery('#intelligent_paste').prop('checked', intelligent_paste);
// Coche Copy tabs from all windows
jQuery('#walk_all_windows').prop('checked', walk_all_windows);
// Coche highlighted
jQuery('#highlighted_tab_only').prop('checked', highlighted_tab_only);
// Default action
jQuery('#default_action').val(default_action);
// MIME type
jQuery('#mime').val(mime);
},
/**
* Checks the Text or HTML checkbox
*/
cocherFormat: function(option){
jQuery('#formats input[type=radio]').attr('checked', false);
jQuery('#format_' + option).attr('checked', true);
},
/**
* Delete options
*/
optionsReset: function(){
delete(localStorage["format"]);
delete(localStorage["anchor"]);
delete(localStorage["format_custom_advanced"]);
delete(localStorage["intelligent_paste"]);
delete(localStorage["walk_all_windows"]);
delete(localStorage["highlighted_tab_only"]);
delete(localStorage["default_action"]);
delete(localStorage["mime"]);
this.init();
}
};