-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
2554 lines (2190 loc) · 96.6 KB
/
main.js
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
function create_db() {
console.log("Checking databases")
db.transaction(function (tx) {
tx.executeSql(
'CREATE TABLE IF NOT EXISTS Card(id TEXT, name TEXT,phone TEXT,email TEXT,company TEXT,alias TEXT, motto TEXT, main TEXT,website1 TEXT,website2 TEXT,website3 TEXT,website4 TEXT,avatar TEXT,cardback TEXT,cat TEXT)')
tx.executeSql('CREATE TABLE IF NOT EXISTS YourCard(id TEXT, cardNum TEXT)')
tx.executeSql(
'CREATE TABLE IF NOT EXISTS Options(id TEXT, sendcard TEXT, alias TEXT, contact TEXT)')
tx.executeSql(
'CREATE TABLE IF NOT EXISTS ContactInfo(contactid TEXT, information TEXT,type TEXT)')
tx.executeSql('CREATE TABLE IF NOT EXISTS Settings(id TEXT, value INT)')
tx.executeSql(
'CREATE TABLE IF NOT EXISTS Themes(id TEXT, backgroundColor TEXT, highLightColor TEXT, seperatorColor TEXT, barColor TEXT, activeColor TEXT, cardcolor TEXT, overlayColor TEXT, fontColorTitle TEXT, fontColor TEXT)')
tx.executeSql(
'CREATE TABLE IF NOT EXISTS Stats(id TEXT, name TEXT,data TEXT, frequency INT)')
tx.executeSql(
'CREATE TABLE IF NOT EXISTS TempCards(id INT UNIQUE, name TEXT, phone TEXT, email TEXT,company TEXT,alias TEXT, motto TEXT,main TEXT,website1 TEXT,website2 TEXT,website3 TEXT,website4 TEXT,avatar TEXT, cardback TEXT,stamp INT,cat TEXT,cardsop INT)')
tx.executeSql(
'CREATE TABLE IF NOT EXISTS RegCards(id INT UNIQUE, name TEXT, phone TEXT, email TEXT,company TEXT,alias TEXT, motto TEXT,main TEXT,website1 TEXT,website2 TEXT,website3 TEXT,website4 TEXT,avatar TEXT, cardback TEXT,stamp INT,cat TEXT,cardsop INT)')
tx.executeSql(
'CREATE TABLE IF NOT EXISTS SavedCards(id INT UNIQUE, name TEXT,phone TEXT,email TEXT,company TEXT,alias TEXT, motto TEXT,main TEXT,website1 TEXT,website2 TEXT,website3 TEXT,website4 TEXT,avatar TEXT, cardback TEXT,cat TEXT,cardsop INT)')
tx.executeSql(
'CREATE TABLE IF NOT EXISTS GlobCards(id INT UNIQUE, name TEXT, phone TEXT, email TEXT,company TEXT,alias TEXT, motto TEXT,main TEXT,website1 TEXT,website2 TEXT,website3 TEXT,website4 TEXT,avatar TEXT, cardback TEXT,stamp INT,cat TEXT,cardsop INT)')
tx.executeSql(
'CREATE TABLE IF NOT EXISTS LIBRARY (id TEXT,thedir TEXT,file TEXT,thedate TEXT,private INT,picture_index INT, base64 BLOB)')
tx.executeSql('CREATE TABLE IF NOT EXISTS NEWS (date TEXT)');
tx.executeSql('CREATE TABLE IF NOT EXISTS Notes (contactid TEXT,title MEDIUMTEXT ,information MEDIUMTEXT,date MEDIUMINT,origin MEDIUMINT)');
tx.executeSql('CREATE TABLE IF NOT EXISTS announcements (id TEXT, name TEXT,type TEXT,version INT,seen INT)');
});
}
function save_card(id, username, userphone, useremail, usercompany, useralias, usermotto, main, website1, website2, website3, website4, sendcard, usealias, contact, avatar, cardback, cardcat, cardindex) {
if (usercompany === "") {
usercompany = " "
}
if (main === "") {
main = " "
}
if (website1 === "") {
website1 = " "
}
if (website2 === "") {
website2 = " "
}
if (website3 === "") {
website3 = " "
}
if (website4 === "") {
website4 = " "
}
if (usermotto === "") {
usermotto = " "
}
if (useremail === "") {
useremail = " "
}
if (userphone === "") {
userphone = " "
}
if (useralias === "") {
useralias = " "
}
if (cardback === "") {
cardback = "./img/default_card.png"
}
usermotto = usermotto.replace(/\'/g, "'")
username = username.replace(/\'/g, "'")
usercompany = usercompany.replace(/\'/g, "'")
useralias = useralias.replace(/\'/g, "'")
var userStr = "INSERT INTO Card VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
var ycStr = "INSERT INTO YourCard VALUES(?,?)"
var data = [id, username, userphone, useremail, usercompany, useralias, usermotto, main, website1, website2, website3, website4, avatar, cardback, cardcat]
var data1 = [id, cardindex]
var testStr = "SELECT * FROM Card WHERE id= '" + id + "'"
var testStr1 = "SELECT * FROM YourCard WHERE id= '" + id + "'"
var updateUser = "UPDATE Card SET name='" + username + "', email='" + useremail + "', phone='"
+ userphone + "', company='" + usercompany + "', alias='"
+ useralias + "', motto='" + usermotto + "', main='"
+ main + "',website1='" + website1 + "', website2='"
+ website2 + "', website3='" + website3 + "', website4='"
+ website4 + "', avatar='" + avatar + "', cardback='"
+ cardback + "', cat='" + cardcat + "' WHERE id='" + id + "'"
var updateYC = "UPDATE YourCard SET cardNum='" + cardindex + "'"
db.transaction(function (tx) {
var test = tx.executeSql(testStr)
var test1 = tx.executeSql(testStr1)
if (test.rows.length === 0) {
if (userid != "") {
tx.executeSql(userStr, data)
}
} else {
if (userid != "") {
tx.executeSql(updateUser)
}
}
if (test1.rows.length === 0) {
if (userid != "") {
tx.executeSql(ycStr, data1)
}
} else {
if (userid != "") {
tx.executeSql(updateYC)
}
}
})
var settingStr = "INSERT INTO Options VALUES(?,?,?,?)"
var settingdata = [id, sendcard, usealias, contact]
var OptStr = "SELECT * FROM Options WHERE id= '" + id + "'"
var updateOptions = "UPDATE Options SET sendcard ='" + sendcard + "',alias='"
+ usealias + "',contact='" + contact + "' WHERE id='" + id + "'"
db.transaction(function (tx) {
var test = tx.executeSql(OptStr)
if (test.rows.length === 0) {
if (userid != "") {
tx.executeSql(settingStr, settingdata)
}
} else {
if (userid != "") {
tx.executeSql(updateOptions)
}
}
})
return 1
}
function load_Card() {
console.log("Loading Card")
var dataStr = "SELECT * FROM Card WHERE 1"
db.transaction(function (tx) {
var pull = tx.executeSql(dataStr)
if (pull.rows.length === 1) {
//standard info card 1 //
userid = pull.rows.item(0).id
username = pull.rows.item(0).name.replace(/'/g, "'")
useremail = pull.rows.item(0).email
userphone = pull.rows.item(0).phone
usercompany = pull.rows.item(0).company.replace(/'/g, "'")
useralias = pull.rows.item(0).alias.replace(/'/g, "'")
usermotto = pull.rows.item(0).motto.replace(/'/g, "'")
website1 = pull.rows.item(0).website1
website2 = pull.rows.item(0).website2
website3 = pull.rows.item(0).website3
avimg = pull.rows.item(0).avatar
cardbImg = pull.rows.item(0).cardback
if (cardbImg.search("internal:") == -1) {
cardbImg = cardbImg
} else {
carddesign = pull.rows.item(0).cardback
var sets = cardbImg.slice(9, cardbImg.length)
fbgnum = sets.split(",")[0]
fsymbolnum = sets.split(",")[1]
ftextnum = sets.split(",")[2]
cardbImg = card_Set("background", fbgnum)
cardsImg = card_Set("symbol", fsymbolnum)
cardtplace = card_Set("text", ftextnum)
}
if (pull.rows.item(0).cat === null) {
usercat = " "
} else {
usercat = pull.rows.item(0).cat
}
if (pull.rows.item(0).website4 === null) {
website4 = " "
} else {
website4 = pull.rows.item(0).website4
}
if (pull.rows.item(0).main === null) {
usermain = " "
} else {
usermain = pull.rows.item(0).main
}
return 1
} else {
firstrun.state = "Active"
mainView.visible = true
return 0
}
})
if (userid > 3) {
console.log("something is wrong launching firstrun")
firstrun.state = "Active"
}
var cardStr = "SELECT * FROM Options WHERE 1"
var test = ""
db.transaction(function (tx) {
var pull = tx.executeSql(cardStr)
if (pull.rows.length > 0) {
stf = torf(pull.rows.item(0).sendcard)
atf = torf(pull.rows.item(0).alias)
ctf = torf(pull.rows.item(0).contact)
cardloaded = 1
} else {
cardloaded = 0
}
})
var cardStr1 = "SELECT * FROM YourCard WHERE 1"
var test1 = ""
db.transaction(function (tx) {
var pull = tx.executeSql(cardStr1)
if (pull.rows.length > 0) {
usercardNum = pull.rows.item(0).cardNum
cardloaded = 1
connect.start()
} else {
connect.start()
cardloaded = 0
}
})
// System Settings more may need to be added later, but for now this is what works //
db.transaction(function (tx) {
var CD = "SELECT * FROM Settings WHERE id='searchDistance'"
var CS = "SELECT * FROM Settings WHERE id='tempSupress'"
var CKT = "SELECT * FROM Settings WHERE id='keepTemp'"
var CT = "SELECT * FROM Settings WHERE id='theme'"
var CCM = "SELECT * FROM Settings WHERE id='CM'"
var CFM = "SELECT * FROM Settings WHERE id='FM'"
var CMM = "SELECT * FROM Settings WHERE id='MM'"
var checkDistance = tx.executeSql(CD)
var checkSupress = tx.executeSql(CS)
var checkKeepTemp = tx.executeSql(CKT)
var checkChanceMeetings = tx.executeSql(CCM)
var checkFrequenTMeetings = tx.executeSql(CFM)
var checkMissedMeetings = tx.executeSql(CMM)
var checkTheme = tx.executeSql(CT)
if (checkDistance.rows.length > 0) {
sD = checkDistance.rows.item(0).value
} else {
tx.executeSql("INSERT INTO Settings VALUES(?,?)",
["searchDistance", sD])
}
if (checkSupress.rows.length > 0) {
sT = checkSupress.rows.item(0).value
} else {
tx.executeSql("INSERT INTO Settings VALUES(?,?)",
["tempSupress", sT])
}
if (checkKeepTemp.rows.length > 0) {
kT = checkKeepTemp.rows.item(0).value
} else {
tx.executeSql("INSERT INTO Settings VALUES(?,?)", ["keepTemp", kT])
}
if (checkChanceMeetings.rows.length > 0) {
cM = checkChanceMeetings.rows.item(0).value
} else {
tx.executeSql("INSERT INTO Settings VALUES(?,?)", ["CM", cM])
}
if (checkFrequenTMeetings.rows.length > 0) {
fM = checkFrequenTMeetings.rows.item(0).value
} else {
tx.executeSql("INSERT INTO Settings VALUES(?,?)", ["FM", fM])
}
if (checkMissedMeetings.rows.length > 0) {
mM = checkMissedMeetings.rows.item(0).value
} else {
tx.executeSql("INSERT INTO Settings VALUES(?,?)", ["MM", mM])
}
if (checkTheme.rows.length > 0) {
theme = checkTheme.rows.item(0).value
} else {
tx.executeSql("INSERT INTO Settings VALUES(?,?)", ["theme", theme])
}
})
db.transaction(function (tx) {
var theplace = "INSERT INTO Themes VALUES(?,?,?,?,?,?,?,?,?,?)"
var theme0 = ["default", "#F9F9F9", "#FDF3E1", "#795548", "#FAFAF5", "#FDF3E1", "#FAFAFA", "#795548", "black", "black"]
var theme1 = ["pink", "#F9E6E6", "#FCF2E1", "#77564B", "#F8AEAE", "#FCF2E1", "#FAF3F3", "#77564B", "black", "black"]
var theme2 = ["PoP", "#24282A", "#48B9C7", "#FAA41A", "#3B3633", "#E88937", "#3B3633", "#FFFFFF", "#FAFAFA", "#FAFAFA"]
var check1 = tx.executeSql("SELECT * FROM Themes WHERE id='default'")
var check2 = tx.executeSql("SELECT * FROM Themes WHERE id='pink'")
var check3 = tx.executeSql("SELECT * FROM Themes WHERE id='PoP'")
if (check1.rows.length !== 1) {
tx.executeSql(theplace, theme0)
}
if (check2.rows.length !== 1) {
tx.executeSql(theplace, theme1)
}
if (check3.rows.length !== 1) {
tx.executeSql(theplace, theme2)
}
switch (theme) {
case 0:
if (check1.rows.length === 1) {
backgroundColor = check1.rows.item(0).backgroundColor
highLightColor1 = check1.rows.item(0).highLightColor
seperatorColor1 = check1.rows.item(0).seperatorColor
barColor = check1.rows.item(0).barColor
activeColor = check1.rows.item(0).activeColor
cardcolor = check1.rows.item(0).cardcolor
overlayColor = check1.rows.item(0).overlayColor
fontColorTitle = check1.rows.item(0).fontColorTitle
fontColor = check1.rows.item(0).fontColor
}
break
case 1:
if (check2.rows.length === 1) {
backgroundColor = check2.rows.item(0).backgroundColor
highLightColor1 = check2.rows.item(0).highLightColor
seperatorColor1 = check2.rows.item(0).seperatorColor
barColor = check2.rows.item(0).barColor
activeColor = check2.rows.item(0).activeColor
cardcolor = check2.rows.item(0).cardcolor
overlayColor = check2.rows.item(0).overlayColor
fontColorTitle = check2.rows.item(0).fontColorTitle
fontColor = check2.rows.item(0).fontColor
}
break
case 2:
if (check3.rows.length === 1) {
backgroundColor = check3.rows.item(0).backgroundColor
highLightColor1 = check3.rows.item(0).highLightColor
seperatorColor1 = check3.rows.item(0).seperatorColor
barColor = check3.rows.item(0).barColor
activeColor = check3.rows.item(0).activeColor
cardcolor = check3.rows.item(0).cardcolor
overlayColor = check3.rows.item(0).overlayColor
fontColorTitle = check3.rows.item(0).fontColorTitle
fontColor = check3.rows.item(0).fontColor
}
break
}
})
// End System Settings //
if (username.length < 1) {
if (usercompany.length < 1) {
selection = 0
cardPage.state = "settings"
mainScreen.state = "InActive"
topBar.state = "Wizard"
}
}
mainView.visible = true
}
function temp_Load(search, locale, sortOpt) {
var dbtable = ""
switch (locale) {
case "temp":
dbtable = "TempCards"
break
case "region":
dbtable = "RegCards"
break
case "global":
dbtable = "GlobCards"
break
default:
dbtable = "TempCards"
break
}
var Sort = ""
switch (sortOpt) {
case 1:
Sort = "name ASC"
break
case 2:
Sort = "company ASC"
break
case 3:
Sort = "cat ASC"
break
default:
Sort = "stamp DESC"
break
}
var dataStr = ""
if (search !== "") {
dataStr = "SELECT * FROM " + dbtable + " WHERE (name LIKE '%" + search
+ "%' OR company LIKE '%" + search + "%' OR motto LIKE '%#"
+ search + "%') ORDER BY " + Sort
} else {
dataStr = "SELECT * FROM " + dbtable + " WHERE 1 ORDER BY " + Sort
}
db.transaction(function (tx) {
var pull = tx.executeSql(dataStr)
numofcards = pull.rows.length
var record = 0
while (pull.rows.length > record) {
var c
var n
var p
var e
var cp
var testStr = "SELECT * FROM SavedCards WHERE id= " + pull.rows.item(
record).id
var duplicate = 0
var savecheck = tx.executeSql(testStr)
var previousdate
var datecollected = "SELECT * FROM Stats WHERE id= '" + pull.rows.item(
record).id + "' AND name ='lastseen'"
var date = tx.executeSql(datecollected)
var humanDate = ""
if (pull.rows.item(record).stamp.length > 10) {
humanDate = new Date(pull.rows.item(record).stamp)
} else {
humanDate = new Date(pull.rows.item(record).stamp * 1000)
}
if (pull.rows.item(record).id !== usercardNum) {
switch (sortOpt) {
case 1:
if (previousdate !== pull.rows.item(record).name[0]) {
previousdate = pull.rows.item(record).name[0]
cardslist.append({
type: 9,
date: pull.rows.item(
record).name[0]
})
}
break
case 2:
if (previousdate !== pull.rows.item(record).company[0]) {
previousdate = pull.rows.item(record).company[0]
cardslist.append({
type: 9,
date: pull.rows.item(
record).company[0]
})
}
break
case 3:
if (previousdate !== pull.rows.item(record).cat) {
previousdate = pull.rows.item(record).cat
cardslist.append({
type: 9,
date: pull.rows.item(record).cat
})
}
break
default:
if (previousdate !== pull.rows.item(record).stamp) {
previousdate = pull.rows.item(record).stamp
cardslist.append({
type: 9,
date: humanDate.toLocaleDateString(
)
})
}
break
}
}
if (duplicate == 0 && pull.rows.item(record).id !== 'undefined') {
var w1 = ""
var w2 = ""
var w3 = ""
var w4 = ""
var main = ""
var card
var symbol
var text
var design
var ava
cardsynctemp = pull.rows.item(record).id + "," + cardsynctemp
if (pull.rows.item(record).website1 !== 'undefined') {
switch (pull.rows.item(record).website1.substring(0, 4)) {
case "http":
w1 = pull.rows.item(record).website1
break
case "HTTP":
w1 = pull.rows.item(record).website1
break
case "Http":
w1 = pull.rows.item(record).website1
break
default:
w1 = "http://" + pull.rows.item(record).website1
break
}
} else {
w1 = ""
}
if (pull.rows.item(record).website2 !== 'undefined') {
switch (pull.rows.item(record).website2.substring(0, 4)) {
case "http":
w2 = pull.rows.item(record).website2
break
case "HTTP":
w2 = pull.rows.item(record).website2
break
case "Http":
w2 = pull.rows.item(record).website2
break
default:
w2 = "http://" + pull.rows.item(record).website2
break
}
} else {
w2 = ""
}
if (pull.rows.item(record).website3 !== 'undefined') {
switch (pull.rows.item(record).website3.substring(0, 4)) {
case "http":
w3 = pull.rows.item(record).website3
break
case "HTTP":
w3 = pull.rows.item(record).website3
break
case "Http":
w3 = pull.rows.item(record).website3
break
default:
w3 = "http://" + pull.rows.item(record).website3
break
}
} else {
w3 = ""
}
if (pull.rows.item(record).website4 !== 'undefined') {
switch (pull.rows.item(record).website4.substring(0, 4)) {
case "http":
w4 = pull.rows.item(record).website4
break
case "HTTP":
w4 = pull.rows.item(record).website4
break
case "Http":
w4 = pull.rows.item(record).website4
break
default:
w4 = "http://" + pull.rows.item(record).website4
break
}
} else {
w4 = ""
}
if (pull.rows.item(record).main !== 'undefined') {
switch (pull.rows.item(record).main.substring(0, 4)) {
case "http":
main = pull.rows.item(record).main
break
case "HTTP":
main = pull.rows.item(record).main
break
case "Http":
main = pull.rows.item(record).main
break
default:
main = "http://" + pull.rows.item(record).main
break
}
} else {
main = ""
}
if (pull.rows.item(record).avatar.length < 4) {
ava = "img/default_avatar.png"
} else {
ava = pull.rows.item(record).avatar
if (ava.search("/9j/4A") !== -1) {
ava = "data:image/jpeg;base64, " + ava.replace(/ /g,
"+")
}
}
var spC = seperatorColor1
for (var num = 0; num < category_list.split(
",").length; num = num + 1) {
if (pull.rows.item(record).cat === category_list.split(
",")[num].split("::")[0]) {
if (category_list.split(",")[num].split(
"::")[1] !== "none") {
spC = category_list.split(",")[num].split("::")[1]
} else {
spC = seperatorColor1
}
}
}
if (currentcat.length > 2 & currentcat !== qsTr("All Cards")) {
if (currentcat === pull.rows.item(record).cat) {
// console.log(currentlist.split(":"));
if (currentlist != "") {
if (currentlist.search(":" + pull.rows.item(
record).id) == -1) {
currentlist = currentlist + ":" + pull.rows.item(
record).id
}
} else {
currentlist = ":" + pull.rows.item(record).id
}
if (pull.rows.item(record).name !== 'undefined') {
n = pull.rows.item(record).name.replace(/'/g,
"'")
} else {
n = ""
}
if (pull.rows.item(record).company !== 'undefined') {
c = pull.rows.item(record).company.replace(
/'/g, "'")
} else {
c = ""
}
if (pull.rows.item(record).phone !== 'undefined') {
p = pull.rows.item(record).phone
} else {
p = ""
}
if (pull.rows.item(record).email !== 'undefined') {
e = pull.rows.item(record).email
} else {
e = ""
}
if (pull.rows.item(record).alias !== 'undefined') {
cp = pull.rows.item(record).alias
} else {
cp = ""
}
if (pull.rows.item(record).id !== usercardNum) {
cardslist.append({
type: 0,
name: n,
colorCode: "white",
imagesource: "img/default_avatar.png",
company: c,
phone: p,
email: e,
cardposition: cp,
motto: pull.rows.item(
record).motto.replace(
/'/g, "'"),
cardId: pull.rows.item(
record).id.toString(
),
mainsite: main,
URL1: w1,
URL2: w2,
URL3: w3,
URL4: w4,
spColor: spC,
cardStatus: "",
connection: parseInt(
get_contact_info(
pull.rows.item(
record).id.toString(
),
"relation")),
cardb: pull.rows.item(
record).cardback,
cardcat: pull.rows.item(
record).cat,
imgsource: ava,
cardsop: pull.rows.item(
record).cardsop,
saved: savecheck.rows.length
})
} else {
usercard = pull.rows.item(record).id.toString()
}
}
} else {
if (currentlist != "") {
if (currentlist.search(":" + pull.rows.item(
record).id) == -1) {
currentlist = currentlist + ":" + pull.rows.item(
record).id
}
} else {
currentlist = ":" + pull.rows.item(record).id
}
if (pull.rows.item(record).id !== usercardNum) {
if (pull.rows.item(record).name !== 'undefined') {
n = pull.rows.item(record).name.replace(/'/g,
"'")
} else {
n = ""
}
if (pull.rows.item(record).company !== 'undefined') {
c = pull.rows.item(record).company.replace(
/'/g, "'")
} else {
c = ""
}
if (pull.rows.item(record).phone !== 'undefined') {
p = pull.rows.item(record).phone
} else {
p = ""
}
if (pull.rows.item(record).email !== 'undefined') {
e = pull.rows.item(record).email
} else {
e = ""
}
if (pull.rows.item(record).alias !== 'undefined') {
cp = pull.rows.item(record).alias
} else {
cp = ""
}
cardslist.append({
type: 0,
name: n,
colorCode: "white",
imagesource: "img/default_avatar.png",
company: c,
phone: p,
email: e,
cardposition: cp,
motto: pull.rows.item(
record).motto.replace(
/'/g, "'"),
cardId: pull.rows.item(
record).id.toString(),
mainsite: main,
URL1: w1,
URL2: w2,
URL3: w3,
URL4: w4,
spColor: spC,
cardStatus: "",
connection: parseInt(
get_contact_info(
pull.rows.item(
record).id.toString(
),
"relation")),
cardcat: pull.rows.item(
record).cat,
imgsource: ava,
cardb: pull.rows.item(
record).cardback,
cardsop: pull.rows.item(
record).cardsop,
saved: savecheck.rows.length
})
} else {
usercard = pull.rows.item(record).id.toString()
}
}
}
record = record + 1
}
})
}
function cards_Save(id, username, userphone, useremail, usercompany, useralias, usermotto, main, website1, website2, website3, website4, avatar, cardback, cardcat, cardsop) {
var userStr = "INSERT INTO SavedCards VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
var data = [id, username, userphone, useremail, usercompany, useralias, usermotto, main, website1, website2, website3, website4, avatar, cardback, cardcat, cardsop]
console.log(data)
db.transaction(function (tx) {
if (id.length !== 0) {
tx.executeSql(userStr, data)
}
})
cardsyncsaved = id + "," + cardsyncsaved
return 1
}
function cards_Load(search, sortOpt) {
var dataStr = ""
cardsyncsaved = ""
var Sort = ""
switch (sortOpt) {
case 1:
Sort = "name DESC"
break
case 2:
Sort = "company ASC"
break
case 3:
Sort = "cat ASC"
break
default:
Sort = "name ASC"
break
}
if (search.length > 0) {
dataStr = "SELECT * FROM SavedCards WHERE (name LIKE '%" + search + "%' OR company LIKE '%"
+ search + "%' OR motto LIKE '%#" + search + "%') ORDER By " + Sort
} else {
dataStr = "SELECT * FROM SavedCards WHERE 1 ORDER By " + Sort
}
db.transaction(function (tx) {
var pull = tx.executeSql(dataStr)
var previousdate
var record = 0
while (pull.rows.length > record) {
if (pull.rows.item(record).id > 1) {
if (pull.rows.item(record).id !== usercardNum) {
switch (sortOpt) {
case 1:
if (previousdate !== pull.rows.item(record).name[0]) {
previousdate = pull.rows.item(record).name[0]
cardslist.append({
type: 9,
date: pull.rows.item(
record).name[0]
})
}
break
case 2:
if (previousdate !== pull.rows.item(
record).company[0]) {
previousdate = pull.rows.item(record).company[0]
cardslist.append({
type: 9,
date: pull.rows.item(
record).company[0]
})
}
break
case 3:
if (previousdate !== pull.rows.item(record).cat) {
previousdate = pull.rows.item(record).cat
cardslist.append({
type: 9,
date: pull.rows.item(
record).cat
})
}
break
default:
if (previousdate !== pull.rows.item(record).name[0]) {
previousdate = pull.rows.item(record).name[0]
cardslist.append({
type: 9,
date: pull.rows.item(
record).name[0]
})
}
break
}
}
cardsyncsaved = pull.rows.item(record).id + "," + cardsyncsaved
var w1 = ""
var w2 = ""
var w3 = ""
var w4 = ""
var main = ""
var card
var ava = ""
var symbol
var text
var c
var n
var p
var e
var cp
if (pull.rows.item(record).website1 !== 'undefined') {
switch (pull.rows.item(record).website1.substring(0, 4)) {
case "http":
w1 = pull.rows.item(record).website1
break
case "HTTP":
w1 = pull.rows.item(record).website1
break
case "Http":
w1 = pull.rows.item(record).website1
break
default:
w1 = "http://" + pull.rows.item(record).website1
break
}
} else {
w1 = ""
}
if (pull.rows.item(record).website2 !== 'undefined') {
switch (pull.rows.item(record).website2.substring(0, 4)) {
case "http":
w2 = pull.rows.item(record).website2
break
case "HTTP":
w2 = pull.rows.item(record).website2
break
case "Http":
w2 = pull.rows.item(record).website2
break
default:
w2 = "http://" + pull.rows.item(record).website2
break