word/edit: prefer binomial name as latin translation
authorMischa POSLAWSKY <perl@shiar.org>
Sun, 15 Aug 2021 02:39:18 +0000 (04:39 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Wed, 25 Aug 2021 04:53:32 +0000 (06:53 +0200)
writer.js

index 6fc79ebcc19c8af97bd9e56164ff00154f0f49ee..e9b86fe01ab1e038364c17f79db774a891f6a210 100644 (file)
--- a/writer.js
+++ b/writer.js
@@ -27,6 +27,13 @@ document.addEventListener('DOMContentLoaded', () => {
                                if (json.error) throw `error returned: ${json.error.info}`;
                                wpinput.value = json.parse.title;
 
+                               let wptext = json.parse.text['*'];
+                               let transrow = document.getElementById('trans-la');
+                               if (transrow && !transrow.value && wptext) {
+                                       transrow.value = wptext
+                                               .match(/ class="binomial">.*?<i>(.*?)<\/i>/)[1];
+                               }
+
                                // translations from language links
                                let wplangs = json.parse.langlinks;
                                if (wplangs) wplangs.forEach(wptrans => {
@@ -38,7 +45,6 @@ document.addEventListener('DOMContentLoaded', () => {
                                });
 
                                // copy first paragraph to story
-                               let wptext = json.parse.text['*'];
                                let storyinput = document.getElementById('story');
                                if (storyinput && !storyinput.value && wptext) {
                                        storyinput.value = wptext