mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-01-15 01:12:12 +00:00
added proxy option for external links
This commit is contained in:
parent
c00a2a4cf9
commit
dabff232be
@ -343,7 +343,7 @@ var postExpandFunction = function( e, postLi )
|
|||||||
var link = originalPost.find("a[rel='nofollow']");
|
var link = originalPost.find("a[rel='nofollow']");
|
||||||
/*is there any link in the post?*/
|
/*is there any link in the post?*/
|
||||||
if (link.siblings().length > 0){
|
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' />"));
|
$(previewContainer).append($("<img src='" + link.html() + "' class='image-preview' />"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.InitOptions = function() {
|
||||||
this.soundNotifOptions();
|
this.soundNotifOptions();
|
||||||
this.volumeControl();
|
this.volumeControl();
|
||||||
|
@ -195,7 +195,25 @@ function htmlFormatMsg( msg, output, mentions ) {
|
|||||||
url = url.replace('&', '&');
|
url = url.replace('&', '&');
|
||||||
var extLinkTemplate = $("#external-page-link-template").clone(true);
|
var extLinkTemplate = $("#external-page-link-template").clone(true);
|
||||||
extLinkTemplate.removeAttr("id");
|
extLinkTemplate.removeAttr("id");
|
||||||
|
var proxy = false;
|
||||||
|
if ($.Options.getOption('useProxy') === 'disable'){
|
||||||
extLinkTemplate.attr("href",url);
|
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.text(url);
|
||||||
extLinkTemplate.attr("title",url);
|
extLinkTemplate.attr("title",url);
|
||||||
output.append(extLinkTemplate);
|
output.append(extLinkTemplate);
|
||||||
|
13
options.html
13
options.html
@ -137,6 +137,7 @@
|
|||||||
<div class="posts-display">
|
<div class="posts-display">
|
||||||
<div class="module">
|
<div class="module">
|
||||||
<p class="label"> Posts display </p>
|
<p class="label"> Posts display </p>
|
||||||
|
<br/>
|
||||||
<div>
|
<div>
|
||||||
<form action="" id="lineFeedsOpt">
|
<form action="" id="lineFeedsOpt">
|
||||||
<p>Line feeds</p>
|
<p>Line feeds</p>
|
||||||
@ -146,6 +147,7 @@
|
|||||||
</select>
|
</select>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
<br/>
|
||||||
<div>
|
<div>
|
||||||
<form action="" id="showPreviewOpt">
|
<form action="" id="showPreviewOpt">
|
||||||
<p class="label">Inline image preview</p>
|
<p class="label">Inline image preview</p>
|
||||||
@ -155,6 +157,17 @@
|
|||||||
</select>
|
</select>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user