v1.18.x
Baris Soner Usakli 11 years ago
parent 8c14a59f93
commit 893efa5f2a

@ -19,6 +19,7 @@ define(['uploader'], function(uploader) {
numFields = fields.length, numFields = fields.length,
saveBtn = document.getElementById('save'), saveBtn = document.getElementById('save'),
x, key, inputType; x, key, inputType;
for (x = 0; x < numFields; x++) { for (x = 0; x < numFields; x++) {
key = fields[x].getAttribute('data-field'); key = fields[x].getAttribute('data-field');
inputType = fields[x].getAttribute('type'); inputType = fields[x].getAttribute('type');
@ -45,56 +46,66 @@ define(['uploader'], function(uploader) {
} }
saveBtn.addEventListener('click', function(e) { saveBtn.addEventListener('click', function(e) {
var key, value;
e.preventDefault(); e.preventDefault();
for (x = 0; x < numFields; x++) { for (x = 0; x < numFields; x++) {
key = fields[x].getAttribute('data-field'); saveField(fields[x]);
if (fields[x].nodeName === 'INPUT') { }
inputType = fields[x].getAttribute('type'); });
switch (inputType) {
case 'text':
case 'password':
case 'textarea':
case 'number':
value = fields[x].value;
break;
case 'checkbox': function saveField(field) {
value = fields[x].checked ? '1' : '0'; var key = field.getAttribute('data-field'),
break; value;
}
} else if (fields[x].nodeName === 'TEXTAREA') { if (field.nodeName === 'INPUT') {
value = fields[x].value; inputType = field.getAttribute('type');
} else if (fields[x].nodeName === 'SELECT') { switch (inputType) {
value = fields[x].value; case 'text':
case 'password':
case 'textarea':
case 'number':
value = field.value;
break;
case 'checkbox':
value = field.checked ? '1' : '0';
break;
} }
} else if (field.nodeName === 'TEXTAREA') {
value = field.value;
} else if (field.nodeName === 'SELECT') {
value = field.value;
}
socket.emit('admin.config.set', { socket.emit('admin.config.set', {
key: key, key: key,
value: value value: value
}, function(err) { }, function(err) {
if(err) { if(err) {
return app.alert({ return app.alert({
alert_id: 'config_status',
timeout: 2500,
title: 'Changes Not Saved',
message: 'NodeBB encountered a problem saving your changes',
type: 'danger'
});
}
app.alert({
alert_id: 'config_status', alert_id: 'config_status',
timeout: 2500, timeout: 2500,
title: 'Changes Saved', title: 'Changes Not Saved',
message: 'Your changes to the NodeBB configuration have been saved.', message: 'NodeBB encountered a problem saving your changes',
type: 'success' type: 'danger'
}); });
}
if(app.config[key] !== undefined) {
app.config[key] = value;
}
app.alert({
alert_id: 'config_status',
timeout: 2500,
title: 'Changes Saved',
message: 'Your changes to the NodeBB configuration have been saved.',
type: 'success'
}); });
}
}); });
}
$('#uploadLogoBtn').on('click', function() { $('#uploadLogoBtn').on('click', function() {
uploader.open(RELATIVE_PATH + '/admin/uploadlogo', {}, 0, function(image) { uploader.open(RELATIVE_PATH + '/admin/uploadlogo', {}, 0, function(image) {

Loading…
Cancel
Save