-
-
Notifications
You must be signed in to change notification settings - Fork 141
/
Copy pathsettings.js
162 lines (135 loc) · 3.77 KB
/
settings.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
var storedLang;
var availLang = ['cs','de','en','es','fr','it','nl','pl','ro','sv','vi','ru','tr','zh-CN'];
var availLangText = ['Čeština', 'Deutsch', 'English', 'Español', 'Français', 'Italiano', 'Nederlands', 'Polski', 'Română', 'Svenska', 'Tiếng Việt', 'Русский', 'Türkçe', '汉语'];
//$.i18n.debug = true;
//Change Password
function changePassword(){
showInfoDialog('changePassword', $.i18n('InfoDialog_changePassword_title'));
// fill default pw if default is set
if(window.defaultPasswordIsSet)
$('#oldPw').val('hyperhdr')
$('#id_btn_ok').off().on('click',function() {
var oldPw = $('#oldPw').val();
var newPw = $('#newPw').val();
requestChangePassword(oldPw, newPw);
$('#new_modal_dialog').modal('toggle');
});
$('#newPw, #oldPw').off().on('input',function(e) {
($('#oldPw').val().length >= 8 && $('#newPw').val().length >= 8) ? $('#id_btn_ok').attr('disabled', false) : $('#id_btn_ok').attr('disabled', true);
});
}
$(document).ready( function() {
//i18n
function initTrans(lc){
if (lc == 'auto')
{
$.i18n().load().done(
function() {
performTranslation();
});
}
else
{
$.i18n().locale = lc;
$.i18n().load( "i18n", lc ).done(
function() {
performTranslation();
});
}
}
if (storageComp())
{
storedLang = getStorage("langcode");
if (storedLang == null)
{
setStorage("langcode", 'auto');
storedLang = 'auto';
initTrans(storedLang);
}
else
{
initTrans(storedLang);
}
}
else
{
showInfoDialog('warning', "Can't store settings", "Your browser doesn't support localStorage. You can't save a specific language setting (fallback to 'auto detection') and access level (fallback to 'default'). Some wizards may be hidden. You could still use the webinterface without further issues");
initTrans('auto');
storedLang = 'auto';
$('#btn_setlang').attr("disabled", true);
}
initLanguageSelection();
// change pw btn
$('#btn_changePassword').off().on('click',function() {
changePassword();
});
//Lock Ui
$('#btn_lock_ui').off().on('click',function() {
requestLogout();
removeStorage('loginToken', true);
location.replace('/');
});
});
function compareHyperHdrVersion(compareA, compareB)
{
if (compareA.length == 0 || compareB.length == 0)
{
console.log(`Invalid length: A:${compareA.length} B:${compareB.length}`);
return true;
}
if (isNaN(compareA[0]))
compareA = compareA.substring(1);
if (isNaN(compareB[0]))
compareB = compareB.substring(1);
if ((compareA.indexOf('alpha') >= 0) &&
(compareB.indexOf('alpha') < 0))
{
return false;
}
if ((compareB.indexOf('alpha') >= 0) &&
(compareA.indexOf('alpha') < 0))
{
return true;
}
var valueA = compareA.split('.');
var valueB = compareB.split('.');
if (valueA.length < 4 || valueB.length < 4)
{
console.log(`Invalid length: A:${valueA.length} B:${valueB.length}`);
return true;
}
var finalA = "";
for (var i = 0; i < valueA[3].length; i++)
if (!isNaN(valueA[3][i]))
finalA = finalA.concat(valueA[3][i]);
valueA[3] = finalA;
var finalB = "";
for (var i = 0; i < valueB[3].length; i++)
if (!isNaN(valueB[3][i]))
finalB = finalB.concat(valueB[3][i]);
valueB[3] = finalB;
if ((compareA.indexOf('beta') >= 0 || compareA.indexOf('alpha') >= 0) &&
(compareB.indexOf('beta') < 0 && compareB.indexOf('alpha') < 0))
{
if (Number(valueA[0]) <= Number(valueB[0]))
return false;
}
if ((compareB.indexOf('beta') >= 0 || compareB.indexOf('alpha') >= 0) &&
(compareA.indexOf('beta') < 0 && compareA.indexOf('alpha') < 0))
{
if (Number(valueA[0]) >= Number(valueB[0]))
return true;
}
for (var i = 0; i < 4; i++)
{
if (Number(valueA[i]) > Number(valueB[i]))
{
return true;
}
else if (Number(valueA[i]) < Number(valueB[i]))
{
return false;
}
}
return false;
}