OctoSearch/common.js
Jaidyn Ann 404479be6c Split communal/utility functions into `common.js`
`common.js` will be prepended to other JS files using the Makefile.
2023-04-04 08:17:50 -05:00

22 lines
788 B
JavaScript

// 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).
function savepreset(preset, name) {
let presets = Array();
let presetName = name.replace(',', ' ');
try { presets = localStorage.getItem('presets').split(','); } catch {}
try { localStorage.removeItem('preset_' + presetName); } catch {}
presets = removefromarray(removeredundantitems(presets), presetName);
presets.push(presetName);
localStorage.setItem('preset_' + presetName, preset);
localStorage.setItem('presets', presets);
}
// Load an array of all saved preset's names.
function loadpresets() {
try { return localStorage.getItem('presets').split(','); } catch { return []; }
}