Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion css/zerobin.css
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ position:relative;
top:2px;
}

div#expiration, div#rawtextbutton, div#burnafterreadingoption, div#opendisc, div#syntaxcoloringoption {
div#expiration, div#rawtextbutton, div#burnafterreadingoption, div#opendisc, div#syntaxcoloringoption, div#urlshorteneroption {
background-color:#414D5A;
padding:6px 8px;
margin:0px 5px 0px 0px;;
Expand Down
32 changes: 30 additions & 2 deletions js/zerobin.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,26 @@ function send_comment(parentid) {
});
}

/**
* Shorten URL via a webservice
*/
function shortenUrl(url)
{
// replace with your webservice URL
$.get ('/shortapi.php',
{ url: url
/* shortener options */ }
)
.error(function() {
showError('Data could not be sent (webservice error).');
})
.success(function(data) {
var shorten = data;
$('div#shortenlink').html('Short URL is <a id="shorturl" href="' + shorten + '">' + shorten + '</a> <span id="copyhint">(Hit CTRL+C to copy)</span>');
$('div#shortenlink').show();
selectText('shorturl');
});
}

/**
* Send a new paste to server
Expand Down Expand Up @@ -356,17 +376,23 @@ function send_data() {
var deleteUrl = scriptLocation() + "?pasteid=" + data.id + '&deletetoken=' + data.deletetoken;
showStatus('');

$('div#pastelink').html('Your paste is <a id="pasteurl" href="' + url + '">' + url + '</a> <span id="copyhint">(Hit CTRL+C to copy)</span>');
var hint = $('input#urlshortener').is(':checked') ? '' : ' <span id="copyhint">(Hit CTRL+C to copy)</span>';

$('div#pastelink').html('Your paste is <a id="pasteurl" href="' + url + '">' + url + '</a>' + hint);
$('div#deletelink').html('<a href="' + deleteUrl + '">Delete link</a>');
$('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());
urls2links($('div#cleartext'));

// FIXME: Add option to remove syntax highlighting ?
if ($('input#syntaxcoloring').is(':checked')) applySyntaxColoring();

if ($('input#urlshortener').is(':checked'))
shortenUrl(url);
else
selectText('pasteurl'); // We pre-select the link so that the user only has to CTRL+C the link.

showStatus('');
}
else if (data.status==1) {
Expand Down Expand Up @@ -412,6 +438,7 @@ function stateNewPaste() {
$('div#burnafterreadingoption').show();
$('div#opendisc').show();
$('div#syntaxcoloringoption').show();
$('div#urlshorteneroption').show();
$('button#newbutton').show();
$('div#pasteresult').hide();
$('textarea#message').text('');
Expand Down Expand Up @@ -440,6 +467,7 @@ function stateExistingPaste() {
$('div#burnafterreadingoption').hide();
$('div#opendisc').hide();
$('div#syntaxcoloringoption').hide();
$('div#urlshorteneroption').hide();
$('button#newbutton').show();
$('div#pasteresult').hide();
$('textarea#message').hide();
Expand Down
5 changes: 5 additions & 0 deletions tpl/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,15 @@ <h3>{$VERSION}</h3>
<input type="checkbox" id="syntaxcoloring" name="syntaxcoloring" />
<label for="syntaxcoloring">Syntax coloring</label>
</div>
<div id="urlshorteneroption" class="button" style="display:none;">
<input type="checkbox" id="urlshortener" name="urlshortener" />
<label for="urlshortener">Shorten URL</label>
</div>
</div>
<div id="pasteresult" style="display:none;">
<div id="deletelink"></div>
<div id="pastelink"></div>
<div id="shortenlink" style="display:none;"></div>
</div>
<div id="cleartext" style="display:none;"></div>
<textarea id="message" name="message" cols="80" rows="25" style="display:none;"></textarea>
Expand Down