From: ArthurHoaro Date: Wed, 31 May 2017 15:44:19 +0000 (+0200) Subject: Merge pull request #884 from ArthurHoaro/hotfix/bookmarklet-url-limit X-Git-Tag: v0.9.1~1^2~25 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=268309df5d8110f516940be06e9481d66f3fb5d6;hp=96b12e55f07e75aff6645d2acdab070e765df2f4;p=github%2Fshaarli%2FShaarli.git Merge pull request #884 from ArthurHoaro/hotfix/bookmarklet-url-limit Selection is now limited to 2k characters using bookmarklets --- diff --git a/tpl/default/tools.html b/tpl/default/tools.html index 6951ad28..35173d17 100644 --- a/tpl/default/tools.html +++ b/tpl/default/tools.html @@ -72,10 +72,15 @@ function(){ var%20url%20=%20location.href; 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( '{$pageabsaddr}?post='%20+%20encodeURIComponent(url)+ '&title='%20+%20encodeURIComponent(title)+ - '&description='%20+%20encodeURIComponent(document.getSelection())+ + '&description='%20+%20encodeURIComponent(desc)+ '&source=bookmarklet','_blank','menubar=no,height=800,width=600,toolbar=no,scrollbars=yes,status=no,dialog=1' ); } @@ -89,9 +94,14 @@ class="bookmarklet-link" href="javascript:( 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( '{$pageabsaddr}?private=1&post='+ - '&description='%20+%20encodeURIComponent(document.getSelection())+ + '&description='%20+%20encodeURIComponent(desc)+ '&source=bookmarklet','_blank','menubar=no,height=800,width=600,toolbar=no,scrollbars=yes,status=no,dialog=1' ); }