forked from flydev-fr/Duplicator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Duplicator.js
executable file
·137 lines (129 loc) · 4.36 KB
/
Duplicator.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
/************************************************/
var $debug = false; // set to TRUE for debug mode (not used here)
/************************************************/
if (typeof jQuery != "undefined") {
$(document).ready(function () {
var $backupNowBtn = $("#backupNow"),
$pruneBackupsBtn = $("#pruneBackups"),
$job = false,
$pageHasBeenModified = false;
baffle(".dup-glitch", {
characters: "█▓█ ▒░1▒░3█░▒▓3 █▒▒7▓▒▓ █ ░█▒ ▒▓░: █)░▒ ▓░",
speed: 110,
}).reveal(11500);
$backupNowBtn.on("click", function (ev) {
if (ev.originalEvent.defaultPrevented) return;
if ($pageHasBeenModified == true) {
alert(
"Duplicator settings have been modified.\n\nSave the module settings before continuing or refresh the page to discard settings.\n\n"
);
return;
}
if ($job == true) {
alert("A job is already running");
return;
}
if (
!$("input[name=useLocalFolder]").is(":checked") &&
!$("input[name=useGoogleDrive]").is(":checked") &&
!$("input[name=useDropbox]").is(":checked") &&
!$("input[name=useFTP]").is(":checked") &&
!$("input[name=useAmazonS3]").is(":checked")
) {
//redirectToDuplicator('You must choose one or more option where to save packages and save the module.', 'warning');
}
$.ajax({
url: $(this).data("action"),
context: document.body,
beforeSend: function () {
$job = true;
$backupNowBtn
.text("")
.append($("<i class='fa fa-spinner fa-spin'></i>"))
.append(" Backing up ...");
},
})
.fail(function (xhr, status, error) {
$job = false;
$backupNowBtn.removeClass("ui-state-active").text("Backup now");
var err = eval("(" + xhr.responseText + ")");
//redirectToDuplicator('An error occured: ' + err.Message, 'error');
})
.done(function () {
$job = false;
$backupNowBtn.removeClass("ui-state-active").text("Backup now");
//redirectToDuplicator('', 'none');
});
});
$pruneBackupsBtn.on("click", function (ev) {
if ($job == true) {
alert("A job is already running");
return;
}
$.ajax({
url: $(this).data("action"),
context: document.body,
beforeSend: function () {
$job = true;
$pruneBackupsBtn
.text("")
.append($("<i class='fa fa-spinner fa-spin'></i>"))
.append(" Cleaning ...");
},
})
.fail(function (xhr, status, error) {
$job = false;
$pruneBackupsBtn
.removeClass("ui-state-active")
.text("Clean packages");
var err = eval("(" + xhr.responseText + ")");
//redirectToDuplicator('An error occured: ' + err.Message, 'error');
})
.done(function () {
$job = false;
$pruneBackupsBtn
.removeClass("ui-state-active")
.text("Clean packages");
//redirectToDuplicator('', 'none');
});
});
$("li#wrap_Inputfield_cycle").addClass("invisible");
if ($("#cronMode_LazyCron").is(":checked")) {
$("li#wrap_Inputfield_cycle").removeClass("invisible");
}
$("#wrap_cronMode").on("click", function () {
if ($("#cronMode_LazyCron").is(":checked")) {
$("li#wrap_Inputfield_cycle").removeClass("invisible");
} else if (
$("#cronMode_PWCron").is(":checked") ||
$("#cronMode_none").is(":checked")
) {
$("li#wrap_Inputfield_cycle").addClass("invisible");
}
});
//wrap_Inputfield_cycle
function redirectToDuplicator(str, type) {
var href = "";
var encoded = encodeURI(str);
switch (type) {
case "none":
href = $backupNowBtn.data("action").replace("&action=backup_now", "");
break;
default:
href = $backupNowBtn
.data("action")
.replace(
"&action=backup_now",
"&action=" + type + "&msg=" + encoded
);
break;
}
if ($debug == false) {
window.location.replace(href);
}
}
$("input, select, textarea").live("click", function () {
$pageHasBeenModified = true;
});
});
}