-
Notifications
You must be signed in to change notification settings - Fork 3
/
directory-name-form.html
59 lines (51 loc) · 1.86 KB
/
directory-name-form.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
<!DOCTYPE html>
<html>
<head>
<script src="sdk/scripts/VSS.SDK.js"></script>
</head>
<body>
<h2 class="title" id="header">Enter directory name</h2>
<div class="single-line-text-input" id="name-input">
<label>Name:</label>
<input id="inpName" />
</div>
<script>
VSS.init();
var directoryNameForm = (function() {
var callbacks = [];
function inputChanged() {
// Execute registered callbacks
for(var i = 0; i < callbacks.length; i++) {
callbacks[i](isValid());
}
}
function isValid() {
// Check whether form is valid or not
return !!(name.value);
}
function getFormData() {
// Get form values
return {
name: name.value
};
}
var name = document.getElementById("inpName");
var url = new URL(window.location.href);
name.value = url.searchParams.get("name")
name.addEventListener("change", inputChanged);
return {
isFormValid: function() {
return isValid();
},
getFormData: function() {
return getFormData();
},
attachFormChanged: function(cb) {
callbacks.push(cb);
}
};
})();
VSS.register("Magenic.DirectoryName", directoryNameForm);
</script>
</body>
</html>