From ee54db4e0110266ec9cb24f3e4ae0898a609a433 Mon Sep 17 00:00:00 2001 From: Hedgehog Date: Mon, 7 Apr 2014 06:45:53 +0400 Subject: [PATCH] Options fix --- js/options.js | 13 ++++++++----- js/twister_formatpost.js | 10 +++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/js/options.js b/js/options.js index 37778f0..46c8365 100644 --- a/js/options.js +++ b/js/options.js @@ -104,18 +104,21 @@ function setTheme() { } function setShowPreviewOpt(){ + if(!localStorage['imagesPreview']) localStorage['imagesPreview'] = 'enable'; + if(!localStorage['imagesPreviewGif']) localStorage['imagesPreviewGif'] = 'true'; + if(!localStorage['youtubePreview']) localStorage['youtubePreview'] = 'enable'; + if(!localStorage['vimeoPreview']) localStorage['vimeoPreview'] = 'enable'; + $('.previewOpt').each(function() { - this.value = localStorage[this.id] || 'enable'; + this.value = localStorage[this.id]; }) - $('input[type="checkbox"]').prop('checked', localStorage['imagesPreviewGif'] == 'true') + $('.gifCheckBox').prop('checked', localStorage['imagesPreviewGif'] === 'true') if(localStorage['imagesPreview'] == 'disable'){ - $('input[type="checkbox"]').prop('disabled', true) + $('input[type="checkbox"]').prop('disabled', localStorage['imagesPreviewGif']) } - if(!localStorage['imagesPreview']) localStorage['imagesPreview'] = "enable"; - $('.previewOpt').on('change', function(){ localStorage[this.id] = $(this).val(); if (this.id === 'imagesPreview'){ diff --git a/js/twister_formatpost.js b/js/twister_formatpost.js index 21a2c96..732cea8 100644 --- a/js/twister_formatpost.js +++ b/js/twister_formatpost.js @@ -107,7 +107,7 @@ function postToElem( post, kind ) { var ytRegExp = /(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?/i; var vimeoRegExp = /http:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/i; - if (postLink && localStorage['imagesPreview'] == 'enable' && (/(\.jpg)|(\.gif)|(\.png)|(\.jpeg)|(\.jpe)/i.test(postLink) || /https:\/\/img.bi/gi.test(postLink))){ + if (postLink && localStorage['imagesPreview'] == 'enable' && (/(\.jpg)|(\.gif)|(\.png)|(\.jpeg)|(\.jpe)/i.test(postLink) || /https:\/\/img.bi/i.test(postLink))){ previewContainer.show(); previewContainer.append(imagePreview(postLink)); }else if(postLink && ytRegExp.test(postLink) && localStorage['youtubePreview'] === 'enable'){ @@ -310,13 +310,13 @@ function escapeHtmlEntities(str) { function imagePreview(link) { var linkAnon = 'https://ssl-proxy.my-addr.org/myaddrproxy.php/http/'; - if (link && /https:\/\/img.bi/gi.test(link)){ - return ""; - imgBiJS(); + if (link && /https:\/\/img.bi/i.test(link)){ + return ''; + //imgBiJS(); }else{ var cleanLink = link.replace(/^http[s]?:\/\//i, ''); if(/\.gif\b/i.test(cleanLink) && localStorage['imagesPreviewGif'] == 'false') return; - return ""; + return ''; } }