Your '+target+' '+type+' '+isAre+' set
';
var thefile = getFile(filename, fileFormat, target, type);
jQuery("."+target+"_"+type+"_uploader").append(thenotice+thefile);
// all is done
return true;
}
function removeFileCheck(clearServer, target, type){
UIkit.modal.confirm('Are you sure you want to delete this '+target+'?', function(){ removeFile(clearServer, target, 1, type); });
}
function removeFile(clearServer, target, flush, type){
if ((clearServer.length > 20 && (type === 'image' || type === 'document')) || (clearServer.length > 1 && (type === 'images' || type === 'documents' || type === 'media'))){
// remove file from server
removeFile_server(clearServer, target, flush, type);
}
jQuery(".success-"+target+"-"+type+"-8768").remove();
// remove locally
if (clearServer.length > 20 && (type === 'image' || type === 'document')) {
// remove the file
jQuery("#jform_"+target+"_"+type).val('');
} else if (clearServer.length > 20 && (type === 'images' || type === 'documents' || type === 'media')) {
// get the old values
var filenames = jQuery("#jform_"+target+"_"+type).val();
if (isJsonString(filenames)) {
filenames = jQuery.parseJSON(filenames);
// remove the current file from those values
filenames = jQuery.grep(filenames, function(value) {
return value != clearServer;
});
if (typeof filenames == 'object' && !jQuery.isEmptyObject(filenames)) {
// set the new values
var filename = JSON.stringify(filenames);
jQuery("#jform_"+target+"_"+type).val(filename);
setFile(filename, 0, target, type);
} else {
jQuery("#jform_"+target+"_"+type).val('');
}
} else {
jQuery("#jform_"+target+"_"+type).val('');
}
}
}
function removeFile_server(currentFileName, target, flush, type){
var getUrl = JRouter("index.php?option=com_membersmanager&task=ajax.removeFile&format=json&vdm="+vastDevMod);
if(token.length > 0 && target.length > 0 && type.length > 0){
var request = 'token='+token+'&filename='+currentFileName+'&target='+target+'&flush='+flush+'&type='+type;
}
return jQuery.ajax({
type: 'GET',
url: getUrl,
dataType: 'jsonp',
data: request,
jsonp: 'callback'
});
}
function isJsonString(str) {
if (typeof str != 'string') {
str = JSON.stringify(str);
}
try {
var json = jQuery.parseJSON(str);
} catch(err) {
return false;
}
if (typeof json == 'object' && isEmpty(json)) {
return false;
} else if(typeof json == 'object') {
return true;
}
return false;
}
function isEmpty(obj) {
for(var prop in obj) {
if(obj.hasOwnProperty(prop))
return false;
}
return true;
}
function checkUnique_server(value, field){
var getUrl = JRouter("index.php?option=com_membersmanager&task=ajax.checkUnique&format=json&vdm="+vastDevMod);
if(token.length > 0 && value.length > 0 && field.length > 0){
var request = 'token='+token+'&value='+value+'&field='+field;
}
return jQuery.ajax({
type: 'GET',
url: getUrl,
dataType: 'jsonp',
data: request,
jsonp: 'callback'
});
}
function checkUnique(value, field, show){
// check that we have a value
if (value.length > 1) {
checkUnique_server(value, field).done(function(result) {
if(result.value && result.message){
// show notice that functioName is okay
if (show) {
UIkit2.notify({message: result.message, timeout: 5000, status: result.status, pos: 'top-right'});
}
jQuery('#jform_'+field).val(result.value);
} else if(result.message){
// show notice that functionName is not okay
if (show) {
UIkit2.notify({message: result.message, timeout: 5000, status: result.status, pos: 'top-right'});
}
jQuery('#jform_'+field).val('');
} else {
// set an error that message was not send
if (show) {
UIkit2.notify({message: Joomla.JText._('COM_MEMBERSMANAGER_VALUE_ALREADY_TAKEN_PLEASE_TRY_AGAIN'), timeout: 5000, status: 'danger', pos: 'top-right'});
}
jQuery('#jform_'+field).val('');
}
});
}
}
// set regions that are on the page
regions = {};
var region = 0;
jQuery(document).ready(function($)
{
jQuery("#jform_region option").each(function()
{
var key = jQuery(this).val();
var text = jQuery(this).text();
regions[key] = text;
});
region = jQuery('#jform_region').val();
getRegion();
});
function getRegion_server(country){
var getUrl = "index.php?option=com_membersmanager&task=ajax.getRegion&format=json";
if(token.length > 0 && country > 0){
var request = 'token='+token+'&country='+country;
}
return jQuery.ajax({
type: 'GET',
url: getUrl,
dataType: 'jsonp',
data: request,
jsonp: 'callback'
});
}
function getRegion(){
jQuery("#loading").show();
// clear the selection
jQuery('#jform_region').find('option').remove().end();
jQuery('#jform_region').trigger('liszt:updated');
// get country value if set
var country = jQuery('#jform_country').val();
getRegion_server(country).done(function(result) {
setRegion(result);
jQuery("#loading").hide();
if (typeof regionButton !== 'undefined') {
// ensure button is correct
var region = jQuery('#jform_region').val();
regionButton(region);
}
});
}
function setRegion(array){
if (array) {
jQuery('#jform_region').append('
');
jQuery.each( array, function( i, id ) {
if (id in regions) {
jQuery('#jform_region').append('
');
}
if (id == region) {
jQuery('#jform_region').val(id);
}
});
} else {
jQuery('#jform_region').append('
');
}
jQuery('#jform_region').trigger('liszt:updated');
}
jQuery(document).ready(function($)
{
var user_id = $("#jform_user_id").val();
var showname = 1;
// check if the user id was found
if (!isSet(user_id)) {
var user_id =$("#jform_user").val();
var showname = 2;
}
getUser(user_id, showname);
});
function getUser_server(id, showname){
var getUrl = JRouter("index.php?option=com_membersmanager&task=ajax.getUser&format=json&vdm="+vastDevMod);
if(token.length > 0 && id > 0 && showname > 0){
var request = 'token='+token+'&id='+id+'&showname='+showname;
}
return jQuery.ajax({
type: 'GET',
url: getUrl,
dataType: 'jsonp',
data: request,
jsonp: 'callback'
});
}
function getUser(id, showname){
getUser_server(id, showname).done(function(result) {
jQuery('#user_info').remove();
if(result) {
loadUser(result);
} else {
getCreateUserFields(1);
}
})
}
function getCreateUserFields_server(id){
var getUrl = JRouter("index.php?option=com_membersmanager&task=ajax.getCreateUserFields&format=json&vdm="+vastDevMod);
if(token.length > 0 && id > 0){
var request = 'token='+token+'&id='+id;
}
return jQuery.ajax({
type: 'GET',
url: getUrl,
dataType: 'jsonp',
data: request,
jsonp: 'callback'
});
}
function getCreateUserFields(id) {
getCreateUserFields_server(id).done(function(result) {
jQuery('#user_info').remove();
if(result) {
loadUser(result);
}
});
}
// user values
var userArray = {};
function setUser_server(id){
var getUrl = JRouter("index.php?option=com_membersmanager&task=ajax.setUser&format=json&vdm="+vastDevMod);
if (token.length > 0 && id > 0) {
var request = 'token='+token+'&id='+id+'&data='+JSON.stringify(userArray);
}
return jQuery.ajax({
type: 'GET',
url: getUrl,
dataType: 'jsonp',
data: request,
jsonp: 'callback'
});
}
function setUser(){
// get the id
var id = jQuery("#jform_user_id").val();
// check if the user id was found
if (!isSet(id)) {
var id = jQuery("#jform_user").val();
}
// get the values
userArray['var'] = encodeURIComponent(jQuery("#vdm_name").val());
userArray['uvar'] = encodeURIComponent(jQuery("#vdm_username").val());
userArray['evar'] = encodeURIComponent(jQuery("#vdm_email").val());
userArray['dvar'] = encodeURIComponent(jQuery("#vdm_password").val());
// set the values
setUser_server(id).done(function(result) {
if(result.html) {
jQuery('#user_info').remove();
loadUser(result.html);
jQuery('#system-message-container').html(result.success);
} else if (result.error) {
jQuery('#system-message-container').html(result.error);
}
});
}
// user values
var userCArray = {};
function createUser_server(){
var getUrl = JRouter("index.php?option=com_membersmanager&task=ajax.createUser&format=json&vdm="+vastDevMod);
if (token.length > 0) {
var request = 'token='+token+'&key=1&data='+JSON.stringify(userCArray);
}
return jQuery.ajax({
type: 'GET',
url: getUrl,
dataType: 'jsonp',
data: request,
jsonp: 'callback'
});
}
function createUser() {
// get the values
userCArray['var'] = encodeURIComponent(jQuery("#vdm_c_name").val());
userCArray['uvar'] = encodeURIComponent(jQuery("#vdm_c_username").val());
userCArray['evar'] = encodeURIComponent(jQuery("#vdm_c_email").val());
userCArray['dvar'] = encodeURIComponent(jQuery("#vdm_c_password").val());
// this takes long so show spinner
jQuery("#loading").show();
// set the values
createUser_server().done(function(result) {
if (result.html) {
jQuery('#user_info').remove();
loadUser(result.html);
jQuery('#system-message-container').html(result.success);
} else if (result.error) {
jQuery('#system-message-container').html(result.error);
}
jQuery("#loading").hide();
});
}
function loadUser(result){
// first check the system type
var account = jQuery("#jform_account").val();
if (1 == account || 4 == account) {
jQuery('#jform_user').closest('.span6').append(result);
}
}