re-enable browser bookmarklets after fixing some naaaaaaaaaaaaaasty bugs with site titles that have special chars in them
This commit is contained in:
parent
28c8cdaf58
commit
7a45f330a7
1 changed files with 40 additions and 20 deletions
|
@ -201,33 +201,34 @@ if (empty($_REQUEST['popup']) && (!isset($showdelete) || !$showdelete)) {
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<h3><?php echo T_('Bookmarklet'); ?></h3>
|
<h3><?php echo T_('Bookmarklet'); ?></h3>
|
||||||
<p>
|
<p id="bookmarklet"></p>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
//<![CDATA[
|
//<![CDATA[
|
||||||
var browser=navigator.appName;
|
var browser = navigator.appName;
|
||||||
if (false && browser == "Opera") {
|
jQuery(function($) {
|
||||||
document.write(
|
if (browser == "Opera") {
|
||||||
|
$('#bookmarklet').append(
|
||||||
<?php echo json_encode(
|
<?php echo json_encode(
|
||||||
sprintf(
|
sprintf(
|
||||||
T_("Click one of the following bookmarklets to add a button you can click whenever you want to add the page you are on to %s"),
|
T_("Click one of the following bookmarklets to add a button you can click whenever you want to add the page you are on to %s") . ':',
|
||||||
$GLOBALS['sitename']
|
$GLOBALS['sitename']
|
||||||
)
|
)
|
||||||
); ?>
|
); ?>
|
||||||
);
|
);
|
||||||
} else if (false) {
|
} else {
|
||||||
document.write(
|
$('#bookmarklet').append(
|
||||||
<?php echo json_encode(
|
<?php echo json_encode(
|
||||||
sprintf(
|
sprintf(
|
||||||
T_("Drag one of the following bookmarklets to your browser's bookmarks and click it whenever you want to add the page you are on to %s"),
|
T_("Drag one of the following bookmarklets to your browser's bookmarks and click it whenever you want to add the page you are on to %s") . ':',
|
||||||
$GLOBALS['sitename']
|
$GLOBALS['sitename']
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
?>
|
?>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
//]]>
|
//]]>
|
||||||
</script>
|
</script>
|
||||||
:</p>
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
//<![CDATA[
|
//<![CDATA[
|
||||||
var selection = '';
|
var selection = '';
|
||||||
|
@ -238,17 +239,36 @@ if (window.getSelection) {
|
||||||
} else if (document.selection) {
|
} else if (document.selection) {
|
||||||
selection = 'document.selection.createRange().text';
|
selection = 'document.selection.createRange().text';
|
||||||
}
|
}
|
||||||
if (false && browser == "Opera")
|
if (browser == "Opera") {
|
||||||
{
|
$('#bookmarklet').append(
|
||||||
document.write('<li><a class="bookmarklet" href="opera:/button/Go%20to%20page,%20%22javascript:x=document;a=encodeURIComponent(x.location.href);t=encodeURIComponent(x.title);d=encodeURIComponent('+selection+');location.href=\'<?php echo createURL('bookmarks', $GLOBALS['user']); ?>?action=add&address=\'+a+\'&title=\'+t+\'&description=\'+d;void 0%22;,,%22Post%20to%20<?php echo jsEscTitle($GLOBALS['sitename']); ?>%22,%22Scuttle%22"><?php echo jsEscTitle(sprintf(T_('Post to %s'), $GLOBALS['sitename'])); ?><\/a><\/li>');
|
'<ul>'
|
||||||
document.write('<li><a class="bookmarklet" href="opera:/button/Go%20to%20page,%20%22javascript:x=document;a=encodeURIComponent(x.location.href);t=encodeURIComponent(x.title);d=encodeURIComponent('+selection+');open(\'<?php echo createURL('bookmarks', $GLOBALS['user']); ?>?action=add&popup=1&address=\'+a+\'&title=\'+t+\'&description=\'+d,\'<?php echo jsEscTitle($GLOBALS['sitename']); ?>\',\'modal=1,status=0,scrollbars=1,toolbar=0,resizable=1,width=790,height=465,left=\'+(screen.width-790)/2+\',top=\'+(screen.height-425)/2);void 0;%22,,%22Post%20to%20<?php echo urlencode($GLOBALS['sitename']); ?>%20(Pop-up)%22,%22Scuttle%22"><?php echo jsEscTitle(sprintf(T_('Post to %s (Pop-up)'), $GLOBALS['sitename'])); ?><\/a><\/li>');
|
+ '<li>'
|
||||||
}
|
+ '<a class="bookmarklet" href="opera:/button/Go%20to%20page,%20%22javascript:x=document;a=encodeURIComponent(x.location.href);t=encodeURIComponent(x.title);d=encodeURIComponent('+selection+');location.href=\'<?php echo createURL('bookmarks', $GLOBALS['user']); ?>?action=add&address=\'+a+\'&title=\'+t+\'&description=\'+d;void 0%22;,,%22Post%20to%20<?php echo htmlspecialchars(jsEscTitle($GLOBALS['sitename'])); ?>%22,%22Scuttle%22"><?php echo jsEscTitle(sprintf(T_('Post to %s'), $GLOBALS['sitename'])); ?></a>'
|
||||||
else if (false)
|
+ '</li>'
|
||||||
{
|
+ '<li>'
|
||||||
document.write('<li><a class="bookmarklet" href="javascript:x=document;a=encodeURIComponent(x.location.href);t=encodeURIComponent(x.title);d=encodeURIComponent('+selection+');location.href=\'<?php echo createURL('bookmarks', $GLOBALS['user']); ?>?action=add&address=\'+a+\'&title=\'+t+\'&description=\'+d;void 0;"><?php echo jsEscTitle(sprintf(T_('Post to %s'), $GLOBALS['sitename'])); ?><\/a><\/li>');
|
+ '<a class="bookmarklet" href="opera:/button/Go%20to%20page,%20%22javascript:x=document;a=encodeURIComponent(x.location.href);t=encodeURIComponent(x.title);d=encodeURIComponent('+selection+');open(\'<?php echo createURL('bookmarks', $GLOBALS['user']); ?>?action=add&popup=1&address=\'+a+\'&title=\'+t+\'&description=\'+d,\'<?php echo htmlspecialchars(jsEscTitle($GLOBALS['sitename'])); ?>\',\'modal=1,status=0,scrollbars=1,toolbar=0,resizable=1,width=790,height=465,left=\'+(screen.width-790)/2+\',top=\'+(screen.height-425)/2);void 0;%22,,%22Post%20to%20<?php echo urlencode($GLOBALS['sitename']); ?>%20(Pop-up)%22,%22Scuttle%22"><?php echo jsEscTitle(sprintf(T_('Post to %s (Pop-up)'), $GLOBALS['sitename'])); ?></a>'
|
||||||
document.write('<li><a class="bookmarklet" href="javascript:x=document;a=encodeURIComponent(x.location.href);t=encodeURIComponent(x.title);d=encodeURIComponent('+selection+');open(\'<?php echo createURL('bookmarks', $GLOBALS['user']); ?>?action=add&popup=1&address=\'+a+\'&title=\'+t+\'&description=\'+d,\'<?php echo jsEscTitle($GLOBALS['sitename']); ?>\',\'modal=1,status=0,scrollbars=1,toolbar=0,resizable=1,width=790,height=465,left=\'+(screen.width-790)/2+\',top=\'+(screen.height-425)/2);void 0;"><?php echo jsEscTitle(sprintf(T_('Post to %s (Pop-up)'), $GLOBALS['sitename'])); ?><\/a><\/li>');
|
+ '</li>'
|
||||||
}
|
+ '</ul>'
|
||||||
//document.write('<\/ul>');
|
);
|
||||||
|
} else {
|
||||||
|
$('#bookmarklet').append(
|
||||||
|
'<ul>'
|
||||||
|
+ '<li><a class="bookmarklet" href="javascript:x=document;a=encodeURIComponent(x.location.href);t=encodeURIComponent(x.title);d=encodeURIComponent('+selection+');location.href=\'<?php echo createURL('bookmarks', $GLOBALS['user']); ?>?action=add&address=\'+a+\'&title=\'+t+\'&description=\'+d;void 0;"><?php echo jsEscTitle(sprintf(T_('Post to %s'), $GLOBALS['sitename'])); ?><\/a><\/li>'
|
||||||
|
+ '<li>'
|
||||||
|
+ '<a class="bookmarklet" href="'
|
||||||
|
+ 'javascript:x=document;'
|
||||||
|
+ 'a=encodeURIComponent(x.location.href);'
|
||||||
|
+ 't=encodeURIComponent(x.title);'
|
||||||
|
+ 'd=encodeURIComponent('+selection+');'
|
||||||
|
+ 'open('
|
||||||
|
+ '\'<?php echo createURL('bookmarks', $GLOBALS['user']); ?>?action=add&popup=1&address=\'+a+\'&title=\'+t+\'&description=\'+d,\'<?php echo htmlspecialchars(jsEscTitle($GLOBALS['sitename'])); ?>\',\'modal=1,status=0,scrollbars=1,toolbar=0,resizable=1,width=790,height=465,left=\'+(screen.width-790)/2+\',top=\'+(screen.height-425)/2'
|
||||||
|
+ ');void 0;">'
|
||||||
|
+ '<?php echo jsEscTitle(sprintf(T_('Post to %s (Pop-up)'), $GLOBALS['sitename'])); ?>'
|
||||||
|
+ '</a>'
|
||||||
|
+ '</li>'
|
||||||
|
+ '</ul>'
|
||||||
|
);
|
||||||
|
}
|
||||||
//]]>
|
//]]>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue