From: Radek Czajka
Date: Wed, 6 Mar 2019 14:40:00 +0000 (+0100)
Subject: Fixes #3866: Text counter with footnotes.
X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/fce465da41831c71697665a594b3f9287856baaa?ds=inline
Fixes #3866: Text counter with footnotes.
---
diff --git a/src/redakcja/static/js/wiki/view_summary.js b/src/redakcja/static/js/wiki/view_summary.js
index 099a0e81..1bc3fb5d 100644
--- a/src/redakcja/static/js/wiki/view_summary.js
+++ b/src/redakcja/static/js/wiki/view_summary.js
@@ -32,15 +32,23 @@
SummaryPerspective.prototype.showCharCount = function() {
var cc;
try {
+ $('#charcounts_text').show();
+ $('#charcounts_raw').hide();
+ cc = this.doc.getLength({noFootnotes: true, noThemes: true});
+ $('#charcount').html(cc);
+ $('#charcount_pages').html((Math.round(cc/18)/100).toLocaleString());
+
cc = this.doc.getLength();
- $('#charcount_untagged').hide();
+ $('#charcount_full').html(cc);
+ $('#charcount_full_pages').html((Math.round(cc/18)/100).toLocaleString());
}
catch (e) {
- $('#charcount_untagged').show();
+ $('#charcounts_text').hide();
+ $('#charcounts_raw').show();
cc = this.doc.text.replace(/\s{2,}/g, ' ').length;
+ $('#charcount_raw').html(cc);
+ $('#charcount_raw_pages').html((Math.round(cc/18)/100).toLocaleString());
}
- $('#charcount').html(cc);
- $('#charcount_pages').html((Math.round(cc/18)/100).toLocaleString());
}
SummaryPerspective.prototype.freezeState = function(){
diff --git a/src/redakcja/static/js/wiki/wikiapi.js b/src/redakcja/static/js/wiki/wikiapi.js
index 8df3ef5a..f4073ff9 100644
--- a/src/redakcja/static/js/wiki/wikiapi.js
+++ b/src/redakcja/static/js/wiki/wikiapi.js
@@ -414,6 +414,7 @@
WikiDocument.prototype.getLength = function(params) {
+ params = $.extend({}, noops, params);
var xml = this.text.replace(/\/(\s+)/g, ' $1');
var parser = new DOMParser();
var doc = parser.parseFromString(xml, 'text/xml');
@@ -423,7 +424,13 @@
throw "Not an XML document.";
}
$.xmlns["rdf"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
- $('rdf|RDF, motyw, pa, pe, pr, pt', doc).remove();
+ $('rdf|RDF', doc).remove();
+ if (params.noFootnotes) {
+ $('pa, pe, pr, pt', doc).remove();
+ }
+ if (params.noThemes) {
+ $('motyw', doc).remove();
+ }
var text = $(doc).text();
text = $.trim(text.replace(/\s{2,}/g, ' '));
return text.length;
diff --git a/src/wiki/templates/wiki/tabs/summary_view.html b/src/wiki/templates/wiki/tabs/summary_view.html
index 49ad5fe7..341a5ef6 100644
--- a/src/wiki/templates/wiki/tabs/summary_view.html
+++ b/src/wiki/templates/wiki/tabs/summary_view.html
@@ -39,7 +39,13 @@
- ( {% trans "pages" %}, {% trans "untagged" %})
+
+ ( {% trans "pages" %}, {% trans "without footnotes and themes" %})
+ ( {% trans "pages" %}, {% trans "with footnotes and themes" %})
+
+
+ ( {% trans "pages" %}, {% trans "untagged" %})
+