X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/e0f595e44766e352edfce0aaf5d32be57f448882..491078616e2129745f300c1f0357f5bac52e801d:/src/redakcja/static/js/wiki/wikiapi.js?ds=inline diff --git a/src/redakcja/static/js/wiki/wikiapi.js b/src/redakcja/static/js/wiki/wikiapi.js index 14b8337e..73642ac0 100644 --- a/src/redakcja/static/js/wiki/wikiapi.js +++ b/src/redakcja/static/js/wiki/wikiapi.js @@ -126,8 +126,9 @@ this.fullUri = $("*[data-key='full-uri']", meta).text(); this.text = null; + this.saving = false; this.has_local_changes = false; - this.active = true; + this.active = new Date(); this._lock = -1; this._context_lock = -1; this._lock_count = 0; @@ -216,22 +217,42 @@ checkRevision(params) { /* this doesn't modify anything, so no locks */ var self = this; - let active = self.active; - self.active = false; + let active = new Date() - self.active < 30 * 1000; + let saving = self.saving; $.ajax({ method: "GET", url: reverse("ajax_document_rev", self.id), data: { 'a': active, + 'new': 1, }, - dataType: 'text', + dataType: 'json', success: function(data) { if (data == '') { if (params.error) params.error(); } - else if (data != self.revision) - params.outdated(); + else { + let people = $('
'); + data.people.forEach((p) => { + let item = $(''); + item.attr('src', p.gravatar), + item.attr( + 'title', + p.name + ' (' + + (p.active ? 'akt.' : 'nieakt.') + + ' od ' + p.since + ')') + if (p.active) { + item.addClass('active'); + } + people.append(item); + }); + $("#people").html(people); + + if (!saving && (data.rev != self.revision)) { + params.outdated(); + } + } } }); } @@ -356,6 +377,7 @@ data['textsave-text'] = self.text; + self.saving = true; $.ajax({ url: reverse("ajax_document_text", self.id), type: "POST", @@ -373,10 +395,12 @@ changed = true; self.triggerDocumentChanged(); }; + self.saving = false; params['success'](self, changed, ((changed && "Udało się zapisać :)") || "Twoja wersja i serwera jest identyczna")); }, error: function(xhr) { + self.saving = false; if ($('#header').hasClass('saving')) { $('#header').removeClass('saving'); $.blockUI({