-
Notifications
You must be signed in to change notification settings - Fork 0
/
code.js
81 lines (78 loc) · 2.65 KB
/
code.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
/**
* Created with JetBrains PhpStorm.
* User: fedmest
* Date: 15/12/2012
* Time: 18:12
* To change this template use File | Settings | File Templates.
*/
$(function() {
$("span[rel=tooltip]").tooltip();
$("#release-date").datepicker({ dateFormat: "yy-mm-dd", maxDate: "+1d" });
$('#registerModal').on('show', function() {
$("#formRegisterProgress").hide();
$("#serverRegisterErrorAlert").hide();
$("#serverRegisterSuccessAlert").hide();
$("#formRegisterErrorAlert").hide();
$("#profileForm").show();
$("#profileSave").show();
$("#profileSave").removeAttr("disabled");
$("#profileCanc").html("Cancel");
});
$("#profileSave").on("click", function(event) {
$(this).attr("disabled", "disabled");
$("#serverRegisterErrorAlert").hide();
$("#formRegisterErrorAlert").hide();
$("#formRegisterProgress").show();
$.ajax({
type: 'POST',
url: 'register.php',
data: $("#profileForm").serialize(),
success: profileSaveSuccess,
error: profileSaveError,
dataType: 'json'
});
return false;
});
});
function profileSaveSuccess(data, status, obj) {
$("#formRegisterProgress").hide();
var msg = null;
switch ( data.status ) {
case 'created':
$("#profileForm").find("input:text, input:password").val("");
case 'saved':
$("#serverRegisterSuccessAlert").show();
$("#profileForm").hide();
$("#profileSave").hide();
$("#profileCanc").html("Close");
break;
case 'missing':
msg = 'You have to fill in all the fields in the form';
break;
case 'password':
msg = 'The password and confirmation password do not match.';
break;
case 'exists':
msg = 'Sorry, but this Plugin ID is already registered.';
break;
case 'existsInactive':
msg = 'Sorry, but this Plugin ID is already registered, although it has not been activated yet.';
break;
case 'dot':
msg = 'Plugin IDs cannot start with a dot.';
break;
case 'unsaved':
msg = 'Could not save your data into the database.';
break;
}
if ( msg ) {
$("#profileSave").removeAttr("disabled");
$("#formRegisterErrorMessage").html(msg);
$("#formRegisterErrorAlert").show();
}
}
function profileSaveError(obj, status, ex) {
$("#formRegisterProgress").hide();
$("#profileSave").removeAttr("disabled");
$("#serverRegisterErrorAlert").show();
}