Browse Source

added proxy option for external links

master
erqan 11 years ago
parent
commit
dabff232be
  1. 2
      js/interface_common.js
  2. 32
      js/options.js
  3. 20
      js/twister_formatpost.js
  4. 13
      options.html

2
js/interface_common.js

@ -343,7 +343,7 @@ var postExpandFunction = function( e, postLi ) @@ -343,7 +343,7 @@ var postExpandFunction = function( e, postLi )
var link = originalPost.find("a[rel='nofollow']");
/*is there any link in the post?*/
if (link.siblings().length > 0){
if (/(\.jpg)|(\.gif)|(\.png)|(\.jpeg)/.test(link.html().toLowerCase())){
if (/((\.jpe{0,1}g)|(\.gif)|(\.png))$/i.test(link.html())){
$(previewContainer).append($("<img src='" + link.html() + "' class='image-preview' />"));
}
}

32
js/options.js

@ -211,6 +211,38 @@ var TwisterOptions = function() @@ -211,6 +211,38 @@ var TwisterOptions = function()
});
}
this.getUseProxyOpt = function () {
return $.Options.getOption('useProxy', 'disable');
}
this.setUseProxyOpt = function () {
$('#useProxy')[0].value = this.getUseProxyOpt();
if (this.getProxyOpt() === 'disable')
$('#useProxyForImgOnly').attr('disabled','disabled');
$('#useProxy').on('change', function () {
$.Options.setOption(this.id, this.value);
if (this.value === 'disable')
$('#useProxyForImgOnly').attr('disabled','disabled');
else
$('#useProxyForImgOnly').removeAttr('disabled');
});
}
this.getUseProxyForImgOnlyOpt = function () {
return $.Options.getOption('useProxyForImgOnly', false);
}
this.setUseProxyForImgOnlyOpt = function () {
$('#useProxyForImgOnly')[0].checked = this.getUseProxyForImgOnlyOpt();
$('useProxyForImgOnly').on('change', function () {
$.Options.setOption(this.id, this.value);
});
}
this.InitOptions = function() {
this.soundNotifOptions();
this.volumeControl();

20
js/twister_formatpost.js

@ -195,7 +195,25 @@ function htmlFormatMsg( msg, output, mentions ) { @@ -195,7 +195,25 @@ function htmlFormatMsg( msg, output, mentions ) {
url = url.replace('&amp;', '&');
var extLinkTemplate = $("#external-page-link-template").clone(true);
extLinkTemplate.removeAttr("id");
extLinkTemplate.attr("href",url);
var proxy = false;
if ($.Options.getOption('useProxy') === 'disable'){
extLinkTemplate.attr("href",url);
} else if ($.Options.getOption('useProxyForImgOnly')){
if ($.Options.getOption('displayPreview') !== 'disable' && /((\.jpe{0,1}g)|(\.gif)|(\.png))$/i.test(url))
proxy = true;
} else {
proxy = true;
}
if (proxy){
//proxy alternatives may be added to options page...
if ($.Options.getOption('useProxy') === 'ssl-proxy-my-addr') {
extLinkTemplate.attr('href', 'https://ssl-proxy.my-addr.com/' +
url.substring(0, url.indexOf(':')) +
url.substr(url.indexOf('/') + 1));
}
}
extLinkTemplate.text(url);
extLinkTemplate.attr("title",url);
output.append(extLinkTemplate);

13
options.html

@ -137,6 +137,7 @@ @@ -137,6 +137,7 @@
<div class="posts-display">
<div class="module">
<p class="label"> Posts display </p>
<br/>
<div>
<form action="" id="lineFeedsOpt">
<p>Line feeds</p>
@ -146,6 +147,7 @@ @@ -146,6 +147,7 @@
</select>
</form>
</div>
<br/>
<div>
<form action="" id="showPreviewOpt">
<p class="label">Inline image preview</p>
@ -155,6 +157,17 @@ @@ -155,6 +157,17 @@
</select>
</form>
</div>
<br/>
<div>
<form action="" id="useProxyOpt">
<p class="label">Use links behind a proxy</p>
<select name="" id="useProxy">
<option value="disable">none</option>
<option value="ssl-proxy-my-addr">ssl-proxy.my-addr.com</option>
</select>
<input name="" id="useProxyForImgOnly" type="checkbox" /> Use proxy for image preview only
</form>
</div>
</div>
</div>

Loading…
Cancel
Save