Merge pull request #329 from nephila/feature/liveblog_fixes
Fix JS to replace liveblog plugin
This commit is contained in:
commit
d0e384c8ff
1 changed files with 4 additions and 4 deletions
|
@ -9,11 +9,11 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||||
var data = JSON.parse(message.data);
|
var data = JSON.parse(message.data);
|
||||||
// See if there's a div to replace it in, or if we should add a new one
|
// See if there's a div to replace it in, or if we should add a new one
|
||||||
var existing = document.querySelectorAll("div[data-post-id*='" + data.id + "']");
|
var existing = document.querySelectorAll("div[data-post-id*='" + data.id + "']");
|
||||||
if (existing.length) {
|
|
||||||
existing.parentNode.replaceChild(data.content, existing);
|
|
||||||
} else {
|
|
||||||
var item = document.createElement('div');
|
var item = document.createElement('div');
|
||||||
item.innerHTML = data.content;
|
item.innerHTML = data.content;
|
||||||
|
if (existing.length > 0) {
|
||||||
|
existing[0].parentNode.replaceChild(item.children[0], existing[0]);
|
||||||
|
} else {
|
||||||
document.getElementById("liveblog-posts").insertBefore(
|
document.getElementById("liveblog-posts").insertBefore(
|
||||||
item.children[0], document.getElementById("liveblog-posts").children[0]
|
item.children[0], document.getElementById("liveblog-posts").children[0]
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue