First commit...
This commit is contained in:
commit
2cd300bb7e
38
README.txt
Normal file
38
README.txt
Normal file
|
@ -0,0 +1,38 @@
|
|||
Mal dokumentacije
|
||||
|
||||
Datoteke:
|
||||
|
||||
1) hamburger.png - slikca za hamburger meni
|
||||
2) main.js - javascript koda,
|
||||
3) main.css - stili
|
||||
4) main.xslt - pretvorba xml -> html
|
||||
5) copy.py - neke vrste linker
|
||||
|
||||
Da proizvedemo koncno kodo, pozenemo `python3 copy.py`. Ta potem koncno kodo vrze v "Ctrl-C" (x11 clipboard...), tako da lahko zatem kar prilepimo kodo v lexonomy. Dela na ta nacin, da zamenja "XSLFILE" z vsebino main.xslt, "CSS" z vsebino main.css in "HAMBURGER" z base64 kodirano vsebino hamburger.png datoteke.
|
||||
|
||||
main.xslt je delno popravljen in pociscen xslt iz "view" pogleda, ampak se vedno je kar v bogem stanju. Videti je, da se uporabljajo atributi iz xml-a, ki jih tam sploh ni. Ti atributi se v xml dodajo pred pretvorbo z uporabo javascripta.
|
||||
|
||||
main.css so pac stili, tu spreminjamo barve, fonte ipd. Zal je veliko stilov ostalo tudi v xslt (nisem vse lepo popucal in locil...).
|
||||
|
||||
Potem pa main.js. Tu je veliko stvari in upam, da sem stvari lepo locil, tu je opis bolj vaznih funkcij:
|
||||
|
||||
- prevodi: seznam <prevod> elementov v xml datoteki
|
||||
- zgledi: seznam <zgledi> elementov v xml datoteki
|
||||
- vecjez: seznam <vecjez> elementov v xml datoteki, ki vsebujejo prevode
|
||||
- xml: sama xml datoteka
|
||||
- original: uporabljeno za debugging, se lahko zbrise
|
||||
- prevod_locations: jquery selectorji za mesta, kjer se nahajajo vecjez starsi od prevodov.
|
||||
- zgledi_locations: podobno kot zgoraj, samo za zglede
|
||||
- storeXml: vzame xml datoteko in pobere ven prevode, zglede, doda prevod_id-je, line_num in zgled_id, spremeni informacijo o semicolon. Vse pac kar potrebujemo, da lahko xslt ustvari uporaben html
|
||||
- loadDependencies: nalozi z interneta knjizice, zaenkrat samo sweet-modal
|
||||
- moveLeft, moveRight, cut, move_to_end, bin, change, semicolon: hamburger meni akcije za prevode.
|
||||
- add: akcija za + knof pri prevedkih
|
||||
- action: kontroler za vse akcije v hamburger meniju.
|
||||
- zgledPrevod: funkcija, ki se izvede, ce dodamo nov prevod za zgled
|
||||
- registerCallbacks: z jquerijem registriramo vse klike in tako...
|
||||
- clanekOldCode: definira/registrira akcije zgornjih modrih knofov (to je se del kode iz view)
|
||||
- editor: "min" koda: nalozi xml, ga "popravi", renderira z xsltProcessor() objektom, doda css stile in potem pozene potrebne klice
|
||||
- show_modal: funkcija, ki uporabi sweet-modal za dodajanje prevedkov
|
||||
- harvester: funkcija ki se izvede ob "save" - tu samo postimamo <pp> elemente in vrnemo storeXml
|
||||
- xslt, css: vsebina teh dveh datotek.
|
||||
|
24
copy.py
Normal file
24
copy.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import base64
|
||||
|
||||
def copy(string):
|
||||
import subprocess
|
||||
subprocess.run(["xclip", "-selection", "c"], input=string, encoding='utf8')
|
||||
|
||||
with open("main.js", 'r') as fp:
|
||||
script = fp.read()
|
||||
|
||||
with open("main.xslt", "r") as fp:
|
||||
xslt = fp.read()
|
||||
|
||||
with open("hamburger.png", "rb") as fp:
|
||||
img = fp.read()
|
||||
|
||||
with open("main.css", "r") as fp:
|
||||
css = fp.read()
|
||||
|
||||
script = script.replace("XSLFILE", "`{}`".format(xslt))
|
||||
script = script.replace("CSS", "`{}`".format(css))
|
||||
script = script.replace("HAMBURGER", base64.b64encode(img).decode('ascii'))
|
||||
copy(script)
|
BIN
hamburger.png
Normal file
BIN
hamburger.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1000 B |
119
main.css
Normal file
119
main.css
Normal file
|
@ -0,0 +1,119 @@
|
|||
.myed-root {
|
||||
font-size: 1em
|
||||
}
|
||||
|
||||
.myed-prevod-div {
|
||||
display: inline;
|
||||
color: #3366ee;
|
||||
margin-right: 0.2em;
|
||||
}
|
||||
|
||||
.myed-prevod-cut {
|
||||
background: linear-gradient(
|
||||
rgba(0, 0, 0, 0.3),
|
||||
rgba(0, 0, 0, 0.3)
|
||||
);
|
||||
filter: brightness(0.7);
|
||||
}
|
||||
|
||||
.myed-prevod-bin {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.myed-prevod-add {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 1.5em;
|
||||
height: 1.5em;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.myed-prevod-buttons {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.clanek {
|
||||
font-family: Verdana, sans-serif;
|
||||
font-size: 1rem;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
|
||||
.clanek label {
|
||||
text-decoration: none;
|
||||
background-color: #99ccff;
|
||||
border-radius: 4px;
|
||||
padding: 5px 15px 5px 5px;
|
||||
color: #666666;
|
||||
text-shadow: 1px 1px 0px #ffffff;
|
||||
font-size: .85em;
|
||||
box-shadow: 0px 0px 2px #336699;
|
||||
cursor: pointer;
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
.myed-clanek-select {
|
||||
width: 1.5em;
|
||||
height: 1.5em;
|
||||
|
||||
padding: 0;
|
||||
margin-left: 0.5em;
|
||||
border: 1px solid #ccc;
|
||||
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
background-size: 100%;
|
||||
background-repeat:no-repeat;
|
||||
background-position: center;
|
||||
color: rgba(0,0,0,0);
|
||||
background-image: url(data:image/png;base64,HAMBURGER);
|
||||
}
|
||||
|
||||
.myed-clanek-select option {
|
||||
color: black;
|
||||
}
|
||||
|
||||
.myed-prevod-razlaga {
|
||||
font-style: italic;
|
||||
}
|
||||
.myed-prevod-razlaga:not(:empty):after {
|
||||
content: ")";
|
||||
}
|
||||
.myed-prevod-razlaga:not(:empty):before {
|
||||
margin-left: 0.5em;
|
||||
content: "(";
|
||||
}
|
||||
|
||||
.myed-prevod-semicolon {}
|
||||
.myed-prevod-semicolon-hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.myed-zgled-prevod {
|
||||
color: #666666;
|
||||
margin-left: 0.5em;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.myed-zgled-prevod:before {
|
||||
font-size: 1.15em;
|
||||
margin-right: 1em;
|
||||
content: '↪';
|
||||
}
|
||||
|
||||
.myed-oznaka:not(:empty) {
|
||||
color: #666666;
|
||||
text-transform: uppercase;
|
||||
font-size: 0.85em;
|
||||
margin-right: 0.2em;
|
||||
}
|
||||
|
||||
.clanek label:hover {box-shadow: 0px 0px 4px #666666;}
|
||||
.clanek label:active {box-shadow: 0px 0px 2px #666666;}
|
||||
.clanek label input {position: relative; top: 0.15em;}
|
||||
|
||||
.clanek div.hiddenBlock {display: none;}
|
||||
.clanek div.hiddenExample {display: none;}
|
||||
|
||||
.clanek .s0 {background-color: #eeeeee; padding: 2px 5px; color: #cccccc;}
|
||||
.clanek .s1 {background-color: #eeeeee; padding: 2px 5px; color: #cc3366;}
|
412
main.js
Normal file
412
main.js
Normal file
|
@ -0,0 +1,412 @@
|
|||
{
|
||||
prevodi: null,
|
||||
zgledi: null,
|
||||
vecjez: null,
|
||||
xml: null,
|
||||
original: null,
|
||||
|
||||
prevod_locations: [
|
||||
'pomen > vecjez',
|
||||
'pomen > skladenjske_skupine > skladenjska_struktura > kolokacije > vecjez',
|
||||
'pomen > stalne_zveze > stalna_zveza > vecjez',
|
||||
'frazeoloske_zveze > frazeoloska_enota > vecjez'
|
||||
],
|
||||
zgledi_locations: [
|
||||
'zgledi > vecjez',
|
||||
'zgledi'
|
||||
],
|
||||
empty_prevod: '<prevod><tekst></tekst><vir></vir></prevod>',
|
||||
oznake: ["a", "b", "c", "iztok", "ozbo", "hhhh"],
|
||||
|
||||
storeXml: function(xml) {
|
||||
this.xml = xml;
|
||||
this.prevodi = [];
|
||||
this.vecjez = [];
|
||||
this.zgledi = [];
|
||||
|
||||
for(let fstring of this.prevod_locations) {
|
||||
for(let vecjez of xml.find(fstring)) {
|
||||
for(let pp of $(vecjez).find('pp')) {
|
||||
$(pp).prev().attr('semicolon', 'true');
|
||||
}
|
||||
|
||||
for(let lprevod of $(vecjez).find("prevod")) {
|
||||
var prevod = $(lprevod);
|
||||
if(prevod.text()) {
|
||||
prevod.attr('prevod_id', this.prevodi.length);
|
||||
this.prevodi.push(prevod);
|
||||
}
|
||||
prevod.attr('line_num', this.vecjez.length);
|
||||
prevod.attr('semicolon', prevod.attr('semicolon') || false);
|
||||
}
|
||||
this.vecjez.push($(vecjez));
|
||||
}
|
||||
}
|
||||
|
||||
for(let fstring of this.zgledi_locations) {
|
||||
for(let zgledi of xml.find(fstring)) {
|
||||
for(let lzgled of $(zgledi).find('zgled')) {
|
||||
var zgled = $(lzgled);
|
||||
zgled.attr('jezik', zgled.attr('ime_korpusa') == "hunTenTen12" ? "hun" : "slo");
|
||||
zgled.attr('zgled_id', this.zgledi.length);
|
||||
this.zgledi.push(zgled);
|
||||
}
|
||||
for(let lprevod of $(zgledi).find('prevod')) {
|
||||
if(!$(lprevod).text().trim().length) {
|
||||
$(lprevod).remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
loadDependencies: function(url) {
|
||||
this.loadJs("https://cdn.jsdelivr.net/npm/sweet-modal@1.3.2/dist/min/jquery.sweet-modal.min.js");
|
||||
this.loadCss('https://cdn.jsdelivr.net/npm/sweet-modal@1.3.2/dist/min/jquery.sweet-modal.min.css');
|
||||
},
|
||||
loadCss: function(url) {
|
||||
var link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.type = 'text/css';
|
||||
link.href = url;
|
||||
link.media = 'all';
|
||||
$('head').append(link);
|
||||
},
|
||||
loadJs: function(url) {
|
||||
var newscript = document.createElement('script');
|
||||
newscript.type = 'text/javascript';
|
||||
newscript.async = true;
|
||||
newscript.src = url;
|
||||
$('head').append(newscript);
|
||||
},
|
||||
isLast: function(el) {
|
||||
return el.next().hasClass("myed-prevod-add") || el.next().hasClass('myed-prevod-bin');
|
||||
},
|
||||
isFirst: function(el) {
|
||||
return !el.prev().hasClass('myed-prevod-div') || el.prev().is(':hidden');
|
||||
},
|
||||
moveLeft: function(el) {
|
||||
if(!this.isFirst(el)) {
|
||||
var xml_el = this.prevodi[el.attr('prevod_id')];
|
||||
|
||||
el.prev().before(el);
|
||||
xml_el.prev().before(xml_el);
|
||||
Screenful.Editor.changed();
|
||||
}
|
||||
},
|
||||
moveRight: function(el) {
|
||||
if(el.next().length && !this.isLast(el)) {
|
||||
var xml_el = this.prevodi[el.attr('prevod_id')];
|
||||
|
||||
el.next().after(el);
|
||||
xml_el.next().after(xml_el);
|
||||
Screenful.Editor.changed();
|
||||
}
|
||||
},
|
||||
cut: function(el) {
|
||||
var xml_el = this.prevodi[el.attr('prevod_id')];
|
||||
el.toggleClass('myed-prevod-cut');
|
||||
xml_el.attr('cut', el.hasClass('myed-prevod-cut'));
|
||||
|
||||
// move to end if cutted
|
||||
if(el.hasClass('myed-prevod-cut')) {
|
||||
this.move_to_end(el);
|
||||
}
|
||||
Screenful.Editor.changed();
|
||||
},
|
||||
move_to_end: function(el) {
|
||||
var xml_el = this.prevodi[el.attr('prevod_id')];
|
||||
while(el.next().length && !this.isLast(el)) {
|
||||
el.next().after(el);
|
||||
xml_el.next().after(xml_el);
|
||||
}
|
||||
},
|
||||
bin: function(el) {
|
||||
el.toggleClass('myed-prevod-bin');
|
||||
this.move_to_end(el);
|
||||
this.prevodi[el.attr('prevod_id')].attr('bin', el.hasClass('myed-prevod-bin'));
|
||||
Screenful.Editor.changed();
|
||||
},
|
||||
change: function(el, func_after) {
|
||||
var text_el = el.find('.myed-prevod-text');
|
||||
var razlaga_el = el.find('.myed-prevod-razlaga');
|
||||
var self = this;
|
||||
|
||||
self.show_modal(text_el.text(), razlaga_el.text(), function(status, text, razlaga) {
|
||||
if(status) {
|
||||
text_el.text(text);
|
||||
razlaga_el.text(razlaga);
|
||||
|
||||
var xml_el = self.prevodi[el.attr('prevod_id')];
|
||||
xml_el.find('tekst').text(text);
|
||||
|
||||
if(xml_el.find('rzg').length == 0) {
|
||||
xml_el.append("<rzg />", this.xml);
|
||||
}
|
||||
xml_el.find('rzg').text(razlaga);
|
||||
|
||||
Screenful.Editor.changed();
|
||||
}
|
||||
|
||||
if(func_after) {
|
||||
func_after(status);
|
||||
}
|
||||
el.focus();
|
||||
});
|
||||
},
|
||||
add: function(el) {
|
||||
var self = this;
|
||||
|
||||
var to_clone = $('.myed-prevod-div').first();
|
||||
var clone = $('<div class="myed-prevod-div">' + to_clone.html() + "</div>");
|
||||
clone.attr('tabindex', '1');
|
||||
clone.attr('prevod_id', this.prevodi.length);
|
||||
|
||||
clone.insertBefore(el);
|
||||
var xml_container = this.vecjez[el.attr('line_num')];
|
||||
var new_child = $(this.empty_prevod, this.xml);
|
||||
|
||||
xml_container.append(new_child);
|
||||
this.prevodi.push(new_child);
|
||||
this.change(clone, function(result) { if(!result) { self.bin(clone); }});
|
||||
},
|
||||
semicolon: function(el) {
|
||||
var scel = el.find('.myed-prevod-semicolon');
|
||||
|
||||
scel.toggleClass('myed-prevod-semicolon-hidden');
|
||||
var xml_el = this.prevodi[el.attr('prevod_id')];
|
||||
xml_el.attr('semicolon', !scel.hasClass('myed-prevod-semicolon-hidden'));
|
||||
},
|
||||
action: function(el, action) {
|
||||
if(action == 'left') {
|
||||
this.moveLeft(el);
|
||||
}
|
||||
else if(action == 'right') {
|
||||
this.moveRight(el);
|
||||
}
|
||||
else if(action == "cut") {
|
||||
this.cut(el);
|
||||
}
|
||||
else if(action == "bin") {
|
||||
this.bin(el);
|
||||
}
|
||||
else if(action == "edit") {
|
||||
this.change(el, null);
|
||||
}
|
||||
else if(action == "semicolon") {
|
||||
this.semicolon(el);
|
||||
}
|
||||
},
|
||||
zgledPrevod: function(el, val) {
|
||||
var zgled_id = el.attr('zgled_id');
|
||||
var zgled = this.zgledi[zgled_id];
|
||||
var new_el = $(`<prevod><tekst>${ val }</tekst></prevod>`);
|
||||
|
||||
el.parent().text(val);
|
||||
el.remove();
|
||||
|
||||
zgled.after(new_el);
|
||||
Screenful.Editor.changed();
|
||||
},
|
||||
registerCallbacks: function() {
|
||||
var self = this;
|
||||
var root = $(".clanek");
|
||||
|
||||
function get_prevod_div(element) {
|
||||
while(element.parent().length) {
|
||||
if(element.hasClass('myed-prevod-div')) {
|
||||
return element;
|
||||
}
|
||||
element = element.parent();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
root.on('change', '.myed-clanek-select', function(e) {
|
||||
var el = get_prevod_div($(this));
|
||||
var action = $(this).find(":selected").val();
|
||||
self.action(el, action);
|
||||
$(this).prop("selectedIndex", -1);
|
||||
});
|
||||
|
||||
root.on('click', '.myed-prevod-add', function(e) {
|
||||
self.add($(this));
|
||||
});
|
||||
|
||||
root.on('keydown', '.myed-prevod-div', function(e) {
|
||||
var action = {
|
||||
13: "edit",
|
||||
37: "left",
|
||||
39: "right",
|
||||
46: "cut"
|
||||
}[e.keyCode];
|
||||
|
||||
if(action) {
|
||||
self.action($(this), action);
|
||||
$(this).focus();
|
||||
}
|
||||
});
|
||||
|
||||
root.on('click', '.myed-zgled-prevod-btn', function(e) {
|
||||
var el = $(this);
|
||||
$.sweetModal.prompt('Prevod Zgleda', 'Vstavi:', '', function(val) {
|
||||
self.zgledPrevod(el, val);
|
||||
});
|
||||
});
|
||||
|
||||
// fixing modal stuff
|
||||
$('body').on('keydown', '.sweet-modal-prompt', function(e) {
|
||||
if(e.keyCode == 13) {
|
||||
$('.greenB').first().trigger('click')
|
||||
return false;
|
||||
}
|
||||
else if(e.keyCode == 27) {
|
||||
$('.redB').first().trigger('click')
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
clanekOldCode: function() {
|
||||
// script from original xslt, don't really wanna touch this!
|
||||
var clanekShowHide = function(button) {
|
||||
if(button.target.tagName !== "INPUT") {
|
||||
// this actually triggers a few times, so...
|
||||
return;
|
||||
}
|
||||
|
||||
var clanek = $('.clanek');
|
||||
var boolCollocations = clanek.find(".lblCollocations input").prop("checked");
|
||||
var boolExamples = clanek.find(".lblExamples input").prop("checked");
|
||||
|
||||
if(boolExamples) {
|
||||
clanek.find(".hiddenExample").slideDown();
|
||||
}
|
||||
else {
|
||||
clanek.find(".hiddenExample").slideUp();
|
||||
}
|
||||
if(boolCollocations) {
|
||||
clanek.find(".hiddenBlock").slideDown();
|
||||
}
|
||||
else {
|
||||
clanek.find(".hiddenBlock").slideUp();
|
||||
}
|
||||
};
|
||||
|
||||
var clanek = $('.clanek');
|
||||
var lblCollocations = clanek.find(".lblCollocations");
|
||||
var lblExamples = clanek.find(".lblExamples");
|
||||
|
||||
lblExamples.hide();
|
||||
lblCollocations.hide()
|
||||
|
||||
if(clanek.find(".hiddenBlock").length > 0) {
|
||||
lblCollocations.show()
|
||||
lblCollocations.first().on("click", clanekShowHide);
|
||||
clanek.find(".buttons").show();
|
||||
}
|
||||
if(clanek.find("*:visible > .hiddenExample").length > 0) {
|
||||
lblExamples.show()
|
||||
lblExamples.first().on("click", clanekShowHide);
|
||||
clanek.find(".buttons").show();
|
||||
}
|
||||
|
||||
// this is actually new but belongs here
|
||||
$(".lblPrevodi").first().on('click', function(e) {
|
||||
if(e.target.tagName !== "INPUT") {
|
||||
return;
|
||||
}
|
||||
$('.myed-zgled-prevod-btn').parent().toggle();
|
||||
});
|
||||
$('.myed-zgled-prevod-btn').parent().toggle();
|
||||
},
|
||||
editor: function(div, entry, uneditable) {
|
||||
var xslt_content = new window.DOMParser().parseFromString(this.xslt, "text/xml");
|
||||
var xml = $($.parseXML(entry.content));
|
||||
|
||||
// for "dodajanje prevodov" we need a model div to copy.
|
||||
// we create one here, that is then made invisible, but is
|
||||
// available for copying
|
||||
$(this.empty_prevod, xml).insertBefore(xml.find('prevod').first());
|
||||
|
||||
// adding prevod_id to prevodi
|
||||
this.storeXml(xml);
|
||||
sessionStorage.myed_original = entry.content;
|
||||
|
||||
var xsltProcessor = new XSLTProcessor();
|
||||
xsltProcessor.importStylesheet(xslt_content);
|
||||
resultDocument = xsltProcessor.transformToFragment(xml[0], document);
|
||||
$(div).append(resultDocument);
|
||||
|
||||
// now I need to hide first prevod that was inserted into
|
||||
// xml by this script, in order to be able to clone it
|
||||
$('.myed-prevod-div').first().hide();
|
||||
xml.find('prevod').first().remove();
|
||||
|
||||
var styleTag = document.createElement('style');
|
||||
styleTag.type = 'text/css';
|
||||
styleTag.appendChild(document.createTextNode(this.css));
|
||||
document.head.appendChild(styleTag);
|
||||
|
||||
this.clanekOldCode();
|
||||
this.loadDependencies();
|
||||
this.registerCallbacks();
|
||||
|
||||
// select nothing in all hamburger dropdowns
|
||||
$('.myed-clanek-select').prop("selectedIndex", -1);
|
||||
},
|
||||
show_modal: function(prevedek, razlaga, callback) {
|
||||
function grabContent(status) {
|
||||
if(!callback) return;
|
||||
var prevedek_t = $('#myed-sm-prevedek').val();
|
||||
var razlaga_t = $('#myed-sm-razlaga').val();
|
||||
callback(status, prevedek_t, razlaga_t);
|
||||
};
|
||||
|
||||
var options = "";
|
||||
for(let option of this.oznake) {
|
||||
options += `<option>${ option }</option>`;
|
||||
}
|
||||
|
||||
$.sweetModal({
|
||||
title: 'Spreminjanje Prevedka',
|
||||
content: `
|
||||
Prevedek: <div class="sweet-modal-prompt"><input id="myed-sm-prevedek" type="text" value="${ prevedek }" /></div><br />
|
||||
Razlaga: <div class="sweet-modal-prompt"><input id="myed-sm-razlaga" type="text" value="${ razlaga }" /></div><br />
|
||||
Oznaka: <select> ${ options } </select`,
|
||||
buttons: {
|
||||
save: {
|
||||
label: 'Shrani',
|
||||
classes: 'greenB',
|
||||
action: function() { grabContent(true); },
|
||||
},
|
||||
cancel: {
|
||||
label: 'Preklici',
|
||||
classes: 'redB',
|
||||
action: function() { grabContent(false); },
|
||||
}
|
||||
},
|
||||
onOpen: function() { $('#myed-sm-prevedek').focus(); }
|
||||
});
|
||||
},
|
||||
harvester: function(div) {
|
||||
for(let fstring of this.prevod_locations) {
|
||||
for(let vecjez of this.xml.find(fstring)) {
|
||||
for(let pp of $(vecjez).find('pp')) {
|
||||
$(pp).remove();
|
||||
}
|
||||
|
||||
for(let lprevod of $(vecjez).find("prevod")) {
|
||||
var prevod = $(lprevod);
|
||||
if(prevod.attr('semicolon') == 'true') {
|
||||
prevod.append($("<pp/>", this.xml));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// console.log((new XMLSerializer()).serializeToString(this.xml[0]));
|
||||
// return sessionStorage.myed_original;
|
||||
return (new XMLSerializer()).serializeToString(this.xml[0]);
|
||||
},
|
||||
xslt: XSLFILE,
|
||||
css: CSS,
|
||||
}
|
246
main.xslt
Normal file
246
main.xslt
Normal file
|
@ -0,0 +1,246 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
<xsl:output method="html"/>
|
||||
|
||||
<xsl:template match="clanek">
|
||||
<div class="clanek">
|
||||
<xsl:apply-templates/>
|
||||
</div>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="clanek/glava">
|
||||
<div>
|
||||
<xsl:apply-templates select="korpusi/korpus[1]/frek_lema | oblika/iztocnica | zaglavje/besedna_vrsta"/>
|
||||
</div>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="korpusi/korpus/frek_lema">
|
||||
<xsl:text xml:space="preserve"> </xsl:text>
|
||||
<span style="float: right;">
|
||||
<xsl:choose>
|
||||
<xsl:when test="number(.)>22561"><span class="s1">⁕</span><span class="s1">⁕</span><span class="s1">⁕</span><span class="s1">⁕</span><span class="s1">⁕</span></xsl:when>
|
||||
<xsl:when test="number(.)>8613"> <span class="s1">⁕</span><span class="s1">⁕</span><span class="s1">⁕</span><span class="s1">⁕</span><span class="s0">⁕</span></xsl:when>
|
||||
<xsl:when test="number(.)>5206"> <span class="s1">⁕</span><span class="s1">⁕</span><span class="s1">⁕</span><span class="s0">⁕</span><span class="s0">⁕</span></xsl:when>
|
||||
<xsl:when test="number(.)>552"> <span class="s1">⁕</span><span class="s1">⁕</span><span class="s0">⁕</span><span class="s0">⁕</span><span class="s0">⁕</span></xsl:when>
|
||||
<xsl:otherwise> <span class="s1">⁕</span><span class="s0">⁕</span><span class="s0">⁕</span><span class="s0">⁕</span><span class="s0">⁕</span></xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</span>
|
||||
<xsl:text xml:space="preserve"> </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="clanek/glava/oblika/iztocnica">
|
||||
<xsl:text xml:space="preserve"> </xsl:text>
|
||||
<span style="font-size: 1.2em; color: #cc3366; font-weight: bold;">
|
||||
<xsl:apply-templates/>
|
||||
</span>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="clanek/glava/zaglavje/besedna_vrsta">
|
||||
<xsl:text xml:space="preserve"> </xsl:text>
|
||||
<span style="color: #666666; font-style: italic;">
|
||||
<xsl:apply-templates/>
|
||||
</span>
|
||||
<xsl:text xml:space="preserve"> </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="clanek/geslo">
|
||||
<div class="buttons" style="border-top: 1px dotted #999999; padding-top: 0.5em; margin-top: 0.5em;">
|
||||
<label class="lblCollocations"><input type="checkbox"/> več kolokacij | több kollokáció</label>
|
||||
<label class="lblExamples"><input type="checkbox"/> več zgledov | több példamondat</label>
|
||||
<label class="lblPrevodi"><input type="checkbox"/> prevajaj zglede | bla bla bla</label>
|
||||
</div>
|
||||
<xsl:apply-templates/>
|
||||
</xsl:template>
|
||||
|
||||
<!--a sense, or any other sense-level element-->
|
||||
<xsl:template match="clanek/geslo/*">
|
||||
<div style="border-top: 1px dotted #999999; padding-top: 0.5em; margin-top: 0.5em;">
|
||||
<xsl:if test="name()='pomen'">
|
||||
<div style="float: left; margin-left: 0.5em; color: #333333; font-weight: bold;">
|
||||
<xsl:choose>
|
||||
<xsl:when test="count(../pomen)>1"><xsl:value-of select="position()"/></xsl:when>
|
||||
<xsl:otherwise>•</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</div>
|
||||
</xsl:if>
|
||||
<div style="margin-left: 2em;">
|
||||
<xsl:if test="ustaljena_oblika | indikator | oznaka | vecjez/prevod ">
|
||||
<div><xsl:apply-templates select="ustaljena_oblika | indikator | oznaka | vecjez/prevod "/></div>
|
||||
</xsl:if>
|
||||
<div>
|
||||
<xsl:apply-templates select="*[name()!='ustaljena_oblika' and name()!='indikator' and name()!='oznaka' and name()!='vecjez']"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="clanek/geslo/*//s_oznaka"/>
|
||||
<!--<xsl:template match="clanek/geslo/*//vir"/>-->
|
||||
<xsl:template match="clanek/geslo/*//pomenska_shema"/>
|
||||
<xsl:template match="clanek/geslo/*//definicija1"/>
|
||||
<xsl:template match="clanek/geslo/*//definicija2"/>
|
||||
<xsl:template match="s_oznaka"/>
|
||||
<!--<xsl:template match="vir"/>-->
|
||||
<xsl:template match="struktura"/>
|
||||
|
||||
<!--override headword at start of sense-->
|
||||
<xsl:template match="ustaljena_oblika">
|
||||
<xsl:text xml:space="preserve"> </xsl:text>
|
||||
<span style="font-weight: bold;"><xsl:apply-templates/></span>
|
||||
<xsl:text xml:space="preserve"> </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<!--disambiguators anywhere-->
|
||||
<xsl:template match="indikator[text() or *]">
|
||||
<xsl:if test="count(parent::pomen/../pomen)>1 or oznaka">
|
||||
<xsl:text xml:space="preserve"> </xsl:text>
|
||||
<span>
|
||||
<xsl:if test="not(oznaka) or text()"><xsl:text xml:space="preserve">(</xsl:text></xsl:if>
|
||||
<xsl:apply-templates/>
|
||||
<xsl:if test="not(oznaka) or text()"><xsl:text xml:space="preserve">)</xsl:text></xsl:if>
|
||||
</span>
|
||||
<xsl:text xml:space="preserve"> </xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
<xsl:template match="oznaka[text() or *]">
|
||||
<xsl:if test="not(parent::indikator)"><xsl:text xml:space="preserve"> </xsl:text></xsl:if>
|
||||
<span class="myed-oznaka">
|
||||
<xsl:apply-templates/>
|
||||
</span>
|
||||
<xsl:if test="not(parent::indikator)"><xsl:text xml:space="preserve"> </xsl:text></xsl:if>
|
||||
</xsl:template>
|
||||
<xsl:template match="oznaka[text() or *]">
|
||||
<span class="myed-oznaka">
|
||||
<xsl:if test="not(parent::indikator/text())"><xsl:text xml:space="preserve">(</xsl:text></xsl:if>
|
||||
<xsl:apply-templates/>
|
||||
<xsl:if test="not(parent::indikator/text())"><xsl:text xml:space="preserve">)</xsl:text></xsl:if>
|
||||
</span>
|
||||
</xsl:template>
|
||||
<xsl:template match="indikator | oznaka"/>
|
||||
|
||||
<!--sense-level translations-->
|
||||
<xsl:template match="vecjez/prevod">
|
||||
<xsl:if test="*">
|
||||
<xsl:element name="div">
|
||||
<xsl:attribute name="class">
|
||||
myed-prevod-div
|
||||
<xsl:if test="@cut='true'"> myed-prevod-cut</xsl:if>
|
||||
<xsl:if test="@bin='true'"> myed-prevod-bin</xsl:if>
|
||||
</xsl:attribute>
|
||||
<xsl:attribute name="prevod_id"><xsl:value-of select="@prevod_id" /></xsl:attribute>
|
||||
<xsl:attribute name="tabindex">1</xsl:attribute>
|
||||
|
||||
<span class="myed-prevod-oznaka"><xsl:apply-templates select=".//oznaka"/></span>
|
||||
<span class="myed-prevod-text"><xsl:apply-templates select=".//tekst"/></span>
|
||||
<sup><xsl:apply-templates select=".//vir"/></sup>
|
||||
<span class="myed-prevod-razlaga"><xsl:apply-templates select=".//rzg"/></span>
|
||||
|
||||
<select class="myed-clanek-select">
|
||||
<option value="edit" title="Spremeni / HUN">✎</option>
|
||||
<option value="right" title="Premakni desno / HUN">→</option>
|
||||
<option value="left" title="Premakni levo / HUN" >←</option>
|
||||
<option value="semicolon" title="Podpicje / HUN">;</option>
|
||||
<option value="cut" title="Osivi / HUN">✀</option>
|
||||
<option value="bin" title="Odstrani trajno / HUN">🗑</option>
|
||||
</select>
|
||||
|
||||
<xsl:element name="span">
|
||||
<xsl:attribute name="class">
|
||||
myed-prevod-semicolon
|
||||
<xsl:if test="@semicolon!='true'">myed-prevod-semicolon-hidden</xsl:if>
|
||||
</xsl:attribute>
|
||||
;
|
||||
</xsl:element>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
<xsl:if test="position()=last()">
|
||||
<xsl:element name="input">
|
||||
<xsl:attribute name="class">myed-prevod-add</xsl:attribute>
|
||||
<xsl:attribute name="tabindex">1</xsl:attribute>
|
||||
<xsl:attribute name="line_num"><xsl:value-of select="@line_num"/></xsl:attribute>
|
||||
<xsl:attribute name="type">button</xsl:attribute>
|
||||
<xsl:attribute name="value">+</xsl:attribute>
|
||||
<xsl:attribute name="title">Dodaj prevedek / HUN</xsl:attribute>
|
||||
</xsl:element>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<!--example-->
|
||||
<xsl:template match="zgledi">
|
||||
<xsl:apply-templates select=".//zgled"/>
|
||||
</xsl:template>
|
||||
<xsl:template match="zgled">
|
||||
<xsl:element name="div">
|
||||
<xsl:attribute name="style">margin: 0.26em 0 0.25em 0;</xsl:attribute>
|
||||
<xsl:if test="not(parent::vecjez) or ancestor::vecjez/*[@hide='true'] or not(parent::vecjez/prevod/tekst/text())"><xsl:attribute name="class">hiddenExample</xsl:attribute></xsl:if>
|
||||
<div style="float: left; margin-left: 0.5em; color: #666666; font-size: 0.65em; position: relative; top: -1px;">
|
||||
■
|
||||
</div>
|
||||
<div style="margin-left: 1.5em;" class="zgled">
|
||||
<div><xsl:apply-templates/></div>
|
||||
<xsl:if test="@jezik='slo'">
|
||||
<div class="myed-zgled-prevod">
|
||||
<xsl:choose>
|
||||
<xsl:when test="following-sibling::*[1][name()='prevod']">
|
||||
<xsl:apply-templates select="following-sibling::*[1][name()='prevod']"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:element name="input">
|
||||
<xsl:attribute name="class">myed-zgled-prevod-btn</xsl:attribute>
|
||||
<xsl:attribute name="zgled_id"><xsl:value-of select="@zgled_id" /></xsl:attribute>
|
||||
<xsl:attribute name="type">button</xsl:attribute>
|
||||
<xsl:attribute name="value">+</xsl:attribute>
|
||||
</xsl:element>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</div>
|
||||
</xsl:if>
|
||||
</div>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
<xsl:template match="prevod[name(preceding-sibling::*[1])='zgled']">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:template>
|
||||
|
||||
<!--phrasemes-->
|
||||
<xsl:template match="*[kolokacija | r_kolokacija | enota | zveza]">
|
||||
<xsl:apply-templates select="kolokacija | r_kolokacija | enota | zveza"/>
|
||||
</xsl:template>
|
||||
<xsl:template match="kolokacija | r_kolokacija | enota | zveza">
|
||||
<xsl:element name="div">
|
||||
<xsl:attribute name="style">margin: 0.25em 0 0.25em 0;</xsl:attribute>
|
||||
<xsl:if test="@hide='true'"><xsl:attribute name="class">hiddenBlock</xsl:attribute></xsl:if>
|
||||
<xsl:element name="span">
|
||||
<xsl:attribute name="style">
|
||||
<xsl:text>color: #cc3366;</xsl:text>
|
||||
<xsl:if test="ancestor::stalne_zveze"><xsl:text>font-weight: bold;</xsl:text></xsl:if>
|
||||
</xsl:attribute>
|
||||
<xsl:apply-templates/>
|
||||
</xsl:element>
|
||||
<xsl:text xml:space="preserve"> </xsl:text>
|
||||
<xsl:apply-templates select="following-sibling::indikator[1] | following-sibling::oznaka[1]"/>
|
||||
<xsl:apply-templates select="parent::vecjez/prevod | parent::vecjez/pp"/>
|
||||
<xsl:apply-templates select="parent::vecjez/zgledi"/>
|
||||
<xsl:apply-templates select="zgledi"/>
|
||||
</xsl:element>
|
||||
</xsl:template>
|
||||
<xsl:template match="kolokacija//* | r_kolokacija//*">
|
||||
<xsl:text xml:space="preserve"> </xsl:text>
|
||||
<xsl:apply-templates/>
|
||||
</xsl:template>
|
||||
|
||||
<!--boxes-->
|
||||
<xsl:template match="stalne_zveze">
|
||||
<div style="margin: 0.5em 0 1em 0; padding: 1em 1em 0.25em 1em; background-color: #f6f6f6; border: 1px solid #dddddd; border-radius: 4px; text-shadow: 1px 1px 0px #ffffff;">
|
||||
<div style="font-size: 0.9em; margin: -5px -5px 0.75px -5px; padding: 3px 10px; background-color: #eeeeee; border-radius: 2px;"><span>STALNE ZVEZE | ÁLLANDÓSULT SZÓKAPCSOLATOK</span></div>
|
||||
<xsl:apply-templates/>
|
||||
</div>
|
||||
</xsl:template>
|
||||
<xsl:template match="clanek/geslo/frazeoloske_enote | clanek/geslo/frazeoloske_zveze">
|
||||
<div style="padding: 0.5em 0 0 0.5em; border-top: 1px dotted #999999; margin-top: 0.5em;">
|
||||
<div style="font-size: 0.9em; margin: 0.5em 0 0.75em -0.5em; padding: 3px 10px; background-color: #eeeeee; border-radius: 2px;"><span>FRAZE | FRAZÉMÁK</span></div>
|
||||
<xsl:apply-templates/>
|
||||
</div>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
Loading…
Reference in New Issue
Block a user