Auto-select paste URL
When creating a paste, we auto-select the resulting URL so that the user only has to press CTRL+C to copy the link. So you basically click "SEND" then press CTRL+C. (cherry picked from commit 3feb4641c7892eeeaff2fe61c6e153919687b9c6) Conflicts: css/zerobin.css
This commit is contained in:
parent
134d22c958
commit
315c45ed0c
|
@ -111,12 +111,14 @@ h3 {
|
||||||
|
|
||||||
#pasteresult a { color: #fff; }
|
#pasteresult a { color: #fff; }
|
||||||
|
|
||||||
#pasteresult button { margin-left: 11px }
|
#pasteresult button { margin-left: 11px; }
|
||||||
|
|
||||||
#deletelink { float: right; }
|
#deletelink { float: right; }
|
||||||
|
|
||||||
#toolbar, #status { margin-bottom: 5px; }
|
#toolbar, #status { margin-bottom: 5px; }
|
||||||
|
|
||||||
|
#copyhint { color: #666; font-size: 0.85em; }
|
||||||
|
|
||||||
button, .button, #expiration, #language {
|
button, .button, #expiration, #language {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
background-color: #323b47;
|
background-color: #323b47;
|
||||||
|
|
|
@ -118,6 +118,7 @@ function decompress(data) {
|
||||||
function zeroCipher(key, message) {
|
function zeroCipher(key, message) {
|
||||||
return sjcl.encrypt(key,compress(message));
|
return sjcl.encrypt(key,compress(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decrypt message with key, then decompress.
|
* Decrypt message with key, then decompress.
|
||||||
*
|
*
|
||||||
|
@ -331,9 +332,10 @@ function send_data() {
|
||||||
var deleteUrl = scriptLocation() + "?pasteid=" + data.id + '&deletetoken=' + data.deletetoken;
|
var deleteUrl = scriptLocation() + "?pasteid=" + data.id + '&deletetoken=' + data.deletetoken;
|
||||||
showStatus('');
|
showStatus('');
|
||||||
|
|
||||||
$('div#pastelink').html('Your paste is <a href="' + url + '">' + url + '</a>');
|
$('div#pastelink').html('Your paste is <a id="pasteurl" href="' + url + '">' + url + '</a> <span id="copyhint">(Hit CTRL+C to copy)</span>');
|
||||||
$('div#deletelink').html('<a href="' + deleteUrl + '">Delete link</a>');
|
$('div#deletelink').html('<a href="' + deleteUrl + '">Delete link</a>');
|
||||||
$('div#pasteresult').show();
|
$('div#pasteresult').show();
|
||||||
|
selectText('pasteurl'); // We pre-select the link so that the user only has to CTRL+C the link.
|
||||||
|
|
||||||
setElementText($('div#cleartext'), $('textarea#message').val());
|
setElementText($('div#cleartext'), $('textarea#message').val());
|
||||||
setElementText($('pre#prettyprint'), $('textarea#message').val());
|
setElementText($('pre#prettyprint'), $('textarea#message').val());
|
||||||
|
@ -350,6 +352,28 @@ function send_data() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Text range selection.
|
||||||
|
* From: http://stackoverflow.com/questions/985272/jquery-selecting-text-in-an-element-akin-to-highlighting-with-your-mouse
|
||||||
|
* @param string element : Indentifier of the element to select (id="").
|
||||||
|
*/
|
||||||
|
function selectText(element) {
|
||||||
|
var doc = document
|
||||||
|
, text = doc.getElementById(element)
|
||||||
|
, range, selection
|
||||||
|
;
|
||||||
|
if (doc.body.createTextRange) { //ms
|
||||||
|
range = doc.body.createTextRange();
|
||||||
|
range.moveToElementText(text);
|
||||||
|
range.select();
|
||||||
|
} else if (window.getSelection) { //all others
|
||||||
|
selection = window.getSelection();
|
||||||
|
range = doc.createRange();
|
||||||
|
range.selectNodeContents(text);
|
||||||
|
selection.removeAllRanges();
|
||||||
|
selection.addRange(range);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Put the screen in "New paste" mode.
|
* Put the screen in "New paste" mode.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue