Browse Source

Options fix

master
Hedgehog 11 years ago
parent
commit
ee54db4e01
  1. 13
      js/options.js
  2. 10
      js/twister_formatpost.js

13
js/options.js

@ -104,18 +104,21 @@ function setTheme() {
} }
function setShowPreviewOpt(){ 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() { $('.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'){ 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(){ $('.previewOpt').on('change', function(){
localStorage[this.id] = $(this).val(); localStorage[this.id] = $(this).val();
if (this.id === 'imagesPreview'){ if (this.id === 'imagesPreview'){

10
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 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; 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.show();
previewContainer.append(imagePreview(postLink)); previewContainer.append(imagePreview(postLink));
}else if(postLink && ytRegExp.test(postLink) && localStorage['youtubePreview'] === 'enable'){ }else if(postLink && ytRegExp.test(postLink) && localStorage['youtubePreview'] === 'enable'){
@ -310,13 +310,13 @@ function escapeHtmlEntities(str) {
function imagePreview(link) { function imagePreview(link) {
var linkAnon = 'https://ssl-proxy.my-addr.org/myaddrproxy.php/http/'; var linkAnon = 'https://ssl-proxy.my-addr.org/myaddrproxy.php/http/';
if (link && /https:\/\/img.bi/gi.test(link)){ if (link && /https:\/\/img.bi/i.test(link)){
return "<img data-imgbi='" + link + "' class='image-preview' />"; return '<img data-imgbi="'+link+'" class="image-preview" />';
imgBiJS(); //imgBiJS();
}else{ }else{
var cleanLink = link.replace(/^http[s]?:\/\//i, ''); var cleanLink = link.replace(/^http[s]?:\/\//i, '');
if(/\.gif\b/i.test(cleanLink) && localStorage['imagesPreviewGif'] == 'false') return; if(/\.gif\b/i.test(cleanLink) && localStorage['imagesPreviewGif'] == 'false') return;
return "<img src='"+linkAnon+cleanLink+"' class='image-preview' />"; return '<img src="'+linkAnon+cleanLink+'" class="image-preview" />';
} }
} }

Loading…
Cancel
Save