+ function insertOtherText(text) {
+ let tree = $(text);
+ let lang = tree.attr('lang') || 'pl';
+
+ // toc?
+ // themes?
+
+ let cursor = $(".main-text-body #book-text").children().first();
+ // wstawiamy przed kursorem
+ lastTarget = '';
+ tree.children().each((i, e) => {
+ let $e = $(e);
+
+ if ($e.hasClass('anchor')) return;
+ if ($e.hasClass('numeracja')) return;
+ if ($e.attr('id') == 'toc') return;
+ if ($e.attr('id') == 'nota_red') return;
+ if ($e.attr('id') == 'themes') return;
+ if ($e.attr('name') && $e.attr('name').startsWith('sec')) return;
+
+ if ($e.hasClass('target')) {
+ let target = $e.attr('name');
+
+ while (lastTarget != target) {
+ let nc = cursor.next();
+ if (!nc.length) {
+ break;
+ }
+ cursor = nc;
+ lastTarget = cursor.attr('name');
+ }
+
+ while (true) {
+ let nc = cursor.next();
+ if (!nc.length) {
+ break;
+ }
+ cursor = nc;
+ lastTarget = cursor.attr('name');
+ if (lastTarget) break;
+ }
+
+ } else {
+ let d = $('<div class="other">');
+ d.attr('lang', lang);
+ d.append(e);
+ d.insertBefore(cursor);
+ }
+ });
+ }
+