-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.php
executable file
·1705 lines (1326 loc) · 63.7 KB
/
app.php
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
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf8" />
<title>Adopt a Verse | Wycliffe Bible Translators</title>
<!-- Links -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/css/font-awesome.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="style.css?ver=2.9" />
<script type="text/javascript" src="js/init.js?v=2.8"></script>
<script type="text/javascript" src="js/select-verse.js?v=2.8"></script>
<script type="text/javascript" src="js/navigate-tab.js?v=2.8"></script>
<script type="text/javascript" src="js/load-chapter.js?v=2.8"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript" src="https://cdn.rawgit.com/filamentgroup/fixed-sticky/master/fixedsticky.js"></script>
<script type="text/javascript" src="js/sidebar.js"></script>
<script type="text/javascript" src="js/countdown.js"></script>
<script type="text/javascript" src="js/remodal-app.js"></script>
<link rel="stylesheet" type="text/css" href="css/remodal-default-theme-app.css" />
<link rel="stylesheet" type="text/css" href="css/remodal.css" />
<!-- Wycliffe links -->
</head>
<body>
<!-- Top Bar -->
<div class="top-bar desktop"><table><tr>
<td id="left-cell">
<a href="index.php"><img id="adopt-logo" alt="Adopt-a-Verse Logo" align="middle" src="img/wycliffe-logo.png"></a>
</td>
<th>
<div class="div-tab font--bold">
<button class="tabs capitalize tabs-now" onclick="tab(event, 'tab-donate')">Donate</button>
<button class="tabs capitalize" onclick="tab(event, 'tab-about')" id="language-tab">About the Language</button>
<button class="tabs capitalize" onclick="tab(event, 'tab-goal')">Our Campaign Goal</button>
</div>
</th>
<td id="right-cell">
<!-- JS checks if logged in -->
</td>
</tr></table></div>
<!-- Top Bar (mobile) -->
<div id="top-bar" class="top-bar mobile">
<div id="top-bar-menu" onclick="toggle_menu()">
<img id="menu-icon" alt="Menu" align="middle" src="img/menu_open.png">
</div>
<div id="top-bar-logo">
<a href="index.php"><img id="adopt-logo" alt="Adopt-a-Verse Logo" align="middle" src="img/wycliffe-logo.png"></a>
</div>
<div id="toggle-menu">
<div class="div-tab font--bold">
<button class="capitalize tabs tabs-now" onclick="tab(event, 'tab-donate')">Donate</button>
<button class="capitalize tabs" onclick="tab(event, 'tab-about')" id="language-tab">About the Language</button>
<button class="capitalize tabs" onclick="tab(event, 'tab-goal')">Our Campaign Goal</button>
</div>
</div>
</div>
<!-- Body -->
<div id="bg" align="center">
<div id="wrapper">
<!-- Tab -->
<div id="content">
<!-- Donate Tab -->
<div id="tab-donate" class="tab-content tab-content-now">
<div class="donate-top-bar">
<div class="donate-bar">
<div>
<span class="title capitalize">Language</span>
<span class="language" id="campaign-language"></span><span class="region" id="campaign-region"></span>
</div>
<div>
<span class="title book-chapter capitalize">Book & Chapter</span>
<button id="button-chapter" onclick="show_chapters()">
<img alt="" src="img/arrow-down.png" />
</button>
<div id="select-chapter">
<div id="select-chapter-close" onclick="hide_chapters()">
<img alt="X" src="img/menu_close.png" />
</div>
<div id="book"></div>
<div id="chapters"></div>
</div>
</div>
</div>
</div>
<div id="div-select-all">
</div>
<div id="bible">
<!-- Bible verses -->
</div>
</div>
<!-- About the Language Tab -->
<div id="tab-about" class="tab-content">
<div class="tab-title" id="language-name">About the Language</div>
<div id="language-description" class="tab-text">
</div>
<div class="tab-text" id="download-pdf">
</div>
<!-- Mobile Language Group Details and Photo -->
<div class="mobile">
<div class="tab-title top-gap">Language Group Details</div>
<div class="tab-text">
<div class="div-details-img">
<img class="details-img" alt="" src="img/details_region.png">
</div>
<div class="div-details-content">
<span class="details-title">Region/Country</span><br>
<span class="details-info">Papua New Guinea</span>
</div>
<div class="div-details-img">
<img class="details-img" alt="" src="img/details_people.png">
</div>
<div class="div-details-content">
<span class="details-title">People Group(s)</span><br>
<span class="details-info">Kaninuwa</span>
</div>
<div class="div-details-img">
<img class="details-img" alt="" src="img/details_speaker.png">
</div>
<div class="div-details-content">
<span class="details-title">Native Speakers</span><br>
<span class="details-info">340</span>
</div>
<div class="div-details-img">
<img class="details-img" alt="" src="img/details_scripture.png">
</div>
<div class="div-details-content">
<span class="details-title">Scriptures Published</span><br>
<span class="details-info">None</span>
</div>
</div>
<div class="tab-title top-gap-more">Photo</div>
<div id="language-photo" class="tab-text">
<img alt="" src="img/example_photo.jpg" id="first-photo">
<div id="more-photo"><img alt="" src="img/open_photo.png"></div>
</div>
</div>
</div>
<!-- Our Campaign Goal Tab -->
<div id="tab-goal" class="tab-content">
<div class="tab-title" id="campaign-goal">Our Campaign Goal</div>
<div id="campaign-description" class="tab-text">
</div>
<div id="campaign-duration">
<div id="count-number">
<div class="count-days">
<span class="countdown-days"></span><br>
days
</div>
<div class="count-hours">
<span class="countdown-hours"></span><br>
hrs
</div>
<div class="count-minutes">
<span class="countdown-minutes"></span><br>
min
</div>
<div class="count-seconds">
<span class="countdown-seconds"></span><br>
sec
</div>
</div>
<div id="count-range">
</div>
</div>
<div class="tab-title top-gap">Total Raised</div>
<div class="tab-text">
<div id="div-chart">
<!-- Donut graph -->
</div>
<!-- Still need -->
<div id="div-chart-info">
<div class="goal-total-info-1">
Still Need: <span id="total-still-need"></span><br>
</div>
<!-- Total goal -->
<div class="goal-total-info-2">
Goal: <span id="total-goal"></span>
</div>
<!-- Total verses adopted -->
<div class="goal-total-adopted-verses">
<span id="total-adopted"></span> of <span id="total-verses"></span> verses adopted
</div>
</div>
<!-- Total raised percentage in the donut -->
<div id="div-chart-percentage">
<span class="chart-percent-span" id="total-percentage">%</span>
<br>
<span class="chart-percent-span capitalize">Funded</span>
</div>
</div>
</div>
<div id="footer">
Holy Bible, New Living Translation, copyright © 1996, 2004, 2015 by Tyndale House Foundation.<br>
©2017 Wycliffe Bible Translators. All rights reserved.
</div>
</div>
<!-- side bar -->
<div id="side-bar" class="desktop">
<!-- Total Raised Side Bar (Tablet) -->
<div id="small-side-total" class="small-sides border--round">
<div id="small-total" class="small-side-bar" onclick="toggle_small_total()">
<span class="small-title capitalize">Total Raised</span>
<img id="small-total-icon" alt="" src="img/cart_open.png">
</div>
<div id="small-total-content" class="small-side-content">
<div id="small-total-raised">
<!-- Donut graph -->
</div>
<!-- Total raised percentage in the donut -->
<span class="total-percent-span" id="small-total-percentage">%</span>
<br>
<span class="total-percent-span capitalize">Funded</span>
<!-- Still need -->
<div class="total-info-1">
Still Need: <span id="small-total-still-need"></span><br>
</div>
<!-- Total goal -->
<div class="total-info-2">
Goal: <span id="small-total-goal"></span>
</div>
<!-- Total verses adopted -->
<div class="total-adopted-verses">
<span id="small-total-adopted" class="highlight"></span> of <span id="small-total-verses"></span> verses adopted
</div>
</div>
</div>
<!-- Cart Side Bar (Tablet) -->
<div id="small-side-cart" class="small-sides border--round">
<div id="small-cart" class="small-side-bar" onclick="toggle_small_cart()">
<span class="small-title capitalize">My Cart</span>
<div id="num-items"></div>
<img id="small-cart-icon" alt="" src="img/cart_close.png">
</div>
<div id="small-cart-content" class="small-side-content">
<div id="small-div-cart">
</div>
<div id="small-div-cart-empty">
<img id="img-empty-cart" alt="Empty Cart" src="img/empty-cart.png">
<br>
Add verses to your cart.
</div>
<div id="small-div-cart-label" class="no-label"> </div>
<div class="div-checkout">
<button id="small-checkout" class="checkout border--round empty" onclick="open_give()">Give $0</button>
</div>
</div>
</div>
<!-- Language Group Details Side Bar -->
<div id="small-side-language" class="small-sides border--round hide">
<div id="small-language" class="small-side-bar" onclick="toggle_small_language()">
<span class="small-title capitalize">Project Details</span>
<img id="small-language-icon" alt="" src="img/cart_open.png">
</div>
<div id="small-language-content" class="small-side-content">
<div id="small-div-details">
<div class="div-details-img">
<img class="details-img" alt="" src="img/details_region.png">
</div>
<div class="div-details-content">
<span class="details-title">Region/Country</span><br>
<span class="details-info" id="details-region"></span>
</div>
<div class="div-details-img">
<img class="details-img" alt="" src="img/details_people.png">
</div>
<div class="div-details-content">
<span class="details-title" id="title-language">Language</span><br>
<span class="details-info" id="details-language"></span>
</div>
<div class="div-details-img">
<img class="details-img" alt="" src="img/details_speaker.png">
</div>
<div class="div-details-content">
<span class="details-title">Native Speakers</span><br>
<span class="details-info" id="details-native-speakers"></span>
</div>
<div class="div-details-img">
<img class="details-img" alt="" src="img/details_scripture.png">
</div>
<div class="div-details-content">
<span class="details-title">Scriptures Published</span><br>
<span class="details-info" id="details-scripture-published"></span>
</div>
</div>
</div>
</div>
<!-- Photo Side Bar -->
<div id="small-side-photo" class="small-sides border--round hide">
<div id="small-photo" class="small-side-bar" onclick="toggle_small_photo()">
<span class="small-title capitalize">Photo</span>
<img id="small-photo-icon" alt="" src="img/cart_close.png">
</div>
<div id="small-photo-content" class="small-side-content">
<img alt="" src="img/example_photo.jpg" id="first-photo">
<div id="more-photo"><img alt="" src="img/open_photo.png"></div>
</div>
</div>
</div>
<!-- Mobile Cart -->
<div id="mobile-cart">
<div id="cart-1">
<div id="cart-toggle" onclick="toggle_cart()">
<img id="cart-icon" alt="Cart" src="img/cart_open.png">
</div>
<div id="cart-label">
<span class="label-title capitalize">My Cart</span><br>
<span class="highlight">1</span> verse selected
</div>
<div id="cart-checkout">
<button id="checkout-mobile" class="checkout border--round">Give $0</button>
</div>
</div>
<div id="cart-2">
<div id="div-cart-mobile">
<!-- cart items -->
</div>
</div>
</div>
<!-- Hidden Data
<input type="hidden" id="data-verse-price" value="">
<input type="hidden" id="data-total-goal" value="">
-->
</div> <!-- wrapper -->
</div> <!-- bg -->
<div class="remodal" data-remodal-id="give" role="dialog" aria-labelledby="modal1Title" aria-describedby="modal1Desc">
<button data-remodal-action="close" class="remodal-close" aria-label="Close"></button>
<div class="lightbox">
<form method="post" enctype="multipart/form-data">
<div id="title">Gift Details</div>
<section>
<div class="col-left">Verses Selected</div>
<div class="col-tip"></div>
<div class="col-right">
<div id="give-verses-selected">
</div>
</div>
<div class="col-left">Total Amount</div>
<div class="col-tip"></div>
<div class="col-right" id="give-total-amount">
</div>
</section>
<section id="section-user">
<div class="col-left">User</div>
<div class="col-tip"></div>
<div class="col-right">
<input type="text" class="form-text" id="give-first-name" onkeyup="input_form('first-name')" placeholder="First Name">
<input type="text" class="form-text" id="give-last-name" onkeyup="input_form('last-name')" placeholder="Last Name"><br>
<input type="text" class="form-text" id="give-email" placeholder="Email Address"><span class="error" id="error-email"></span>
</div>
</section>
<section>
<div class="col-left">Display Name</div>
<div class="col-tip">
<span class="tool-tip">?<div class="tooltip">This is the name that will be displayed with your adopted verse(s)<br>(e.g. "the Smith Family").</div></span>
</div>
<div class="col-right">
<input type="text" class="form-text" id="give-honor-name" onkeyup="input_form('honor-name')" placeholder="Honoree's Name">
<input type="text" class="form-text" id="give-memory-name" onkeyup="input_form('memory-name')" placeholder="In Memory of Name">
<input type="text" class="form-text" id="give-display-name" onkeyup="input_form('display-name')" placeholder="Name"><br>
<div id="give-options">
<input id="give-anonymous" class="checkbox-custom" name="give-anonymous" type="checkbox" onclick="give_anonymous()"><label for="give-anonymous" class="checkbox-custom-label">Give anonymously</label><br>
<input id="give-honor" class="checkbox-custom" name="give-honor" type="checkbox" onclick="give_honor()"><label for="give-honor" class="checkbox-custom-label">Give in honor of someone else</label><br>
<input id="give-memory" class="checkbox-custom" name="give-memory" type="checkbox" onclick="give_memory()"><label for="give-memory" class="checkbox-custom-label">Give in memory of someone else</label>
</div>
</div>
<div class="col-left">Preview</div>
<div class="col-tip">
</div>
<div class="col-right" id="col-preview">
<span id="tooltip-preview" class="tooltip-taken">This verse has been sponsored<span id="give-preview"></span>.
</span>
</div>
</section>
<section class="last-section">
<button type="button" class="form-button" onclick="close_give()">Cancel</button>
<button type="button" class="form-submit long" onclick="checkout()">Proceed to Checkout</button>
</section>
</form>
</div>
</div>
<div class="remodal" id="remodal-login" data-remodal-id="login" role="dialog" aria-labelledby="modal1Title" aria-describedby="modal1Desc">
<button data-remodal-action="close" class="remodal-close" aria-label="Close"></button>
<div class="lightbox">
<img id="login-logo" alt="Adopt a Verse" src="img/wycliffe-logo.png">
<br>
<input type="email" id="login-email" class="login-text" placeholder="Email Address"><br>
<input type="password" id="login-password" class="login-text" placeholder="Password"><br>
<div id="login-error">
Invalid email or password
</div>
<button type="button" id="login-submit" class="admin-submit" onclick="login()">Sign In</button>
<div id="login-more">
<a href="#">Forgot your password?</a>
</div>
<div id="login-division"></div>
<div id="login-first-time">
<span>First time using Adopt-a-Verse?</span>
<button class="login-link" onclick="create_account()">Create an Account</button>
</div>
</div>
</div>
<script>
// CHECK USER LOGIN
var user_data = {
id: 0,
first_name: "",
last_name: "",
email: ""
};
function check_login() {
var ajaxObj = new XMLHttpRequest();
ajaxObj.onreadystatechange= function() { if(ajaxObj.readyState == 4) { if(ajaxObj.status == 200) {
console.log("check login: "+ajaxObj.responseText);
if (ajaxObj.responseText == 0) {
document.getElementById('right-cell').innerHTML = '<a href="#login"><button class="button-submit" id="button-login">Log In</button></a>';
} else {
var resp = JSON.parse(ajaxObj.responseText);
user_data.id = resp.id;
user_data.first_name = resp.first_name;
user_data.last_name = resp.last_name;
user_data.email = resp.email;
document.getElementById('right-cell').innerHTML = '<button id="button-profile" onclick="toggle_profile()">Welcome, '+resp.first_name+'<img id="profile-icon" alt="" src="img/cart_close.png"><div id="menu"><div class="button-menu" id="my_account" onclick="my_account()"><img class="menu-icon" alt="" src="img/icon_account.svg"> My Account</div><div class="button-menu" id="giving_history" onclick="giving_history()"><img class="menu-icon" alt="" src="img/icon_gift.svg"> Giving History</div><div id="menu-division"></div><div id="button-logout" onclick="logout()">Log Out</div></div></button>';
}
}}}
ajaxObj.open("GET", "sql-check-login.php");
ajaxObj.send();
}
check_login();
$(document).ready(function () {
$("html,body").scrollTop(0);
});
var page_param = window.location.search.substring(1);
var page_url = new URL(window.location.href);
var code = page_url.searchParams.get("id");
// fixed side bar
$(function() {
var $sidebar = $("#side-bar"),
$window = $(window),
offset = $sidebar.offset(),
topPadding = 100;
$window.scroll(function() {
if ($window.scrollTop() > offset.top) {
var newMargin = $window.scrollTop() - offset.top + topPadding
$sidebar.css('margin-top', newMargin);
} else {
$sidebar.css('margin-top', 0);
}
});
});
// initialize all the necessary fields on page
function init() {
campaign = {};
chapter = 1;
verses = [];
selected = {};
abbreviation = "";
var ajaxObj = new XMLHttpRequest();
ajaxObj.onreadystatechange= function() { if(ajaxObj.readyState == 4) { if(ajaxObj.status == 200) {
if (ajaxObj.responseText == "no\n") {
alert("The campaign does not exist.");
window.location.href = "index.php";
} else {
var resp = JSON.parse(ajaxObj.responseText);
campaign.book = resp.book;
campaign.church = resp.church;
campaign.profile_picture = resp.profile_picture;
campaign.language = resp.language;
campaign.project_description = resp.project_description;
campaign.goal_description = resp.goal_description;
campaign.goal_amount = parseFloat(resp.goal_amount).toFixed(2);
campaign.verse_price = parseFloat(resp.verse_price).toFixed(2);
campaign.start_date = resp.start_date;
campaign.end_date = resp.end_date;
campaign.region = resp.region;
campaign.number_of_speakers = parseInt(resp.number_of_speakers);
campaign.scripture_published = resp.scripture_published;
campaign.pdf_url = resp.pdf_url;
countdownDate(campaign.end_date);
var start_date = new Date(campaign.start_date);
var start_year = (""+start_date.getFullYear()).slice(-2);
var start_month = start_date.getMonth() + 1;
var start = start_month+"/"+start_date.getDate()+"/"+start_year;
var end_date = new Date(campaign.end_date);
var end_year = (""+end_date.getFullYear()).slice(-2);
var end_month = end_date.getMonth() + 1;
var end = end_month+"/"+end_date.getDate()+"/"+end_year;
document.getElementById('count-range').innerHTML = start+" - "+end;
book = campaign.book;
verse_price = parseFloat(campaign.verse_price).toFixed(2);
total_goal = parseFloat(campaign.goal_amount).toFixed(2);
document.getElementById('total-goal').innerHTML = "$" + total_goal.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
document.getElementById('small-total-goal').innerHTML = "$" + total_goal.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
if (campaign.profile_picture != null) {
//document.getElementById('church-logo').style.backgroundImage = 'url("img/profile/'+campaign.profile_picture+'")';
}
document.getElementById('book').innerHTML = book;
document.getElementById('campaign-language').innerHTML = campaign.language;
document.getElementById('campaign-region').innerHTML = campaign.region;
//document.getElementById('church-name').innerHTML = campaign.church;
document.getElementById('language-name').innerHTML = campaign.language;
document.getElementById('language-tab').innerHTML = "About the "+campaign.language;
document.getElementById('language-description').innerHTML = "<p>"+campaign.project_description+"</p>";
document.getElementById('campaign-description').innerHTML = "<p>"+campaign.goal_description+"</p>";
document.getElementById('details-region').innerHTML = campaign.region;
document.getElementById('details-language').innerHTML = campaign.language;
var num_speakers = campaign.number_of_speakers.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
document.getElementById('details-native-speakers').innerHTML = num_speakers;
if (campaign.scripture_published == '0000-00-00') {
document.getElementById('details-scripture-published').innerHTML = "N/A";
} else {
var p_date = new Date(campaign.scripture_published);
var p_year = (""+p_date.getFullYear()).slice(-2);
var p_month = p_date.getMonth() + 1;
var publish_date = p_month+"/"+p_date.getDate()+"/"+p_year;
document.getElementById('details-scripture-published').innerHTML = publish_date;
}
document.getElementById('download-pdf').innerHTML = '<a href="'+campaign.pdf_url+'" target="_blank"><button class="tab-button" type="button">View PDF</button></a>';
taken = {};
var ajaxObj1 = new XMLHttpRequest();
ajaxObj1.onreadystatechange= function() { if(ajaxObj1.readyState == 4) { if(ajaxObj1.status == 200) {
var total_still_need = 0;
if (ajaxObj1.responseText == "no\n") {
total_adopted = 0;
total_raised = 0;
total_percentage = 0;
total_still_need = parseFloat(total_goal).toFixed(2);
} else {
var resp = JSON.parse(ajaxObj1.responseText);
var count = 0;
for (var i = 0; i < Object.keys(resp).length; i++) {
var chapter = Object.keys(resp)[i];
taken[chapter] = {};
for (var j = 0; j < Object.keys(resp[chapter]).length; j++) {
var verse = Object.keys(resp[chapter])[j];
var sponsor = resp[chapter][verse];
taken[chapter][verse] = sponsor;
count++;
}
}
total_adopted = count;
total_raised = parseFloat(count * campaign.verse_price).toFixed(2);
total_percentage = Math.round(total_raised / total_goal * 100);
total_still_need = parseFloat(total_goal - total_raised).toFixed(2);
}
console.log("Taken Verses:");
console.log(taken);
document.getElementById('total-still-need').innerHTML = "$" + total_still_need.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
document.getElementById('small-total-still-need').innerHTML = "$" + total_still_need.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
document.getElementById('total-adopted').innerHTML = total_adopted;
document.getElementById('small-total-adopted').innerHTML = total_adopted;
}}}
ajaxObj1.open("GET", "sql-taken-verses.php?id="+code);
ajaxObj1.send();
bible = {};
var ajaxObj2 = new XMLHttpRequest();
ajaxObj2.onreadystatechange= function() { if(ajaxObj2.readyState == 4) { if(ajaxObj2.status == 200) {
var resp = JSON.parse(ajaxObj2.responseText);
max_chapter = resp.size;
bible = resp.bible;
// load book of the Bible
load_book(book);
}}}
ajaxObj2.open("GET", "bible.php?book="+book);
ajaxObj2.send();
var ajaxObj3 = new XMLHttpRequest();
ajaxObj3.onreadystatechange= function() { if(ajaxObj3.readyState == 4) { if(ajaxObj3.status == 200) {
var resp = JSON.parse(ajaxObj3.responseText);
abbreviation = resp[book]['abbreviation'];
total_verses = resp[book]['verses'];
document.getElementById('total-verses').innerHTML = total_verses;
document.getElementById('small-total-verses').innerHTML = total_verses;
}}}
ajaxObj3.open("GET", "sql-chapters-verses.php");
ajaxObj3.send();
}
}}}
ajaxObj.open("GET", "search-campaign.php?id="+code);
ajaxObj.send();
cart = {
price: 0, // total price
items: {}, // items
total: 0 // total number of items
}
}
init();
// reload total raised chart when screen is resized
$(window).on('resize', function(){
// on side bar
google.charts.load("current", {packages: ["corechart"]});
google.charts.setOnLoadCallback(drawSmallChart);
// on campaign goal
google.charts.load("current", {packages: ["corechart"]});
google.charts.setOnLoadCallback(drawChart);
});
// draw total-raised chart
var chart_goal = true;
function drawChart() {
if (chart_goal) {
var data = new google.visualization.DataTable();
data.addColumn('string', 'text');
data.addColumn('number', 'number');
data.addRows(2);
data.setValue(0, 0, 'Total Raised');
data.setValue(0, 1, 0);
data.setValue(1, 0, 'Still Needed');
data.setValue(1, 1, total_goal);
var options = {
pieHole: 0.6,
chartArea: {
width: 160,
height: 160,
backgroundColor: '#dbdbdb'
},
height: 180,
colors: [ '#dbdbdb', '#039da6'],
pieSliceBorderColor: '#dbdbdb',
legend: 'none',
pieSliceText: 'none',
pieSliceBorderColor: 'white',
reverseCategories: true,
tooltip: {
textStyle: {
fontName: "Gotham-Book",
fontSize: 14
},
text: 'value'
},
animation: {
duration: 1000,
easing: 'out',
startup: true
}
};
var chart = new google.visualization.PieChart(document.getElementById('div-chart'));
chart.draw(data, options);
// initial value
var percent = 0;
// start the animation loop
var handler = setInterval(function(){
// values increment
if (total_percentage != 0) {
percent += 1;
document.getElementById('total-percentage').innerHTML = percent + "%";
// apply new values
data.setValue(0, 1, (total_goal * percent / 100));
data.setValue(1, 1, total_goal - (total_goal * percent / 100));
// update the pie
chart.draw(data, options);
// check if we have reached the desired value
if (percent >= total_percentage)
// stop the loop
clearInterval(handler);
} else {
document.getElementById('total-percentage').innerHTML = percent + "%";
clearInterval(handler);
}
}, 10);
} else {
// do not animate chart when resize screen
var data = new google.visualization.DataTable();
data.addColumn('string', 'text');
data.addColumn('number', 'number');
data.addRows(2);
data.setValue(0, 0, 'Total Raised');
data.setValue(0, 1, total_raised);
data.setValue(1, 0, 'Still Needed');
data.setValue(1, 1, total_goal-total_raised);
var options = {
pieHole: 0.6,
chartArea: {
width: 160,
height: 160,
backgroundColor: '#dbdbdb'
},
height: 180,
colors: [ '#dbdbdb', '#039da6'],
pieSliceBorderColor: '#dbdbdb',
legend: 'none',
pieSliceText: 'none',
pieSliceBorderColor: 'white',
reverseCategories: true,
tooltip: {
trigger: 'none'
},
animation: {
duration: 1000,
easing: 'out',
startup: true
}
};
var chart = new google.visualization.PieChart(document.getElementById('div-chart'));
chart.draw(data, options);
}
chart_goal = false;
}
// draw total-raised chart (tablet)
var chart_sidebar = true;
google.charts.load("current", {packages: ["corechart"]});
google.charts.setOnLoadCallback(drawSmallChart);
function drawSmallChart() {
// animate when load first time
if (chart_sidebar) {
var data = new google.visualization.DataTable();
data.addColumn('string', 'text');
data.addColumn('number', 'number');
data.addRows(2);
data.setValue(0, 0, 'Total Raised');
data.setValue(0, 1, 0);
data.setValue(1, 0, 'Still Needed');
data.setValue(1, 1, total_goal);
var options = {
backgroundColor: 'none',
pieHole: 0.6,
chartArea: {
width: 160,
height: 160,
backgroundColor: '#dbdbdb'
},
height: 180,
colors: [ '#dbdbdb', '#039da6' ],
pieSliceBorderColor: '#dbdbdb',
legend: 'none',
pieSliceText: 'none',
pieSliceBorderColor: 'white',
reverseCategories: true,
tooltip: {
trigger: 'none'
},
animation: {
duration: 1000,
easing: 'out',
startup: true
}
};
var chart = new google.visualization.PieChart(document.getElementById('small-total-raised'));
chart.draw(data, options);
// initial value
var percent = 0;
// start the animation loop
var handler = setInterval(function(){
// values increment
if (total_percentage != 0) {
percent += 1;
document.getElementById('small-total-percentage').innerHTML = percent + "%";
// apply new values
data.setValue(0, 1, (total_goal * percent / 100));
data.setValue(1, 1, total_goal - (total_goal * percent / 100));
// update the pie
chart.draw(data, options);
// check if we have reached the desired value
if (percent >= total_percentage)
// stop the loop
clearInterval(handler);
} else {
document.getElementById('small-total-percentage').innerHTML = percent + "%";
clearInterval(handler);
}
}, 10);
} else {
// do not animate chart when resize screen
var data = new google.visualization.DataTable();
data.addColumn('string', 'text');
data.addColumn('number', 'number');
data.addRows(2);
data.setValue(0, 0, 'Total Raised');
data.setValue(0, 1, total_raised);
data.setValue(1, 0, 'Still Needed');
data.setValue(1, 1, total_goal-total_raised);
var options = {
pieHole: 0.6,
chartArea: {
width: 160,
height: 160,
backgroundColor: '#dbdbdb'
},
height: 180,
colors: [ '#dbdbdb', '#039da6'],
pieSliceBorderColor: '#dbdbdb',
legend: 'none',
pieSliceText: 'none',
pieSliceBorderColor: 'white',
reverseCategories: true,
tooltip: {