PageSourceSearch

https://smrs.ubd.edu.bn/cas/js/material.js

js ubd.edu.bn collected 2026-10-02 05:00:40 UTC 6,245 bytes, 181 lines download raw bytes

1let cas = {
2    init: () => {
3        cas.attachFields();
4        mdc.autoInit();
5    },
6    openMenu: () => {
7        const menu = new mdc.menu.MDCMenu(document.querySelector('.mdc-menu'));
8        menu.open = true;
9    },
10    attachFields: () => {
11        let divs = document.querySelectorAll('.mdc-text-field');
12        for (const div of divs) {
13            new mdc.textField.MDCTextField(div);
14            let field = mdc.textField.MDCTextField.attachTo(div);
15            if (div.classList.contains('caps-check')) {
16                field.foundation.adapter.registerInputInteractionHandler('keypress', cas.checkCaps);
17            }
18        }
19
20        let helpers = document.querySelectorAll('.mdc-text-field-helper-text');
21        for (const helper of helpers) {
22            new mdc.textField.MDCTextFieldHelperText(helper);
23        }
24        
25        let selectors = document.querySelectorAll('.mdc-select');
26        for (const selector of selectors) {
27            const select = new mdc.select.MDCSelect(selector);
28            select.listen('MDCSelect:change', () => {
29                $('#source').val(select.value);
30            });
31            $('#source').val(select.value);
32        }
33
34        let tooltips = document.querySelectorAll('.mdc-tooltip');
35        if (tooltips != null) {
36            tooltips.forEach(t => new mdc.tooltip.MDCTooltip(t))
37        }
38        let banners = document.querySelectorAll('.mdc-banner');
39        if (banners != null) {
40            banners.forEach(b => new mdc.banner.MDCBanner(b))
41        }
42        let dialogs = document.querySelectorAll('.mdc-dialog');
43        if (dialogs != null) {
44            dialogs.forEach(b => new mdc.dialog.MDCDialog.attachTo(b))
45        }
46
47        for (const el of document.querySelectorAll('.mdc-switch')) {
48            let switchElement = new mdc.switchControl.MDCSwitch(el);
49            const switchInputs = document.querySelectorAll(`input[data-switch-btn="${el.id}"]`);
50            if (switchInputs.length === 1) {
51                el.addEventListener('click', () => {
52                    const switchInput = switchInputs[0];
53                    console.log(`Clicked switch element "${switchInput.id}": ${switchElement.selected}`);
54                    switchInput.value = switchElement.selected;
55                });
56            }
57        }
58
59        for (const el of document.querySelectorAll('.mdc-menu')) {
60            new mdc.menu.MDCMenu(el);
61        }
62
63        for (const el of document.querySelectorAll('.mdc-linear-progress')) {
64            new mdc.linearProgress.MDCLinearProgress(el);
65        }
66
67        for (const el of document.querySelectorAll('.mdc-data-table')) {
68            new mdc.dataTable.MDCDataTable(el);
69        }
70        for (const el of document.querySelectorAll('.mdc-snackbar')) {
71            new mdc.snackbar.MDCSnackbar(el);
72        }
73
74        let elms = document.querySelectorAll('.mdc-tab-bar');
75        for (const elm of elms) {
76            let tabs = mdc.tabBar.MDCTabBar.attachTo(elm);
77
78            tabs.listen('MDCTabBar:activated', ev => {
79                let index = ev.detail.index;
80                $('.attribute-tab').addClass('d-none');
81                $(`#attribute-tab-${index}`).removeClass('d-none');
82            });
83            tabs.foundation.adapter.activateTabAtIndex(0);
84        }
85
86        for (const el of document.querySelectorAll('.mdc-fab')) {
87           new mdc.ripple.MDCRipple(el);
88        }
89
90    },
91    checkCaps: (ev) => {
92        let s = String.fromCharCode(ev.which);
93        if (s.toUpperCase() === s && s.toLowerCase() !== s && !ev.shiftKey) {
94            for (let el of document.getElementsByClassName("caps-warn")) {
95                el.classList.remove("caps-warn");
96                el.classList.add('caps-on');
97            }
98        } else {
99            for (let el of document.getElementsByClassName("caps-on")) {
100                el.classList.remove("caps-on");
101                el.classList.add('caps-warn');
102            }
103        }
104
105    },
106    openDialog: (id) => {
107        const dialog = new mdc.dialog.MDCDialog(document.getElementById(id));
108        dialog.open();
109        return false;
110    },
111};
112
113let header = {
114    init: () => {
115        header.attachTopbar();
116        mdc.autoInit();
117    },
118    attachDrawer: () => {
119        let elm = document.getElementById('app-drawer');
120        if (elm != null) {
121            let drawer = mdc.drawer.MDCDrawer.attachTo(elm);
122            let closeDrawer = evt => {
123                drawer.open = false;
124            };
125            drawer.foundation.handleScrimClick = closeDrawer;
126            document.onkeydown = evt => {
127                evt = evt || window.event;
128                if (evt.keyCode === 27) {
129                    closeDrawer();
130                }
131            };
132            header.drawer = drawer;
133            return drawer;
134        }
135        return undefined;
136    },
137    attachTopbar: drawer => {
138
139        drawer = header.attachDrawer();
140        let dialog = header.attachNotificationDialog();
141
142        if (drawer !== undefined) {
143            header.attachDrawerToggle(drawer);
144        }
145        if (dialog !== undefined) {
146            header.attachNotificationToggle(dialog);
147        }
148    },
149    attachDrawerToggle: drawer => {
150        let appBar = document.getElementById('app-bar');
151        if (appBar != null) {
152            let topAppBar = mdc.topAppBar.MDCTopAppBar.attachTo(appBar);
153            topAppBar.setScrollTarget(document.getElementById('main-content'));
154            topAppBar.listen('MDCTopAppBar:nav', () => {
155                drawer.open = !drawer.open;
156            });
157            return topAppBar;
158        }
159        return undefined;
160    },
161    attachNotificationDialog: () => {
162        let element = document.getElementById('cas-notification-dialog');
163        if (element != null) {
164            return mdc.dialog.MDCDialog.attachTo(element);
165        }
166        return undefined;
167    },
168    attachNotificationToggle: dialog => {
169        let btn = document.getElementById('cas-notifications-menu');
170        if (btn != null) {
171            btn.addEventListener('click', () => {
172                dialog.open();
173            });
174        }
175    }
176};
177
178document.addEventListener('DOMContentLoaded', () => {
179    cas.init();
180    header.init();
181});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.