temporary attributes for bible tags
[redakcja.git] / src / redakcja / static / js / wiki / view_summary.js
1 (function($){
2
3     class SummaryPerspective extends $.wiki.Perspective {
4         constructor(options) {
5             super(options);
6             var self = this;
7
8             // first time page is rendered
9             $('#summary-cover-refresh').click(function() {
10                 self.refreshCover();
11             });
12         }
13
14         refreshCover() {
15             $('#summary-cover-refresh').attr('disabled', 'disabled');
16             this.doc.refreshCover({
17                 success: function(text) {
18                     $('#summary-cover').attr('src', text);
19                     $('#summary-cover-refresh').removeAttr('disabled');
20                 }
21             });
22         }
23
24         showCharCount() {
25             var cc;
26             try {
27                 $('#charcounts_text').show();
28                 $('#charcounts_raw').hide();
29                 cc = this.doc.getLength({noFootnotes: true, noThemes: true});
30                 $('#charcount').html(cc);
31                 $('#charcount_pages').html((Math.round(cc/18)/100).toLocaleString());
32
33                 cc = this.doc.getLength();
34                 $('#charcount_full').html(cc);
35                 $('#charcount_full_pages').html((Math.round(cc/18)/100).toLocaleString());
36             }
37             catch (e) {
38                 $('#charcounts_text').hide();
39                 $('#charcounts_raw').show();
40                 cc = this.doc.text.replace(/\s{2,}/g, ' ').length;
41                 $('#charcount_raw').html(cc);
42                 $('#charcount_raw_pages').html((Math.round(cc/18)/100).toLocaleString());
43             }
44         }
45
46         onEnter(success, failure){
47             super.onEnter();
48
49             this.showCharCount();
50         }
51     }
52     $.wiki.SummaryPerspective = SummaryPerspective;
53
54 })(jQuery);