Skip to content

Commit

Permalink
Sync some settings
Browse files Browse the repository at this point in the history
  • Loading branch information
flaksp committed Oct 21, 2019
1 parent 84029ca commit 075769a
Show file tree
Hide file tree
Showing 9 changed files with 5,142 additions and 5,243 deletions.
10,240 changes: 5,065 additions & 5,175 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"crypto-js-npm": "github:ssimplix/crypto-js-npm"
},
"devDependencies": {
"laravel-mix": "0.*"
"laravel-mix": "^0.12.1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/terron-kun/camellia.git"
"url": "git+https://github.com/neluzhin/camellia.git"
}
}
2 changes: 1 addition & 1 deletion public/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,6 @@
"message": "Who's the author of the default background picture?"
},
"help_background_author_answer": {
"message": "<p>The photographer is <a href=\"https://www.pexels.com/u/joshua-nkolwa-141357/\" class=\"underlined\">Joshua Nkolwa</a>. The picture was taken from <a href=\"https://www.pexels.com/photo/clouds-countryside-dark-dawn-426613/\" class=\"underlined\">pexels.com</a>.</p><p>Previous background images:</p><ul><li><a href=\"https://www.facebook.com/stefancikphotography\" class=\"underlined\">Stefan Stefancik</a>: <a href=\"https://www.pexels.com/photo/nature-flowers-plant-rain-96920/\" class=\"underlined\">pexels.com</a> (from 1.3.0)</li></ul>"
"message": "<p>The photographer is <a href=\"https://www.pexels.com/@fatamorkidd/\" class=\"underlined\">Fatan ZW</a>. The picture was taken from <a href=\"https://www.pexels.com/photo/white-5-petaled-flower-1587575/\" class=\"underlined\">pexels.com</a>."
}
}
2 changes: 1 addition & 1 deletion public/_locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,6 @@
"message": "Кто автор фоновой картинки, которая идет по умолчанию?"
},
"help_background_author_answer": {
"message": "<p>Фотограф &mdash; <a href=\"https://www.pexels.com/u/joshua-nkolwa-141357/\" class=\"underlined\">Joshua Nkolwa</a>. Фотография была взята с фотостока <a href=\"https://www.pexels.com/photo/clouds-countryside-dark-dawn-426613/\" class=\"underlined\">pexels.com</a>.</p><p>Предыдущие фоны:</p><ul><li><a href=\"https://www.facebook.com/stefancikphotography\" class=\"underlined\">Stefan Stefancik</a>: <a href=\"https://www.pexels.com/photo/nature-flowers-plant-rain-96920/\" class=\"underlined\">pexels.com</a> (c 1.3.0)</li></ul>"
"message": "<p>Фотограф &mdash; <a href=\"https://www.pexels.com/@fatamorkidd/\" class=\"underlined\">Fatan ZW</a>. Фотография была взята с фотостока <a href=\"https://www.pexels.com/photo/white-5-petaled-flower-1587575/\" class=\"underlined\">pexels.com</a>.</p>"
}
}
6 changes: 3 additions & 3 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"manifest_version": 2,
"name": "__MSG_app_name__",
"version": "1.5.1",
"author": "terron",
"homepage_url": "https://github.com/ssimplix/camellia",
"version": "1.6.0",
"author": "Petr Flaks",
"homepage_url": "https://github.com/neluzhin/camellia",
"description": "__MSG_app_description__",
"content_security_policy": "script-src 'self' 'unsafe-eval' https://www.google-analytics.com; object-src 'self'",
"short_name": "Camellia",
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/_variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ const AVAILABLE_COLUMNS = [1, 2, 3, 4, 6, 12];
/**
* Default wallpaper URL
*/
const DEFAULT_WALLPAPER_URL = 'https://i.imgur.com/Lsnc2yC.jpg';
const DEFAULT_WALLPAPER_URL = 'https://i.imgur.com/Wq4FTcf.jpg';
89 changes: 49 additions & 40 deletions resources/assets/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ browser.omnibox.onInputChanged.addListener((text, suggest) => {

let bookmarkMd5 = CryptoJS.MD5(bookmark.url);

if (local_storage['display_click_counter'] === true
if (sync_storage['display_click_counter'] === true
&& typeof sync_storage['click_counter'][bookmarkMd5] !== 'undefined'
&& sync_storage['click_counter'][bookmarkMd5] > 0) {
title += ' <dim>(' + sync_storage['click_counter'][bookmarkMd5] + ')</dim>';
Expand Down Expand Up @@ -118,7 +118,7 @@ browser.omnibox.onInputEntered.addListener(bookmarkId => {

browser.storage.sync.set(sync_storage);

if (local_storage['bookmarks_in_new_tab'] === true) {
if (sync_storage['bookmarks_in_new_tab'] === true) {
browser.tabs.create({
url: bookmark.url
});
Expand All @@ -127,7 +127,7 @@ browser.omnibox.onInputEntered.addListener(bookmarkId => {
browser.tabs.update(tabs[0].id, {url: bookmark.url});
});
}

})
.catch(error => {
browser.notifications.create({
Expand Down Expand Up @@ -175,12 +175,52 @@ browser.runtime.onInstalled.addListener(details => {
sync_storage['vote_remind_displayed'] = false;
}

// Object with bookmark click counter
if (typeof sync_storage['click_counter'] === 'undefined'
|| typeof sync_storage['click_counter'] !== 'object') {
sync_storage['click_counter'] = {};
}

// Object with bookmark click counter
if (typeof sync_storage['click_counter'] === 'undefined'
|| typeof sync_storage['click_counter'] !== 'object') {
sync_storage['click_counter'] = {};
}

// Background wallpaper
if (typeof sync_storage['background_image'] === 'undefined'
|| typeof sync_storage['background_image'] !== 'string') {
sync_storage['background_image'] = local_storage['background_image'] !== undefined
? local_storage['background_image']
: DEFAULT_WALLPAPER_URL;
}

// Background brightness
if (typeof sync_storage['background_brightness'] === 'undefined'
|| typeof sync_storage['background_brightness'] !== 'number') {
sync_storage['background_brightness'] = local_storage['background_brightness'] !== undefined
? local_storage['background_brightness']
: 0.5;
}

// Opens all links in new tab
if (typeof sync_storage['bookmarks_in_new_tab'] === 'undefined'
|| typeof sync_storage['bookmarks_in_new_tab'] !== 'boolean') {
sync_storage['bookmarks_in_new_tab'] = local_storage['bookmarks_in_new_tab'] !== undefined
? local_storage['bookmarks_in_new_tab']
: false;
}

// Enables and disabled text selecting
if (typeof sync_storage['user_select'] === 'undefined'
|| typeof sync_storage['user_select'] !== 'boolean') {
sync_storage['user_select'] = local_storage['user_select'] !== undefined
? local_storage['user_select']
: false;
}

// Shows and hides click counter
if (typeof sync_storage['display_click_counter'] === 'undefined'
|| typeof sync_storage['display_click_counter'] !== 'boolean') {
sync_storage['display_click_counter'] = local_storage['display_click_counter'] !== undefined
? local_storage['display_click_counter']
: true;
}

/*
|--------------------------------------------------------------------------
| Local default settings
Expand All @@ -201,37 +241,12 @@ browser.runtime.onInstalled.addListener(details => {
local_storage['use_custom_scrollbar'] = true;
}

// Background wallpaper
if (typeof local_storage['background_image'] === 'undefined'
|| typeof local_storage['background_image'] !== 'string'
|| local_storage['background_image'] === '/img/wallpaper.jpg') {
local_storage['background_image'] = DEFAULT_WALLPAPER_URL;
}

// Display number of clicks at each bookmark
if (typeof local_storage['display_click_counter'] === 'undefined'
|| typeof local_storage['display_click_counter'] !== 'boolean') {
local_storage['display_click_counter'] = true;
}

// Enables and disabled text selecting
if (typeof local_storage['user_select'] === 'undefined'
|| typeof local_storage['user_select'] !== 'boolean') {
local_storage['user_select'] = false;
}

// Enables and disabled text selecting
if (typeof local_storage['font_size'] === 'undefined'
|| Number.isInteger(local_storage['font_size']) === false) {
local_storage['font_size'] = 16;
}

// Opens all links in new tab
if (typeof local_storage['bookmarks_in_new_tab'] === 'undefined'
|| typeof local_storage['bookmarks_in_new_tab'] !== 'boolean') {
local_storage['bookmarks_in_new_tab'] = false;
}

// Display top sites block
if (typeof local_storage['top_sites'] === 'undefined'
|| typeof local_storage['top_sites'] !== 'boolean') {
Expand All @@ -244,12 +259,6 @@ browser.runtime.onInstalled.addListener(details => {
local_storage['recently_closed'] = false;
}

// Background brightness
if (typeof local_storage['background_brightness'] === 'undefined'
|| typeof local_storage['background_brightness'] !== 'number') {
local_storage['background_brightness'] = 0.5;
}

browser.storage.sync.set(sync_storage);
browser.storage.local.set(local_storage);
})
Expand Down
16 changes: 8 additions & 8 deletions resources/assets/js/newtab.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ Promise.all([
browserBookmarks[0]['children'][1]['children']
);
let columnsCount = local_storage['columns_count'];
let backgroundImage = local_storage['background_image'];
let openBookmarksInNewTab = local_storage['bookmarks_in_new_tab'];
let backgroundImage = sync_storage['background_image'];
let openBookmarksInNewTab = sync_storage['bookmarks_in_new_tab'];
let allTopSites = local_storage['top_sites'] === true ? topSites : [];
let backgroundBrightness = local_storage['background_brightness'];
let backgroundBrightness = sync_storage['background_brightness'];

//
// Preparing recently closed tabs
Expand Down Expand Up @@ -434,7 +434,7 @@ Promise.all([
|--------------------------------------------------------------------------
|
| This component gets bookmarks array splitted in N sub-arrays
| and inserts all sub-arrays in columns at main page.
| and inserts all sub-arrays in columns at main page.
*/

Vue.component('bookmark-column', {
Expand Down Expand Up @@ -477,7 +477,7 @@ Promise.all([
data: function () {
return {
clicksCount: sync_storage['click_counter'],
displayClickCounter: local_storage['display_click_counter'],
displayClickCounter: sync_storage['display_click_counter'],
openBookmarksInNewTab: openBookmarksInNewTab
};
},
Expand Down Expand Up @@ -561,7 +561,7 @@ Promise.all([
}

this.getClicksCount();

this.clicksCount[bookmarkMd5]++;
browser.storage.sync.set({click_counter: this.clicksCount});
},
Expand Down Expand Up @@ -630,7 +630,7 @@ Promise.all([
}

// User select
if (local_storage['user_select'] === true) {
if (sync_storage['user_select'] === true) {
$('body').removeClass('disabled-user-select');
}

Expand Down Expand Up @@ -660,7 +660,7 @@ $(document).on('shown.bs.modal', '.modal', function () {

$(document).on('click', '[href^="chrome://"]', function (event) {
event.preventDefault();

browser.tabs.create({
url: $(this).attr('href')
});
Expand Down
24 changes: 12 additions & 12 deletions resources/assets/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,27 @@ Promise.all([
show: false,
available_columns: AVAILABLE_COLUMNS,

background_image: local_storage['background_image'],
background_image: sync_storage['background_image'],
columns_count: local_storage['columns_count'],
use_custom_scrollbar: Number(local_storage['use_custom_scrollbar']),
display_click_counter: Number(local_storage['display_click_counter']),
user_select: Number(local_storage['user_select']),
display_click_counter: Number(sync_storage['display_click_counter']),
user_select: Number(sync_storage['user_select']),
font_size: local_storage['font_size'],
bookmarks_in_new_tab: Number(local_storage['bookmarks_in_new_tab']),
bookmarks_in_new_tab: Number(sync_storage['bookmarks_in_new_tab']),
top_sites: Number(local_storage['top_sites']),
recently_closed: Number(local_storage['recently_closed']),
background_brightness: local_storage['background_brightness'],
background_brightness: sync_storage['background_brightness'],

locale: i18nObject([
'save',

'option_background_image_label',
'option_background_image_hint',

'option_columns_count_label',
'option_columns_count_column',
'option_columns_count_hint',

'option_use_custom_scrollbar_label',
'option_use_custom_scrollbar_styled',
'option_use_custom_scrollbar_system',
Expand Down Expand Up @@ -87,16 +87,16 @@ Promise.all([
? this.background_image
: DEFAULT_WALLPAPER_URL;

local_storage['background_image'] = this.background_image;
sync_storage['background_image'] = this.background_image;
local_storage['columns_count'] = parseInt(this.columns_count);
local_storage['use_custom_scrollbar'] = this.use_custom_scrollbar == 1;
local_storage['display_click_counter'] = this.display_click_counter == 1;
local_storage['user_select'] = this.user_select == 1;
sync_storage['display_click_counter'] = this.display_click_counter == 1;
sync_storage['user_select'] = this.user_select == 1;
local_storage['font_size'] = parseInt(this.font_size);
local_storage['bookmarks_in_new_tab'] = this.bookmarks_in_new_tab == 1;
sync_storage['bookmarks_in_new_tab'] = this.bookmarks_in_new_tab == 1;
local_storage['top_sites'] = this.top_sites == 1;
local_storage['recently_closed'] = this.recently_closed == 1;
local_storage['background_brightness'] = parseFloat(this.background_brightness);
sync_storage['background_brightness'] = parseFloat(this.background_brightness);

browser.storage.local.set(local_storage);
},
Expand Down

0 comments on commit 075769a

Please sign in to comment.