-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.js
123 lines (118 loc) · 3.69 KB
/
scripts.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
function validateSubdomain(domain, responseID){
new Ajax({
url: 'ajax.php?modul=validation&typ=subdomain&domain='+domain,
ResponseHandle: {
id: responseID,
action: "callback",
callback: validate_Callback
}
}).go();
}
function getNodeValue(elem){
if(elem.text) return elem.text;
else return elem.textContent;
}
function validate_Callback(http){
xml = http.responseXML.documentElement;
targetID = this.options.ResponseHandle.id;
message = getNodeValue(xml.childNodes[1]);
classes = getNodeValue(xml.childNodes[0]);
writeElement(targetID, message, classes);
}
function updateSubdomain(hostElem){
subdomainElem = document.getElementById('subdomain');
new_value = subdomainElem.value.split(".")[0];
if(hostElem.selectedIndex != 0){
new_value += "."+hostElem.options[hostElem.selectedIndex].value;
}
subdomainElem.value = new_value
subdomainElem.onchange();
}
function writeElement(id, content, classes) {
elem = document.getElementById(id);
elem.innerHTML = content;
elem.className = classes;
}
function builtProgressbar(value){
string = "<div style='width:250px;'>";
string += "<div style='width: "+value+"; overflow:hidden;'>";
string += "<img src='images/progress_bar.jpg' width='250px' height='10px;' alt='' />";
string += "</div>";
string += "</div>";
return string;
}
function validatePasswordStrength(pass, responseID){
new Ajax({
url: 'ajax.php?modul=validation&typ=password_strength&password='+pass,
ResponseHandle: {
id: responseID,
action: "callback",
callback: validatePasswordStrength_Callback
}
}).go();
}
function validatePasswordStrength_Callback(http){
xml = http.responseXML.documentElement;
targetID = this.options.ResponseHandle.id;
message = getNodeValue(xml.childNodes[2]);
classes = getNodeValue(xml.childNodes[0]);
value = getNodeValue(xml.childNodes[1]);
message += builtProgressbar(value);
writeElement(targetID, message, classes);
}
function validatePassword(pass1, pass2, responseID){
new Ajax({
url: 'ajax.php?modul=validation&typ=password&pass1='+pass1+'&pass2='+pass2,
ResponseHandle: {
id: responseID,
action: "callback",
callback: validate_Callback
}
}).go();
}
function validateEmail(email, responseID){
new Ajax({
url: 'ajax.php?modul=validation&typ=email&email='+email,
ResponseHandle: {
id: responseID,
action: "callback",
callback: validate_Callback
}
}).go();
}
function loadTemplates(select, responseID){
new Ajax({
url: 'ajax.php?modul=communication&typ=loadTemplates&short='+select.options[select.selectedIndex].value,
ResponseHandle: {
id: responseID,
action: "callback",
callback: loadTemplates_Callback
}
}).go();
}
function loadTemplates_Callback(http){
xml = http.responseXML.documentElement;
targetID = this.options.ResponseHandle.id;
targetElem = document.getElementById(targetID);
for (i = targetElem.length - 1; i > 0; i--) {
targetElem.remove(i);
}
templates = xml.getElementsByTagName('result');
for (i = 0; i < templates.length; i++) {
option = document.createElement("option");
option.text = getNodeValue(templates[i].childNodes[1]);
option.value = getNodeValue(templates[i].childNodes[0]);
try {
targetElem.add(option, null);
}
catch (e) {
targetElem.add(option);
}
}
}
function $(id){
return document.getElementById(id);
}
function load_template_preview(template){
$('template_preview').src = 'templates/'+template;
}