View difference between Paste ID: uUkmQqEt and LnH4gsaB
SHOW: | | - or go back to the newest paste.
1-
            let boxAttr = $('.catalog .box-item .box-heading');
1+
2
            let catalogTitle = [];
3
            if (JSON.parse(localStorage.getItem('requested-catalog-id')) != null) {
4
                catalog = JSON.parse(localStorage.getItem('requested-catalog-id'));
5
                catalogTitle = JSON.parse(localStorage.getItem('requested-catalog-title'));
6
            }
7
            $('.catalog .box-item .box-heading input[type=checkbox]').on('change', function () {
8
9-
                let id = boxAttr.attr('data-catalog-id');
9+
				// Dini ngalih ID ne bli, sing ngidang ngalih uli luar
10-
                let title = boxAttr.attr('data-catalog-title');
10+
                let $check = $(this); // Ne current checkbox ne;
11
				let $boxHeading = $check.closest('.box-heading'); // Ne box heading ane alih bli, sesuaikan jak DOM bli ditu.
12-
                let $check = $(this);
12+
13
				let id = $boxHeading.attr('data-catalog-id'); // Ne ID ne.
14
                let title = $boxHeading.attr('data-catalog-title'); // Ne Title ne.
15
16
                let showBigCheckBox = $(".catalog .box-heading span#" + id);
17
18
                // let checked = !!$check.val();
19
                
20
                let valueChecked = $check.val();
21
                let checked = valueChecked === $check.val();
22
                console.log(checked);
23
24
                if (checked) {
25
                    if (catalog.length >= 3) {
26
                        $('#staticBackdrop').modal({
27
                            keyboard: false,
28
                            static: true,
29
                            focus: true,
30
                            show: true,
31
                        });
32
                        return false;
33
                    } else {
34
                        catalog.push(id);
35
                        catalogTitle.push(title);
36
                        localStorage.setItem('requested-catalog-id', JSON.stringify(catalog));
37
                        localStorage.setItem('requested-catalog-title', JSON.stringify(catalogTitle));
38
                        showBigCheckBox.addClass('selected');
39
                    }
40
                } else {
41
                    catalog.splice($.inArray(id, catalog), 1);
42
                    catalogTitle.splice($.inArray(title, catalogTitle), 1);
43
                    localStorage.setItem('requested-catalog-id', JSON.stringify(catalog));
44
                    localStorage.setItem('requested-catalog-title', JSON.stringify(catalogTitle));
45
                    showBigCheckBox.removeClass('selected');
46
                }
47
            });