fix for null source urls
[redakcja.git] / redakcja / static / js / wiki_img / wikiapi.js
index 81cd316..377e4f9 100644 (file)
@@ -17,9 +17,9 @@
                var vname = arguments[0];
                var base_path = "/images";
 
                var vname = arguments[0];
                var base_path = "/images";
 
-               if (vname == "ajax_document_text") {
-                       return base_path + "/text/" + arguments[1] + "/";
-               }
+               if (vname == "ajax_document_text")
+                   return base_path + "/text/" + arguments[1] + "/";
+
 
         if (vname == "ajax_document_revert") {
             return base_path + "/revert/" + arguments[1] + '/';
 
         if (vname == "ajax_document_revert") {
             return base_path + "/revert/" + arguments[1] + '/';
                this.revision = $("*[data-key='revision']", meta).text();
                this.readonly = !!$("*[data-key='readonly']", meta).text();
 
                this.revision = $("*[data-key='revision']", meta).text();
                this.readonly = !!$("*[data-key='readonly']", meta).text();
 
+        var diff = $("*[data-key='diff']", meta).text();
+        if (diff) {
+            diff = diff.split(',');
+            if (diff.length == 2 && diff[0] < diff[1])
+                this.diff = diff;
+            else if (diff.length == 1) {
+                diff = parseInt(diff);
+                if (diff != NaN)
+                    this.diff = [diff - 1, diff];
+            }
+        }
+
                this.text = null;
                this.has_local_changes = false;
                this._lock = -1;
                this.text = null;
                this.has_local_changes = false;
                this._lock = -1;
                $.ajax({
                        method: "GET",
                        url: reverse("ajax_document_text", self.id),
                $.ajax({
                        method: "GET",
                        url: reverse("ajax_document_text", self.id),
-                       data: {"commit": self.commit},
+                       data: {"revision": self.revision},
                        dataType: 'json',
                        success: function(data) {
                                var changed = false;
 
                        dataType: 'json',
                        success: function(data) {
                                var changed = false;
 
-                               if (self.text === null || self.commit !== data.commit) {
+                               if (self.text === null || self.revision !== data.revision) {
                                        self.text = data.text;
                                        if (self.text === '') {
                                            self.text = '<picture></picture>';
                                        }
                                        self.revision = data.revision;
                                        self.text = data.text;
                                        if (self.text === '') {
                                            self.text = '<picture></picture>';
                                        }
                                        self.revision = data.revision;
-                    self.commit = data.commit;
+//                    self.commit = data.commit;
                                        changed = true;
                                        self.triggerDocumentChanged();
                                };
                                        changed = true;
                                        self.triggerDocumentChanged();
                                };
                                if (data.text) {
                                        self.text = data.text;
                                        self.revision = data.revision;
                                if (data.text) {
                                        self.text = data.text;
                                        self.revision = data.revision;
-                    self.commit = data.commit;
+//                    self.commit = data.commit;
                                        changed = true;
                                        self.triggerDocumentChanged();
                                };
                                        changed = true;
                                        self.triggerDocumentChanged();
                                };