-
Notifications
You must be signed in to change notification settings - Fork 0
/
newArticle.js
30 lines (27 loc) · 961 Bytes
/
newArticle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
(function() {
const newArticle = {};
newArticle.initNewArticlePage = function() {
$('.tab-content').show();
$('#export-field').hide();
$('#article-json').on('focus', function() {
$(this).select();
});
$('#new-form').on('change', newArticle.create);
};
newArticle.create = function() {
$('#articles').empty();
let formArticle = new Article({
title: $('#article-title').val(),
author: $('#article-author').val(),
authorUrl: $('#article-author-url').val(),
category: $('#article-category').val(),
body: $('#article-body').val(),
publishedOn: $('#article-published:checked').length ? new Date() : null
});
$('#articles').append(formArticle.toHtml('#article-template'));
$('pre code').each((i, block) => hljs.highlightBlock(block));
$('#export-field').show();
$('#article-json').val(JSON.stringify(formArticle) + ',');
};
newArticle.initNewArticlePage();
})();