$(document).ready(function(){ $('#loglevel').change(function(){ $.post(OC.filePath('settings','ajax','setloglevel.php'), { level: $(this).val() },function(){ OC.Log.reload(); } ); }); $('#backgroundjobs input').change(function(){ if($(this).attr('checked')){ var mode = $(this).val(); if (mode === 'ajax' || mode === 'webcron' || mode === 'cron') { OC.AppConfig.setValue('core', 'backgroundjobs_mode', mode); } } }); $('#shareAPIEnabled').change(function() { $('.shareAPI td:not(#enable)').toggle(); }); $('#shareAPI input').change(function() { if ($(this).attr('type') === 'checkbox') { if (this.checked) { var value = 'yes'; } else { var value = 'no'; } } else { var value = $(this).val(); } OC.AppConfig.setValue('core', $(this).attr('name'), value); }); $('#security').change(function(){ $.post(OC.filePath('settings','ajax','setsecurity.php'), { enforceHTTPS: $('#forcessl').val() },function(){} ); }); $('#mail_smtpauth').change(function() { if (!this.checked) { $('#mail_credentials').toggle(false); } else { $('#mail_credentials').toggle(true); } }); $('#mail_settings').change(function(){ OC.msg.startSaving('#mail_settings .msg'); var post = $( "#mail_settings" ).serialize(); $.post(OC.Router.generate('settings_mail_settings'), post, function(data){ OC.msg.finishedSaving('#mail_settings .msg', data); }); }); }); OC.msg={ startSaving:function(selector){ $(selector) .html( t('settings', 'Saving...') ) .removeClass('success') .removeClass('error') .stop(true, true) .show(); }, finishedSaving:function(selector, data){ if( data.status === "success" ){ $(selector).html( data.data.message ) .addClass('success') .stop(true, true) .delay(3000) .fadeOut(900); }else{ $(selector).html( data.data.message ).addClass('error'); } } };