-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
2267 lines (2034 loc) · 75.2 KB
/
index.html
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
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!-- Developer Notes 1:
- Creating a side bar icon which opens a side bar tab whose main function is to work like a smol wiki having
two tabs, one is example of usage and how it works.
- Another thing is to make the width 30% and make area outside of the side dark when opened.
-- (Give an option to make it normal for people having issues).
- Click outside should close the window or make it hidden.
-- a pin button can be used to pin it so it doesn't gives issues with clicking outside of the area
-->
<!-- Developer Notes 2:
- Functions will have their own seperate JS file.
-- Wellll, I will think about it
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Marginal Calculator</title>
<!-- Custom Styles -->
<link rel="stylesheet" href="css/global-styles.css" />
<link rel="stylesheet" href="css/custom-styles.css" />
<link rel="stylesheet" href="components/tabs.css" />
<link rel="icon" type="image/x-icon" href="components/favicon-1.ico" />
</head>
<body>
<div class="se-pre-con"></div>
<div class="flex horiz-center mg-d-1r">
<h1 style="color: #fff">Marginal Calculator</h1>
<!-- use storage session check if there is a session.
<span>
Cache Clear in case of new commit/change
<button onclick="window.location.reload(true)">Clear</button>
</span> -->
</div>
<!-- <div class="side_bar_tab"></div> -->
<div id="tabs">
<div class="tab">
<button
class="tablinks"
onclick="openTab(event, 'Marginal_Revenue_Tab')"
>
Marginal Revenue
</button>
<button class="tablinks" onclick="openTab(event, 'PED')">
Price Elasticity of Demand (PED)
</button>
<button class="tablinks" onclick="openTab(event, 'YED')">
Income Elasticity of Demand (YED)
</button>
<button class="tablinks" onclick="openTab(event, 'XED')">
Cross Price Elasticity of Demand (XED)
</button>
<button class="tablinks" onclick="openTab(event, 'PC')">
Alpha Feature
</button>
</div>
<!-- Marginal Revenue (MR) -->
<div id="Marginal_Revenue_Tab" class="tabcontent">
<div class="text_and_input">
<p class="margin-right-1rem">Expression</p>
<input
type="text"
value="49 + 8*q + 6*Q^2"
placeholder="49 + 8*q + 6*Q^2"
id="expression"
/>
</div>
<!-- 55 + 6*q - 7*q^2 + 3*q^3 === Q = 4 === 94 -->
<div class="text_and_input">
<p class="margin-right-1rem">Value of Q:</p>
<input type="text" value="9" placeholder="Value of Q" id="q_value" />
</div>
<button
style="margin-top: 6px"
class="calculate-button"
type="button"
class="calculate-button"
onclick="MRCheck()"
>
Calculate!
</button>
<div id="mr1" class="left-align">
<h2 id="derivation_h2"></h2>
<p id="derivative_step1" class="hide"></p>
<p id="derivative_step1_2" class="no-margin"></p>
<p id="derivative_step2" class="hide"></p>
<p id="derivative_step2_2" class="no-margin"></p>
</div>
<div id="mr2" class="left-align">
<h2 id="puttingValues_h2"></h2>
<p id="puttingValues_step1" class="hide"></p>
<p id="puttingValues_step1_1" class="no-margin"></p>
<p id="puttingValues_step1_2" class="no-margin"></p>
<p id="puttingValues_step2" class="hide"></p>
<p id="puttingValues_step2_1" class="no-margin"></p>
<span id="result"></span>
</div>
<div id="mr3" class="left-align">
<h2 id="Marginal_Conclusion_1"></h2>
<span id="Marginal_Conclusion_2"></span>
</div>
</div>
<!-- Price Elasticity of Demand (PED) -->
<div id="PED" class="tabcontent">
<div>
<p style="color: #d10000">
*Note: This feature is currently experimental and incomplete. Please
use YED and 2 as price of goods limit
</p>
<h1 style="font-size: 20px">Price Elasticity of Demand (PED)</h1>
<!-- Need of Values -->
<div id="checkPEDRequirements">
<span> Do you need to take out: </span>
<label id="ped_1_1">
<input type="checkbox" value="1" name="status" checked />
YED
</label>
<label id="ped_1_2">
<input type="checkbox" value="1" name="status" />
XED
</label>
<label id="ped_1_3">
<input type="checkbox" value="1" name="status" />
Percentage Change
</label>
</div>
<!-- HTML Selector: 1, 2, 3 -->
<div id="observe_ped_change">
<span>Price Goods Limit:</span>
<label>
<input type="radio" value="1" id="ped_1" name="status" checked />
1
</label>
<label>
<input type="radio" value="2" id="ped_2" name="status" />
2
</label>
<label>
<input type="radio" value="3" id="ped_3" name="status" />
3
</label>
</div>
<div>
<!-- PED Expression -->
<span class="margin-right-1rem">Expression</span>
<input
type="text"
style="width: 50vw"
value="4850 - 5 * p1 + 1.5 * p2 + 0.1 * y"
placeholder="1456 - P1 + 0.75 * P2 - 0.5 * p3 + 0.05*Y"
id="ped_expression"
/>
</div>
<!-- 700-2*p+0.02*y -->
<!-- 5000 -->
<!-- One P Value Holder-->
<!-- Two P Value Holder-->
<!-- "4850 - 5 * p1 + 1.5 * p2 + 0.1 * y" -->
<!-- Three P Value Holder-->
<!-- "1456 - P1 + 0.75 * P2 - 0.5 * p3 + 0.05*Y" -->
<!-- 18361 -->
<div
style="
display: flex;
flex-direction: column;
align-items: flex-start;
"
>
<!-- PED Goods Result -->
<div id="PED_goods" style="display: block; margin: 1rem 0">
<span id="ped_result"></span>
</div>
<div
style="display: flex; flex-direction: row; align-items: baseline"
>
<!-- PED Income (Y) -->
<p class="margin-right-1rem" style="margin-top: 0">Income (Y)</p>
<input
id="ped_income"
value="18361"
type="text"
placeholder="Income"
/>
</div>
<!-- PED Calculate -->
<button
style="margin: 1rem 0"
class="calculate-button"
type="button"
onclick="PEDCheck()"
>
Calculate!
</button>
</div>
<!-- PED Answer Display -->
<div id="ped1" class="left-align">
<h2 id="ped_find_q"></h2>
<p id="ped_calculate_step1" class="hide"></p>
<p id="ped_calculate_step1_1" class="no-margin"></p>
<p id="ped_calculate_step1_2" class="no-margin"></p>
<p id="ped_calculate_step1_3" class="no-margin"></p>
</div>
<div id="ped2" class="left-align">
<h2 id="ped_find_dev"></h2>
<p id="ped_deviation_1" class="hide"></p>
<p id="ped_deviation_1_1" class="no-margin"></p>
<p id="ped_deviation_1_2" class="no-margin"></p>
<p id="ped_deviation_1_3" class="no-margin"></p>
</div>
<div id="ped3" class="left-align">
<h2 id="find_ped"></h2>
<p id="find_ped_1" class="hide"></p>
<p id="find_ped_1_1" class="no-margin"></p>
<p id="find_ped_1_2" class="no-margin"></p>
<p id="find_ped_1_3" class="no-margin"></p>
</div>
<div id="ped4" class="left-align">
<h2 id="ped_result_h2"></h2>
<p id="ped_result_1" class="hide"></p>
<p id="ped_result_1_1" class="no-margin"></p>
<p id="ped_result_1_2" class=""></p>
</div>
<div class="if_active_yed">
<div id="ped5-yed" class="left-align">
<h2 id="ped5-yed-h2"></h2>
<p id="ped5-yed-1" class="hide"></p>
<p id="ped5-yed-1_1" class="no-margin"></p>
<p id="ped5-yed-1_2" class="no-margin"></p>
<p id="ped5-yed-1_3" class="no-margin"></p>
</div>
</div>
<div class="if_active_xed">
<div id="ped6-yed" class="left-align">
<h2 id="ped6-yed-1"></h2>
<p id="ped6-yed-1_1" class="hide"></p>
<p id="ped6-yed-1_2" class="no-margin"></p>
<p id="ped6-yed-1_3" class=""></p>
</div>
</div>
</div>
</div>
<!-- YED Elasticity of Demand (YED) -->
<div id="YED" class="tabcontent">
<h3>YED</h3>
<p>YED is in development.</p>
</div>
<!-- Cross Price Elasticity of Demand (XED) -->
<div id="XED" class="tabcontent">
<h3>XED</h3>
<p>XED will be arriving soon</p>
</div>
<!-- Alpha Feature for students -->
<div id="PC" class="tabcontent">
<div>
<h3>Alpha Version</h3>
<p>
This feature currently supports calculation of PED, YED, XED, and
Percent Change without any text Styling.
</p>
</div>
<!-- PED Expression -->
<span class="margin-right-1rem">Expression</span>
<input
type="text"
style="width: 50vw"
value="2444 - 3 * P1 + 0.4 * P2 - 0.5 * P3 + 0.04 * Y"
placeholder="Expression"
id="student_expression"
/>
<div class="text_and_input style='margin: 10px 0 0 1rem'">
<p class="margin-right-1rem">Pay of Goods 1 (P1)</p>
<input
ng-pattern="/^\d+$/"
id="pog1"
value="55"
type="number"
placeholder="Price of Good 1"
/>
</div>
<div class="text_and_input">
<p class="margin-right-1rem">Pay of Goods 2 (P2)</p>
<input
ng-pattern="/^\d+$/"
id="pog2"
value="286"
type="number"
placeholder="Price of Good 2"
/>
</div>
<div class="text_and_input">
<p class="margin-right-1rem">Pay of Goods 3 (P3)</p>
<input
ng-pattern="/^\d+$/"
id="pog3"
value="196"
type="number"
placeholder="Price of Good 3"
/>
</div>
<div class="text_and_input">
<!-- PED Income (Y) -->
<p class="margin-right-1rem">Income (Y)</p>
<input
id="student_income"
type="number"
value="48929"
placeholder="Income"
ng-pattern="/^\d+$/"
/>
</div>
<!-- Select Options for Percent Change -->
<h3>Percent Change</h3>
<div
style="display: flex; flex-direction: row; align-items: flex-start"
>
<p>
Select the goods to compare:
<select name="good1" id="good1">
<option value="good 1">Goods 1</option>
<option value="good 2">Goods 2</option>
<option value="good 3">Goods 3</option>
</select>
<select name="good2" id="good2">
<option value="good 1">Goods 1</option>
<option value="good 2">Goods 2</option>
<option value="good 3">Goods 3</option>
</select>
</p>
</div>
<div
style="display: flex; flex-direction: row; align-items: flex-start"
>
<p>
And was there a decrease or increase:
<select name="decreaseOrIncrease" id="decreaseOrIncrease">
<option value="+">Increase</option>
<option value="-">Decrease</option>
</select>
</p>
</div>
<div
style="display: flex; flex-direction: row; align-items: flex-start"
>
<p>
Then by how much percent?
<input
value="5"
type="number"
style="width: 50px"
class="input-percent"
id="percent"
/>
<span>%</span>
</p>
</div>
<!-- PED Calculate -->
<button
style="margin: 1rem 0"
type="button"
class="calculate-button"
onclick="StudentValuesCheck()"
>
Calculate!
</button>
<!-- -->
<!-- Answers -->
<!-- Part 1 -->
<div id="students_tab_1" class="left-align">
<hr />
<span id="part_1_PED_h2"></span>
<span id="part_1_PED-1_hide" class="hide"></span>
<span id="part_1_PED-1-1" class="px-10-ud"></span>
<span id="part_1_PED-1-2" class="px-10-ud"></span>
<span id="part_1_PED-1-3" class="px-10-ud"></span>
<span id="part_1_PED-1-4" class="px-10-ud"></span>
<span id="part_1_PED-1-5" class="px-10-ud"></span>
<span id="part_1_PED-1-6" class="px-10-ud"></span>
<span id="part_1_PED-1-7" class="px-10-ud"></span>
<span id="part_1_PED-1-8" class="px-10-ud"></span>
<span id="part_1_PED-1-9" class="px-10-ud"></span>
<span id="part_1_PED-1-10" class="px-10-ud"></span>
<span id="part_1_PED-1-11" class="px-10-ud"></span>
</div>
<!-- Part 2 -->
<div id="students_tab_2" class="left-align">
<hr />
<span id="part_2_YED_h2"></span>
<span id="part_2_YED-1_hide" class="hide"></span>
<span id="part_2_YED-1-1" class="px-10-ud"></span>
<span id="part_2_YED-1-2" class="px-10-ud"></span>
<span id="part_2_YED-1-3" class="px-10-ud"></span>
<span id="part_2_YED-1-4" class="px-10-ud"></span>
<span id="part_2_YED-1-5" class="px-10-ud"></span>
<span id="part_2_YED-1-6" class="px-10-ud"></span>
<span id="part_2_YED-1-7" class="px-10-ud"></span>
<span id="part_2_YED-1-8" class="px-10-ud"></span>
<span id="part_2_YED-1-9" class="px-10-ud"></span>
</div>
<!-- Part 3 -->
<div id="students_tab_3" class="left-align">
<hr />
<span id="part_3_XED_h2"></span>
<span id="part_3_XED_hide" class="hide"></span>
<span id="part_3_XED_1" class="px-10-ud"></span>
<span id="part_3_XED_2" class="px-10-ud"></span>
<span id="part_3_XED_3" class="px-10-ud"></span>
<span id="part_3_XED_4" class="px-10-ud"></span>
<span id="part_3_XED_5" class="px-10-ud"></span>
<span id="part_3_XED_6" class="px-10-ud"></span>
<span id="part_3_XED_7" class="px-10-ud"></span>
<span id="part_3_XED_8" class="px-10-ud"></span>
</div>
<!-- Part 4 -->
<div id="students_tab_4" class="left-align">
<hr />
<span id="part_4_XED_h2"></span>
<span id="part_4_XED_hide" class="hide"></span>
<span id="part_4_XED_1" class="px-10-ud"></span>
<span id="part_4_XED_2" class="px-10-ud"></span>
<span id="part_4_XED_3" class="px-10-ud"></span>
<span id="part_4_XED_4" class="px-10-ud"></span>
<span id="part_4_XED_5" class="px-10-ud"></span>
<span id="part_4_XED_6" class="px-10-ud"></span>
<span id="part_4_XED_7" class="px-10-ud"></span>
<span id="part_4_XED_8" class="px-10-ud"></span>
</div>
<!-- Part 5 -->
<div id="students_tab_5" class="left-align">
<hr />
<span id="part_5_percent_change_h2"></span>
<span id="part_5_percent_change_hide" class="hide"></span>
<span id="part_5_percent_change_1" class="px-10-ud"></span>
<span id="part_5_percent_change_2" class="px-10-ud"></span>
<span id="part_5_percent_change_3" class="px-10-ud"></span>
<span id="part_5_percent_change_4" class="px-10-ud"></span>
<span id="part_5_percent_change_5" class="px-10-ud"></span>
<span id="part_5_percent_change_6" class="px-10-ud"></span>
<span id="part_5_percent_change_7" class="px-10-ud"></span>
<span id="part_5_percent_change_8" class="px-10-ud"></span>
<span id="part_5_percent_change_9" class="px-10-ud"></span>
<span id="part_5_percent_change_10" class="px-10-ud"></span>
<span id="part_5_percent_change_11" class="px-10-ud"></span>
<span id="part_5_percent_change_12" class="px-10-ud"></span>
<span id="part_5_percent_change_13" class="px-10-ud"></span>
</div>
</div>
</div>
<!-- Footer -->
<footer>
<div>
<p>
A github repository created by
<a href="https://github.com/AcmeGamers">Acme Gamers</a>
</p>
</div>
</footer>
</body>
<!-- Nerdamer -->
<script src="https://cdn.jsdelivr.net/npm/nerdamer@1.1.12/nerdamer.core.min.js"></script>
<script
src="https://cdn.jsdelivr.net/npm/nerdamer@1.1.12/Algebra.js"
integrity="sha256-oJEHFFp8pDXx0Myx6cc7RVmh3a2kZPEGOP+bAunJptU="
crossorigin="anonymous"
></script>
<script
src="https://cdn.jsdelivr.net/npm/nerdamer@1.1.12/Calculus.js"
integrity="sha256-1X0hl2yReR/yZuZo7R3A9LUgS9+zWl8GzYjuk4pd6bE="
crossorigin="anonymous"
></script>
<!-- Math JS -->
<script src="https://cdn.jsdelivr.net/npm/mathjs@10.0.0/lib/browser/math.min.js"></script>
<!-- Katex -->
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/katex.min.css"
integrity="sha384-R4558gYOUz8mP9YWpZJjofhk+zx0AS11p36HnD2ZKj/6JR5z27gSSULCNHIRReVs"
crossorigin="anonymous"
/>
<!-- Math Quill -->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/mathquill/0.9.1/mathquill.min.css"
integrity="sha512-ClJLWtbX5z9xE5ZeKRcTGB+nJGP32tjiM75BMsvTYbl1L93KDrtK3SNVtJnv0lpIyv6G/JqD4ovPr7NxdeZVBA=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/mathquill/0.9.1/mathquill.min.js"
integrity="sha512-nrkcp3u2ytFW9WsmuD0JwlIhY6ZDCfL8+vd9cofdsl7m4XvmCR+DCvhvq0Zuhg69rGLsASKfYgcJKvyh6dyf0A=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<script>
// var MQ = MathQuill.getInterface(2);
</script>
<!-- The loading of KaTeX is deferred to speed up page rendering -->
<script
defer
src="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/katex.min.js"
integrity="sha384-z1fJDqw8ZApjGO3/unPWUPsIymfsJmyrDVWC8Tv/a1HeOtGmkwNd/7xUS0Xcnvsx"
crossorigin="anonymous"
></script>
<!-- To automatically render math in text elements, include the auto-render extension: -->
<script
defer
src="https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/contrib/auto-render.min.js"
integrity="sha384-+XBljXPPiv+OzfbB3cVmLHf4hdUFHlWNZN5spNQ7rmHTXpd7WvJum6fIACpNNfIR"
crossorigin="anonymous"
onload="renderMathInElement(document.body);"
></script>
<!-- My Scripts -->
<script src="altogether.js"></script>
<script>
function openTab(evt, cityName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(cityName).style.display = "block";
evt.currentTarget.className += " active";
}
</script>
<!-- Custom Functions / Scripts -->
<script>
document.onreadystatechange = () => {
if (document.readyState === "complete") {
document.querySelector(".se-pre-con").style.display = "none";
}
};
var select_value;
// Add Custom Style Property
function hideToShow(name, value, repeat) {
try {
if (repeat > 0) {
for (var data = 1; data <= repeat; data++) {
document.getElementById(name + data).style.display = value;
}
console.log("Complete");
} else {
log(
`The repeat is given less than 1, current value of repeat: ${repeat}`
);
}
} catch (error) {
console.log(`There is some error in the user input`);
}
}
// Latex Function
function LatexValue(id, nerdamerExpression, TheElement, data) {
// Renders data
document.getElementById(id).innerHTML = katex.render(
data + `= ${nerdamer.expressions(true, "LaTeX")[nerdamerExpression]}`,
document.getElementById(TheElement),
{
displayMode: true,
macros: {
"\\RR": "\\mathbb{R}",
},
}
);
}
// Latex Function Without Nerdamer
function LatexValue_WithoutNerdamer(id, expressionValue, TheElement, data) {
document.getElementById(id).innerHTML = katex.render(
data + `= ${expressionValue}`,
document.getElementById(TheElement),
{
displayMode: true,
macros: {
"\\RR": "\\mathbb{R}",
},
}
);
}
// Each Value Checker
function valueCheck(dataExpression) {
// Split using a space character
let arr = dataExpression.split(" ");
// Making the Array
var value1 = [];
for (let index = 0; index < arr.length; index++) {
value1 += `${arr[index]} `;
}
// Result
var finalAnswer = eval(math.evaluate(value1));
console.log(value1);
console.log(finalAnswer);
answers = {
derivative: deriveExpression(expressionValue),
puttingValues: value1,
answer: finalAnswer,
};
return answers;
}
// Marginal Revenue Function
function MRCheck() {
hideToShow("mr", "flex", 3);
// Obtaining Input Value
var expression = document
.getElementById("expression")
.value.toLowerCase()
.replace(/q/g, "x"); // This line replaces any `x` variable with `q`
// Logs The Result
console.log(expression);
var q_value = document.getElementById("q_value").value; // Gets Value of Q
// Marginal Revenue Calculation
function MarginalRevenue(expression, Q) {
// Obtaining the Expression from first Function
var expressionValue = expression,
deviationResult = deriveExpression(expressionValue),
result = deviationResult.replace(/x/g, Q);
console.log(deviationResult);
// Split using a space character
let arr = result.split(" ");
// Making the Array
var value1 = [];
for (let index = 0; index < arr.length; index++) {
value1 += `${arr[index]} `;
}
// Result
var finalAnswer = eval(math.evaluate(value1));
console.log(value1);
console.log(finalAnswer);
// Providing the answers to variables which needs it.
answers = {
derivative: deriveExpression(expressionValue),
puttingValues: value1,
answer: finalAnswer,
};
console.log("-------------------");
return answers;
}
// Marginal Revenue Function Calculation 2
function MarginalRevenueDisplay() {
var result = MarginalRevenue(expression, q_value);
// Derivation
document.getElementById("derivation_h2").innerHTML =
"Step 1: Derivation";
var element = "derivative_step1_2";
var firstNearDream = nerdamer(`d/dQ(${expression.replace(/x/g, "Q")})`);
LatexValue("derivative_step1", "1", element, "MR ");
element = "derivative_step2_2";
var secondNearDream = nerdamer(
`${result.derivative.replace(/x/g, "Q")}`
);
LatexValue("derivative_step2", "2", element, "MR ");
// Putting Values
document.getElementById("puttingValues_h2").innerHTML =
"Step 2: Putting Values";
// puttingValues_step1_2
element = "puttingValues_step1_1";
var thirdNearDream = nerdamer(`${q_value}`);
LatexValue("puttingValues_step1", "3", element, "Value of Q");
// puttingValues_step1_1
element = "puttingValues_step1_2";
var secondNearDream = nerdamer(`${result.derivative}`);
LatexValue("puttingValues_step1", "2", element, "MR ");
// puttingValues_step2_1
element = "puttingValues_step2_1";
LatexValue_WithoutNerdamer(
"puttingValues_step2",
result.puttingValues,
element,
`MR `
);
// Results
document.getElementById("result").innerHTML = `MR = ${result.answer}`;
// Conclusion
document.getElementById("Marginal_Conclusion_1").innerHTML =
"Conclusion";
document.getElementById(
"Marginal_Conclusion_2"
).innerHTML = `Hence the revenue of ${q_value} units is $${result.answer}`;
nerdamer.flush();
}
// Function that displays values on HTML page
try {
MarginalRevenueDisplay();
} catch (error) {
document.getElementById("result").innerHTML =
"There is some issue in the formula or the typed data is invalid";
console.log(error);
}
}
// <!-- Script for PED -->
// <!-- Script to change Price good limits -->
var result = document.querySelector("#ped_result");
document
.querySelector("#observe_ped_change")
.addEventListener("change", function (e) {
var target = e.target;
var data;
switch (target.value) {
case "1":
data = `<div class="text_and_input"><p class="margin-right-1rem">Pay of Goods 1 (P)</p><input id="pg1"value="25"type="text"placeholder="Price of Good 1"/></div>`;
hideToShow();
document.querySelector("#ped_1_2").style.visibility = "hidden";
document.querySelector("#ped_1_3").style.visibility = "hidden";
break;
case "2":
data = `<div class="text_and_input"><p class="margin-right-1rem">Pay of Goods 1 (P1)</p><input id="pg1"value="209"type="text"placeholder="Price of Good 1"/></div><div class="text_and_input"><p class="margin-right-1rem">Pay of Goods 2 (P2)</p><input id="pg2"value="101"type="text"placeholder="Price of Good 2"/></div>`;
document.querySelector("#ped_1_2").style.visibility = "initial";
document.querySelector("#ped_1_3").style.visibility = "initial";
break;
case "3":
data = `<div class="text_and_input"><p class="margin-right-1rem">Pay of Goods 1 (P1)</p><input id="pg1"value="209"type="text"placeholder="Price of Good 1"/></div><div class="text_and_input"><p class="margin-right-1rem">Pay of Goods 2 (P2)</p><input id="pg2"value="101"type="text"placeholder="Price of Good 2"/></div><div class="text_and_input"><p class="margin-right-1rem">Pay of Goods 3 (P3)</p><input id="pg3"value="478"type="text"placeholder="Price of Good 3"/></div>`;
document.querySelector("#ped_1_2").style.visibility = "hidden";
document.querySelector("#ped_1_3").style.visibility = "hidden";
hideToShow();
break;
}
console.log(e.target.defaultValue);
select_value = e.target.defaultValue;
result.innerHTML = data;
});
// <!-- PED, YED, XED Calculator -->
////////////
// Functions
////////////
// Variable Replacer
function variableReplacer(
expression,
valueToChange,
value1,
valueToChange2,
value2,
valueToChange3,
value3,
valueToChange4,
value4
) {
var result;
if (value4) {
result = expression.split(valueToChange).join(value1);
result = result.split(valueToChange2).join(value2);
result = result.split(valueToChange3).join(value3);
result = result.split(valueToChange4).join(value4);
return result;
} else if (value3) {
result = expression.split(valueToChange).join(value1);
result = result.split(valueToChange2).join(value2);
result = result.split(valueToChange3).join(value3);
return result;
} else if (value2) {
result = expression.split(valueToChange).join(value1);
result = result.split(valueToChange2).join(value2);
return result;
} else {
result = expression.split(valueToChange).join(value1);
return result;
}
}
// Expression Spliter
function expressionSpliter(expression) {
// Split using a space character
let arr = expression.split(" ");
// Making the Array
var array = [];
for (let index = 0; index < arr.length; index++) {
array += `${arr[index]} `;
}
console.log("Hello, The array is complete! " + array);
return array;
}
// Q Finder
function Q_Checker(expression) {
var q_array = expressionSpliter(expression);
// var q_result = eval(math.evaluate(q_array));
var q_result = eval(q_array);
console.log(q_array);
console.log(q_result);
var answers = {
puttingValues: q_array,
answer: q_result,
};
return answers;
}
function checkPED(value) {
var comment, is_Q, data;
if (value < 1) {
comment = `Since the value is less than 1, (${value} < 1), demand is inelastic.`;
is_Q = `Q is a necessary good`;
data = {
comment: comment,
is_Q: is_Q,
};
return data;
}
if (value > 1) {
comment = `Since the value is greater than 1, (${value} > 1), demand is elastic.`;
is_Q = `Q is a Luxury good`;
data = {
comment: comment,
is_Q: is_Q,
};
return data;
} else {
comment = `Since the value is equal to 1, (${value} = 1), demand is unitary`;
is_Q = `Demand for Q does not change in response to price.`;
data = {
comment: comment,
is_Q: is_Q,
};
return data;
}
}
function checkYED(value) {
var comment, elasticity, data;
if (value < 0) {
comment = `Since the value is less than 0, (${value} < 0). It is a necessary good.`;
elasticity = `Such that, Income Elasticity is <b>Low Income Elasticity</b> having <b>necessary goods</b> from Normal Goods.`;
data = {
comment: comment,
elasticity: elasticity,
};
return data;
}
if (value > 0) {
comment = `Since the value is greater than 0, (${value} > 0). This is typical of a luxury or superior good.`;
elasticity = `Such that, Income Elasticity is <b>High Income Elasticity</b> having <b>luxury or superior goods</b> from Normal Goods.`;
data = {
comment: comment,
elasticity: elasticity,
};
return data;
}
if (value == 0) {
comment = `Since the value is equal to 0, (${value} = 0). Proportional increase in price and goods.`;
elasticity = `Such that, Income Elasticity is <b>Unitary Income Elasticity</b> having no change.`;
data = {
comment: comment,
elasticity: elasticity,
};
return data;
}
}
function checkXED(value, good1, good2) {
var comment, elasticity, data;
if (value < 1) {
comment = `Since the value is less than 1, (${value} < 1). It is Complementary Elasticity.`;
elasticity = `Such that, This means that when the price of ${good1} increases, the demand for ${good2} decreases. `;
data = {
comment: comment,
elasticity: elasticity,
};
return data;
}
if (value > 1) {
comment = `Since the value is greater than 1, (${value} > 1). It is Subsitute Elasticity.`;
elasticity = `Such that, This means that when the price of ${good1} increases, the demand for ${good2} also increases. `;
data = {
comment: comment,
elasticity: elasticity,
};
return data;
}
if (value == 1) {
comment = `Since the value is equal to 0, (${value} == 0). It is Unrelated Elasticity.`;
elasticity = `Such that, te price of ${good1} can increase by 100 percent, but it will create no effect on demand for ${good2}. `;
data = {
comment: comment,
elasticity: elasticity,
};
return data;
}
}
function calculatePED(derivative, paymentOfGoods1, quantity) {
// Find PED
console.log("");
console.log("####### PED #######");
var PED_formula = "(d*q / d * p) * p/q";
console.log(PED_formula);
console.log(derivative, paymentOfGoods1, quantity);
var PED_answer_string = `| ${derivative} * (${paymentOfGoods1} / ${quantity}) | `;
var PED_answer = derivative * (paymentOfGoods1 / quantity),
PED_answer = Math.abs(PED_answer).toPrecision(3);
console.log(PED_answer);
var PED_commentary = checkPED(PED_answer);
console.log(PED_commentary);
var PED_Data = {
PED_answer_string: PED_answer_string,
PED_formula: PED_formula,
PED_answer: PED_answer,
PED_commentary: PED_commentary,
};
return PED_Data;
}
function if2PED_Calc(expression, paymentOfGoods1, paymentOfGoods2, income) {
// Finding Q1
console.log("");
console.log("##### Finding Q1 #####");
var p1_replaced = variableReplacer(expression, "p1", paymentOfGoods1),
p1_p2_replaced = variableReplacer(p1_replaced, "p2", paymentOfGoods2),
y_p1_p2_replaced = variableReplacer(p1_p2_replaced, "y", income),
valueOf_Q1 = eval(y_p1_p2_replaced);
var p2_replaced = variableReplacer(expression, "p2", paymentOfGoods2),
y_p2_replaced = variableReplacer(p2_replaced, "y", income),
x_variable = variableReplacer(y_p2_replaced, "p1", "x");
console.log(y_p1_p2_replaced);
console.log(valueOf_Q1);
console.log("");
console.log("##### Finding Derivation #####");
// Finding Derivation == (dq1 / dp1 = d/dp1[expression])
// Keeping p1 varible, other than them, all are constants.
derivation = deriveExpression(x_variable);
console.log("Keeping p1 varible, other than them, all are constants.");