forked from bashGroup/node-red-contrib-fritz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.html
88 lines (84 loc) · 2.98 KB
/
config.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
<script type="text/javascript">
RED.nodes.registerType("fritzbox-config", {
category: "config",
defaults: {
name: {
value: "",
required: false
},
host: {
value: "fritz.box",
required: true
},
port: {
value: 49000,
required: true
},
ssl: {
value: false,
required: true
},
user: {
required: true,
value: "admin"
}
},
credentials: {
username: {
type: "text",
},
password: {
type: "password"
}
},
label: function () {
return this.name ? this.name : "FRITZ!Box";
},
oneditprepare: function () {
// For backward compatibility
if ($('#node-config-input-username').val() !== "") {
$('#node-config-input-user').val($('#node-config-input-username').val())
}
$('#node-config-input-user').change(function() {
const username = $('#node-config-input-user').val()
$('#node-config-input-username').val(username)
})
$('#node-config-input-ssl').change(function () {
var ssl = $('#node-config-input-ssl').is(":checked");
var port = $('#node-config-input-port').val();
if (ssl === true && port === "49000") {
$('#node-config-input-port').val("49443");
}
if (ssl === false && port === "49443") {
$('#node-config-input-port').val("49000");
}
})
}
});
</script>
<script type="text/x-red" data-template-name="fritzbox-config">
<div class="form-row">
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-config-input-name"/>
</div>
<div class="form-row">
<label for="node-config-input-host"><i class="fa fa-globe"></i> Host</label>
<input type="text" id="node-config-input-host" style="width: 40%;"/>
<input type="text" id="node-config-input-port" style="width:60px" />
</div>
<div class="form-row">
<label> </label>
<input type="checkbox" id="node-config-input-ssl" placeholder="" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-config-input-ssl" style="width: 70%;">Enable secure connection (SSL/TLS)</label>
</div>
<div class="form-row">
<label for="node-config-input-username"><i class="fa fa-user"></i> Username</label>
<input type="text" id="node-config-input-user" />
<input type="hidden" id="node-config-input-username"/>
</div>
<div class="form-row">
<label for="node-config-input-password"><i class="fa fa-key"></i> Password</label>
<input type="password" id="node-config-input-password" />
</div>
<div class="form-tips"><span>Hint: If you have set your fritzbox to login with "password only" you have to choose a random username that does not exist on the fritzbox, e.g. "admin" or "doesnotexist".</span></div>
</script>