├── assets
├── css
│ └── main.min.css
├── fonts
│ ├── inter-v12-latin-500.woff2
│ ├── inter-v12-latin-600.woff2
│ ├── inter-v12-latin-800.woff2
│ └── inter-v12-latin-regular.woff2
├── images
│ ├── apple-touch-icon.png
│ ├── banner-1544x500.png
│ ├── banner-772x250.png
│ ├── favicon.ico
│ ├── icon-128.png
│ ├── icon-128x128.png
│ ├── icon-16.png
│ ├── icon-192.png
│ ├── icon-196.png
│ ├── icon-256x256.png
│ ├── icon-32.png
│ ├── icon-48.png
│ ├── icon-96.png
│ ├── icon-og.png
│ ├── icon-rounded.png
│ ├── icon-square.png
│ ├── illustration-1.png
│ ├── illustration-1.svg
│ ├── illustration-and.png
│ ├── illustration-and.svg
│ ├── illustration-og.png
│ ├── probability-01.png
│ ├── probability-02.png
│ ├── probability-03.png
│ ├── probability-04.png
│ ├── probability-05.png
│ ├── probability-calculator-01.svg
│ ├── probability-calculator-02.svg
│ ├── probability-calculator-03.svg
│ ├── probability-calculator-04.svg
│ ├── probability-calculator-05.svg
│ ├── probability-calculator-06.svg
│ ├── probability-calculator-07.svg
│ ├── probability-calculator-08.svg
│ ├── screenshot-1.png
│ └── screenshot-2.png
└── js
│ ├── all-calculators.js
│ ├── app.js
│ ├── calculator.js
│ ├── chart.js
│ ├── datepicker.js
│ ├── dialog-table.js
│ ├── dropdown-icon.js
│ ├── fractions.js
│ ├── functions.js
│ ├── hourpicker.js
│ ├── lib
│ ├── air-datepicker.js
│ ├── chartjs
│ │ ├── chart.js
│ │ ├── chart.js.map
│ │ ├── chart.min.js
│ │ ├── chart.umd.js
│ │ ├── chart.umd.js.map
│ │ ├── chunks
│ │ │ ├── helpers.core.d.ts
│ │ │ ├── helpers.segment.js
│ │ │ └── helpers.segment.js.map
│ │ ├── helpers.d.ts
│ │ ├── helpers.js
│ │ ├── helpers.js.map
│ │ └── types.d.ts
│ ├── input-mask.min.js
│ ├── katex
│ │ ├── auto-render.min.js
│ │ ├── fonts
│ │ │ ├── KaTeX_AMS-Regular.ttf
│ │ │ ├── KaTeX_AMS-Regular.woff
│ │ │ ├── KaTeX_AMS-Regular.woff2
│ │ │ ├── KaTeX_Caligraphic-Bold.ttf
│ │ │ ├── KaTeX_Caligraphic-Bold.woff
│ │ │ ├── KaTeX_Caligraphic-Bold.woff2
│ │ │ ├── KaTeX_Caligraphic-Regular.ttf
│ │ │ ├── KaTeX_Caligraphic-Regular.woff
│ │ │ ├── KaTeX_Caligraphic-Regular.woff2
│ │ │ ├── KaTeX_Fraktur-Bold.ttf
│ │ │ ├── KaTeX_Fraktur-Bold.woff
│ │ │ ├── KaTeX_Fraktur-Bold.woff2
│ │ │ ├── KaTeX_Fraktur-Regular.ttf
│ │ │ ├── KaTeX_Fraktur-Regular.woff
│ │ │ ├── KaTeX_Fraktur-Regular.woff2
│ │ │ ├── KaTeX_Main-Bold.ttf
│ │ │ ├── KaTeX_Main-Bold.woff
│ │ │ ├── KaTeX_Main-Bold.woff2
│ │ │ ├── KaTeX_Main-BoldItalic.ttf
│ │ │ ├── KaTeX_Main-BoldItalic.woff
│ │ │ ├── KaTeX_Main-BoldItalic.woff2
│ │ │ ├── KaTeX_Main-Italic.ttf
│ │ │ ├── KaTeX_Main-Italic.woff
│ │ │ ├── KaTeX_Main-Italic.woff2
│ │ │ ├── KaTeX_Main-Regular.ttf
│ │ │ ├── KaTeX_Main-Regular.woff
│ │ │ ├── KaTeX_Main-Regular.woff2
│ │ │ ├── KaTeX_Math-BoldItalic.ttf
│ │ │ ├── KaTeX_Math-BoldItalic.woff
│ │ │ ├── KaTeX_Math-BoldItalic.woff2
│ │ │ ├── KaTeX_Math-Italic.ttf
│ │ │ ├── KaTeX_Math-Italic.woff
│ │ │ ├── KaTeX_Math-Italic.woff2
│ │ │ ├── KaTeX_SansSerif-Bold.ttf
│ │ │ ├── KaTeX_SansSerif-Bold.woff
│ │ │ ├── KaTeX_SansSerif-Bold.woff2
│ │ │ ├── KaTeX_SansSerif-Italic.ttf
│ │ │ ├── KaTeX_SansSerif-Italic.woff
│ │ │ ├── KaTeX_SansSerif-Italic.woff2
│ │ │ ├── KaTeX_SansSerif-Regular.ttf
│ │ │ ├── KaTeX_SansSerif-Regular.woff
│ │ │ ├── KaTeX_SansSerif-Regular.woff2
│ │ │ ├── KaTeX_Script-Regular.ttf
│ │ │ ├── KaTeX_Script-Regular.woff
│ │ │ ├── KaTeX_Script-Regular.woff2
│ │ │ ├── KaTeX_Size1-Regular.ttf
│ │ │ ├── KaTeX_Size1-Regular.woff
│ │ │ ├── KaTeX_Size1-Regular.woff2
│ │ │ ├── KaTeX_Size2-Regular.ttf
│ │ │ ├── KaTeX_Size2-Regular.woff
│ │ │ ├── KaTeX_Size2-Regular.woff2
│ │ │ ├── KaTeX_Size3-Regular.ttf
│ │ │ ├── KaTeX_Size3-Regular.woff
│ │ │ ├── KaTeX_Size3-Regular.woff2
│ │ │ ├── KaTeX_Size4-Regular.ttf
│ │ │ ├── KaTeX_Size4-Regular.woff
│ │ │ ├── KaTeX_Size4-Regular.woff2
│ │ │ ├── KaTeX_Typewriter-Regular.ttf
│ │ │ ├── KaTeX_Typewriter-Regular.woff
│ │ │ └── KaTeX_Typewriter-Regular.woff2
│ │ ├── katex.min.css
│ │ └── katex.min.js
│ ├── lazysizes.min.js
│ └── math.min.js
│ ├── mask.js
│ ├── module.js
│ ├── options.js
│ ├── themes.js
│ └── timepicker.js
├── ci_probability_calculator.php
├── index.html
├── plugin.php
├── readme.md
└── readme.txt
/assets/fonts/inter-v12-latin-500.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/fonts/inter-v12-latin-500.woff2
--------------------------------------------------------------------------------
/assets/fonts/inter-v12-latin-600.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/fonts/inter-v12-latin-600.woff2
--------------------------------------------------------------------------------
/assets/fonts/inter-v12-latin-800.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/fonts/inter-v12-latin-800.woff2
--------------------------------------------------------------------------------
/assets/fonts/inter-v12-latin-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/fonts/inter-v12-latin-regular.woff2
--------------------------------------------------------------------------------
/assets/images/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/apple-touch-icon.png
--------------------------------------------------------------------------------
/assets/images/banner-1544x500.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/banner-1544x500.png
--------------------------------------------------------------------------------
/assets/images/banner-772x250.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/banner-772x250.png
--------------------------------------------------------------------------------
/assets/images/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/favicon.ico
--------------------------------------------------------------------------------
/assets/images/icon-128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/icon-128.png
--------------------------------------------------------------------------------
/assets/images/icon-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/icon-128x128.png
--------------------------------------------------------------------------------
/assets/images/icon-16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/icon-16.png
--------------------------------------------------------------------------------
/assets/images/icon-192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/icon-192.png
--------------------------------------------------------------------------------
/assets/images/icon-196.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/icon-196.png
--------------------------------------------------------------------------------
/assets/images/icon-256x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/icon-256x256.png
--------------------------------------------------------------------------------
/assets/images/icon-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/icon-32.png
--------------------------------------------------------------------------------
/assets/images/icon-48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/icon-48.png
--------------------------------------------------------------------------------
/assets/images/icon-96.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/icon-96.png
--------------------------------------------------------------------------------
/assets/images/icon-og.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/icon-og.png
--------------------------------------------------------------------------------
/assets/images/icon-rounded.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/icon-rounded.png
--------------------------------------------------------------------------------
/assets/images/icon-square.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/icon-square.png
--------------------------------------------------------------------------------
/assets/images/illustration-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/illustration-1.png
--------------------------------------------------------------------------------
/assets/images/illustration-and.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/illustration-and.png
--------------------------------------------------------------------------------
/assets/images/illustration-og.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/illustration-og.png
--------------------------------------------------------------------------------
/assets/images/probability-01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/probability-01.png
--------------------------------------------------------------------------------
/assets/images/probability-02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/probability-02.png
--------------------------------------------------------------------------------
/assets/images/probability-03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/probability-03.png
--------------------------------------------------------------------------------
/assets/images/probability-04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/probability-04.png
--------------------------------------------------------------------------------
/assets/images/probability-05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/probability-05.png
--------------------------------------------------------------------------------
/assets/images/probability-calculator-01.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/images/probability-calculator-02.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/images/probability-calculator-03.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/images/probability-calculator-04.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/images/probability-calculator-05.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/images/probability-calculator-06.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/images/probability-calculator-07.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/images/probability-calculator-08.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/assets/images/screenshot-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/screenshot-1.png
--------------------------------------------------------------------------------
/assets/images/screenshot-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pub-calculator-io/probability-calculator/272f21fc4869f7f83fe8a121a44a1e04cddfcaf3/assets/images/screenshot-2.png
--------------------------------------------------------------------------------
/assets/js/app.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | window._ = document.getElementById.bind(document);
4 | window.$ = document.querySelector.bind(document);
5 | window.$$ = document.querySelectorAll.bind(document);
6 |
7 | console.log('Script is OK! ༼ つ ◕_◕ ༽つ')
8 | // IS MAIN PAGE
9 | // if(window.location.pathname === '/') document.body.classList.add('isMainPage')
10 |
11 | // DIALOG TABLE
12 | if(document.querySelector('.result-table__dialog')) {
13 | import('./dialog-table.js').then(e => {
14 | console.log("Dialog table loaded (づ ◕‿◕ )づ")
15 | }).catch(e => {
16 | console.log("Sorry, dialog tables not loaded (ಥ﹏ಥ)", e)
17 | })
18 | }
19 | // MASK
20 | if(document.querySelector('[data-inputmask]')) {
21 | import('./mask.js').then(e => {
22 | console.log("Mask loaded (づ ◕‿◕ )づ")
23 | }).catch(e => {
24 | console.log("Sorry, masks not loaded (ಥ﹏ಥ)", e)
25 | })
26 | }
27 | // DATEPICKER
28 | if(document.querySelector('.datepicker')) {
29 | import('./datepicker.js').then(e => {
30 | console.log("Datepicker loaded (づ ◕‿◕ )づ")
31 | }).catch(e => {
32 | console.log("Sorry, datepicker not loaded (ಥ﹏ಥ)", e)
33 | })
34 | }
35 | // TIMEPICKER
36 | if(document.querySelector('.timepicker-input')) {
37 | import('./timepicker.js').then(e => {
38 | console.log("Timepicker loaded (づ ◕‿◕ )づ")
39 | }).catch(e => {
40 | console.log("Sorry, timepicker not loaded (ಥ﹏ಥ)", e)
41 | })
42 | }
43 | // HOURPICKER
44 | if(document.querySelector('.hourpicker-input')) {
45 | import('./hourpicker.js').then(e => {
46 | console.log("Hourpicker loaded (づ ◕‿◕ )づ")
47 | }).catch(e => {
48 | console.log("Sorry, Hourpicker not loaded (ಥ﹏ಥ)", e)
49 | })
50 | }
51 | // OPTIONS
52 | if(document.querySelector('.calculator-content--options')) {
53 | import('./options.js').then(e => {
54 | console.log("Options loaded (づ ◕‿◕ )づ")
55 | }).catch(e => {
56 | console.log("Sorry, options not loaded (ಥ﹏ಥ)", e)
57 | })
58 | }
59 | // ICON DROPDOWN
60 | if(document.querySelector('.dropdown-icon')) {
61 | import('./dropdown-icon.js').then(e => {
62 | console.log("Dropdown-icon loaded (づ ◕‿◕ )づ")
63 | }).catch(e => {
64 | console.log("Sorry, dropdown-icon not loaded (ಥ﹏ಥ)", e)
65 | })
66 | }
67 |
68 | // MODAL
69 | const MODAL_OPENERS = document.querySelectorAll('.js-modal-open')
70 | const MODAL_CLOSERS = document.querySelectorAll('.js-modal-close')
71 | const MODAL_WINDOW = document.querySelector('.modal-window')
72 |
73 | let currentShare = 0
74 | let isOpenPopupHeader = false;
75 | let focusedElement = 0;
76 |
77 | const closeAll = () => {
78 | MODAL_SEARCH.value = ''
79 | MODAL_SEARCH_LIST.classList.remove('modal-search__list--error')
80 | MODAL_SEARCH_LIST.classList.remove('modal-search__list--active')
81 | MODAL_OPENERS.forEach(MODAL_OPENER => {
82 | const MODAL_ID = MODAL_OPENER.getAttribute('data-modal')
83 | const MODAL = document.querySelector(`.modal-${MODAL_ID}`)
84 | MODAL.classList.remove(`modal-${MODAL_ID}--active`)
85 | })
86 | }
87 |
88 | window.addEventListener('click', (e) => {
89 | let controllerTheme = document.querySelector('#popup-theme')
90 | let controllerLang = document.querySelector('#popup-lang')
91 | if(isOpenPopupHeader && !(e.composedPath().includes(controllerLang) || e.composedPath().includes(controllerTheme))) {
92 | isOpenPopupHeader = false
93 | document.querySelector('.modal-lang--active')?.classList.remove(`modal-lang--active`)
94 | document.querySelector('.modal-theme--active')?.classList.remove(`modal-theme--active`)
95 | }
96 | })
97 |
98 | window.addEventListener('keydown', (e) => {
99 | if(e.key === 'Escape') {
100 | MODAL_WINDOW.classList.remove('modal-window--active')
101 | closeAll()
102 | }
103 |
104 | if((e.metaKey && e.key === 'k') || (e.ctrlKey && e.key === 'k')) {
105 | closeAll();
106 | $('.modal-search__input').focus();
107 | MODAL_WINDOW.classList.add(`modal-window--active`)
108 | $('.modal-search').classList.toggle(`modal-search--active`);
109 | }
110 |
111 | if(!MODAL_WINDOW) return;
112 |
113 | if(e.key === 'ArrowUp') {
114 | let listItem = [...MODAL_SEARCH_LIST_CONTENT.children]
115 | if(focusedElement - 1 < 0) {
116 | focusedElement = listItem.length - 1
117 | } else {
118 | focusedElement--
119 | }
120 | listItem[focusedElement]?.focus()
121 | // listItem[focusedElement].scrollIntoView(true)
122 | }
123 |
124 | if(e.key === 'ArrowDown') {
125 | let listItem = [...MODAL_SEARCH_LIST_CONTENT.children]
126 | listItem[focusedElement]?.focus()
127 | if(focusedElement + 1 > listItem.length - 1) {
128 | focusedElement = 0
129 | } else {
130 | focusedElement++
131 | }
132 | }
133 | })
134 |
135 | if(MODAL_WINDOW) {
136 | MODAL_WINDOW.addEventListener('click', (e) => {
137 | if(e.target.classList.contains('modal-window')) {
138 | MODAL_WINDOW.classList.remove(`modal-window--active`)
139 | MODAL_WINDOW.classList.remove(`modal-window--active-mini`)
140 | closeAll()
141 | }
142 | })
143 | }
144 | if(MODAL_OPENERS.length > 0) {
145 | MODAL_OPENERS.forEach(MODAL_OPENER => {
146 | MODAL_OPENER.addEventListener('click', () => {
147 | const MODAL_ID = MODAL_OPENER.getAttribute('data-modal')
148 | const MODAL = document.querySelector(`.modal-${MODAL_ID}`)
149 |
150 | closeAll();
151 |
152 | if(MODAL_ID !== 'lang' && MODAL_ID !== 'theme') MODAL_WINDOW.classList.toggle(`modal-window--active`)
153 | else isOpenPopupHeader = true
154 |
155 | if(MODAL_ID === 'search') document.querySelector('.modal-search__input').focus()
156 | if(MODAL_ID === 'share') {
157 | console.log($('.modal-share__textarea').value)
158 | $$('.modal-share__textarea')[currentShare].focus()
159 | $$('.modal-share__textarea')[currentShare].setSelectionRange(0, $$('.modal-share__textarea')[currentShare].value.length)
160 | }
161 |
162 | MODAL.classList.toggle(`modal-${MODAL_ID}--active`)
163 | })
164 | })
165 | }
166 | if(MODAL_CLOSERS.length > 0) {
167 | MODAL_CLOSERS.forEach(MODAL_CLOSER => {
168 | MODAL_CLOSER.addEventListener('click', () => {
169 | const MODAL_ID = MODAL_CLOSER.getAttribute('data-modal')
170 | const MODAL = document.querySelector(`.modal-${MODAL_ID}`)
171 |
172 | closeAll();
173 |
174 | if(MODAL_ID !== 'lang' && MODAL_ID !== 'theme') MODAL_WINDOW.classList.toggle(`modal-window--active`)
175 | else isOpenPopupHeader = true
176 |
177 | MODAL.classList.remove(`modal-${MODAL_ID}--active`)
178 | })
179 | })
180 | }
181 |
182 | // THEME
183 | const light = document.querySelectorAll('.light-theme');
184 | const dark = document.querySelectorAll('.dark-theme');
185 | const system = document.querySelectorAll('.system-theme');
186 |
187 | light.forEach((i) =>
188 | i.addEventListener('click', () => {
189 | document.documentElement.classList = '';
190 | localStorage.setItem('theme', 'light');
191 | setActiveThemeButton('light')
192 | if(switchTheme !== null) {
193 | if(typeof switchTheme === 'object') {
194 | switchTheme.forEach(element => element('light'))
195 | } else {
196 | switchTheme('light')
197 | }
198 | }
199 | }),
200 | );
201 | dark.forEach((i) =>
202 | i.addEventListener('click', () => {
203 | document.documentElement.classList = 'dark';
204 | localStorage.setItem('theme', 'dark');
205 | setActiveThemeButton('dark')
206 | if(switchTheme !== null) {
207 | if(typeof switchTheme === 'object') {
208 | switchTheme.forEach(element => element('dark'))
209 | } else {
210 | switchTheme('dark')
211 | }
212 | }
213 | }),
214 | );
215 | system.forEach((i) =>
216 | i.addEventListener('click', () => {
217 | document.documentElement.classList = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : '';
218 | localStorage.setItem('theme', 'system');
219 | setActiveThemeButton('system')
220 | if(switchTheme !== null) {
221 | if(typeof switchTheme === 'object') {
222 | switchTheme.forEach(element => element(window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'))
223 | } else {
224 | switchTheme(window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')
225 | }
226 | }
227 | }),
228 | );
229 |
230 | // SEARCH
231 | const MODAL_SEARCH = document.querySelector('.modal-search__input')
232 | const MODAL_SEARCH_LIST = document.querySelector('.modal-search__list')
233 | const MODAL_SEARCH_LIST_CONTENT = document.querySelector('.modal-search__list-content')
234 |
235 | if(MODAL_SEARCH) MODAL_SEARCH.addEventListener('input', (e) => {
236 | focusedElement = 0
237 | if(e.target.value.length > 0) {
238 | const FILTERED_JSON = JSON_CALCULATORS.filter(CALCULATOR => {
239 | return (CALCULATOR.description.toLowerCase().match(e.target.value.toLowerCase()) !== null) ||
240 | CALCULATOR.title.toLowerCase().match(e.target.value.toLowerCase()) !== null;
241 | })
242 | if(FILTERED_JSON.length > 0) {
243 | MODAL_SEARCH_LIST.classList.remove('modal-search__list--error')
244 | MODAL_SEARCH_LIST.classList.add('modal-search__list--active')
245 | MODAL_SEARCH_LIST_CONTENT.innerHTML = ''
246 | FILTERED_JSON.forEach(CALCULATOR => {
247 | let calculatorWrapper = document.createElement('a')
248 | calculatorWrapper.classList.add('modal-search-item')
249 | calculatorWrapper.href = CALCULATOR.uri
250 |
251 | let calculatorImg = document.createElement('img')
252 | calculatorImg.classList.add('modal-search-item__img')
253 | calculatorImg.src = CALCULATOR.image
254 |
255 | let calculatorTitle = document.createElement('span')
256 | calculatorTitle.classList.add('modal-search-item__text')
257 | calculatorTitle.innerText = CALCULATOR.title
258 |
259 | calculatorWrapper.append(calculatorImg, calculatorTitle)
260 | MODAL_SEARCH_LIST_CONTENT.append(calculatorWrapper)
261 | })
262 | } else {
263 | MODAL_SEARCH_LIST_CONTENT.innerHTML = ''
264 | MODAL_SEARCH_LIST.classList.remove('modal-search__list--active')
265 | MODAL_SEARCH_LIST.classList.add('modal-search__list--error')
266 | }
267 | } else {
268 | MODAL_SEARCH_LIST_CONTENT.innerHTML = ''
269 | MODAL_SEARCH_LIST.classList.remove('modal-search__list--active')
270 | MODAL_SEARCH_LIST.classList.remove('modal-search__list--error')
271 | }
272 | })
273 |
274 | // LANG
275 | const LANG_SELECTS = document.querySelectorAll('.header-lang__select')
276 |
277 | if (LANG_SELECTS){
278 | let langIsEng = true
279 |
280 | for (const LANG_SELECT of LANG_SELECTS) {
281 | if(LANG_SELECT.innerText !== 'ENG' && window.location.href.match(LANG_SELECT.href) !== null) {
282 | LANG_SELECT.classList.add('header-lang__select--active')
283 | langIsEng = false
284 | }
285 | }
286 |
287 | if(langIsEng) LANG_SELECTS[0]?.classList?.add('header-lang__select--active')
288 | }
289 |
290 | // SHARE
291 | $$('.modal-share__button').forEach((button,index) => {
292 | button.addEventListener('click', () => {
293 | $$('.modal-share__button').forEach(i => i.classList.remove('modal-share__button--active'))
294 | $$('.modal-share__content').forEach(i => i.classList.remove('modal-share__content--active'))
295 | button.classList.add('modal-share__button--active')
296 | $$('.modal-share__content')[index].classList.add('modal-share__content--active')
297 | $$('.modal-share__textarea')[index].setSelectionRange(0, $$('.modal-share__textarea')[index].value.length)
298 | currentShare = index
299 | })
300 | })
301 |
302 | window.copyWidget = function (button) {
303 | button.classList.add('button--copy-active')
304 | navigator.clipboard.writeText($$('.modal-share__textarea')[currentShare].value)
305 | setTimeout(() => {
306 | button.classList.remove('button--copy-active')
307 | }, 1000)
308 | }
309 |
310 | window.now = function (suffix = 0){
311 | let date = new Date();
312 | date.setDate(date.getDate() + suffix);
313 | return ("0" + date.getHours()).slice(-2) + ':' + ("0" + date.getMinutes()).slice(-2) + ':' + ("0" + date.getSeconds()).slice(-2)
314 | }
315 |
316 | if(window.innerWidth < 1024){
317 | $$('.calculator-content .button--primary').forEach((button) => {
318 | button.addEventListener('click', () => {
319 | let scrollValue = _('result-container').offsetTop;
320 | window.scrollTo({ top: scrollValue, behavior: 'smooth'});
321 | })
322 | });
323 | }
324 |
--------------------------------------------------------------------------------
/assets/js/calculator.js:
--------------------------------------------------------------------------------
1 | function calculate(){
2 | // 1. init & validate
3 | const type = input.get('type').raw();
4 | let pa=null, pb=null, paNot=null, pbNot=null, paAndPb=null,
5 | paOrPb=null, paXorPb=null, paNorPb=null, paNotPb=null, pbNotPa=null,
6 | result, confidenceIntervals;
7 | const events = {
8 | "A: P(A)": 'pa',
9 | "B: P(B)": 'pb',
10 | "A NOT occuring: P(A')": 'paNot',
11 | "B NOT occuring: P(B')": 'pbNot',
12 | "A and B both occuring: P(A∩B)": 'paAndPb',
13 | "A or B or both occur: P(A∪B)": 'paOrPb',
14 | "A or B occurs but NOT both: P(AΔB)": 'paXorPb',
15 | "Neither A nor B occuring: P((A∪B)')": 'paNorPb',
16 | }
17 |
18 | // 2. calculate
19 | const calcProbabilities = () => {
20 | paNot = calc('1-pa',{pa,pb});
21 | pbNot = calc('1-pb',{pa,pb});
22 | paAndPb = calc('pa*pb',{pa,pb});
23 | paOrPb = calc('pa+pb-pa*pb',{pa,pb});
24 | paXorPb = calc('pa+pb-2*pa*pb',{pa,pb});
25 | paNorPb = calc('1-pa-pb+pa*pb',{pa,pb});
26 | paNotPb = calc('pa*(1-pb)',{pa,pb});
27 | pbNotPa = calc('(1-pa)*pb',{pa,pb});
28 | };
29 | switch(type){
30 | case 'Probability of Two Events':
31 | pa = input.get('probability_a').probability().val();
32 | pb = input.get('probability_b').probability().val();
33 | if(!input.valid()) return;
34 |
35 | calcProbabilities();
36 | result = {paNot, pbNot, paAndPb, paOrPb, paXorPb, paNorPb, paNotPb, pbNotPa};
37 | break;
38 |
39 | case 'Probability Solver for Two Events':
40 | const eventA = events[input.get('probability_of_dropdown_a').raw()];
41 | const eventB = events[input.get('probability_of_dropdown_b').raw()];
42 | const pEventA = input.get('probability_of_a').probability().val();
43 | const pEventB = input.get('probability_of_b').probability().val();
44 | const fields = ['probability_of_dropdown_a','probability_of_dropdown_b'];
45 | const eventAB = [eventA,eventB];
46 | if(eventA == eventB){
47 | input.error(fields, "Provide 2 different events");
48 | }
49 | if(eventAB.includes('pa') && eventAB.includes('paNot')){
50 | input.error(fields, "Provide 2 values other than P(A) and P(A')");
51 | }
52 | if(eventAB.includes('pb') && eventAB.includes('pbNot')){
53 | input.error(fields, "Provide 2 values other than P(B) and P(B')");
54 | }
55 | if(eventAB.includes('paOrPb') && eventAB.includes('paNorPb')){
56 | input.error(fields, "Provide 2 values other than P(A∪B) and P((A∪B)')");
57 | }
58 | if(eventAB.includes('pa') && eventAB.includes('paXorPb')){
59 | input.error(fields, "Unable to find P(B) and the rest probabilities.");
60 | }
61 | if(eventAB.includes('pb') && eventAB.includes('paXorPb')){
62 | input.error(fields, "Unable to find P(A) and the rest probabilities.");
63 | }
64 | if(eventAB.includes('paNot') && eventAB.includes('paXorPb')){
65 | input.error(fields, "Unable to find P(B) and the rest probabilities.");
66 | }
67 | if(eventAB.includes('pbNot') && eventAB.includes('paXorPb')){
68 | input.error(fields, "Unable to find P(A) and the rest probabilities.");
69 | }
70 | if(!input.valid()) return;
71 |
72 | const getPEvent = (eventX, pEventX) => {
73 | switch(eventX){
74 | case 'pa': pa = pEventX; break;
75 | case 'pb': pb = pEventX; break;
76 | case 'paNot': paNot = pEventX; break;
77 | case 'pbNot': pbNot = pEventX; break;
78 | case 'paAndPb': paAndPb = pEventX; break;
79 | case 'paOrPb': paOrPb = pEventX; break;
80 | case 'paXorPb': paXorPb = pEventX; break;
81 | case 'paNorPb': paNorPb = pEventX; break;
82 | }
83 | };
84 | getPEvent(eventA, pEventA);
85 | getPEvent(eventB, pEventB);
86 |
87 | try{
88 | // solve
89 | if(paNot != null){
90 | pa = calc(`1-paNot`,{paNot});
91 | }
92 | if(pbNot != null){
93 | pb = calc(`1-pbNot`,{pbNot});
94 | }
95 |
96 | // pa
97 | if(pa != null){
98 | if(paAndPb != null){
99 | pb = calc(`paAndPb/pa`,{paAndPb,pa});
100 | }
101 | else if(paOrPb != null){
102 | pb = calc(`(paOrPb-pa)/(1-pa)`,{paOrPb,pa});
103 | }
104 | else if(paXorPb != null){
105 | pb = calc(`(paXorPb-pa)/(1-2*pa)`,{paXorPb,pa});
106 | }
107 | else if(paNorPb != null){
108 | pb = calc(`(1-paNorPb-pa)/(1-pa)`,{paNorPb,pa});
109 | }
110 | }
111 | // pb
112 | else if(pb != null){
113 | if(pb != null && paAndPb != null){
114 | pa = calc(`paAndPb/pb`,{paAndPb,pb});
115 | }
116 | else if(pb != null && paOrPb != null){
117 | pa = calc(`(paOrPb-pb)/(1-pb)`,{paOrPb,pb});
118 | }
119 | else if(pb != null && paXorPb != null){
120 | pa = calc(`(paXorPb-pb)/(1-2*pb)`,{paXorPb,pb});
121 | }
122 | else if(pb != null && paNorPb != null){
123 | pa = calc(`(1-paNorPb-pb)/(1-pb)`,{paNorPb,pb});
124 | }
125 | }
126 | // other
127 | else if(pa == null && pb == null){
128 | let q /* pa*pb */, p /* pa+pb */;
129 | if(paAndPb != null && paOrPb != null){
130 | q = calc(`paAndPb`,{paAndPb});
131 | p = calc(`paAndPb+paOrPb`,{paAndPb,paOrPb});
132 | }
133 | else if(paAndPb != null && paXorPb != null){
134 | q = calc(`paAndPb`,{paAndPb});
135 | p = calc(`2*paAndPb+paXorPb`,{paAndPb,paXorPb});
136 | }
137 | else if(paAndPb != null && paNorPb != null){
138 | q = calc(`paAndPb`,{paAndPb});
139 | p = calc(`paAndPb-paNorPb+1`,{paAndPb,paNorPb});
140 | }
141 | else if(paOrPb != null && paXorPb != null){
142 | q = calc(`paOrPb-paXorPb`,{paOrPb,paXorPb});
143 | p = calc(`2*paOrPb-paXorPb`,{paOrPb,paXorPb});
144 | }
145 | else if(paXorPb != null && paNorPb != null){
146 | q = calc(`1-paNorPb-paXorPb`,{paNorPb,paXorPb});
147 | p = calc(`paXorPb+2*q`,{paXorPb,q});
148 | }
149 | pa = calc(`(p-sqrt(p^2-4*q))/2`,{p,q});
150 | pb = calc(`(p+sqrt(p^2-4*q))/2`,{p,q});
151 | }
152 |
153 | calcProbabilities();
154 | result = [
155 | `Probability of A: P(A) = ${format(pa)}`,
156 | `Probability of B: P(B) = ${format(pb)}`,
157 | `Probability of A NOT occuring: P(A') = 1 - P(A) = ${format(paNot)}`,
158 | `Probability of B NOT occuring: P(B') = 1 - P(B) = ${format(pbNot)}`,
159 | `Probability of A and B both occuring: P(A∩B) = P(A) × P(B) = ${format(paAndPb)}`,
160 | `Probability that A or B or both occur: P(A∪B) = P(A) + P(B) - P(A∩B) = ${format(paOrPb)}`,
161 | `Probability that A or B occurs but NOT both: P(AΔB) = P(A) + P(B) - 2P(A∩B) = ${format(paXorPb)}`,
162 | `Probability of neither A nor B occuring: P((A∪B)') = 1 - P(A∪B) = ${format(paNorPb)}`,
163 | `Probability of A occuring but NOT B: P(A) × (1 - P(B)) = ${format(paNotPb)}`,
164 | `Probability of B occuring but NOT A: (1 - P(A)) × P(B) = ${format(pbNotPa)}`,
165 | ].join('
');
166 | } catch(e){
167 | input.exception(fields,e); return;
168 | }
169 | break;
170 |
171 | case 'Series of Independent Events':
172 | pa = input.get('probability_event_a').probability().val();
173 | pb = input.get('probability_event_b').probability().val();
174 | paRepeat = input.get('probability_repeat_a').natural().val();
175 | pbRepeat = input.get('probability_repeat_b').natural().val();
176 | if(!input.valid()) return;
177 |
178 | result = [
179 | `Probability of A occuring ${paRepeat} time(s) = ${pa}${paRepeat} = ` + format(calc(`${pa}^${paRepeat}`)),
180 | `Probability of A NOT occuring = (1-${pa})${paRepeat} = ` + format(calc(`(1-${pa})^${paRepeat}`)),
181 | `Probability of A occuring = 1-(1-${pa})${paRepeat} = ` + format(calc(`1-(1-${pa})^${paRepeat}`)),
182 | `Probability of B occuring ${pbRepeat} time(s) = ${pb}${pbRepeat} = ` + format(calc(`${pb}^${pbRepeat}`)),
183 | `Probability of B NOT occuring = (1-${pb})${pbRepeat} = ` + format(calc(`(1-${pb})^${pbRepeat}`)),
184 | `Probability of B occuring = 1-(1-${pb})${pbRepeat} = ` + format(calc(`1-(1-${pb})^${pbRepeat}`)),
185 | `Probability of A occuring ${paRepeat} time(s) and B occuring ${pbRepeat} time(s) = ${pa}${paRepeat} × ${pb}${pbRepeat} = ` + format(calc(`${pa}^${paRepeat}*${pb}^${pbRepeat}`)),
186 | `Probability of neither A nor B occuring = (1-${pa})${paRepeat} × (1-${pb})${pbRepeat} = ` + format(calc(`(1-${pa})^${paRepeat}*(1-${pb})^${pbRepeat}`)),
187 | `Probability of both A and B occuring = (1-(1-${pa})${paRepeat}) × (1-(1-${pb})${pbRepeat}) = ` + format(calc(`(1-(1-${pa})^${paRepeat})*(1-(1-${pb})^${pbRepeat})`)),
188 | `Probability of A occuring ${paRepeat} times but not B = ${pa}${paRepeat} × (1-${pb})${pbRepeat} = ` + format(calc(`${pa}^${paRepeat}*(1-${pb})^${pbRepeat}`)),
189 | `Probability of B occuring ${pbRepeat} times but not A = (1-${pa})${paRepeat} × ${pb}${pbRepeat} = ` + format(calc(`(1-${pa})^${paRepeat}*${pb}^${pbRepeat}`)),
190 | `Probability of A occuring but not B = (1-(1-${pa})${paRepeat}) × (1-${pb})${pbRepeat} = ` + format(calc(`(1-(1-${pa})^${paRepeat})*(1-${pb})^${pbRepeat}`)),
191 | `Probability of B occuring but not A = (1-${pa})${paRepeat} × (1-(1-${pb})${pbRepeat}) = ` + format(calc(`(1-${pa})^${paRepeat}*(1-(1-${pb})^${pbRepeat})`))
192 | ].join('
');
193 | break;
194 |
195 | case 'Normal Distribution':
196 | const m = input.get('probability_mean').number().val();
197 | const s = input.get('probability_deviation').positive().val();
198 | const lb = input.get('probability_lb').number().val();
199 | const rb = input.get('probability_rb').number().val();
200 | if(lb > rb) input.error('lb','Specify the left bound value less than or equal to the right bound value');
201 | if(!input.valid()) return;
202 |
203 | const z = [
204 | 0 , 0.00399, 0.00798, 0.01197, 0.01595, 0.01994, 0.02392, 0.0279 , 0.03188, 0.03586,
205 | 0.03983, 0.0438 , 0.04776, 0.05172, 0.05567, 0.05962, 0.06356, 0.06749, 0.07142, 0.07535,
206 | 0.07926, 0.08317, 0.08706, 0.09095, 0.09483, 0.09871, 0.10257, 0.10642, 0.11026, 0.11409,
207 | 0.11791, 0.12172, 0.12552, 0.1293 , 0.13307, 0.13683, 0.14058, 0.14431, 0.14803, 0.15173,
208 | 0.15542, 0.1591 , 0.16276, 0.1664 , 0.17003, 0.17364, 0.17724, 0.18082, 0.18439, 0.18793,
209 | 0.19146, 0.19497, 0.19847, 0.20194, 0.2054 , 0.20884, 0.21226, 0.21566, 0.21904, 0.2224 ,
210 | 0.22575, 0.22907, 0.23237, 0.23565, 0.23891, 0.24215, 0.24537, 0.24857, 0.25175, 0.2549 ,
211 | 0.25804, 0.26115, 0.26424, 0.2673 , 0.27035, 0.27337, 0.27637, 0.27935, 0.2823 , 0.28524,
212 | 0.28814, 0.29103, 0.29389, 0.29673, 0.29955, 0.30234, 0.30511, 0.30785, 0.31057, 0.31327,
213 | 0.31594, 0.31859, 0.32121, 0.32381, 0.32639, 0.32894, 0.33147, 0.33398, 0.33646, 0.33891,
214 | 0.34134, 0.34375, 0.34614, 0.34849, 0.35083, 0.35314, 0.35543, 0.35769, 0.35993, 0.36214,
215 | 0.36433, 0.3665 , 0.36864, 0.37076, 0.37286, 0.37493, 0.37698, 0.379 , 0.381 , 0.38298,
216 | 0.38493, 0.38686, 0.38877, 0.39065, 0.39251, 0.39435, 0.39617, 0.39796, 0.39973, 0.40147,
217 | 0.4032 , 0.4049 , 0.40658, 0.40824, 0.40988, 0.41149, 0.41308, 0.41466, 0.41621, 0.41774,
218 | 0.41924, 0.42073, 0.4222 , 0.42364, 0.42507, 0.42647, 0.42785, 0.42922, 0.43056, 0.43189,
219 | 0.43319, 0.43448, 0.43574, 0.43699, 0.43822, 0.43943, 0.44062, 0.44179, 0.44295, 0.44408,
220 | 0.4452 , 0.4463 , 0.44738, 0.44845, 0.4495 , 0.45053, 0.45154, 0.45254, 0.45352, 0.45449,
221 | 0.45543, 0.45637, 0.45728, 0.45818, 0.45907, 0.45994, 0.4608 , 0.46164, 0.46246, 0.46327,
222 | 0.46407, 0.46485, 0.46562, 0.46638, 0.46712, 0.46784, 0.46856, 0.46926, 0.46995, 0.47062,
223 | 0.47128, 0.47193, 0.47257, 0.4732 , 0.47381, 0.47441, 0.475 , 0.47558, 0.47615, 0.4767 ,
224 | 0.47725, 0.47778, 0.47831, 0.47882, 0.47932, 0.47982, 0.4803 , 0.48077, 0.48124, 0.48169,
225 | 0.48214, 0.48257, 0.483 , 0.48341, 0.48382, 0.48422, 0.48461, 0.485 , 0.48537, 0.48574,
226 | 0.4861 , 0.48645, 0.48679, 0.48713, 0.48745, 0.48778, 0.48809, 0.4884 , 0.4887, 0.48899,
227 | 0.48928, 0.48956, 0.48983, 0.4901 , 0.49036, 0.49061, 0.49086, 0.49111, 0.49134, 0.49158,
228 | 0.4918 , 0.49202, 0.49224, 0.49245, 0.49266, 0.49286, 0.49305, 0.49324, 0.49343, 0.49361,
229 | 0.49379, 0.49396, 0.49413, 0.4943 , 0.49446, 0.49461, 0.49477, 0.49492, 0.49506, 0.4952 ,
230 | 0.49534, 0.49547, 0.4956 , 0.49573, 0.49585, 0.49598, 0.49609, 0.49621, 0.49632, 0.49643,
231 | 0.49653, 0.49664, 0.49674, 0.49683, 0.49693, 0.49702, 0.49711, 0.4972 , 0.49728, 0.49736,
232 | 0.49744, 0.49752, 0.4976 , 0.49767, 0.49774, 0.49781, 0.49788, 0.49795, 0.49801, 0.49807,
233 | 0.49813, 0.49819, 0.49825, 0.49831, 0.49836, 0.49841, 0.49846, 0.49851, 0.49856, 0.49861,
234 | 0.49865, 0.49869, 0.49874, 0.49878, 0.49882, 0.49886, 0.49889, 0.49893, 0.49896, 0.499 ,
235 | 0.49903, 0.49906, 0.4991 , 0.49913, 0.49916, 0.49918, 0.49921, 0.49924, 0.49926, 0.49929,
236 | 0.49931, 0.49934, 0.49936, 0.49938, 0.4994 , 0.49942, 0.49944, 0.49946, 0.49948, 0.4995 ,
237 | 0.49952, 0.49953, 0.49955, 0.49957, 0.49958, 0.4996 , 0.49961, 0.49962, 0.49964, 0.49965,
238 | 0.49966, 0.49968, 0.49969, 0.4997 , 0.49971, 0.49972, 0.49973, 0.49974, 0.49975, 0.49976,
239 | 0.49977, 0.49978, 0.49978, 0.49979, 0.4998 , 0.49981, 0.49981, 0.49982, 0.49983, 0.49983,
240 | 0.49984, 0.49985, 0.49985, 0.49986, 0.49986, 0.49987, 0.49987, 0.49988, 0.49988, 0.49989,
241 | 0.49989, 0.4999 , 0.4999 , 0.4999 , 0.49991, 0.49991, 0.49992, 0.49992, 0.49992, 0.49992,
242 | 0.49993, 0.49993, 0.49993, 0.49994, 0.49994, 0.49994, 0.49994, 0.49995, 0.49995, 0.49995,
243 | 0.49995, 0.49995, 0.49996, 0.49996, 0.49996, 0.49996, 0.49996, 0.49996, 0.49997, 0.49997,
244 | 0.49997, 0.49997, 0.49997, 0.49997, 0.49997, 0.49997, 0.49998, 0.49998, 0.49998, 0.49998
245 | ];
246 | const l = calc(`(${lb}-${m})/${s}`);
247 | const r = calc(`(${rb}-${m})/${s}`);
248 | const zl = calc(`round(abs(${l}*100))<${z.length}`) ? z[calc(`round(abs(${l}*100))`)] : 0.5;
249 | const zr = calc(`round(abs(${r}*100))<${z.length}`) ? z[calc(`round(abs(${r}*100))`)] : 0.5;
250 | const p = r >=0 && l >=0 || r <= 0 && l <=0 ? calc(`abs(${zr}-${zl})`) : calc(`${zr}+${zl}`);
251 | const pNot = calc(`1-${p}`);
252 | const pLessLb = calc(`0.5 + ${l<=0?-zl:zl}`);
253 | const pMoreRb = calc(`0.5 + ${r>=0?-zr:zr}`);
254 | result = [
255 | `The probability between ${lb} and ${rb} is ${format(p)}`,
256 | `The probability outside of ${lb} and ${rb} is ${format(pNot)}`,
257 | `The probability of ${lb} or less (≤${lb}) is ${format(pLessLb)}`,
258 | `The probability of ${rb} or more (≥${rb}) is ${format(pMoreRb)}`
259 | ].join('
');
260 |
261 | const confidence = [0.6828, 0.80, 0.90, 0.95, 0.98, 0.99, 0.995, 0.998, 0.999, 0.9999, 0.99999];
262 | const n = [1, 1.281551565545, 1.644853626951, 1.959963984540, 2.326347874041, 2.575829303549, 2.807033768344, 3.090232306168, 3.290526731492, 3.890591886413, 4.417173413469];
263 | const range = n.map(n => calc(`format(${m}-${s}*${n},{precision:5,notation:'fixed'})`) + ' – ' + calc(`format(${m}+${s}*${n},{precision:5,notation:'fixed'})`));
264 | confidenceIntervals = confidence.map((c,i) => {
265 | return `
Hour
22 | 23 |:
25 |Minute
27 | 28 |(parentContext: P, context: T): P extends null ? T : P & T;
339 |
340 | /**
341 | * @alias Chart.helpers.math
342 | * @namespace
343 | */
344 | declare const PI: number;
345 | declare const TAU: number;
346 | declare const PITAU: number;
347 | declare const INFINITY: number;
348 | declare const RAD_PER_DEG: number;
349 | declare const HALF_PI: number;
350 | declare const QUARTER_PI: number;
351 | declare const TWO_THIRDS_PI: number;
352 | declare const log10: (x: number) => number;
353 | declare const sign: (x: number) => number;
354 | declare function almostEquals(x: number, y: number, epsilon: number): boolean;
355 | /**
356 | * Implementation of the nice number algorithm used in determining where axis labels will go
357 | */
358 | declare function niceNum(range: number): number;
359 | /**
360 | * Returns an array of factors sorted from 1 to sqrt(value)
361 | * @private
362 | */
363 | declare function _factorize(value: number): number[];
364 | declare function isNumber(n: unknown): n is number;
365 | declare function almostWhole(x: number, epsilon: number): boolean;
366 | /**
367 | * @private
368 | */
369 | declare function _setMinAndMaxByKey(array: Record Hour : Minute : Second {
4 | const OPTION_HEAD = option.querySelector('.calculator-content-head')
5 |
6 | OPTION_HEAD.addEventListener('click', (event) => {
7 |
8 | if(!event.composedPath().includes($('.js-add-button'))) {
9 | option.classList.toggle('calculator-content--active')
10 | }
11 | })
12 | })
--------------------------------------------------------------------------------
/assets/js/themes.js:
--------------------------------------------------------------------------------
1 | const setActiveThemeButton = (theme) => {
2 | document.querySelectorAll('.header-popup__button').forEach(button => {
3 | if(button.classList.contains(`${theme}-theme`)) button.classList.add('header-popup__button--active')
4 | else button.classList.remove('header-popup__button--active')
5 | })
6 | }
7 |
8 | switch (localStorage.getItem('theme')) {
9 | case 'light':
10 | document.documentElement.classList = '';
11 | console.log('Theme: Light');
12 | localStorage.setItem('theme', 'light');
13 | window.addEventListener('DOMContentLoaded', () => {
14 | setActiveThemeButton('light')
15 | })
16 | break;
17 | case 'dark':
18 | document.documentElement.classList = 'dark';
19 | console.log('Theme: Dark');
20 | localStorage.setItem('theme', 'dark');
21 | window.addEventListener('DOMContentLoaded', () => {
22 | setActiveThemeButton('dark')
23 | })
24 | break;
25 | case 'system':
26 | default:
27 | document.documentElement.classList = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : '';
28 | console.log('Theme: System');
29 | localStorage.setItem('theme', 'system');
30 | window.addEventListener('DOMContentLoaded', () => {
31 | setActiveThemeButton('system')
32 | })
33 | }
--------------------------------------------------------------------------------
/assets/js/timepicker.js:
--------------------------------------------------------------------------------
1 | const INPUTS = $$('.timepicker-input');
2 | let timepickerFormat = true
3 | let currentInput = {
4 | input: null,
5 | hour: null,
6 | minute: null,
7 | second: null,
8 | }
9 |
10 | function createTimepicker() {
11 | const TIMEPICKER = document.createElement('div');
12 | const {top, left} = currentInput.input.getBoundingClientRect()
13 | const {offsetHeight} = currentInput.input
14 | const VALUE = currentInput.input.value.split(':')
15 |
16 | TIMEPICKER.classList.add('timepicker');
17 | TIMEPICKER.innerHTML = `
18 | Probability Calculator';
20 | }
21 |
22 |
23 | add_shortcode( 'ci_probability_calculator', 'display_calcio_ci_probability_calculator' );
--------------------------------------------------------------------------------
/plugin.php:
--------------------------------------------------------------------------------
1 |
Probability Calculator';
20 | }
21 |
22 | add_shortcode( 'ci_probability_calculator', 'display_ci_probability_calculator' );
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # Probability Calculator Widget for WordPress
2 |
3 | The probability calculator can find two events' probability and the normal distribution probability. Learn more about probability's laws and calculations.
4 |
5 | 
6 |
7 | ## Installation
8 |
9 | 1. [Download](https://github.com/pub-calculator-io/probability-calculator/archive/refs/heads/master.zip) the ZIP file of this repository.
10 | 2. Upload the /probability-calculator-master/ folder to the /wp-content/plugins/ directory.
11 | 3. Activate the [Probability Calculator](https://www.calculator.io/probability-calculator/ "Probability Calculator Homepage") plugin through the "Plugins" menu in WordPress.
12 |
13 | ## Usage
14 | * Add the shortcode `[ci_probability_calculator]` to your page, post or sidebar.
15 | * Or add the following code: `` to your template where you would like the Probability Calculator to appear.
16 |
17 | ## Libraries in Use
18 | 1. https://mathjs.org/
19 | 2. https://katex.org/
20 | 3. https://github.com/aFarkas/lazysizes
21 | 4. https://github.com/RobinHerbots/Inputmask
22 | 5. https://air-datepicker.com/
23 | 6. https://www.chartjs.org/
24 |
--------------------------------------------------------------------------------
/readme.txt:
--------------------------------------------------------------------------------
1 | === CI Probability calculator ===
2 | Contributors: calculatorio
3 | Tags: odds probability calculator, winning and losing probability, odds and probability differences, calculating odds, probability of winning, probability of losing, odds for winning, odds against winning, event probability calculation, odds calculation methods
4 | Requires at least: 5.0
5 | Tested up to: 6.4.0
6 | Stable tag: 1.0.0
7 | License: GPLv2 or later
8 | License URI: https://www.gnu.org/licenses/gpl-2.0.html
9 |
10 | The probability calculator can find two events' probability and the normal distribution probability. Learn more about probability's laws and calculations.
11 |
12 | [https://www.calculator.io/probability-calculator/](https://www.calculator.io/probability-calculator/)
13 |
14 | == Usage ==
15 |
16 | Add the Probability Calculator shortcode to your page, post or sidebar:
17 |
18 | `[ci_probability_calculator]`
19 |
20 | Add the following code to your template where you would like the Probability Calculator to appear:
21 |
22 | ``
23 |
24 | == Screenshots ==
25 |
26 | 1. The Probability Calculator Input Form.
27 |
28 | == Installation ==
29 |
30 | 1. Upload the Probability Calculator /ci_probability_calculator/ folder to the /wp-content/plugins/ directory.
31 | 2. Activate the Probability Calculator plugin through the "Plugins" menu in WordPress.
32 |
33 | == Changelog ==
34 |
35 | = 1.0.0 =
36 | * Initial release of Probability Calculator
37 |
--------------------------------------------------------------------------------