forked from rouleaup88/item-inspector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWaniKani Open Framework Statistics Filters-1.5.0.user.js
937 lines (830 loc) · 36.8 KB
/
WaniKani Open Framework Statistics Filters-1.5.0.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
// ==UserScript==
// @name WaniKani Open Framework Statistics Filters
// @namespace https://www.wanikani.com
// @description Additional statistics filters for the WaniKani Open Framework
// @author prouleau
// @version 1.5.0
// @match https://www.wanikani.com/*
// @license MIT; http://opensource.org/licenses/MIT
// @grant none
// ==/UserScript==
(function(wkof) {
'use strict';
var wkofMinimumVersion = '1.0.52';
if (!wkof) {
var response = confirm('WaniKani Open Framework Date Filters requires WaniKani Open Framework.\n Click "OK" to be forwarded to installation instructions.');
if (response) {
window.location.href = 'https://community.wanikani.com/t/instructions-installing-wanikani-open-framework/28549';
}
return;
}
var settingsDialog;
var settingsScriptId = 'statsFilters';
var settingsTitle = 'Statistics Filters';
var needToRegisterFilters = true;
var filterNamePrefix = 'statsFilters_';
var leechLteqFilterName = filterNamePrefix + 'LeechLteq';
var meaningCorAnsLteqFilterName = filterNamePrefix + 'meaningCorAnsLteq';
var meaningCorAnsGteqFilterName = filterNamePrefix + 'meaningCorAnsGteq';
var readingCorAnsLteqFilterName = filterNamePrefix + 'readingCorAnsLteq';
var readingCorAnsGteqFilterName = filterNamePrefix + 'readingCorAnsGteq';
var meaningIncorAnsLteqFilterName = filterNamePrefix + 'meaningIncorAnsLteq';
var meaningIncorAnsGteqFilterName = filterNamePrefix + 'meaningIncorAnsGteq';
var readingIncorAnsLteqFilterName = filterNamePrefix + 'readingIncorAnsLteq';
var readingIncorAnsGteqFilterName = filterNamePrefix + 'readingIncorAnsGteq';
var totalCorAnsLteqFilterName = filterNamePrefix + 'totalCorAnsLteq';
var totalCorAnsGteqFilterName = filterNamePrefix + 'totalCorAnsGteq';
var totalIncorAnsLteqFilterName = filterNamePrefix + 'totalIncorAnsLteq';
var totalIncorAnsGteqFilterName = filterNamePrefix + 'totalIncorAnsGteq';
var percentageTotalCorLteqFilterName = filterNamePrefix + 'percentageTotalCorLteq';
var percentageTotalCorGteqFilterName = filterNamePrefix + 'percentageTotalCorGteq';
var percentageMeaningCorLteqFilterName = filterNamePrefix + 'pecentagerMeaningCorLteq';
var percentageMeaningCorGteqFilterName = filterNamePrefix + 'percentageMeaningCorGteq';
var percentageReadingCorLteqFilterName = filterNamePrefix + 'percentageReadingCorLteq';
var percentageReadingCorGteqFilterName = filterNamePrefix + 'percentageReadingCorGteq';
var meaningCurStrLteqFilterName = filterNamePrefix + 'meaningCurStrLteq';
var meaningCurStrGteqFilterName = filterNamePrefix + 'meaningCurStrGteq';
var meaningMaxStrLteqFilterName = filterNamePrefix + 'meaningMaxStrLteq';
var meaningMaxStrGteqFilterName = filterNamePrefix + 'meaningMaxStrGteq';
var readingCurStrLteqFilterName = filterNamePrefix + 'readingCurStrLteq';
var readingCurStrGteqFilterName = filterNamePrefix + 'readingCurStrGteq';
var readingMaxStrLteqFilterName = filterNamePrefix + 'readingMaxStrLteq';
var readingMaxStrGteqFilterName = filterNamePrefix + 'readingMaxStrGteq';
var bothCurStrLteqFilterName = filterNamePrefix + 'bothCurStrLteq';
var bothCurStrGteqFilterName = filterNamePrefix + 'bothCurStrGteq';
var minCurStrLteqFilterName = filterNamePrefix + 'minCurStrLteq';
var minCurStrGteqFilterName = filterNamePrefix + 'minCurStrGteq';
var numReviewsLteqFilterName = filterNamePrefix + 'numReviewsLteq';
var numReviewGteqFilterName = filterNamePrefix + 'numReviewsGteq';
var supportedFilters = [leechLteqFilterName, meaningCorAnsLteqFilterName, meaningCorAnsGteqFilterName, readingCorAnsLteqFilterName, readingCorAnsGteqFilterName,
meaningIncorAnsLteqFilterName, meaningIncorAnsGteqFilterName, readingIncorAnsLteqFilterName, readingIncorAnsGteqFilterName,
totalCorAnsLteqFilterName, totalCorAnsGteqFilterName, totalIncorAnsLteqFilterName, totalIncorAnsGteqFilterName,
percentageTotalCorLteqFilterName, percentageTotalCorGteqFilterName, percentageMeaningCorLteqFilterName, percentageMeaningCorGteqFilterName,
percentageReadingCorLteqFilterName, percentageReadingCorGteqFilterName, meaningCurStrLteqFilterName, meaningCurStrGteqFilterName,
meaningMaxStrLteqFilterName, meaningMaxStrGteqFilterName, readingCurStrLteqFilterName, readingCurStrGteqFilterName,
readingMaxStrLteqFilterName, readingMaxStrGteqFilterName, bothCurStrLteqFilterName, bothCurStrGteqFilterName,
minCurStrLteqFilterName, minCurStrGteqFilterName, numReviewsLteqFilterName, numReviewGteqFilterName];
function updateFiltersWhenReady() {
wkof.set_state(settingsScriptId, 'loading');
needToRegisterFilters = true;
waitForItemDataRegistry().then(registerFilters);
}
function waitForItemDataRegistry() {
return wkof.wait_state('wkof.ItemData.registry', 'ready');
}
function registerFilters() {
if (!needToRegisterFilters) {
return;
}
supportedFilters.forEach(function(filterName) {
delete wkof.ItemData.registry.sources.wk_items.filters[filterName];
});
registerLeechLteqFilter();
registerMeaningCorAnsGteqFilter();
registerMeaningCorAnsLteqFilter();
registerReadingCorAnsGteqFilter();
registerReadingCorAnsLteqFilter();
registerMeaningIncorAnsGteqFilter();
registerMeaningIncorAnsLteqFilter();
registerReadingIncorAnsGteqFilter();
registerReadingIncorAnsLteqFilter();
registerTotalCorAnsGteqFilter();
registerTotalCorAnsLteqFilter();
registerTotalIncorAnsGteqFilter();
registerTotalIncorAnsLteqFilter();
registerPercentageTotalCorGteqFilter();
registerPercentageTotalCorLteqFilter();
registerPercentageMeaningCorGteqFilter();
registerPercentageMeaningCorLteqFilter();
registerPercentageReadingCorGteqFilter();
registerPercentageReadingCorLteqFilter();
registerMeaningCurStrGteqFilter();
registerMeaningCurStrLteqFilter();
registerMeaningMaxStrGteqFilter();
registerMeaningMaxStrLteqFilter();
registerReadingCurStrGteqFilter();
registerReadingCurStrLteqFilter();
registerReadingMaxStrGteqFilter();
registerReadingMaxStrLteqFilter();
registerBothCurStrGteqFilter();
registerBothCurStrLteqFilter();
registerMinCurStrGteqFilter();
registerMinCurStrLteqFilter();
registerNumberReviewsGteqFilter();
registerNumberReviewsLteqFilter();
needToRegisterFilters = false;
wkof.set_state(settingsScriptId, 'ready');
}
// BEGIN Leech
let leechLteqHover_tip = 'Select items that have a leech value less than or equal to the stated value.';
function registerLeechLteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[leechLteqFilterName] = {
type: 'number',
label: 'Leech value <=',
default: 10,
filter_func: leechLteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: leechLteqHover_tip,
};
}
function leechLteqFilter(filterValue, item) {
if (item.review_statistics === undefined) {
return false;
}
var reviewStats = item.review_statistics;
var meaningScore = getLeechScore(reviewStats.meaning_incorrect, reviewStats.meaning_current_streak);
var readingScore = getLeechScore(reviewStats.reading_incorrect, reviewStats.reading_current_streak);
return meaningScore <= filterValue && readingScore <= filterValue;
}
// Leech scores a rounded because otherwise the behavior of the filter is not consistent with rounded values presented to users in scripts.
// In other words, data would be not filtered when based on user facing data it appears that it should be.
function getLeechScore(incorrect, currentStreak) {
return Math.round((incorrect / Math.pow((currentStreak || 0.5), 1.5)) * 100) / 100;
}
// END Leech
// BEGIN Meaning correct answers
let meaningCorAnsGteqFilterHover_tip = 'Selects items where the number of correct\nanswers for Meaning is >= this value.';
let meaningCorAnsLteqFilterHover_tip = 'Selects items where the number of correct\nanswers for Meaning is <= this value.';
function registerMeaningCorAnsGteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[meaningCorAnsGteqFilterName] = {
type: 'number',
label: 'Meaning Cor. Ans. >=',
default: 0,
filter_func: meaningCorAnsGteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: meaningCorAnsGteqFilterHover_tip,
};
}
function meaningCorAnsGteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
return review_statistics.meaning_correct >= filterValue;
}
function registerMeaningCorAnsLteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[meaningCorAnsLteqFilterName] = {
type: 'number',
label: 'Meaning Cor. Ans. <=',
default: 100,
filter_func: meaningCorAnsLteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: meaningCorAnsLteqFilterHover_tip,
};
}
function meaningCorAnsLteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
};
return review_statistics.meaning_correct <= filterValue;
};
// END Meaning correct answers
// BEGIN Reading correct answers
let readingCorAnsGteqFilterHover_tip = 'Selects items where the number of correct\nanswers for Reading is >= this value.';
let readingCorAnsLteqFilterHover_tip = 'Selects items where the number of correct\nanswers for Reading is <= this value.';
function registerReadingCorAnsGteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[readingCorAnsGteqFilterName] = {
type: 'number',
label: 'Reading Cor. Ans. >=',
default: 0,
filter_func: readingCorAnsGteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: readingCorAnsGteqFilterHover_tip,
};
};
function readingCorAnsGteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
};
if (item.object === 'radical' || item.object === 'kana_vocabulary'){
return true;
};
return review_statistics.reading_correct >= filterValue;
};
function registerReadingCorAnsLteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[readingCorAnsLteqFilterName] = {
type: 'number',
label: 'Reading Cor. Ans. <=',
default: 100,
filter_func: readingCorAnsLteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: readingCorAnsLteqFilterHover_tip,
};
}
function readingCorAnsLteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
if (item.object === 'radical' || item.object === 'kana_vocabulary'){
return true;
}
return review_statistics.reading_correct <= filterValue;
}
// END Reading correct answers
// BEGIN Meaning incorrect answers
let meaningIncorAnsGteqFilterHover_tip = 'Selects items where the number of incorrect\nanswers for Meaning is >= this value.';
let meaningIncorAnsLteqFilterHover_tip = 'Selects items where the number of incorrect\nanswers for Meaning is <= this value.';
function registerMeaningIncorAnsGteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[meaningIncorAnsGteqFilterName] = {
type: 'number',
label: 'Meaning Incor. Ans. >=',
default: 0,
filter_func: meaningIncorAnsGteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: meaningIncorAnsGteqFilterHover_tip,
};
}
function meaningIncorAnsGteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
return review_statistics.meaning_incorrect >= filterValue;
}
function registerMeaningIncorAnsLteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[meaningIncorAnsLteqFilterName] = {
type: 'number',
label: 'Meaning Incor. Ans. <=',
default: 100,
filter_func: meaningIncorAnsLteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: meaningIncorAnsLteqFilterHover_tip,
};
}
function meaningIncorAnsLteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
return review_statistics.meaning_incorrect <= filterValue;
}
// END Meaning incorrect answers
// BEGIN Reading incorrect answers
let readingIncorAnsGteqFilterHover_tip = 'Selects items where the number of incorrect\nanswers for Reading is >= this value.';
let readingIncorAnsLteqFilterHover_tip = 'Selects items where the number of incorrect\nanswers for Reading is <= this value.';
function registerReadingIncorAnsGteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[readingIncorAnsGteqFilterName] = {
type: 'number',
label: 'Reading Incor. Ans. >=',
default: 0,
filter_func: readingIncorAnsGteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: readingIncorAnsGteqFilterHover_tip,
};
}
function readingIncorAnsGteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
if (item.object === 'radical' || item.object === 'kana_vocabulary'){
return true;
}
return review_statistics.reading_incorrect >= filterValue;
}
function registerReadingIncorAnsLteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[readingIncorAnsLteqFilterName] = {
type: 'number',
label: 'Reading Incor. Ans. <=',
default: 100,
filter_func: readingIncorAnsLteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: readingIncorAnsLteqFilterHover_tip,
};
}
function readingIncorAnsLteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
if (item.object === 'radical' || item.object === 'kana_vocabulary'){
return true;
}
return review_statistics.reading_incorrect <= filterValue;
}
// END Reading incorrect answers
// BEGIN Total correct answers
let totalCorAnsGteqFilterHover_tip = 'Selects items where the total number\nof correct answers is >= this value.';
let totalCorAnsLteqFilterHover_tip = 'Selects items where the total number\nof correct answers is <= this value.';
function registerTotalCorAnsGteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[totalCorAnsGteqFilterName] = {
type: 'number',
label: 'Total Cor. Ans. >=',
default: 0,
filter_func: totalCorAnsGteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: totalCorAnsGteqFilterHover_tip,
};
}
function totalCorAnsGteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
if (item.object === 'radical' || item.object === 'kana_vocabulary'){
return review_statistics.meaning_correct >= filterValue;
}
return review_statistics.meaning_correct + review_statistics.reading_correct >= filterValue;
}
function registerTotalCorAnsLteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[totalCorAnsLteqFilterName] = {
type: 'number',
label: 'Total Cor. Ans. <=',
default: 100,
filter_func: totalCorAnsLteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: totalCorAnsLteqFilterHover_tip,
};
}
function totalCorAnsLteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
if (item.object === 'radical' || item.object === 'kana_vocabulary'){
return review_statistics.meaning_correct <= filterValue;
}
return review_statistics.meaning_correct + review_statistics.reading_correct <= filterValue;
}
// END Total correct answers
// BEGIN Number of reviews
// The number of reviews is always equal to the total correct answers because
// you need to answer correctly exactly once to terminate a review
// Therefore this is the same filters as Total correct answer with a different user
// interface to inform the user of what they are doing
let numberReviewsGteqFilterHover_tip = 'Selects items where the total number\nof reviews is >= this value.';
let numberReviewsLteqFilterHover_tip = 'Selects items where the total number\nof reviews is <= this value.';
function registerNumberReviewsGteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[numReviewGteqFilterName] = {
type: 'number',
label: 'Number of Reviews >=',
default: 0,
filter_func: totalCorAnsGteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: numberReviewsGteqFilterHover_tip,
};
}
function registerNumberReviewsLteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[numReviewsLteqFilterName] = {
type: 'number',
label: 'Number of Reviews <=',
default: 100,
filter_func: totalCorAnsLteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: numberReviewsLteqFilterHover_tip,
};
}
// END Number of reviews
// BEGIN Total incorrect answers
let totalIncorAnsGteqFilterHover_tip = 'Selects items where the total number\nof incorrect answers is >= this value.';
let totalIncorAnsLteqFilterHover_tip = 'Selects items where the total number\nof incorrect answers is <= this value.';
function registerTotalIncorAnsGteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[totalIncorAnsGteqFilterName] = {
type: 'number',
label: 'Total Incor. Ans. >=',
default: 0,
filter_func: totalIncorAnsGteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: totalIncorAnsGteqFilterHover_tip,
};
}
function totalIncorAnsGteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
if (item.object === 'radical' || item.object === 'kana_vocabulary'){
return review_statistics.meaning_incorrect >= filterValue;
}
return review_statistics.meaning_incorrect + review_statistics.reading_incorrect >= filterValue;
}
function registerTotalIncorAnsLteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[totalIncorAnsLteqFilterName] = {
type: 'number',
label: 'Total Incor. Ans. <=',
default: 100,
filter_func: totalIncorAnsLteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: totalIncorAnsLteqFilterHover_tip,
};
}
function totalIncorAnsLteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
if (item.object === 'radical' || item.object === 'kana_vocabulary'){
return review_statistics.meaning_incorrect <= filterValue;
}
return review_statistics.meaning_incorrect + review_statistics.reading_incorrect <= filterValue;
}
// END Total incorrect answers
//==============================================
// Percentages filters
//
// Needs rounding because otherwise user facing data is usually floored and inconsistencies in displayed data will occur
// Flooring is used instead of rounding because otherwise we could have 100% correct while missing some answers due to rounding
function percentageRounding(value){return Math.floor(value * 100)};
// BEGIN Percentage Total Correct
let percentageTotalCorGteqFilterHover_tip = 'Selects items where % of correct answers\non Total is >= this value.';
let percentageTotalCorLteqFilterHover_tip = 'Selects items where % of correct answers\non Total is <= this value.';
function registerPercentageTotalCorGteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[percentageTotalCorGteqFilterName] = {
type: 'number',
label: '%Total Correct >=',
default: 0,
filter_func: percentageTotalCorGteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: percentageTotalCorGteqFilterHover_tip,
};
}
function percentageTotalCorGteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
return review_statistics.percentage_correct >= filterValue;
}
function registerPercentageTotalCorLteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[percentageTotalCorLteqFilterName] = {
type: 'number',
label: '%Total Correct <=',
default: 100,
filter_func: percentageTotalCorLteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: percentageTotalCorLteqFilterHover_tip,
};
}
function percentageTotalCorLteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
return review_statistics.percentage_correct <= filterValue;
}
// END Percentage Total Correct
// BEGIN Percentage Meaning Correct
let percentageMeaningCorGteqFilterHover_tip = 'Selects items where % of correct answers\non Meaning is >= this value.';
let percentageMeaningCorLteqFilterHover_tip = 'Selects items where % of correct answers\non Meaning is <= this value.';
function registerPercentageMeaningCorGteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[percentageMeaningCorGteqFilterName] = {
type: 'number',
label: '%Meaning Correct >=',
default: 0,
filter_func: percentageMeaningCorGteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: percentageMeaningCorGteqFilterHover_tip,
};
}
function percentageMeaningCorGteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
return percentageRounding(review_statistics.meaning_correct / (review_statistics.meaning_correct + review_statistics.meaning_incorrect)) >= filterValue;
}
function registerPercentageMeaningCorLteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[percentageMeaningCorLteqFilterName] = {
type: 'number',
label: '%Meaning Correct <=',
default: 100,
filter_func: percentageMeaningCorLteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: percentageMeaningCorLteqFilterHover_tip,
};
}
function percentageMeaningCorLteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
return percentageRounding(review_statistics.meaning_correct / (review_statistics.meaning_correct + review_statistics.meaning_incorrect)) <= filterValue;
}
// END Percentage Meaning Correct
// BEGIN Percentage Reading Correct
let percentageReadingCorGteqFilterHover_tip = 'Selects items where % of correct answers\non Reading is >= this value.';
let percentageReadingCorLteqFilterHover_tip = 'Selects items where % of correct answers\non Reading is <= this value.';
function registerPercentageReadingCorGteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[percentageReadingCorGteqFilterName] = {
type: 'number',
label: '%Reading Correct >=',
default: 0,
filter_func: percentageReadingCorGteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: percentageReadingCorGteqFilterHover_tip,
};
}
function percentageReadingCorGteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
if (item.object === 'radical' || item.object === 'kana_vocabulary'){
return true;
}
return percentageRounding(review_statistics.reading_correct / (review_statistics.reading_correct + review_statistics.reading_incorrect)) >= filterValue;
}
function registerPercentageReadingCorLteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[percentageReadingCorLteqFilterName] = {
type: 'number',
label: '%Reading Correct <=',
default: 100,
filter_func: percentageReadingCorLteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: percentageReadingCorLteqFilterHover_tip,
};
}
function percentageReadingCorLteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
if (item.object === 'radical' || item.object === 'kana_vocabulary'){
return true;
}
return percentageRounding(review_statistics.reading_correct / (review_statistics.reading_correct + review_statistics.reading_incorrect)) <= filterValue;
}
// END Percentage Reading Correct
//======================================================
// Streak Filters
//
// Wanikani starts the streak count at 1, that is when the last review is failed, the streak is 1, not 0.
// User facing data is adjusted in Item Inspector to start the streak count at 0 because starting at 1 is not intuitive.
// The filters do so too because the filter value in the settings panel is also user facing data that may be correlated with Item Inspector data.
// This is done by adjusting the filter value through passing streakValueAdjustment to the filter_value_map: registering option.
// This adjustment is not made in leech calculations because a- this use of streaks is not user facing data - and b- there is an history of
// calculating leech values this way and it would be disruptive to change it.
function streakValueAdjustment(param){return param + 1};
// BEGIN Meaning Current Streak
let meaningCurStrGteqFilterHover_tip = 'Selects items where current Meaning streak is >= this value.';
let meaningCurStrLteqFilterHover_tip = 'Selects items where current Meaning streak is <= this value.';
function registerMeaningCurStrGteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[meaningCurStrGteqFilterName] = {
type: 'number',
label: 'Meaning Cur. Str. >=',
default: 0,
filter_value_map: streakValueAdjustment,
filter_func: meaningCurStrGteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: meaningCurStrGteqFilterHover_tip,
};
}
function meaningCurStrGteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
return review_statistics.meaning_current_streak >= filterValue;
}
function registerMeaningCurStrLteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[meaningCurStrLteqFilterName] = {
type: 'number',
label: 'Meaning Cur. Str. <=',
default: 100,
filter_value_map: streakValueAdjustment,
filter_func: meaningCurStrLteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: meaningCurStrLteqFilterHover_tip,
};
}
function meaningCurStrLteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
return review_statistics.meaning_current_streak <= filterValue;
}
// END Meaning Current Streak
// BEGIN Meaning Maximum Streak
let meaningMaxStrGteqFilterHover_tip = 'Selects items where maximum Meaning streak is >= this value.';
let meaningMaxStrLteqFilterHover_tip = 'Selects items where maximum Meaning streak is <= this value.';
function registerMeaningMaxStrGteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[meaningMaxStrGteqFilterName] = {
type: 'number',
label: 'Meaning Max. Str. >=',
default: 0,
filter_value_map: streakValueAdjustment,
filter_func: meaningMaxStrGteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: meaningMaxStrGteqFilterHover_tip,
};
}
function meaningMaxStrGteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
return review_statistics.meaning_max_streak >= filterValue;
}
function registerMeaningMaxStrLteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[meaningMaxStrLteqFilterName] = {
type: 'number',
label: 'Meaning Max. Str. <=',
default: 100,
filter_value_map: streakValueAdjustment,
filter_func: meaningMaxStrLteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: meaningMaxStrLteqFilterHover_tip,
};
}
function meaningMaxStrLteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
return review_statistics.meaning_max_streak <= filterValue;
}
// END Meaning Maximum Streak
// BEGIN Reading Current Streak
let readingCurStrGteqFilterHover_tip = 'Selects items where current Reading streak is >= this value.';
let readingCurStrLteqFilterHover_tip = 'Selects items where current Reading streak is <= this value.';
function registerReadingCurStrGteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[readingCurStrGteqFilterName] = {
type: 'number',
label: 'Reading Cur. Str. >=',
default: 0,
filter_value_map: streakValueAdjustment,
filter_func: readingCurStrGteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: readingCurStrGteqFilterHover_tip,
};
}
function readingCurStrGteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
if (item.object === 'radical' || item.object === 'kana_vocabulary'){
return true;
}
return review_statistics.reading_current_streak >= filterValue;
}
function registerReadingCurStrLteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[readingCurStrLteqFilterName] = {
type: 'number',
label: 'Reading Cur. Str. <=',
default: 100,
filter_value_map: streakValueAdjustment,
filter_func: readingCurStrLteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: readingCurStrLteqFilterHover_tip,
};
}
function readingCurStrLteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
if (item.object === 'radical' || item.object === 'kana_vocabulary'){
return true;
}
return review_statistics.reading_current_streak <= filterValue;
}
// END Reading Current Streak
// BEGIN Reading Maximum Streak
let readingMaxStrGteqFilterHover_tip = 'Selects items where maximum Reading streak is >= this value.';
let readingMaxStrLteqFilterHover_tip = 'Selects items where maximum Reading streak is <= this value.';
function registerReadingMaxStrGteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[readingMaxStrGteqFilterName] = {
type: 'number',
label: 'Reading Max. Str. >=',
default: 0,
filter_value_map: streakValueAdjustment,
filter_func: readingMaxStrGteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: readingMaxStrGteqFilterHover_tip,
};
}
function readingMaxStrGteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
if (item.object === 'radical' || item.object === 'kana_vocabulary'){
return true;
}
return review_statistics.reading_max_streak >= filterValue;
}
function registerReadingMaxStrLteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[readingMaxStrLteqFilterName] = {
type: 'number',
label: 'Reading Max. Str. <=',
default: 100,
filter_value_map: streakValueAdjustment,
filter_func: readingMaxStrLteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: readingMaxStrLteqFilterHover_tip,
};
}
function readingMaxStrLteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
if (item.object === 'radical' || item.object === 'kana_vocabulary'){
return true;
}
return review_statistics.reading_max_streak <= filterValue;
}
// END Reading Maximum Streak
// BEGIN Both Current Streaks
let bothCurStrGteqFilterHover_tip = 'Selects items where both current Meaning streak\nand current Reading streak are >= this value.';
let bothCurStrLteqFilterHover_tip = 'Selects items where both current Meaning streak\nand current Reading streak are <= this value.';
function registerBothCurStrGteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[bothCurStrGteqFilterName] = {
type: 'number',
label: 'Both Cur. Str. >=',
default: 0,
filter_value_map: streakValueAdjustment,
filter_func: bothCurStrGteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: bothCurStrGteqFilterHover_tip,
};
}
function bothCurStrGteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
if (item.object === 'radical' || item.object === 'kana_vocabulary'){
return review_statistics.meaning_current_streak >= filterValue;
} else {
return review_statistics.meaning_current_streak >= filterValue && review_statistics.reading_current_streak >= filterValue;
}
}
function registerBothCurStrLteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[bothCurStrLteqFilterName] = {
type: 'number',
label: 'Both Cur. Str. <=',
default: 100,
filter_value_map: streakValueAdjustment,
filter_func: bothCurStrLteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: bothCurStrLteqFilterHover_tip,
};
}
function bothCurStrLteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
if (item.object === 'radical' || item.object === 'kana_vocabulary'){
return review_statistics.meaning_current_streak <= filterValue;
} else {
return review_statistics.meaning_current_streak <= filterValue && review_statistics.reading_current_streak <= filterValue;
}
}
// END Both Current Streaks
// BEGIN Minimum Current Streaks
let minCurStrGteqFilterHover_tip = 'Selects items where the minimum of current Meaning streak\nand current Reading streak is >= this value.';
let minCurStrLteqFilterHover_tip = 'Selects items where the minimum of current Meaning streak\nand current Reading streak is <= this value.';
function registerMinCurStrGteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[minCurStrGteqFilterName] = {
type: 'number',
label: 'Minimum Cur. Str. >=',
default: 0,
filter_value_map: streakValueAdjustment,
filter_func: minCurStrGteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: minCurStrGteqFilterHover_tip,
};
}
function minCurStrGteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
if (item.object === 'radical' || item.object === 'kana_vocabulary'){
return review_statistics.meaning_current_streak >= filterValue;
} else {
return review_statistics.meaning_current_streak >= filterValue && review_statistics.reading_current_streak >= filterValue;
};
}
function registerMinCurStrLteqFilter() {
wkof.ItemData.registry.sources.wk_items.filters[minCurStrLteqFilterName] = {
type: 'number',
label: 'Minimum Cur. Str. <=',
default: 100,
filter_value_map: streakValueAdjustment,
filter_func: minCurStrLteqFilter,
set_options: function(options) { options.review_statistics = true; },
hover_tip: minCurStrLteqFilterHover_tip,
};
}
function minCurStrLteqFilter(filterValue, item) {
let review_statistics = item.review_statistics;
if (review_statistics === undefined) {
return false;
}
if (item.object === 'radical' || item.object === 'kana_vocabulary'){
return review_statistics.meaning_current_streak <= filterValue;
} else {
return review_statistics.meaning_current_streak <= filterValue || review_statistics.reading_current_streak <= filterValue;
}
}
// END Minimum Current Streaks
updateFiltersWhenReady();
})(window.wkof);