Browse Source

Merge pull request #136 from erqan/use-proxy

Use proxy and preview update
master
miguelfreitas 11 years ago
parent
commit
65f5ae4239
  1. 3
      css/style.css
  2. 17
      js/interface_common.js
  3. 6
      js/interface_localization.js
  4. 34
      js/options.js
  5. 15
      js/twister_formatpost.js
  6. 14
      options.html

3
css/style.css

@ -956,12 +956,15 @@ button.disabled:hover @@ -956,12 +956,15 @@ button.disabled:hover
max-height: 500px;
max-width: 530px;
width: auto;
display: block;
margin: 0 auto;
}
.preview-container
{
max-height: 500px;
width: 100%;
text-align: center;
overflow-y: auto;
}
.post-stats
{

17
js/interface_common.js

@ -342,9 +342,20 @@ var postExpandFunction = function( e, postLi ) @@ -342,9 +342,20 @@ var postExpandFunction = function( e, postLi )
if ($(previewContainer).children().length == 0) {
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())){
$(previewContainer).append($("<img src='" + link.html() + "' class='image-preview' />"));
for (var i=0; i<link.length; i++){
if (/((\.jpe{0,1}g)|(\.gif)|(\.png))$/i.test(link[i].href)){
var url = link[i].href;
if ($.Options.getUseProxyOpt() !== 'disable' && $.Options.getUseProxyForImgOnlyOpt()){
//proxy alternatives may be added to options page...
if ($.Options.getUseProxyOpt() === 'ssl-proxy-my-addr') {
url = 'https://ssl-proxy.my-addr.org/myaddrproxy.php/' +
url.substring(0, url.indexOf(':')) +
url.substr(url.indexOf('/') + 1);
} else if ($.Options.getUseProxyOpt() ==='anonymouse') {
url = 'http://anonymouse.org/cgi-bin/anon-www.cgi/' + url;
}
}
$(previewContainer).append($("<img src='" + url + "' class='image-preview' />"));
}
}
}

6
js/interface_localization.js

@ -204,6 +204,8 @@ if(preferredLanguage == "en"){ @@ -204,6 +204,8 @@ if(preferredLanguage == "en"){
"none": "none",
"Custom": "Custom",
"Mentions": "Mentions",
"Use proxy for image preview only": "Use proxy for image preview only",
"Use external links behind a proxy": "Use external links behind a proxy"
};
}
if(preferredLanguage == "es"){
@ -1806,7 +1808,9 @@ if(preferredLanguage == "tr"){ @@ -1806,7 +1808,9 @@ if(preferredLanguage == "tr"){
"You are not following anyone because you are not logged in.": "Giriş yapmadığınız için kimseyi takip etmiyorsunuz.",
"You don't have any followers because you are not logged in.": "Giriş yapmadığınız için hiç takipçiniz yok.",
"No one can mention you because you are not logged in.": "Giriş yapmadığınız için kimse adınıza mesaj gönderemiyor.",
"You don't have any profile because you are not logged in.": "Giriş yapmadığınız için profiliniz yok."
"You don't have any profile because you are not logged in.": "Giriş yapmadığınız için profiliniz yok.",
"Use proxy for image preview only": "Vekil sunucuyu sadece resim ön izleme için kullan",
"Use external links behind a proxy": "Harici bağlantılar için vekil sunucu kullan"
};
}

34
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.getUseProxyOpt() === '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.checked);
});
}
this.InitOptions = function() {
this.soundNotifOptions();
this.volumeControl();
@ -224,6 +256,8 @@ var TwisterOptions = function() @@ -224,6 +256,8 @@ var TwisterOptions = function()
this.setConvertEmotionsOpt();
this.setConvertSignsOpt();
this.setConvertFractionsOpt();
this.setUseProxyOpt();
this.setUseProxyForImgOnlyOpt();
}
}

15
js/twister_formatpost.js

@ -195,7 +195,20 @@ function htmlFormatMsg( msg, output, mentions ) { @@ -195,7 +195,20 @@ function htmlFormatMsg( msg, output, mentions ) {
url = url.replace('&amp;', '&');
var extLinkTemplate = $("#external-page-link-template").clone(true);
extLinkTemplate.removeAttr("id");
extLinkTemplate.attr("href",url);
if ($.Options.getUseProxyOpt() !== 'disable' && !$.Options.getUseProxyForImgOnlyOpt()){
//proxy alternatives may be added to options page...
if ($.Options.getUseProxyOpt() === 'ssl-proxy-my-addr') {
extLinkTemplate.attr('href', 'https://ssl-proxy.my-addr.org/myaddrproxy.php/' +
url.substring(0, url.indexOf(':')) +
url.substr(url.indexOf('/') + 1));
} else if ($.Options.getUseProxyOpt() ==='anonymouse') {
extLinkTemplate.attr('href', 'http://anonymouse.org/cgi-bin/anon-www.cgi/' + url);
}
} else {
extLinkTemplate.attr("href",url);
}
extLinkTemplate.text(url);
extLinkTemplate.attr("title",url);
output.append(extLinkTemplate);

14
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,18 @@ @@ -155,6 +157,18 @@
</select>
</form>
</div>
<br/>
<div>
<form action="" id="useProxyOpt">
<p class="label">Use external links behind a proxy</p>
<select name="" id="useProxy">
<option value="disable">none</option>
<option value="ssl-proxy-my-addr">ssl-proxy.my-addr.org</option>
<option value="anonymouse">anonymouse.org</option>
</select>
<input name="" id="useProxyForImgOnly" type="checkbox" /> <span class="label">Use proxy for image preview only</span>
</form>
</div>
</div>
</div>

Loading…
Cancel
Save