X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/ae9eecda5561b99cd51b1f3709e3cdc803ba47eb..75b7209eaa096a8d3bff42fa83eec838791b6f3a:/platforma/static/js/xslt.js?ds=inline diff --git a/platforma/static/js/xslt.js b/platforma/static/js/xslt.js index 7397d349..71a68598 100644 --- a/platforma/static/js/xslt.js +++ b/platforma/static/js/xslt.js @@ -132,12 +132,12 @@ function withStylesheets(block, onError) { } $.blockUI({message: 'Åadowanie arkuszy stylów...'}); $.ajax({ - url: '/static/xsl/wl2html_client.xsl', + url: STATIC_URL + 'xsl/wl2html_client.xsl', dataType: 'xml', success: function(data) { xml2htmlStylesheet = createXSLT(data); $.ajax({ - url: '/static/xsl/html2wl_client.xsl', + url: STATIC_URL + 'xsl/html2wl_client.xsl', dataType: 'xml', success: function(data) { html2xmlStylesheet = createXSLT(data); @@ -170,7 +170,7 @@ function xml2html(options) { } else { options.success(doc.firstChild); } - }, function() { options.error && options.success('Nie udaÅo siÄ zaÅadowaÄ XSLT'); }); + }, function() { options.error && options.error('Nie udaÅo siÄ zaÅadowaÄ XSLT'); }); } @@ -181,19 +181,25 @@ function html2xml(options) { var serializer = new XMLSerializer(); var doc = parser.parseFromString(xml, 'text/xml'); var error = $('parsererror', doc.documentElement); - + if (error.length == 0) { - doc = html2xmlStylesheet.transformToDocument(doc, document); + doc = html2xmlStylesheet.transformToDocument(doc); error = $('parsererror', doc.documentElement); } if (error.length > 0 && options.error) { options.error(error.text()); - console.log(error); - $('#source-editor').html('
WystÄ piÅ bÅÄ d:
' + error.text()); } else { - options.success(serialize(doc.documentElement).join('')); + if (options.inner) { + var result = []; + for (var i = 0; i < doc.documentElement.childNodes.length; i++) { + result.push(serialize(doc.documentElement.childNodes[i]).join('')); + }; + options.success(result.join('')); + } else { + options.success(serialize(doc.documentElement).join('')); + } } - }, function() { options.error && options.success('Nie udaÅo siÄ zaÅadowaÄ XSLT'); }); + }, function() { options.error && options.error('Nie udaÅo siÄ zaÅadowaÄ XSLT'); }); };