2016-06-28 13:59:33 +00:00
|
|
|
'use strict';
|
2016-06-28 16:12:02 +00:00
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', event => {
|
|
|
|
document.getElementById('logout').insertAdjacentHTML('beforebegin', `<a href="/admin/settings/">
|
|
|
|
<div class="action">
|
|
|
|
<i class="material-icons">settings</i>
|
|
|
|
</div>
|
|
|
|
</a>`);
|
2016-06-28 21:20:42 +00:00
|
|
|
});
|
|
|
|
|
2016-06-28 16:12:02 +00:00
|
|
|
|
2016-06-28 21:20:42 +00:00
|
|
|
document.addEventListener('listing', event => {
|
|
|
|
document.getElementById('newdir').placeholder = "file[:archetype]...";
|
|
|
|
});
|
|
|
|
|
|
|
|
document.addEventListener('editor', event => {
|
2016-06-28 16:12:02 +00:00
|
|
|
document.getElementById('submit').insertAdjacentHTML('afterend', `<div class="right">
|
2016-06-28 21:20:42 +00:00
|
|
|
<button id="publish">
|
|
|
|
<span>
|
|
|
|
<i class="material-icons">send</i>
|
|
|
|
</span>
|
|
|
|
<span>publish</span>
|
|
|
|
</button>
|
|
|
|
</div>`);
|
2016-06-28 16:12:02 +00:00
|
|
|
|
|
|
|
if (document.getElementById('date') || document.getElementById('publishdate')) {
|
2016-06-28 21:20:42 +00:00
|
|
|
document.querySelector('#editor .right').insertAdjacentHTML('afterbegin', ` <button id="schedule">
|
|
|
|
<span>
|
|
|
|
<i class="material-icons">alarm</i>
|
|
|
|
</span>
|
|
|
|
<span>Schedule</span>
|
|
|
|
</button>`);
|
|
|
|
|
|
|
|
document.getElementById('schedule').addEventListener('click', event => {
|
|
|
|
event.preventDefault();
|
|
|
|
});
|
2016-06-28 16:12:02 +00:00
|
|
|
}
|
|
|
|
|
2016-06-28 21:20:42 +00:00
|
|
|
document.getElementById('publish').addEventListener('click', event => {
|
|
|
|
console.log("Hey")
|
|
|
|
event.preventDefault();
|
2016-06-28 16:12:02 +00:00
|
|
|
|
2016-06-28 21:20:42 +00:00
|
|
|
if (document.getElementById('draft')) {
|
|
|
|
document.getElementById('block-draft').remove();
|
|
|
|
}
|
|
|
|
let container = document.getElementById('editor');
|
|
|
|
let kind = container.dataset.kind;
|
|
|
|
let button = document.querySelector('#publish span:first-child');
|
2016-06-28 16:12:02 +00:00
|
|
|
|
2016-06-28 21:20:42 +00:00
|
|
|
let data = form2js(document.querySelector('form'));
|
|
|
|
let html = button.changeToLoading();
|
|
|
|
let request = new XMLHttpRequest();
|
|
|
|
request.open("PUT", window.location);
|
|
|
|
request.setRequestHeader('Kind', kind);
|
|
|
|
request.setRequestHeader('Regenerate', "true");
|
|
|
|
request.send(JSON.stringify(data));
|
|
|
|
request.onreadystatechange = function() {
|
|
|
|
if (request.readyState == 4) {
|
|
|
|
button.changeToDone((request.status != 200), html);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2016-06-28 16:12:02 +00:00
|
|
|
});
|