mirror of
https://github.com/writeas/writefreely
synced 2025-01-02 19:19:32 +01:00
Fix broken links in drafts loaded with "load more" by dynamically creating edit link based on single_user bool in config.ini
This commit is contained in:
parent
71033ecc3d
commit
4f3bacb182
@ -188,7 +188,7 @@ var movePostHTML = function(postID) {
|
||||
}
|
||||
return $tmpl.innerHTML.replace(/POST_ID/g, postID);
|
||||
}
|
||||
var createPostEl = function(post, owned) {
|
||||
var createPostEl = function(post, owned, singleUser) {
|
||||
var $post = document.createElement('div');
|
||||
let p = H.createPost(post.id, "", post.body)
|
||||
var title = (post.title || p.title || post.id);
|
||||
@ -202,7 +202,7 @@ var createPostEl = function(post, owned) {
|
||||
posted = getFormattedDate(new Date(post.created))
|
||||
}
|
||||
var hasDraft = H.exists('draft' + post.id);
|
||||
$post.innerHTML += '<h4><date>' + posted + '</date> <a class="action" href="/pad/' + post.id + '">edit' + (hasDraft ? 'ed' : '') + '</a> <a class="delete action" href="/' + post.id + '" onclick="delPost(event, \'' + post.id + '\'' + (owned === true ? ', true' : '') + ')">delete</a> '+movePostHTML(post.id)+'</h4>';
|
||||
$post.innerHTML += '<h4><date>' + posted + '</date> <a class="action" href="' + (singleUser ? '/d/' : '/') + post.id + '/edit">edit' + (hasDraft ? 'ed' : '') + '</a> <a class="delete action" href="/' + post.id + '" onclick="delPost(event, \'' + post.id + '\'' + (owned === true ? ', true' : '') + ')">delete</a> '+movePostHTML(post.id)+'</h4>';
|
||||
|
||||
if (post.error) {
|
||||
$post.innerHTML += '<p class="error"><strong>Sync error:</strong> ' + post.error + ' <nav><a href="#" onclick="localPosts.dismissError(event, this)">dismiss</a> <a href="#" onclick="localPosts.deletePost(event, this, \''+post.id+'\')">remove post</a></nav></p>';
|
||||
|
@ -202,8 +202,9 @@ function loadMorePosts() {
|
||||
if (http.readyState == 4) {
|
||||
if (http.status == 200) {
|
||||
var data = JSON.parse(http.responseText);
|
||||
var singleUser = {{ .SingleUser }};
|
||||
for (var i=0; i<data.data.length; i++) {
|
||||
$posts.el.appendChild(createPostEl(data.data[i], true));
|
||||
$posts.el.appendChild(createPostEl(data.data[i], true, singleUser));
|
||||
}
|
||||
if (data.data.length < 10) {
|
||||
$loadMore.el.parentNode.removeChild($loadMore.el);
|
||||
|
Loading…
Reference in New Issue
Block a user