Store selected highlighter in the URL

pull/1/head
Joe Biellik 9 years ago
parent df7bda0d6e
commit 55c572c9a9

@ -0,0 +1,35 @@
$(document).ready(function() {
autosize($('textarea'));
$('textarea').keydown(function(e) {
if ((e.keyCode == 10 || e.keyCode == 13) && e.ctrlKey) {
$(this).closest('form').submit();
}
});
$('pre').click(function() {
var range = document.createRange();
range.setStart(this.firstChild, 19);
range.setEnd(this.firstChild, this.firstChild.textContent.length);
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
});
$('select#highlight').change(function(e) {
location.hash = $(this).val();
});
$(window).on('hashchange', function() {
var value = location.hash.slice(1);
if ($('select#highlight option[value=' + value + ']').length) {
$('select#highlight').val(value);
} else {
$('select#highlight').val('');
}
});
$(window).trigger('hashchange');
});

@ -1,7 +1,7 @@
extends layout
block head
link(rel='stylesheet', href='http://fonts.googleapis.com/css?family=Open+Sans:400,300')
link(rel='stylesheet', href='https://fonts.googleapis.com/css?family=Open+Sans:400,300')
link(rel='stylesheet', href='https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha/css/bootstrap.min.css')
style.
html {
@ -34,12 +34,12 @@ block content
fieldset.form-group
textarea.form-control(name='paste', rows='5', required, autofocus)
select.c-select.select-lg.m-t-md.m-r-md(name='highlight')
select#highlight.c-select.select-lg.m-t-md.m-r-md(name='highlight')
option(value='', selected) Choose syntax highlighting
each val, key in highlights
option(value='#{key}') #{val}
select.c-select.select-lg.m-t-md(name='expire')
select#expire.c-select.select-lg.m-t-md(name='expire')
option(value='', selected) Choose expiry
each val, key in expires
option(value='#{key}') #{val}
@ -47,20 +47,9 @@ block content
button.btn.btn-primary.btn-lg.m-t-md.m-l-md.pull-right(type='submit') Upload
footer.hidden-sm-down
pre.text-center.text-muted.m-b-0(onclick='selectCommand(this);').
pre.text-center.text-muted.m-b-0.
echo 'Hello World' | curl -F 'paste=<-' #{url}
script(src='https://cdnjs.cloudflare.com/ajax/libs/autosize.js/3.0.13/autosize.min.js')
script.
autosize(document.querySelector('textarea'));
function selectCommand(el) {
var range = document.createRange();
range.setStart(el.firstChild, 19);
range.setEnd(el.firstChild, el.firstChild.textContent.length);
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
return false;
}
script(src='https://cdnjs.cloudflare.com/ajax/libs/autosize.js/3.0.13/autosize.min.js')
script(src='https://code.jquery.com/jquery-2.1.4.min.js')
script(src='/main.js')

Loading…
Cancel
Save