-
Notifications
You must be signed in to change notification settings - Fork 1
/
circlepic.js
98 lines (81 loc) · 3.66 KB
/
circlepic.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
function returnImage(who, locale, source) {
var dbtable = ""
switch (locale) {
case "temp":
dbtable = "TempCards"
break
case "region":
dbtable = "RegCards"
break
case "global":
dbtable = "GlobCards"
break
case "saved":
dbtable = "SavedCards"
break
case "mycard":
dbtable = "Card"
break
default:
dbtable = "TempCards"
break
}
var dataStr = "SELECT avatar FROM " + dbtable + " WHERE id ='" + who + "'"
var ava = ""
if (source.length > 4) {
if (source.search("/9j/4A") !== -1 && source.search(
"data:image/jpeg;base64") === -1) {
ava = "data:image/jpeg;base64, " + source.replace(/ /g, "+")
fixpic = ava
} else {
fixpic = source
}
} else if (locale.length > 1) {
if (locale !== "mycard") {
db.transaction(function (tx) {
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)')
var pull = tx.executeSql(dataStr)
if (pull.rows.length === 1) {
if (pull.rows.item(0).avatar === null) {
ava = "img/default_avatar.png"
} else {
ava = pull.rows.item(0).avatar
if (ava.search("/9j/4A") != -1 && ava.search(
"data:image/jpeg;base64") == -1) {
ava = "data:image/jpeg;base64, " + ava.replace(
/ /g, "+")
}
}
fixpic = ava
} else {
ava = currentcard_avatarimg
}
})
fixpic = ava
} else {
dataStr = "SELECT avatar FROM " + dbtable + " WHERE 1"
db.transaction(function (tx) {
var pull = tx.executeSql(dataStr)
if (pull.rows.item(0).avatar.length < 4) {
ava = "./img/default_avatar.png"
} else {
ava = pull.rows.item(0).avatar
if (ava.search("/9j/4A") != -1 && ava.search(
"data:image/jpeg;base64") == -1) {
ava = "data:image/jpeg;base64, " + ava.replace(/ /g,
"+")
}
}
fixpic = ava
})
}
}
return ava
}