X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/3d61fc117d9e5274189d16be83d4489cd4b36d7f..ab8425976b9ee467efdbae6b1bcdb3e9e27b9525:/platforma/static/js/xslt.js?ds=inline
diff --git a/platforma/static/js/xslt.js b/platforma/static/js/xslt.js
index f164c5bd..7397d349 100644
--- a/platforma/static/js/xslt.js
+++ b/platforma/static/js/xslt.js
@@ -151,72 +151,49 @@ function withStylesheets(block, onError) {
})
}
-function transform(editor) {
- $.blockUI({message: 'Åadowanie...'});
+
+function xml2html(options) {
withStylesheets(function() {
- setTimeout(function() {
- var doc = null;
- var parser = new DOMParser();
- var serializer = new XMLSerializer();
-
- doc = editor.getCode().replace(/\/\s+/g, '
');
- doc = parser.parseFromString(doc, 'text/xml');
- var error = $('parsererror', doc);
- console.log(error);
- if (error.length == 0) {
- doc = xml2htmlStylesheet.transformToFragment(doc, document);
- error = $('parsererror', doc);
- }
- console.log('xml', doc);
- if (error.length > 0) {
- console.log(error);
- $('#html-view').html('
WystÄ piÅ bÅÄ d:
' + error.text() + ''); - } else { - console.log('after transform', doc); - $('#html-view').html(doc.firstChild); - } - - $.unblockUI(); - }, 200); - }, function() { alert('Nie udaÅo siÄ zaÅadowaÄ XSLT!'); }); -}; + var xml = options.xml.replace(/\/\s+/g, '
WystÄ piÅ bÅÄ d:
' + error.text()); - } else { - doc = serialize(doc.documentElement).join(''); - editor.setCode(doc); - } - - console.log('after transform', doc, doc.documentElement); - $.unblockUI(); - }, 200) - }, function() { alert('Nie udaÅo siÄ zaÅadowaÄ XSLT!')}); + $('#source-editor').html('WystÄ piÅ bÅÄ d:
' + error.text()); + } else { + options.success(serialize(doc.documentElement).join('')); + } + }, function() { options.error && options.success('Nie udaÅo siÄ zaÅadowaÄ XSLT'); }); };