-
Notifications
You must be signed in to change notification settings - Fork 1
/
cloudChecker.js
62 lines (58 loc) · 2.08 KB
/
cloudChecker.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
const settings = require('electron-settings');
var useCloud
function checkCloudSettings() {
useCloud = settings.get('useCloud')
if (useCloud === true) {
menu.items[4].submenu.items[0].checked= true
} else if (useCloud === false) {
menu.items[4].submenu.items[0].checked= false
savePath = path.join(app.getPath('userData'), 'Data')
} else if (typeof(useCloud) === "undefined") {
console.log ("useCloud was undefined")
settings.set('useCloud', true)
useCloud = true
menu.items[4].submenu.items[0].checked= true
}
}
function toggleCloudSetting() {
useCloud = settings.get('useCloud')
if (useCloud === true) {
menu.items[4].submenu.items[0].checked= false
settings.set('useCloud', false)
console.log("useCloud is now false")
savePath = path.join(app.getPath('userData'), 'Data')
} else if (useCloud === false) {
menu.items[4].submenu.items[0].checked= true
settings.set('useCloud', true)
useCloud = true
console.log("useCloud is now true")
checkForCloudOptions()
}
}
function checkForCloudOptions() {
savePath = path.join(app.getPath('userData'), 'Data')
var userHome = app.getPath('home')
var boxSyncDir = path.join(userHome,'Box Sync')
var dropboxDir = path.join(userHome,'Dropbox')
var dropboxCstarDir = path.join(userHome,'Dropbox (C-STAR)')
if (useCloud === true) {
// Box Sync will be rarely used, so check it first
if (fs.existsSync(boxSyncDir)) {
savePath = path.join(boxSyncDir, 'MUSC_POLAR')
console.log("save path is: ", savePath)
return savePath
} else if (fs.existsSync(dropboxCstarDir)) {
savePath = path.join(dropboxCstarDir, 'PolarData')
console.log("save path is: ", savePath)
return savePath
} else if (fs.existsSync(dropboxDir)) {
savePath = path.join(dropboxDir, 'PolarData')
console.log("save path is: ", savePath)
return savePath
}
console.log("save path is: ", savePath)
return savePath
}
}
document.addEventListener('DOMContentLoaded', checkCloudSettings);
document.addEventListener('DOMContentLoaded', checkForCloudOptions);