2011-05-16 20:26:21 +04:00
|
|
|
$(function() {
|
2013-02-17 04:27:39 +04:00
|
|
|
var isEdited = false;
|
|
|
|
|
2020-08-10 16:32:13 +03:00
|
|
|
let convert = () => {
|
|
|
|
let html = marked($('#markdown').val());
|
2020-08-14 15:56:03 +03:00
|
|
|
let sanitized = DOMPurify.sanitize(html);
|
|
|
|
$('#output').html(sanitized);
|
2020-08-10 16:32:13 +03:00
|
|
|
}
|
|
|
|
|
2013-02-17 04:27:39 +04:00
|
|
|
$('#markdown').bind('keyup', function() {
|
|
|
|
isEdited = true;
|
2020-08-10 16:32:13 +03:00
|
|
|
convert();
|
2019-02-16 17:50:49 +03:00
|
|
|
$('#output a').each(function(index, element) {
|
|
|
|
var href = element.getAttribute('href');
|
|
|
|
if (RegExp('^javascript', 'i').test(href)) {
|
|
|
|
element.setAttribute('href', '#');
|
|
|
|
}
|
|
|
|
});
|
2013-02-17 04:27:39 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
//autoresize
|
|
|
|
$('textarea').autosize();
|
2013-02-17 09:43:20 +04:00
|
|
|
|
2013-02-17 04:27:39 +04:00
|
|
|
//leave
|
|
|
|
$(window).bind('beforeunload', function() {
|
|
|
|
if (isEdited) {
|
|
|
|
return 'Are you sure you want to leave? Your changes will be lost.';
|
|
|
|
}
|
|
|
|
});
|
2020-07-17 19:31:22 +03:00
|
|
|
|
2020-08-10 16:32:13 +03:00
|
|
|
convert();
|
2020-08-14 16:35:54 +03:00
|
|
|
});
|