mirror of
https://bitbucket.org/skobkin/chrome_point_plus.git
synced 2024-11-23 18:56:04 +00:00
Quick failure fix. Needs to be optimized.
This commit is contained in:
parent
082e7dbdb2
commit
ceb01f9d8d
|
@ -1,6 +1,37 @@
|
||||||
var ppOptions = {};
|
var ppOptions = {};
|
||||||
|
|
||||||
|
// Initializing full options structure
|
||||||
// Saves options to localStorage.
|
// Saves options to localStorage.
|
||||||
|
function pp_init_options() {
|
||||||
|
$('.option-node').find('input').each(function(idx, $input) {
|
||||||
|
console.log($(this));
|
||||||
|
|
||||||
|
// Using option types
|
||||||
|
if ($(this).hasClass('option-boolean')) {
|
||||||
|
ppOptions[$(this).prop('id').replace(/-/g, '_')] = {
|
||||||
|
'type': 'boolean',
|
||||||
|
'value': $(this).prop('checked')
|
||||||
|
};
|
||||||
|
} else if ($(this).hasClass('option-enum')) {
|
||||||
|
if ($(this).prop('checked')) {
|
||||||
|
ppOptions[$(this).prop('name').replace(/-/g, '_')] = {
|
||||||
|
'type': 'enum',
|
||||||
|
'value': $(this).val()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('Saving options: %O', ppOptions);
|
||||||
|
|
||||||
|
// Saving parameters
|
||||||
|
chrome.storage.sync.set({'options': ppOptions}, function() {
|
||||||
|
console.log('Default options initialized');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Saves options to localStorage.
|
||||||
|
// @todo: optimize it!
|
||||||
function pp_save_options() {
|
function pp_save_options() {
|
||||||
$('.option-node').find('input').each(function(idx, $input) {
|
$('.option-node').find('input').each(function(idx, $input) {
|
||||||
console.log($(this));
|
console.log($(this));
|
||||||
|
@ -49,6 +80,13 @@ function pp_restore_options() {
|
||||||
|
|
||||||
// Loading options
|
// Loading options
|
||||||
chrome.storage.sync.get('options', function(options) {
|
chrome.storage.sync.get('options', function(options) {
|
||||||
|
// Initializing clean options
|
||||||
|
// @todo: rewrite for all options
|
||||||
|
if (options.option_embedding === undefined) {
|
||||||
|
console.warn('Clean options detected. Initializing...');
|
||||||
|
pp_init_options();
|
||||||
|
}
|
||||||
|
|
||||||
// Setting options in DOM
|
// Setting options in DOM
|
||||||
$.each(options.options, function(key, data) {
|
$.each(options.options, function(key, data) {
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "Point+",
|
"name": "Point+",
|
||||||
"version": "1.17.0",
|
"version": "1.17.1",
|
||||||
"default_locale": "ru",
|
"default_locale": "ru",
|
||||||
"author": "__MSG_ext_author__",
|
"author": "__MSG_ext_author__",
|
||||||
"homepage_url": "https://bitbucket.org/skobkin/chrome_point_plus",
|
"homepage_url": "https://bitbucket.org/skobkin/chrome_point_plus",
|
||||||
|
|
Loading…
Reference in a new issue