mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-25 21:39:21 +00:00
Perform a request on the API to check user domain availability.
This commit is contained in:
parent
4d9aeb7041
commit
afb65e1d81
@ -20,3 +20,8 @@
|
||||
margin: auto;
|
||||
display: block;
|
||||
}
|
||||
|
||||
invalidDirectory {
|
||||
color: red;
|
||||
font-size: 120%;
|
||||
}
|
@ -20,4 +20,18 @@ ComunicWeb.components.settings.interface = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Check the availability of the virtual directory for user
|
||||
*
|
||||
* @param {string} directory The directory to check
|
||||
* @param {function} callback The result of the request
|
||||
*/
|
||||
checkUserDirectoryAvailability: function(directory, callback){
|
||||
var apiURI = "settings/check_user_directory_availability";
|
||||
var params = {
|
||||
directory: directory
|
||||
};
|
||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
|
||||
}
|
||||
|
||||
}
|
@ -177,7 +177,7 @@ ComunicWeb.pages.settings.sections.general = {
|
||||
});
|
||||
|
||||
//Personnal website
|
||||
var lastName = createFormGroup({
|
||||
var personnalWebsite = createFormGroup({
|
||||
target: target,
|
||||
label: "Personnal website (optionnal)",
|
||||
type: "text",
|
||||
@ -186,7 +186,7 @@ ComunicWeb.pages.settings.sections.general = {
|
||||
});
|
||||
|
||||
//Virtual directory
|
||||
var lastName = createFormGroup({
|
||||
var virtualDirectory = createFormGroup({
|
||||
target: target,
|
||||
label: "Virtual directory for your user page (" + ComunicWeb.__config.siteURL + "user/{virtual_directory})",
|
||||
type: "text",
|
||||
@ -194,6 +194,33 @@ ComunicWeb.pages.settings.sections.general = {
|
||||
value: infos.virtual_directory != "null" ? infos.virtual_directory : ""
|
||||
});
|
||||
|
||||
//Auto-check the virtual directory when it is updated
|
||||
var checkTarget = createElem2({
|
||||
appendTo: target,
|
||||
type: "small"
|
||||
});
|
||||
|
||||
virtualDirectory.onkeyup = function(){
|
||||
checkTarget.innerHTML = "Checking availability...";
|
||||
|
||||
//Get the directory to check
|
||||
var directory = virtualDirectory.value;
|
||||
|
||||
//Check if the directory is empty
|
||||
if(directory == ""){
|
||||
checkTarget.innerHTML = "";
|
||||
return;
|
||||
}
|
||||
|
||||
//Perform a request on the API
|
||||
ComunicWeb.components.settings.interface.checkUserDirectoryAvailability(directory, function(callback){
|
||||
|
||||
//Check if the directory is available or not
|
||||
checkTarget.innerHTML = callback.error ? "<invalidDirectory>This directory is not available!</invalidDirectory>" : "This directory seems to be available!";
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
//Submit button
|
||||
var sendButton = createElem2({
|
||||
appendTo: target,
|
||||
@ -205,7 +232,7 @@ ComunicWeb.pages.settings.sections.general = {
|
||||
//Make the submit button lives
|
||||
sendButton.onclick = function(){
|
||||
|
||||
|
||||
//Check the given values
|
||||
|
||||
};
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user