allow users to easily work with preferences stored in session (when pmadb is disabled): after logging in, user is presented with a message asking whether settings from localStorage should be loaded

This commit is contained in:
Crack
2010-07-14 21:28:24 +02:00
parent 60285cd665
commit 7a5fd62810
7 changed files with 107 additions and 18 deletions

View File

@@ -631,6 +631,7 @@ $(function() {
//
$(function() {
offerPrefsAutoimport();
var radios = $('#import_local_storage, #export_local_storage');
if (!radios.length) {
return;
@@ -747,6 +748,32 @@ function formatDate(d)
+ ':' + (d.getMinutes() < 10 ? '0'+d.getMinutes() : d.getMinutes());
}
/**
* Prepares message which informs that localStorage preferences are available and can be imported
*/
function offerPrefsAutoimport()
{
var has_config = (window.localStorage || false) && (window.localStorage['config'] || false);
var cnt = $('#prefs_autoload');
if (!cnt.length || !has_config) {
return;
}
cnt.find('a').click(function(e) {
e.stopPropagation();
var a = $(this);
if (a.attr('href') == '#no') {
cnt.remove();
$.post('main.php', {
token: cnt.find('input[name=token]').val(),
prefs_autoload: 'hide'});
return;
}
cnt.find('input[name=json]').val(window.localStorage['config']);
cnt.find('form').submit();
});
cnt.show();
}
//
// END: User preferences import/export
// ------------------------------------------------------------------