This repository has been archived by the owner on Aug 27, 2022. It is now read-only.
forked from andreknieriem/photobooth
-
-
Notifications
You must be signed in to change notification settings - Fork 39
/
dependencies.js
73 lines (62 loc) · 2.46 KB
/
dependencies.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
/* globals photoboothTools */
const dependencies = (function () {
// vars
const api = {};
let command;
// init
api.init = function () {
api.checkOS();
};
api.checkOS = function () {
jQuery
.post('api/checkOS.php')
.done(function (result) {
photoboothTools.console.log('Operating system: ' + result.os);
const checkDependencies = photoboothTools.getTranslation('check_dependencies'),
unsupportedOs = photoboothTools.getTranslation('unsupported_os');
if (result.os == 'linux') {
$('.white-box').append($('<p style="color:green">').text(result.os));
$('.white-box').append($('<p>').text(checkDependencies));
api.runCmd('check-deps');
} else {
$('.white-box').append($('<p style="color:red">').text(unsupportedOs));
$('.white-box').append($('<p style="color:red">').text(result.os));
}
})
.fail(function (xhr, status, result) {
photoboothTools.console.log('Operating system check failed: ', result);
});
};
api.runCmd = function ($mode) {
command = {
mode: $mode
};
photoboothTools.console.log('Run' + $mode);
jQuery
.post('api/update.php', command)
.done(function (result) {
photoboothTools.console.log($mode, 'result: ', result);
const updateError = photoboothTools.getTranslation('update_error');
if (result.success) {
if ($mode == 'check-deps') {
// eslint-disable-next-line
result.output.forEach(function (item, index, array) {
$('.white-box').append($('<p>').text(item));
});
}
} else {
$('.white-box').append($('<p style="color:red">').text(updateError));
}
})
.fail(function (xhr, status, result) {
const updateFail = photoboothTools.getTranslation('update_fail');
$('.white-box').append($('<p style="color:red">').text(updateFail));
photoboothTools.console.log($mode, 'result: ', result);
});
};
return api;
})();
// Init on domready
$(function () {
dependencies.init();
});