X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/4dae2117bd399c1076973d325c6425e79fda1220..ddfd0025304ea7087fdd2a4e06893a6f998b9f19:/project/static/js/models.js?ds=sidebyside diff --git a/project/static/js/models.js b/project/static/js/models.js index e2ee8b15..c03aa1e7 100644 --- a/project/static/js/models.js +++ b/project/static/js/models.js @@ -176,7 +176,7 @@ Editor.HTMLModel = Editor.Model.extend({ this.set('state', 'loading'); // load the transformed data - messageCenter.addMessage('info', 'WczytujÄ HTML...'); + // messageCenter.addMessage('info', 'WczytujÄ HTML...'); $.ajax({ url: this.htmlURL, @@ -196,16 +196,42 @@ Editor.HTMLModel = Editor.Model.extend({ } this.set('data', data); this.set('state', 'synced'); - messageCenter.addMessage('success', 'WczytaÅem HTML :-)'); + // messageCenter.addMessage('success', 'WczytaÅem HTML :-)'); }, - loadingFailed: function() { + loadingFailed: function(response) { if (this.get('state') != 'loading') { alert('erroneous state:', this.get('state')); } - this.set('error', 'Nie udaÅo siÄ zaÅadowaÄ panelu'); + + var json_response = null; + var message = ""; + + try { + json_response = $.evalJSON(response.responseText); + + if(json_response.reason == 'xml-parse-error') { + + message = json_response.message.replace(/(line\s+)(\d+)(\s+)/i, + "$1$2$3"); + + message = message.replace(/(line\s+)(\d+)(\,\s*column\s+)(\d+)/i, + "$1$2$3$4"); + + + } + else { + message = json_response.message || json_response.reason || "nieznany bÅÄ d."; + } + } + catch (e) { + message = response.statusText; + } + + this.set('error', '
Nie udaÅo siÄ wczytaÄ widoku HTML:
' + message); + this.set('state', 'error'); - messageCenter.addMessage('error', 'Nie udaÅo mi siÄ wczytaÄ HTML. Spróbuj ponownie :-('); + // messageCenter.addMessage('error', 'Nie udaÅo mi siÄ wczytaÄ HTML. Spróbuj ponownie :-('); }, getXMLPart: function(elem, callback) @@ -224,7 +250,7 @@ Editor.HTMLModel = Editor.Model.extend({ $.ajax({ url: this.dataURL, - dataType: 'text; charset=utf-8', + dataType: 'text', data: { revision: this.get('revision'), part: path @@ -548,12 +574,12 @@ $(function() toolbarUrl = $('#api-toolbar-url').text(); doc = new Editor.DocumentModel(); - var editor = new EditorView('#body-wrap', doc); - editor.freeze(); - var flashView = new FlashView('#flashview', messageCenter); - var splitView = new SplitView('#splitview', doc); + EditorView = new EditorView('#body-wrap', doc); + EditorView.freeze(); leftPanelView = new PanelContainerView('#left-panel-container', doc); rightPanelContainer = new PanelContainerView('#right-panel-container', doc); + + var flashView = new FlashView('#flashview', messageCenter); });