2023-04-04 08:17:50 -05:00
|
|
|
// Saves a search-group of the given `name`, containing all search-engines of
|
|
|
|
// `preset` (which is an array of search-engine display-names truncated to 7 chars).
|
2023-04-05 16:49:13 -05:00
|
|
|
function savePreset(preset, name) {
|
2023-04-04 08:17:50 -05:00
|
|
|
let presets = Array();
|
|
|
|
let presetName = name.replace(',', ' ');
|
|
|
|
try { presets = localStorage.getItem('presets').split(','); } catch {}
|
|
|
|
|
|
|
|
try { localStorage.removeItem('preset_' + presetName); } catch {}
|
|
|
|
|
2023-04-05 16:49:13 -05:00
|
|
|
presets = removeFromArray(removeRedundantItems(presets), presetName);
|
2023-04-04 08:17:50 -05:00
|
|
|
presets.push(presetName);
|
|
|
|
|
|
|
|
localStorage.setItem('preset_' + presetName, preset);
|
|
|
|
localStorage.setItem('presets', presets);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Load an array of all saved preset's names.
|
2023-04-05 16:49:13 -05:00
|
|
|
function loadPresets() {
|
2023-04-04 08:17:50 -05:00
|
|
|
try { return localStorage.getItem('presets').split(','); } catch { return []; }
|
|
|
|
}
|