Continue to refactor options.

This commit is contained in:
Alexey Skobkin 2014-11-15 07:14:58 +04:00
parent 6951f07bdd
commit dbd857b9a7

View file

@ -41,78 +41,34 @@ var ppOptions = [
// Saves options to localStorage. // Saves options to localStorage.
function pp_save_options() { function pp_save_options() {
// CTRL+Enter ppOptions = {};
var option_ctrl_enter = document.getElementById('option-ctrl-enter'); ppOptions.option_ctrl_enter = document.getElementById('option-ctrl-enter').checked;
// Fancybox ppOptions.option_fancybox = document.getElementById('option-fancybox').checked;
// ppOptions.option_fancybox_images = document.getElementById('option-fancybox-images').checked;
var option_fancybox = document.getElementById('option-fancybox'); ppOptions.option_fancybox_videos = document.getElementById('option-fancybox-videos').checked;
// Images ppOptions.option_fancybox_posts = document.getElementById('option-fancybox-posts').checked;
var option_fancybox_images = document.getElementById('option-fancybox-images'); ppOptions.option_fluid_layout = document.getElementById('option-layout-fluid').checked;
// Videos ppOptions.option_images_load_original = document.getElementById('option-images-load-original').checked;
var option_fancybox_videos = document.getElementById('option-fancybox-videos'); ppOptions.option_embedding = document.getElementById('option-embedding').checked;
// Posts ppOptions.option_images_load_booru = document.getElementById('option-images-load-booru').checked;
var option_fancybox_posts = document.getElementById('option-fancybox-posts'); ppOptions.option_videos_parse_webm = document.getElementById('option-videos-parse-webm').checked;
// Fluid layout ppOptions.option_visual_editor_post = document.getElementById('option-visual-editor-post').checked;
var option_fluid_layout = document.getElementById('option-layout-fluid'); ppOptions.checkbox_search_with_google = document.getElementById('option-search-with-google').checked;
// Load original images ppOptions.option_ws = document.getElementById('option-ws').checked;
var option_images_load_original = document.getElementById('option-images-load-original'); ppOptions.option_ws_comments = document.getElementById('option-ws-comments').checked;
// Embedding ppOptions.option_ws_comments_color_fadeout = document.getElementById('option-ws-comments-color-fadeout').checked;
var option_embedding = document.getElementById('option-embedding'); ppOptions.option_ws_comments_notifications = document.getElementById('option-ws-comments-notifications').checked;
// Visual editor for posts ppOptions.option_ws_feeds = document.getElementById('option-ws-feeds').checked;
var option_visual_editor_post = document.getElementById('option-visual-editor-post'); ppOptions.option_ws_feeds_subscriptions = document.getElementById('option-ws-feeds-subscriptions').checked;
// Google search ppOptions.option_ws_feeds_blogs = document.getElementById('option-ws-feeds-blogs').checked;
var checkbox_search_with_google = document.getElementById('option-search-with-google'); ppOptions.option_enlarge_font = document.getElementById('option-enlarge-font').checked;
// WebSocket ppOptions.option_enlarge_font_size = document.querySelector('input[name="pp-font-size"]:checked').value;
// ppOptions.option_at_before_username = document.getElementById('option-at-before-username').checked;
var option_ws = document.getElementById('option-ws'); ppOptions.option_other_hightlight_post_comments = document.getElementById('option-other-hightlight-post-comments').checked;
// Comments ppOptions.option_other_show_recommendation_count = document.getElementById('option-other-show-recommendation-count').checked;
var option_ws_comments = document.getElementById('option-ws-comments');
// Fade out highlight comments
var option_ws_comments_color_fadeout = document.getElementById('option-ws-comments-color-fadeout');
// Comments desktop notifications
var option_ws_comments_notifications = document.getElementById('option-ws-comments-notifications');
// Feeds
var option_ws_feeds = document.getElementById('option-ws-feeds');
// Subscriptions
var option_ws_feeds_subscriptions = document.getElementById('option-ws-feeds-subscriptions');
// Blogs
var option_ws_feeds_blogs = document.getElementById('option-ws-feeds-blogs');
// Font size
var option_enlarge_font = document.getElementById('option-enlarge-font');
// Size ratio
var option_enlarge_font_size = document.querySelector('input[name="pp-font-size"]:checked');
// @ before username
var option_at_before_username = document.getElementById('option-at-before-username');
// Saving parameters // Saving parameters
chrome.storage.sync.set({ chrome.storage.sync.set(ppOptions, function() {
'option_ctrl_enter': option_ctrl_enter.checked,
'option_fancybox': option_fancybox.checked,
'option_fancybox_images': option_fancybox_images.checked,
'option_fancybox_videos': option_fancybox_videos.checked,
'option_fancybox_posts': option_fancybox_posts.checked,
'option_fluid_layout': option_fluid_layout.checked,
'option_images_load_original': option_images_load_original.checked,
'option_embedding': option_embedding.checked,
'option_visual_editor_post': option_visual_editor_post.checked,
'option_search_with_google': checkbox_search_with_google.checked,
'option_ws': option_ws.checked,
'option_ws_comments': option_ws_comments.checked,
'option_ws_comments_color_fadeout': option_ws_comments_color_fadeout.checked,
'option_ws_comments_notifications': option_ws_comments_notifications.checked,
'option_ws_feeds': option_ws_feeds.checked,
'option_ws_feeds_subscriptions': option_ws_feeds_subscriptions.checked,
'option_ws_feeds_blogs': option_ws_feeds_blogs.checked,
'option_enlarge_font': option_enlarge_font.checked,
'option_enlarge_font_size': option_enlarge_font_size.value,
'option_at_before_username': option_at_before_username.checked,
'option_images_load_booru' :document.getElementById('option-images-load-booru').checked,
'option_videos_parse_webm' :document.getElementById('option-videos-parse-webm').checked,
'option_other_hightlight_post_comments' :document.getElementById('option-other-hightlight-post-comments').checked,
'option_other_show_recommendation_count':document.getElementById('option-other-show-recommendation-count').checked
}, function() {
// Update status to let user know options were saved. // Update status to let user know options were saved.
var status = document.getElementById('status'); var status = document.getElementById('status');
status.innerHTML = 'Options Saved.'; status.innerHTML = 'Options Saved.';
@ -159,6 +115,14 @@ function pp_restore_options() {
if (options.option_embedding == true) { if (options.option_embedding == true) {
document.getElementById('option-embedding').checked = true; document.getElementById('option-embedding').checked = true;
} }
// Load images from Gelbooru, Danbooru, etc
if (options.option_images_load_booru == true) {
document.getElementById('option-images-load-booru').checked = true;
}
// Wrap WEBM videos into the <video> tag
if (options.option_videos_parse_webm == true) {
document.getElementById('option-videos-parse-webm').checked = true;
}
// Visual editor for posts // Visual editor for posts
if (options.option_visual_editor_post == true) { if (options.option_visual_editor_post == true) {
document.getElementById('option-visual-editor-post').checked = true; document.getElementById('option-visual-editor-post').checked = true;
@ -208,16 +172,11 @@ function pp_restore_options() {
if (options.option_at_before_username == true) { if (options.option_at_before_username == true) {
document.getElementById('option-at-before-username').checked = true; document.getElementById('option-at-before-username').checked = true;
} }
// Highlight posts with new comments
if (options.option_images_load_booru == true) {
document.getElementById('option-images-load-booru').checked = true;
}
if (options.option_videos_parse_webm == true) {
document.getElementById('option-videos-parse-webm').checked = true;
}
if (options.option_other_hightlight_post_comments == true) { if (options.option_other_hightlight_post_comments == true) {
document.getElementById('option-other-hightlight-post-comments').checked = true; document.getElementById('option-other-hightlight-post-comments').checked = true;
} }
// Show recommendations and unique comments count
if (options.option_other_show_recommendation_count == true) { if (options.option_other_show_recommendation_count == true) {
document.getElementById('option-other-show-recommendation-count').checked = true; document.getElementById('option-other-show-recommendation-count').checked = true;
} }