Skip to content

Commit 22ece00

Browse files
committed
Starting to clean up javascript
1 parent 6c57560 commit 22ece00

14 files changed

+174
-314
lines changed

Diff for: actions-log.php

+13-49
Original file line numberDiff line numberDiff line change
@@ -21,52 +21,7 @@
2121
include('header.php');
2222
?>
2323

24-
<script type="text/javascript">
25-
$(document).ready( function() {
26-
$("#do_action").click(function() {
27-
var checks = $("td>input:checkbox").serializeArray();
28-
var action = $('#action').val();
29-
30-
if (action == 'delete') {
31-
if (checks.length == 0) {
32-
alert('<?php _e('Please select at least one activity to proceed.','cftp_admin'); ?>');
33-
return false;
34-
}
35-
else {
36-
var msg_1 = '<?php _e("You are about to delete",'cftp_admin'); ?>';
37-
var msg_2 = '<?php _e("activities. Are you sure you want to continue?",'cftp_admin'); ?>';
38-
if (confirm(msg_1+' '+checks.length+' '+msg_2)) {
39-
return true;
40-
} else {
41-
return false;
42-
}
43-
}
44-
}
45-
if (action == 'clear') {
46-
var msg = '<?php _e("You are about to delete all activities from the log. Only those used for statistics will remain. Are you sure you want to continue?",'cftp_admin'); ?>';
47-
if (confirm(msg)) {
48-
return true;
49-
} else {
50-
return false;
51-
}
52-
}
53-
54-
if (action == 'download') {
55-
$(document).psendmodal();
56-
$('.modal_content').html('<p class="loading-img">'+
57-
'<img src="<?php echo BASE_URI; ?>img/ajax-loader.gif" alt="Loading" /></p>'+
58-
'<p class="lead text-center text-info"><?php _e('Please wait while your download is prepared.','cftp_admin'); ?></p>'
59-
);
60-
$('.modal_content').append('<iframe src="<?php echo BASE_URI; ?>includes/actions.log.export.php?format=csv"></iframe>');
61-
return false;
62-
}
63-
});
64-
65-
});
66-
</script>
67-
6824
<div class="col-xs-12">
69-
7025
<?php
7126
/**
7227
* Apply the corresponding action to the selected users.
@@ -201,10 +156,19 @@
201156
<div class="form-group group_float">
202157
<label class="control-label hidden-xs hidden-sm"><i class="glyphicon glyphicon-check"></i> <?php _e('Activities actions','cftp_admin'); ?>:</label>
203158
<select name="action" id="action" class="form-control">
204-
<option value="none"><?php _e('Select action','cftp_admin'); ?></option>
205-
<option value="download"><?php _e('Download as csv','cftp_admin'); ?></option>
206-
<option value="delete"><?php _e('Delete selected','cftp_admin'); ?></option>
207-
<option value="clear"><?php _e('Clear entire log','cftp_admin'); ?></option>
159+
<?php
160+
$actions_options = array(
161+
'none' => __('Select action','cftp_admin'),
162+
'log_download' => __('Download as csv','cftp_admin'),
163+
'delete' => __('Delete selected','cftp_admin'),
164+
'log_clear' => __('Clear entire log','cftp_admin'),
165+
);
166+
foreach ( $actions_options as $val => $text ) {
167+
?>
168+
<option value="<?php echo $val; ?>"><?php echo $text; ?></option>
169+
<?php
170+
}
171+
?>
208172
</select>
209173
</div>
210174
<button type="submit" id="do_action" class="btn btn-sm btn-default"><?php _e('Proceed','cftp_admin'); ?></button>

Diff for: assets.php

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
$load_js_files[] = BASE_URI . 'includes/js/jen/jen.js';
2424
$load_js_files[] = BASE_URI . 'includes/js/js.cookie.js';
2525
$load_js_files[] = BASE_URI . 'includes/js/main.js';
26+
$load_js_files[] = BASE_URI . 'includes/js/js.functions.php';
2627

2728
/** CSS */
2829

Diff for: categories.php

+4-26
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,6 @@
2626

2727
<script type="text/javascript">
2828
$(document).ready( function() {
29-
$("#do_action").click(function() {
30-
var action = $('#categories_actions').val();
31-
if (action != 'none') {
32-
var checks = $("td>input:checkbox").serializeArray();
33-
if (checks.length == 0) {
34-
alert('<?php _e('Please select at least one category to proceed.','cftp_admin'); ?>');
35-
return false;
36-
}
37-
else {
38-
if (action == 'delete') {
39-
var msg_1 = '<?php _e("You are about to delete",'cftp_admin'); ?>';
40-
var msg_2 = '<?php _e("categories. Are you sure you want to continue?",'cftp_admin'); ?>';
41-
if (confirm(msg_1+' '+checks.length+' '+msg_2)) {
42-
return true;
43-
} else {
44-
return false;
45-
}
46-
}
47-
}
48-
}
49-
});
50-
5129
$("#process_category").submit(function() {
5230
clean_form( this );
5331

@@ -83,8 +61,8 @@
8361
/**
8462
* Apply the corresponding action to the selected categories.
8563
*/
86-
if ( isset( $_GET['categories_actions'] ) ) {
87-
if ( $_GET['categories_actions'] != 'none' ) {
64+
if ( isset( $_GET['action'] ) ) {
65+
if ( $_GET['action'] != 'none' ) {
8866
/** Continue only if 1 or more categories were selected. */
8967
if ( !empty($_GET['batch'] ) ) {
9068

@@ -105,7 +83,7 @@
10583
$my_info = get_user_by_username(get_current_user_username());
10684
$affected_users = 0;
10785

108-
switch($_GET['categories_actions']) {
86+
switch($_GET['action']) {
10987
case 'delete':
11088
foreach ($selected_categories as $category) {
11189
$this_category = new CategoriesActions();
@@ -265,7 +243,7 @@
265243
<div class="form_actions_submit">
266244
<div class="form-group group_float">
267245
<label class="control-label hidden-xs hidden-sm"><i class="glyphicon glyphicon-check"></i> <?php _e('Selected categories actions','cftp_admin'); ?>:</label>
268-
<select name="categories_actions" id="categories_actions" class="txtfield form-control">
246+
<select name="action" id="action" class="txtfield form-control">
269247
<?php
270248
$actions_options = array(
271249
'none' => __('Select action','cftp_admin'),

Diff for: clients-requests.php

-22
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,6 @@
2424

2525
<script type="text/javascript">
2626
$(document).ready(function() {
27-
$("#do_action").click(function() {
28-
var checks = $(".footable-first-column>input:checkbox").serializeArray();
29-
if (checks.length == 0) {
30-
alert('<?php _e('Please select at least one client to proceed.','cftp_admin'); ?>');
31-
return false;
32-
}
33-
else {
34-
var action = $('#action').val();
35-
if (action == 'delete') {
36-
var msg_1 = '<?php _e("You are about to delete",'cftp_admin'); ?>';
37-
var msg_2 = '<?php _e("requests. Are you sure you want to continue?",'cftp_admin'); ?>';
38-
if (confirm(msg_1+' '+checks.length+' '+msg_2)) {
39-
return true;
40-
} else {
41-
return false;
42-
}
43-
}
44-
}
45-
});
46-
4727
$('.change_all').click(function(e) {
4828
e.preventDefault();
4929
var target = $(this).data('target');
@@ -301,8 +281,6 @@ function check_client(client_id) {
301281
$actions_options = array(
302282
'none' => __('Select action','cftp_admin'),
303283
'apply' => __('Apply selection','cftp_admin'),
304-
//'approve_account' => __('Approve accounts only','cftp_admin'),
305-
//'approve_all' => __('Approve accounts and memberships','cftp_admin'),
306284
'delete' => __('Delete requests','cftp_admin'),
307285
);
308286
foreach ( $actions_options as $val => $text ) {

Diff for: clients.php

-26
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,6 @@
2020
include('header.php');
2121
?>
2222

23-
<script type="text/javascript">
24-
$(document).ready(function() {
25-
$("#do_action").click(function() {
26-
var action = $('#action').val();
27-
if (action != 'none') {
28-
var checks = $("td>input:checkbox").serializeArray();
29-
if (checks.length == 0) {
30-
alert('<?php _e('Please select at least one client to proceed.','cftp_admin'); ?>');
31-
return false;
32-
}
33-
else {
34-
if (action == 'delete') {
35-
var msg_1 = '<?php _e("You are about to delete",'cftp_admin'); ?>';
36-
var msg_2 = '<?php _e("clients and all of the assigned files. Are you sure you want to continue?",'cftp_admin'); ?>';
37-
if (confirm(msg_1+' '+checks.length+' '+msg_2)) {
38-
return true;
39-
} else {
40-
return false;
41-
}
42-
}
43-
}
44-
}
45-
});
46-
});
47-
</script>
48-
4923
<div class="col-xs-12">
5024
<?php
5125
/**

Diff for: groups.php

-29
Original file line numberDiff line numberDiff line change
@@ -53,37 +53,8 @@
5353
}
5454

5555
include('header.php');
56-
57-
5856
?>
5957

60-
<script type="text/javascript">
61-
$(document).ready( function() {
62-
$("#do_action").click(function() {
63-
var action = $('#action').val();
64-
if (action != 'none') {
65-
var checks = $("td>input:checkbox").serializeArray();
66-
if (checks.length == 0) {
67-
alert('<?php _e('Please select at least one group to proceed.','cftp_admin'); ?>');
68-
return false;
69-
}
70-
else {
71-
if (action == 'delete') {
72-
var msg_1 = '<?php _e("You are about to delete",'cftp_admin'); ?>';
73-
var msg_2 = '<?php _e("groups. Are you sure you want to continue?",'cftp_admin'); ?>';
74-
if (confirm(msg_1+' '+checks.length+' '+msg_2)) {
75-
return true;
76-
} else {
77-
return false;
78-
}
79-
}
80-
}
81-
}
82-
});
83-
84-
});
85-
</script>
86-
8758
<div class="col-xs-12">
8859

8960
<?php

Diff for: includes/actions.log.export.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,6 @@
5151

5252
fputcsv($output, $rendered);
5353
}
54-
}
54+
}
55+
56+
setCookie("log_download_started", 1, time() + 20, '/', "", false, false);

Diff for: includes/functions.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -971,8 +971,8 @@ function meta_noindex()
971971
function meta_favicon()
972972
{
973973
$favicon_location = BASE_URI . 'img/favicon/';
974-
echo '<link rel="icon" href="' . $favicon_location . 'favicon-32.png" />';
975-
echo '<link rel="apple-touch-icon-precomposed" href="' . $favicon_location . 'favicon-152.png">';
974+
echo '<link rel="icon" href="' . $favicon_location . 'favicon-32.png" />' . "\n";
975+
echo '<link rel="apple-touch-icon-precomposed" href="' . $favicon_location . 'favicon-152.png">' . "\n";
976976
}
977977

978978

Diff for: includes/js/jquery.psendmodal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ $.fn.psendmodal = function() {
33
var modal_structure = '<div class="modal_overlay"></div>'+
44
'<div class="modal_psend">'+
55
'<div class="modal_title">'+
6-
'<span></span>'+
6+
'<span>&nbsp;</span>'+
77
'<a href="#" class="modal_close">&times;</a>'+
88
'</div>'+
99
'<div class="modal_content"></div>'+

0 commit comments

Comments
 (0)