Merge pull request #884 from ArthurHoaro/hotfix/bookmarklet-url-limit

Selection is now limited to 2k characters using bookmarklets
This commit is contained in:
ArthurHoaro 2017-05-31 17:44:19 +02:00 committed by GitHub
commit 268309df5d

View file

@ -72,10 +72,15 @@ <h2 class="window-title">Bookmarklets</h2>
function(){ function(){
var%20url%20=%20location.href; var%20url%20=%20location.href;
var%20title%20=%20document.title%20||%20url; var%20title%20=%20document.title%20||%20url;
var%20desc=document.getSelection().toString();
if(desc.length>4000){
desc=desc.substr(0,4000)+'...';
alert('{function="str_replace(' ', '%20', t('The selected text is too long, it will be truncated.'))"}');
}
window.open( window.open(
'{$pageabsaddr}?post='%20+%20encodeURIComponent(url)+ '{$pageabsaddr}?post='%20+%20encodeURIComponent(url)+
'&amp;title='%20+%20encodeURIComponent(title)+ '&amp;title='%20+%20encodeURIComponent(title)+
'&amp;description='%20+%20encodeURIComponent(document.getSelection())+ '&amp;description='%20+%20encodeURIComponent(desc)+
'&amp;source=bookmarklet','_blank','menubar=no,height=800,width=600,toolbar=no,scrollbars=yes,status=no,dialog=1' '&amp;source=bookmarklet','_blank','menubar=no,height=800,width=600,toolbar=no,scrollbars=yes,status=no,dialog=1'
); );
} }
@ -89,9 +94,14 @@ <h2 class="window-title">Bookmarklets</h2>
class="bookmarklet-link" class="bookmarklet-link"
href="javascript:( href="javascript:(
function(){ function(){
var%20desc=document.getSelection().toString();
if(desc.length>4000){
desc=desc.substr(0,4000)+'...';
alert("{function="str_replace(' ', '%20', t('The selected text is too long, it will be truncated.'))"}");
}
window.open( window.open(
'{$pageabsaddr}?private=1&amp;post='+ '{$pageabsaddr}?private=1&amp;post='+
'&amp;description='%20+%20encodeURIComponent(document.getSelection())+ '&amp;description='%20+%20encodeURIComponent(desc)+
'&amp;source=bookmarklet','_blank','menubar=no,height=800,width=600,toolbar=no,scrollbars=yes,status=no,dialog=1' '&amp;source=bookmarklet','_blank','menubar=no,height=800,width=600,toolbar=no,scrollbars=yes,status=no,dialog=1'
); );
} }