mirror of https://github.com/kianby/blog
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.
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
// --------------------------------------------------------------------------
|
|
// Common functions
|
|
// --------------------------------------------------------------------------
|
|
|
|
function show_hide(panel_id, button_id){
|
|
if (document.getElementById(panel_id).style.display == 'none'){
|
|
document.getElementById(panel_id).style.display = '';
|
|
document.getElementById(button_id).style.display = 'none';
|
|
} else {
|
|
document.getElementById(panel_id).style.display = 'none';
|
|
}
|
|
}
|
|
|
|
// --------------------------------------------------------------------------
|
|
// Markdown preview
|
|
// --------------------------------------------------------------------------
|
|
|
|
function preview_markdown() {
|
|
if (document.getElementById('preview-container').style.display == 'none'){
|
|
document.getElementById('preview-container').style.display = '';
|
|
}
|
|
var $ = function (id) { return document.getElementById(id); };
|
|
new Editor($("message"), $("preview"));
|
|
}
|
|
|
|
function Editor(input, preview) {
|
|
this.update = function () {
|
|
preview.innerHTML = markdown.toHTML(input.value);
|
|
};
|
|
input.editor = this;
|
|
this.update();
|
|
}
|