You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
paste/public/main.js

39 lines
902 B
JavaScript

/* eslint-env browser */
/* global $ autosize */
$(document).ready(function() {
autosize($('textarea'));
$('textarea').keydown(function(e) {
if ((e.keyCode == 10 || e.keyCode == 13) && e.ctrlKey && $(this).val()) {
$(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() {
location.hash = $(this).val();
});
$(window).on('hashchange', function() {
var value = location.hash.slice(1);
8 years ago
if (value && $('select#highlight option[value=' + value + ']').length) {
$('select#highlight').val(value);
} else {
$('select#highlight').val('');
}
});
$(window).trigger('hashchange');
});