From 57fc31d2b3b5b4e850dc4aed1f0ffa9b18722447 Mon Sep 17 00:00:00 2001 From: Ozbolt Menegatti Date: Sun, 10 Mar 2019 14:04:28 +0100 Subject: [PATCH] Opomba implemented and freq logic moved (xsl -> js) --- main.css | 13 +++++++++++++ main.js | 27 +++++++++++++++++++++++++++ main.xslt | 19 ++++++++++--------- 3 files changed, 50 insertions(+), 9 deletions(-) diff --git a/main.css b/main.css index 55b0470..7aafe17 100644 --- a/main.css +++ b/main.css @@ -2,6 +2,19 @@ font-size: 1em } +#myed-freq-start { + float: right; +} + +#myed-opomba { + float: right; + margin-right: 1em; + padding-left: 0.5em; + padding-right: 0.5em; + background-color: #e9d76d; + cursor: pointer; +} + .myed-prevod-div { display: inline; color: #3366ee; diff --git a/main.js b/main.js index a5473a0..3c1d5e7 100644 --- a/main.js +++ b/main.js @@ -4,6 +4,7 @@ zgledi: null, vecjez: null, xml: null, original: null, +freq_start: null, prevod_locations: [ 'pomen > vecjez', @@ -17,6 +18,7 @@ zgledi_locations: [ ], empty_prevod: '', oznake: ["a", "b", "c", "iztok", "ozbo", "hhhh"], +freq_stars_limits: [0, 552, 5206, 8613, 22561], storeXml: function(xml) { this.xml = xml; @@ -58,6 +60,12 @@ storeXml: function(xml) { } } } + + var opomba = xml.find('glava > opomba'); + if(!opomba.length) { + var zaglavje = xml.find('glava > zaglavje'); + zaglavje.after($('/', xml)); + } }, loadDependencies: function(url) { this.loadJs("https://cdn.jsdelivr.net/npm/sweet-modal@1.3.2/dist/min/jquery.sweet-modal.min.js"); @@ -78,6 +86,14 @@ loadJs: function(url) { newscript.src = url; $('head').append(newscript); }, +render_freq_start: function() { + var element = $("#myed-freq-start"); + var freq = element.attr("freq"); + for(let f_lim of this.freq_stars_limits) { + var cls = (f_lim > freq) ? "s0" : "s1"; + element.append($(`*`)); + } +}, isLast: function(el) { return el.next().hasClass("myed-prevod-add") || el.next().hasClass('myed-prevod-bin'); }, @@ -160,6 +176,7 @@ add: function(el) { var clone = $('
' + to_clone.html() + "
"); clone.attr('tabindex', '1'); clone.attr('prevod_id', this.prevodi.length); + clone.find('.myed-clanek-select').prop("selectedIndex", -1); clone.insertBefore(el); var xml_container = this.vecjez[el.attr('line_num')]; @@ -253,6 +270,15 @@ registerCallbacks: function() { }); }); + root.on('click', '#myed-opomba', function() { + var el = $(this); + $.sweetModal.prompt('Opomba', 'Opomba', el.text(), function(val) { + el.text(val); + self.xml.find('glava > opomba').text(val); + Screenful.Editor.changed(); + }); + }); + // fixing modal stuff $('body').on('keydown', '.sweet-modal-prompt', function(e) { if(e.keyCode == 13) { @@ -346,6 +372,7 @@ editor: function(div, entry, uneditable) { styleTag.appendChild(document.createTextNode(this.css)); document.head.appendChild(styleTag); + this.render_freq_start(); this.clanekOldCode(); this.loadDependencies(); this.registerCallbacks(); diff --git a/main.xslt b/main.xslt index 56d621b..828c2e7 100644 --- a/main.xslt +++ b/main.xslt @@ -11,21 +11,22 @@
+
+ + myed-freq-start + + + + + - - - - - - - - + + -