/
config.js
176 lines (151 loc) · 7.46 KB
/
config.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
'use strict';
var sett;
const wideSpacingMultiplier = 2;
const lblTitle = `${_('Title')} (${_('Album')})`,
lblNone = _('None'),
lblAlbumArtist = _('Album Artist'),
lblDate = _('Date'),
lblDesc = _('Description'),
lblCount = _('# Tracks in Album'),
lblAlbum = _('Album'),
lblYear = _('Year'),
lblTrackTitle = `${_('Title')} (${_('Track')} - ${_('Playing')})`;
function textLabelToKey(label) {
switch(label) {
case lblNone: return undefined;
case lblTitle: return 'title';
case lblAlbumArtist: return 'albumArtist';
case lblDate: return 'date';
case lblDesc: return 'description';
case lblCount: return 'count';
case lblTrackTitle: return 'trackTitle';
}
}
function textKeyToLabel(key) {
if (!key) return lblNone;
switch(key) {
case 'title': return lblTitle;
case 'albumArtist': return lblAlbumArtist;
case 'date': return lblDate;
case 'description': return lblDesc;
case 'count': return lblCount;
case 'trackTitle': return lblTrackTitle;
}
}
function hotlinkLabelToKey(label) {
switch(label) {
case lblNone: return undefined;
case lblAlbumArtist: return 'albumartist';
case lblYear: return 'year';
case lblAlbum: return 'album';
}
}
function hotlinkKeyToLabel(key) {
if (!key) return lblNone;
switch(key) {
case 'albumartist': return lblAlbumArtist;
case 'year': return lblYear;
case 'album': return lblAlbum;
}
}
window.configInfo = {
load: function (pnlDiv, addon) {
sett = app.getValue('FlowAlbumView_settings', {
spacingMultiplier: 1,
disablePerspectiveDistortion: false,
capFramerate: false,
highResThumbnails: true,
backgroundColor: undefined,
useHotlinks: true,
throttleCarouselSpeed: true,
mouseWheelScrollNumber: undefined,
showPrefix: false,
textFields: {
header: 'title',
subheader: 'albumArtist',
line1: 'date',
line2: 'description'
},
textHotlinks: {
header: 'album',
subheader: undefined,
line1: 'year',
line2: undefined
}
});
const UI = getAllUIElements(pnlDiv);
if (sett.backgroundColor) {
UI.bgColor.controlClass.rgb = sett.backgroundColor;
UI.bgCustomChoice.controlClass.checked = true;
}
else {
UI.bgSkinChoice.controlClass.checked = true;
UI.bgColor.setAttribute('data-disabled', '1');
}
localListen(UI.bgCustomChoice, 'click', () => {
UI.bgColor.removeAttribute('data-disabled');
});
localListen(UI.bgSkinChoice, 'click', () => {
UI.bgColor.setAttribute('data-disabled', '1');
});
UI.chbHighQuality.controlClass.checked = sett.highResThumbnails;
UI.chbCapFramerate.controlClass.checked = sett.capFramerate;
UI.chbDisablePerspective.controlClass.checked = sett.disablePerspectiveDistortion;
UI.mouseScrollNum.controlClass.value = String(sett.mouseWheelScrollNumber || 'Use Windows setting');
UI.chbWiderAlbums.controlClass.checked = (sett.spacingMultiplier == wideSpacingMultiplier);
UI.chbPrefix.controlClass.checked = sett.showPrefix;
var textFieldItems = [lblNone,lblTitle,lblAlbumArtist,lblDate,lblDesc,lblCount,lblTrackTitle].join(',');
var hotlinkFieldItems = [lblNone,lblAlbum,lblYear,lblAlbumArtist].join(',');
// var textFieldItems = `None,${lblTitle},Album Artist,Date,Description,# Tracks`;
// var hotlinkFieldItems = 'None,Album,Year,Album Artist';
UI.textFieldHeader.controlClass.items = textFieldItems;
UI.textFieldSubheader.controlClass.items = textFieldItems;
UI.textFieldLine1.controlClass.items = textFieldItems;
UI.textFieldLine2.controlClass.items = textFieldItems;
UI.hotlinkFieldHeader.controlClass.items = hotlinkFieldItems;
UI.hotlinkFieldSubheader.controlClass.items = hotlinkFieldItems;
UI.hotlinkFieldLine1.controlClass.items = hotlinkFieldItems;
UI.hotlinkFieldLine2.controlClass.items = hotlinkFieldItems;
UI.textFieldHeader.controlClass.value = textKeyToLabel(sett.textFields.header);
UI.textFieldSubheader.controlClass.value = textKeyToLabel(sett.textFields.subheader);
UI.textFieldLine1.controlClass.value = textKeyToLabel(sett.textFields.line1);
UI.textFieldLine2.controlClass.value = textKeyToLabel(sett.textFields.line2);
UI.hotlinkFieldHeader.controlClass.value = hotlinkKeyToLabel(sett.textHotlinks.header);
UI.hotlinkFieldSubheader.controlClass.value = hotlinkKeyToLabel(sett.textHotlinks.subheader);
UI.hotlinkFieldLine1.controlClass.value = hotlinkKeyToLabel(sett.textHotlinks.line1);
UI.hotlinkFieldLine2.controlClass.value = hotlinkKeyToLabel(sett.textHotlinks.line2);
},
save: function(pnlDiv, addon) {
const UI = getAllUIElements(pnlDiv);
sett.textFields.header = textLabelToKey(UI.textFieldHeader.controlClass.value);
sett.textFields.subheader = textLabelToKey(UI.textFieldSubheader.controlClass.value);
sett.textFields.line1 = textLabelToKey(UI.textFieldLine1.controlClass.value);
sett.textFields.line2 = textLabelToKey(UI.textFieldLine2.controlClass.value);
sett.textHotlinks.header = hotlinkLabelToKey(UI.hotlinkFieldHeader.controlClass.value);
sett.textHotlinks.subheader = hotlinkLabelToKey(UI.hotlinkFieldSubheader.controlClass.value);
sett.textHotlinks.line1 = hotlinkLabelToKey(UI.hotlinkFieldLine1.controlClass.value);
sett.textHotlinks.line2 = hotlinkLabelToKey(UI.hotlinkFieldLine2.controlClass.value);
if (UI.mouseScrollNum.controlClass.value == 'Use Windows setting') sett.mouseWheelScrollNumber = undefined;
else sett.mouseWheelScrollNumber = parseInt(UI.mouseScrollNum.controlClass.value);
// sett.throttleCarouselSpeed = UI.chbThrottleCarouselSpeed.controlClass.checked;
sett.highResThumbnails = UI.chbHighQuality.controlClass.checked;
sett.capFramerate = UI.chbCapFramerate.controlClass.checked;
sett.disablePerspectiveDistortion = UI.chbDisablePerspective.controlClass.checked;
sett.spacingMultiplier = (UI.chbWiderAlbums.controlClass.checked) ? wideSpacingMultiplier : 1;
sett.showPrefix = UI.chbPrefix.controlClass.checked;
// if custom choice is selected, then set the background
if (UI.bgCustomChoice.controlClass.checked) {
sett.backgroundColor = UI.bgColor.controlClass.rgb;
}
else sett.backgroundColor = undefined;
// Save the values
app.setValue('FlowAlbumView_settings', sett);
// Ensure thumbnail cache size is 512px
var iniSett = window.settings.get('Options');
iniSett.Options.imageCacheSizes = '80;200;512';
window.settings.set(iniSett, 'Options');
// Notify the settings change, for the view control to update
app.notifySettingsChange();
app.flushState();
}
}