-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
631 lines (615 loc) · 21.5 KB
/
index.html
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
<!--[if IE]>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<![endif]-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>U-NAS</title>
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<link
rel="stylesheet"
type="text/css"
href="/apps/ddns-go/css/index.css?v=6.0.2&"
/>
<script>
window.top.UNAS.SetAppState('DDNS GO', 'active')
</script>
<script language="JavaScript" type="text/javascript">
jQuery.noConflict()
let usedPort = undefined
;(function () {
getConfig()
jQuery('#ddns_go_enable').click(function () {
if (jQuery('#ddns_go_enable').prop('checked') == false) {
jQuery("[name='ddns_go_input']").attr('disabled', true)
if (jQuery('#ddns_go_enable').attr('oldvalue') == 'enable')
jQuery('#ddns_go_apply').attr('class', 'unas_button')
}
if (jQuery('#ddns_go_enable').prop('checked') == true) {
jQuery("[name='ddns_go_input']").attr('disabled', false)
jQuery('#ddns_go_enable').attr('disabled', false)
}
})
jQuery('#ddns_go_port').keyup(ddnsGoCheckPortFunc)
})()
function getConfig() {
jQuery('#ddns_go_manager_waiting_content').attr(
'style',
'display:block'
)
jQuery('#ddns_go_manager_waiting_logo').attr('style', 'display:block')
jQuery.ajax({
url: '/apps/ddns-go/includes/services.php',
type: 'POST',
async: true,
contentType: 'application/json',
data: JSON.stringify({ token: UToken, action: 'getConfig' }),
dataType: 'json',
timeout: 20000,
success: function (data) {
if (data.pass == 'exit') {
parent.location.assign('/desktop/')
} else {
if (
data.enable == true ||
jQuery('#ddns_go_enable').prop('checked')
) {
jQuery('#ddns_go_enable').prop('checked', true)
jQuery('#ddns_go_enable').attr('oldvalue', 'enable')
} else {
jQuery("[name='ddns_go_input']").attr('disabled', true)
jQuery('#ddns_go_enable').prop('checked', false)
jQuery('#ddns_go_enable').attr('oldvalue', 'disable')
}
if (data.enable) {
jQuery('#ddns_go_manage').attr(
'url',
'http://' + window.location.hostname + ':' + data.port
)
jQuery('#ddns_go_manage').attr(
'style',
'width: 120px; display:inline-block;'
)
usedPort = data.port
} else {
jQuery('#ddns_go_manage').attr('style', 'display:none;')
usedPort = undefined
}
var shareFolders = data.shareFolders
var selectFolder = data.configDir
if (
data.homesExtConfigFolder &&
data.homesExtConfigFolder !== ''
) {
if (shareFolders) {
shareFolders.unshift({
path: data.homesExtConfigFolder,
})
} else {
shareFolders = [
{
path: data.homesExtConfigFolder,
},
]
}
if (
selectFolder === null ||
selectFolder === undefined ||
selectFolder === ''
) {
selectFolder = data.homesExtConfigFolder
}
}
var shareFolderAvail = share_folder_list(
'ddns_go_config_dir',
shareFolders,
selectFolder
)
jQuery('#ddns_go_port').val(data.port)
jQuery('#ddns_go_update_interval').val(data.updateInterval)
jQuery('#ddns_go_comparison_interval').val(
data.comparisonInterval
)
jQuery('#ddns_go_skip_verify_cert').prop(
'checked',
data.skipVerifyCert
)
var str = ''
const dnss = {
'': UNAS._('Default DNS'),
'223.5.5.5': UNAS._('Ali DNS (223.5.5.5)'),
'223.6.6.6': UNAS._('Ali DNS (223.6.6.6)'),
'119.29.29.29': UNAS._('Tencent DNS (119.29.29.29)'),
'1.1.1.1': 'CloudFlare DNS(1.1.1.1)',
'8.8.4.4': UNAS._('Google DNS(8.8.4.4)'),
'8.8.8.8': UNAS._('Google DNS(8.8.8.8)'),
}
jQuery.each(dnss, function (key, value) {
if (key == data.dns) {
str +=
'<option value="' +
key +
'" selected>' +
value +
'</option>'
} else {
str += '<option value="' + key + '">' + value + '</option>'
}
})
jQuery('#ddns_go_dns').html(str)
jQuery('#ddns_go_no_web').prop('checked', data.noWeb)
jQuery('#ddns_go_apply').attr('class', 'unas_button')
jQuery('#ddns_go_manager_waiting_content').attr(
'style',
'display:none'
)
jQuery('#ddns_go_manager_waiting_logo').attr(
'style',
'display:none'
)
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus)
jQuery('#ddns_go_manager_waiting_content').attr(
'style',
'display:none'
)
jQuery('#ddns_go_manager_waiting_logo').attr(
'style',
'display:none'
)
},
})
}
function ddnsGoCheckPortFunc() {
if (ddnsGoCheckPort()) {
jQuery('#ddns_go_apply').attr('class', 'unas_button')
} else {
jQuery('#ddns_go_apply').attr('class', 'unas_button_disabled')
}
}
function ddnsGoCheckPort() {
var portState = false
var port = parseInt(jQuery.trim(jQuery('#ddns_go_port').val()), 10)
if (isNaN(port)) {
jQuery('#ddns_go_port').val('')
} else {
jQuery('#ddns_go_port').val(port)
}
if (usedPort === port) {
// 端口可正在用的端口是一样的,不需要验证
jQuery('#ddns_go_port_warning').attr('class', 'input_warning')
jQuery('#ddns_go_port_warning').attr('title', '')
jQuery('#ddns_go_port_warning').html('')
portState = true
} else if (port > 65535 || port < 1) {
jQuery('#ddns_go_port_warning').attr('class', 'input_warning_info')
jQuery('#ddns_go_port_warning').attr(
'title',
UNAS._('Port should between 1 and 65535')
)
jQuery('#ddns_go_port_warning').html(
'* ' + UNAS._('Port should between 1 and 65535')
)
} else {
jQuery.ajax({
url: '/apps/ddns-go/includes/services.php',
type: 'POST',
async: false,
contentType: 'application/json',
data: JSON.stringify({
token: UToken,
port: port,
action: 'checkport',
}),
timeout: 20000,
dataType: 'json',
success: function (data) {
if (data.err === 1) {
jQuery('#ddns_go_port_warning').attr(
'class',
'input_warning_info'
)
jQuery('#ddns_go_port_warning').attr('title', UNAS._(data.msg))
jQuery('#ddns_go_port_warning').html('* ' + UNAS._(data.msg))
} else {
jQuery('#ddns_go_port_warning').attr('class', 'input_warning')
jQuery('#ddns_go_port_warning').attr('title', '')
jQuery('#ddns_go_port_warning').html('')
portState = true
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus)
},
})
}
return portState
}
function isNumeric(strval) {
var c
for (var i = 0; i < strval.length; i++) {
c = strval.charAt(i)
if (c < '0' || c > '9') {
return false
}
}
return true
}
function submit() {
jQuery('#ddns_go_info').html('')
if (jQuery('#ddns_go_apply').hasClass('unas_button_disabled')) {
return false
}
jQuery('#ddns_go_manager_waiting_content').attr(
'style',
'display:block'
)
jQuery('#ddns_go_manager_waiting_logo').attr('style', 'display:block')
var enable = jQuery('#ddns_go_enable').prop('checked'),
configDir = jQuery('#ddns_go_config_dir').val(),
port = jQuery('#ddns_go_port').val(),
updateInterval = jQuery('#ddns_go_update_interval').val(),
comparisonInterval = jQuery('#ddns_go_comparison_interval').val(),
skipVerifyCert = jQuery('#ddns_go_skip_verify_cert').prop('checked'),
dns = jQuery('#ddns_go_dns').val(),
noWeb = jQuery('#ddns_go_no_web').prop('checked')
var params = {
token: UToken,
enable: enable,
configDir: configDir,
port: port,
updateInterval: updateInterval,
comparisonInterval: comparisonInterval,
skipVerifyCert: skipVerifyCert,
noWeb: noWeb,
action: 'manage',
}
if (dns && dns !== '') {
params.dns = dns
}
jQuery.ajax({
url: '/apps/ddns-go/includes/services.php',
type: 'POST',
async: true,
contentType: 'application/json',
data: JSON.stringify(params),
timeout: 20000,
dataType: 'json',
success: function (data) {
if (data.err === 0) {
jQuery('#ddns_go_info').attr(
'style',
'display:block;color: #333333'
)
jQuery('#ddns_go_info').html(UNAS._('Operation successful'))
} else {
jQuery('#ddns_go_info').attr(
'style',
'display:block;color: #DF3E21'
)
jQuery('#ddns_go_info').html(UNAS._(data.msg))
}
jQuery('#ddns_go_manager_waiting_content').attr(
'style',
'display:none'
)
jQuery('#ddns_go_manager_waiting_logo').attr(
'style',
'display:none'
)
getConfig()
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus)
jQuery('#ddns_go_manager_waiting_content').attr(
'style',
'display:none'
)
jQuery('#ddns_go_manager_waiting_logo').attr(
'style',
'display:none'
)
},
})
}
function openDdnsGo() {
window.open(jQuery('#ddns_go_manage').attr('url'), '_blank')
}
// 功能函数,缩略太长的字符串
function trunc(str, len) {
if (str == null) return ''
var str_length = 0
var str_cut = new String()
for (var i = 0; i < str.length; i++) {
a = str.charAt(i)
str_length++
if (escape(a).length > 4) {
str_length++
}
str_cut = str_cut.concat(a)
if (str_length > len) {
str_cut = str_cut.concat('...')
return str_cut
}
}
if (str_length <= len) {
return str
}
}
function share_folder_list(elementId, folders, folder_selected) {
var folder_opts = ''
var selected = false
var shareFolderAvail = false
if (folders === null || folders === undefined || folders.length === 0) {
// 没有共享文件夹可用
shareFolderAvail = false
folder_opts =
'<option value="">' +
UNAS._(
'##$@ddns@$##Enable Home Dir or create a SHARE FOLDER before select##$@ddns@$##'
) +
'</option>'
} else {
shareFolderAvail = true
for (var i = 0; i < folders.length; i++) {
var folderPath = folders[i].path
folder_opts +=
'<option value="' +
folderPath +
'"' +
' title="' +
folderPath +
'"'
if (folderPath == folder_selected) {
folder_opts += ' selected="selected"'
selected = true
}
folder_opts += '>' + trunc(folderPath, 30) + '</option>'
}
}
jQuery('#' + elementId).html(folder_opts)
if (shareFolderAvail && !selected) {
jQuery('#' + elementId + ' option:first').prop('selected', 'selected')
}
return shareFolderAvail
}
</script>
</head>
<body>
<div id="ddns_go" class="ddns_go_manager">
<div
id="ddns_go_manager_waiting_content"
class="unas_loading_modal"
style="display: none"
></div>
<div
id="ddns_go_manager_waiting_logo"
class="unas_loading"
style="display: none"
></div>
<div class="unas_title">
<div
id="poweroptions_manager_immediately_tab"
class="unas_tab_sel"
poweroptionsitemtableid="poweroptions_manager_immediately_page"
>
<span>##$@ddns@$##DDNS GO##$@ddns@$##</span>
</div>
</div>
<div class="unas_content">
<div
id="jv-unas_content_left"
class="unas_content_left"
style="
position: absolute;
width: calc(100% - 150px);
left: 0;
bottom: 60px;
top: 60px;
"
>
<div class="unas_items ddns-item-li">
<ul>
<li class="unas_item_li" style="margin-bottom: 10px">
<span>
<div class="unas_checkbox">
<input type="checkbox" id="ddns_go_enable" oldvalue="" />
<label for="ddns_go_enable"></label>
</div>
</span>
<span>##$@ddns@$##Enable DDNS GO Service##$@ddns@$##</span>
</li>
<li class="unas_item_li" style="margin-bottom: 10px">
<span class="span_left" style="margin-left: 40px"
>##$@ddns@$##Configuration Directory:##$@ddns@$##</span
>
<span>
<select
class="unas_select"
id="ddns_go_config_dir"
name="ddns_go_config_dir"
></select>
</span>
<label
class=""
id="ddns_go_config_dir_warning"
title=""
></label>
</li>
<li class="unas_item_li" style="margin-bottom: 10px">
<span class="span_left" style="margin-left: 40px"
>##$@ddns@$##Port:##$@ddns@$##</span
><span
><input
type="text"
id="ddns_go_port"
name="ddns_go_input"
class="unas_input" /></span
><label class="" id="ddns_go_port_warning" title=""></label>
</li>
<li class="unas_item_li" style="margin-bottom: 10px">
<span class="span_left" style="margin-left: 40px"
>##$@ddns@$##Update Interval:##$@ddns@$##</span
><span
><input
type="text"
id="ddns_go_update_interval"
name="ddns_go_input"
class="unas_input" /></span
><label
class=""
id="ddns_go_update_interval_warning"
title=""
></label>
</li>
<li class="unas_item_li" style="margin-bottom: 10px">
<span class="span_left" style="margin-left: 40px"
>##$@ddns@$##Comparison Interval:##$@ddns@$##</span
><span
><input
type="text"
id="ddns_go_comparison_interval"
name="ddns_go_input"
class="unas_input" /></span
><label
class=""
id="ddns_go_comparison_interval_warning"
title=""
></label>
</li>
<li class="unas_item_li" style="margin-bottom: 10px">
<span class="span_left" style="margin-left: 40px"
>##$@ddns@$##Skip verifying certificates:##$@ddns@$##</span
><span>
<div class="unas_checkbox">
<input
type="checkbox"
id="ddns_go_skip_verify_cert"
oldvalue=""
/>
<label for="ddns_go_skip_verify_cert"></label>
</div> </span
><label
class=""
id="ddns_go_skip_verify_cert_warning"
title=""
></label>
</li>
<li class="unas_item_li" style="margin-bottom: 10px">
<span class="span_left" style="margin-left: 40px"
>##$@ddns@$##Specify DNS resolution server:##$@ddns@$##</span
>
<span>
<label class="unas_select_label">
<select
class="unas_select"
id="ddns_go_dns"
name="ddns_go_input"
style="width: 80px"
></select> </label
><label class="" id="ddns_go_dns_warning" title=""></label>
</span>
</li>
<li class="unas_item_li" style="margin-bottom: 10px">
<span class="span_left" style="margin-left: 40px"
>##$@ddns@$##Do not start web services:##$@ddns@$##</span
><span>
<div class="unas_checkbox">
<input type="checkbox" id="ddns_go_no_web" oldvalue="" />
<label for="ddns_go_no_web"></label>
</div> </span
><label class="" id="ddns_go_no_web_warning" title=""></label>
</li>
<li class="unas_item_li" style="margin-bottom: 10px">
<span id="ddns_go_info" style="display: none"></span>
</li>
</ul>
</div>
</div>
<div class="unas_content_right">
<span class="ddns_go_page_logo"></span>
<div class="project-addr">
<a href="https://github.com/jeessy2/ddns-go" target="_blank"
>##$@ddns@$##DDNS GO Project##$@ddns@$##</a
>
</div>
<div class="project-addr">
<a
href="https://github.com/UNS-Third-Party-Applications/ddns-go"
target="_blank"
>##$@ddns@$##Current Project##$@ddns@$##</a
>
</div>
</div>
</div>
<div class="unas_footer">
<a
id="docker_main_button"
target="_blank"
style="
width: 72px;
height: 32px;
display: inline-block;
margin-right: 10px;
"
>
<button
onClick="submit()"
class="unas_button_disabled"
id="ddns_go_apply"
>
##$@ddns@$##Apply##$@ddns@$##
</button>
</a>
<button
onClick="openDdnsGo()"
class="unas_button"
id="ddns_go_manage"
style="display: none"
>
##$@ddns@$##Manage DDNS GO##$@ddns@$##
</button>
</div>
</div>
<script type="text/javascript">
;(function () {
var rt = document.getElementById('ddns_go')
var pageTranslators = window.top.UNAS.CreateNodesTranslators(
rt.parentNode
)
var OnChangeLanguage = function (e) {
for (var i = 0; i < pageTranslators.length; i++) {
var node = pageTranslators[i].node
var p = pageTranslators[i].translateProperty
node[p] = window.top.UNAS._(pageTranslators[i].originalText)
}
if (
jQuery('#ddns_go_port_warning').attr('class') ==
'input_warning_info'
) {
ddnsGoCheckPort()
}
}
OnChangeLanguage()
window.top.UNAS.Event.addEvent('ChangeLanguage', OnChangeLanguage)
window.addEventListener(
'unload',
function (e) {
window.top.UNAS.Event.removeEvent(
'ChangeLanguage',
OnChangeLanguage
)
window.top.UNAS.SetAppState('DDNS GO', 'inactive')
},
false
)
})()
jQuery('#jv-unas_content_left').mCustomScrollbar({
autoHideScrollbar: true,
theme: 'minimal-dark',
})
</script>
</body>
</html>