});
});
+ // copy first paragraph to story
+ let wptext = json.parse.text['*'];
+ let storyinput = document.getElementById('story');
+ if (storyinput && wptext) {
+ storyinput.innerHTML = wptext
+ .replace(/<h2.*/s, '') // prefix
+ .replace(/<table.*?<\/table>/sg, '') // ignore infobox
+ .match(/<p>(.*?)<\/p>/s)[0] // first paragraph
+ .replace(/<[^>]*>/g, '') // strip html tags
+ }
+
// list images in article html
let imginput = document.getElementById('source');
if (!imginput || imginput.value) return;
- let wpimages = json.parse.text['*'].match(/<img\s[^>]+>/g);
+ let wpimages = wptext.match(/<img\s[^>]+>/g);
let wpselect = wpinput.parentNode.appendChild(document.createElement('ul'));
wpselect.className = 'popup';
wpimages.forEach(img => {