From: zuber Date: Fri, 15 Jan 2010 00:05:55 +0000 (+0100) Subject: Konwersja HTML do XML przed zapisaniem XML na serwer. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/465f9d370fb3b96b4cc30e139d24e4479a9f7ab0?ds=inline;hp=75b7209eaa096a8d3bff42fa83eec838791b6f3a Konwersja HTML do XML przed zapisaniem XML na serwer. --- diff --git a/platforma/static/js/main.js b/platforma/static/js/main.js index de848350..a19dc14e 100644 --- a/platforma/static/js/main.js +++ b/platforma/static/js/main.js @@ -253,7 +253,7 @@ function transform(editor) { }; -function reverseTransform(editor) { +function reverseTransform(editor, cont) { var serializer = new XMLSerializer(); if ($('#html-view .error').length > 0) { return; @@ -265,6 +265,9 @@ function reverseTransform(editor) { success: function(text) { editor.setCode(text); $.unblockUI(); + if (cont) { + cont(); + } }, error: function(text) { $('#source-editor').html('

Wystąpił błąd:

' + text + '
'); $.unblockUI(); @@ -410,41 +413,49 @@ $(function() { $('#save-ok').click(function() { $.blockUI({message: 'Zapisywanie...'}); - var metaComment = '' - - var data = { - name: $('#document-name').html(), - text: metaComment + editor.getCode(), - revision: $('#document-revision').html(), - author: 'annonymous', - comment: $('#komentarz').val() - }; - - console.log(data); + function doSave (argument) { + var metaComment = '' + + var data = { + name: $('#document-name').html(), + text: metaComment + editor.getCode(), + revision: $('#document-revision').html(), + author: 'annonymous', + comment: $('#komentarz').val() + }; + + console.log(data); + + $.ajax({ + url: document.location.href, + type: "POST", + dataType: "json", + data: data, + success: function(data) { + if (data.text) { + editor.setCode(data.text); + $('#document-revision').html(data.revision); + } else { + console.log(data.errors); + alert(data.errors); + } + $.unblockUI(); + }, + error: function(xhr, textStatus, errorThrown) { + alert('error: ' + textStatus + ' ' + errorThrown); + }, + }) + } - $.ajax({ - url: document.location.href, - type: "POST", - dataType: "json", - data: data, - success: function(data) { - if (data.text) { - editor.setCode(data.text); - $('#document-revision').html(data.revision); - } else { - console.log(data.errors); - alert(data.errors); - } - $.unblockUI(); - }, - error: function(xhr, textStatus, errorThrown) { - alert('error: ' + textStatus + ' ' + errorThrown); - }, - }) + if ('#simple-view-tab.active') { + reverseTransform(editor, doSave); + } else { + doSave(); + } }); $('#save-cancel').click(function() { diff --git a/platforma/templates/base.html b/platforma/templates/base.html index 4819b7c4..750cf7b3 100755 --- a/platforma/templates/base.html +++ b/platforma/templates/base.html @@ -4,7 +4,8 @@ {% block title %}Platforma Redakcyjna{% block subtitle %}{% endblock subtitle %}{% endblock title%} - + + {# #} {% block extrahead %} {% endblock %}