cdnhost 1.5.3 → 1.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -13,9 +13,14 @@ function loadBanner(divId = '1', userId = 'admin', width = 300, height = 250) {
|
|
|
13
13
|
div.style.background = '#000';
|
|
14
14
|
div.innerHTML = '';
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
fetch('https://ipapi.co/json/')
|
|
17
|
+
.then(res => res.json())
|
|
18
|
+
.then(data => {
|
|
19
|
+
const ip = data.ip;
|
|
20
|
+
const region = data.region || '';
|
|
21
|
+
return fetch(`https://gig.snapp.im/banner_test.php?user=${encodeURIComponent(userId)}&country=ko&ip=${ip}®ion=${encodeURIComponent(region)}`);
|
|
22
|
+
})
|
|
23
|
+
|
|
19
24
|
.then(res => res.json())
|
|
20
25
|
.then(data => {
|
|
21
26
|
const hasImage = data.image && data.image.trim() !== '';
|
|
@@ -169,4 +174,3 @@ function loadBanner(divId = '1', userId = 'admin', width = 300, height = 250) {
|
|
|
169
174
|
console.error('배너 로드 실패:', err);
|
|
170
175
|
});
|
|
171
176
|
}
|
|
172
|
-
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
function loadBanner(divId = '1', userId = 'admin', width = 300, height = 250) {
|
|
2
3
|
const div = document.getElementById(divId);
|
|
3
4
|
if (!div) {
|
|
@@ -7,124 +8,150 @@ function loadBanner(divId = '1', userId = 'admin', width = 300, height = 250) {
|
|
|
7
8
|
|
|
8
9
|
div.style.height = (typeof height === 'number' ? height + 'px' : height);
|
|
9
10
|
div.style.width = (typeof width === 'number' ? width + 'px' : width);
|
|
11
|
+
div.style.overflow = 'hidden';
|
|
12
|
+
|
|
10
13
|
div.style.background = '#000';
|
|
11
14
|
div.innerHTML = '';
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
fetch('https://ipapi.co/json/')
|
|
17
|
+
.then(res => res.json())
|
|
18
|
+
.then(data => {
|
|
19
|
+
const ip = data.ip;
|
|
20
|
+
const region = data.region || '';
|
|
21
|
+
return fetch(`https://gig.snapp.im/banner_api.php?user=${encodeURIComponent(userId)}&country=ko&ip=${ip}®ion=${encodeURIComponent(region)}`);
|
|
22
|
+
})
|
|
23
|
+
|
|
16
24
|
.then(res => res.json())
|
|
17
25
|
.then(data => {
|
|
18
|
-
const
|
|
19
|
-
banner
|
|
20
|
-
|
|
26
|
+
const hasImage = data.image && data.image.trim() !== '';
|
|
27
|
+
const banner = document.createElement('div');
|
|
28
|
+
|
|
29
|
+
const targetUrl = `https://gig.snapp.im/banner2.php?link=${encodeURIComponent(data.link)}&user=${encodeURIComponent(userId)}&country=ko`;
|
|
30
|
+
|
|
31
|
+
// 배너 기본 스타일
|
|
21
32
|
banner.style.background = '#000';
|
|
22
33
|
banner.style.color = '#fff';
|
|
23
|
-
banner.style.textDecoration = 'none';
|
|
24
34
|
banner.style.display = 'flex';
|
|
25
35
|
banner.style.overflow = 'hidden';
|
|
26
|
-
banner.style.position = 'relative';
|
|
36
|
+
banner.style.position = 'relative';
|
|
37
|
+
banner.style.cursor = 'pointer';
|
|
27
38
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
imageDiv.style.backgroundSize = 'cover';
|
|
34
|
-
imageDiv.style.backgroundPosition = 'center';
|
|
35
|
-
imageDiv.style.flexShrink = '0';
|
|
39
|
+
// 배너 클릭 시 링크 이동
|
|
40
|
+
banner.addEventListener('click', (e) => {
|
|
41
|
+
if (e.target.closest('.fixed-icon')) return; // 아이콘 클릭 제외
|
|
42
|
+
window.open(targetUrl, '_blank');
|
|
43
|
+
});
|
|
36
44
|
|
|
37
45
|
const textDiv = document.createElement('div');
|
|
38
|
-
textDiv.style.color = '#fff';
|
|
39
46
|
textDiv.style.boxSizing = 'border-box';
|
|
40
47
|
textDiv.style.padding = '10px';
|
|
41
48
|
textDiv.style.overflow = 'hidden';
|
|
49
|
+
textDiv.style.height = '600px';
|
|
50
|
+
textDiv.style.display = 'flex';
|
|
51
|
+
textDiv.style.flexDirection = 'column';
|
|
52
|
+
textDiv.style.justifyContent = 'center';
|
|
53
|
+
textDiv.style.setProperty('color', '#fff', 'important');
|
|
54
|
+
textDiv.style.setProperty('line-height', '1.4', 'important');
|
|
42
55
|
|
|
43
56
|
const title = document.createElement('h3');
|
|
44
57
|
title.textContent = data.title;
|
|
45
58
|
title.style.margin = '0 0 10px 0';
|
|
59
|
+
title.style.setProperty('color', '#fff', 'important');
|
|
60
|
+
title.style.setProperty('line-height', '1.4', 'important');
|
|
46
61
|
|
|
47
62
|
const desc = document.createElement('p');
|
|
48
63
|
desc.textContent = data.desc;
|
|
49
64
|
desc.style.margin = '0';
|
|
65
|
+
desc.style.setProperty('color', '#fff', 'important');
|
|
66
|
+
desc.style.setProperty('line-height', '1.4', 'important');
|
|
50
67
|
|
|
51
68
|
textDiv.appendChild(title);
|
|
52
69
|
textDiv.appendChild(desc);
|
|
53
70
|
|
|
54
71
|
const widthNum = typeof width === 'number' ? width : null;
|
|
72
|
+
const imgWidth = 300;
|
|
73
|
+
const imgHeight = 250;
|
|
55
74
|
const isFullWidth = width.toString() === '100%';
|
|
56
75
|
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
imageDiv.style.
|
|
62
|
-
imageDiv.style.
|
|
76
|
+
if (hasImage) {
|
|
77
|
+
const imageDiv = document.createElement('div');
|
|
78
|
+
imageDiv.style.backgroundImage = `url('${data.image}')`;
|
|
79
|
+
imageDiv.style.backgroundSize = 'cover';
|
|
80
|
+
imageDiv.style.backgroundPosition = 'center';
|
|
81
|
+
imageDiv.style.flexShrink = '0';
|
|
63
82
|
|
|
64
|
-
|
|
83
|
+
if (widthNum === imgWidth && height === imgHeight) {
|
|
84
|
+
banner.style.width = imgWidth + 'px';
|
|
85
|
+
banner.style.height = imgHeight + 'px';
|
|
86
|
+
banner.style.flexDirection = 'column';
|
|
65
87
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
banner.style.height = imgHeight + 'px';
|
|
69
|
-
banner.style.flexDirection = 'row';
|
|
88
|
+
imageDiv.style.width = imgWidth + 'px';
|
|
89
|
+
imageDiv.style.height = imgHeight + 'px';
|
|
70
90
|
|
|
71
|
-
|
|
72
|
-
imageDiv.style.height = imgHeight + 'px';
|
|
91
|
+
banner.appendChild(imageDiv);
|
|
73
92
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
textDiv.style.justifyContent = 'center';
|
|
93
|
+
} else if (isFullWidth) {
|
|
94
|
+
banner.style.width = '100%';
|
|
95
|
+
banner.style.height = imgHeight + 'px';
|
|
96
|
+
banner.style.flexDirection = 'row';
|
|
79
97
|
|
|
80
|
-
|
|
81
|
-
|
|
98
|
+
imageDiv.style.width = imgWidth + 'px';
|
|
99
|
+
imageDiv.style.height = imgHeight + 'px';
|
|
82
100
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
banner.style.width = widthNum + 'px';
|
|
86
|
-
banner.style.height = imgHeight + 'px';
|
|
87
|
-
banner.style.flexDirection = 'row';
|
|
101
|
+
textDiv.style.flexGrow = '1';
|
|
102
|
+
textDiv.style.height = imgHeight + 'px';
|
|
88
103
|
|
|
89
|
-
|
|
90
|
-
|
|
104
|
+
banner.appendChild(imageDiv);
|
|
105
|
+
banner.appendChild(textDiv);
|
|
91
106
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
107
|
+
} else if (widthNum !== null && widthNum > imgWidth) {
|
|
108
|
+
const extraWidth = widthNum - imgWidth;
|
|
109
|
+
banner.style.width = widthNum + 'px';
|
|
110
|
+
banner.style.height = imgHeight + 'px';
|
|
111
|
+
banner.style.flexDirection = 'row';
|
|
97
112
|
|
|
98
|
-
|
|
99
|
-
|
|
113
|
+
imageDiv.style.width = imgWidth + 'px';
|
|
114
|
+
imageDiv.style.height = imgHeight + 'px';
|
|
100
115
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
banner.style.width = imgWidth + 'px';
|
|
104
|
-
banner.style.height = height + 'px';
|
|
105
|
-
banner.style.flexDirection = 'column';
|
|
116
|
+
textDiv.style.width = extraWidth + 'px';
|
|
117
|
+
textDiv.style.height = imgHeight + 'px';
|
|
106
118
|
|
|
107
|
-
|
|
108
|
-
|
|
119
|
+
banner.appendChild(imageDiv);
|
|
120
|
+
banner.appendChild(textDiv);
|
|
109
121
|
|
|
110
|
-
|
|
111
|
-
|
|
122
|
+
} else if (typeof height === 'number' && height > imgHeight) {
|
|
123
|
+
const extraHeight = height - imgHeight;
|
|
124
|
+
banner.style.width = imgWidth + 'px';
|
|
125
|
+
banner.style.height = height + 'px';
|
|
126
|
+
banner.style.flexDirection = 'column';
|
|
112
127
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
} else {
|
|
116
|
-
banner.style.width = (typeof width === 'number' ? width + 'px' : width);
|
|
117
|
-
banner.style.height = (typeof height === 'number' ? height + 'px' : height);
|
|
118
|
-
banner.style.flexDirection = 'column';
|
|
128
|
+
imageDiv.style.width = imgWidth + 'px';
|
|
129
|
+
imageDiv.style.height = imgHeight + 'px';
|
|
119
130
|
|
|
120
|
-
|
|
121
|
-
|
|
131
|
+
textDiv.style.width = imgWidth + 'px';
|
|
132
|
+
textDiv.style.height = extraHeight + 'px';
|
|
122
133
|
|
|
123
|
-
|
|
134
|
+
banner.appendChild(imageDiv);
|
|
135
|
+
banner.appendChild(textDiv);
|
|
136
|
+
} else {
|
|
137
|
+
banner.style.width = (typeof width === 'number' ? width + 'px' : width);
|
|
138
|
+
banner.style.height = (typeof height === 'number' ? height + 'px' : height);
|
|
139
|
+
banner.style.flexDirection = 'column';
|
|
140
|
+
|
|
141
|
+
imageDiv.style.width = (typeof width === 'number' ? width + 'px' : width);
|
|
142
|
+
imageDiv.style.height = (typeof height === 'number' ? height + 'px' : height);
|
|
143
|
+
|
|
144
|
+
banner.appendChild(imageDiv);
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
banner.style.flexDirection = 'column';
|
|
148
|
+
textDiv.style.display = 'block';
|
|
149
|
+
banner.appendChild(textDiv);
|
|
124
150
|
}
|
|
125
151
|
|
|
126
|
-
//
|
|
152
|
+
// 고정 아이콘 (클릭 제외 대상)
|
|
127
153
|
const fixedIcon = document.createElement('a');
|
|
154
|
+
fixedIcon.className = 'fixed-icon';
|
|
128
155
|
fixedIcon.href = 'https://gig.snapp.im/';
|
|
129
156
|
fixedIcon.target = '_blank';
|
|
130
157
|
fixedIcon.style.position = 'absolute';
|
|
@@ -146,4 +173,4 @@ function loadBanner(divId = '1', userId = 'admin', width = 300, height = 250) {
|
|
|
146
173
|
.catch(err => {
|
|
147
174
|
console.error('배너 로드 실패:', err);
|
|
148
175
|
});
|
|
149
|
-
}
|
|
176
|
+
}
|
package/cdnbanner.js
CHANGED
|
@@ -18,7 +18,7 @@ fetch('https://ipapi.co/json/')
|
|
|
18
18
|
.then(data => {
|
|
19
19
|
const ip = data.ip;
|
|
20
20
|
const region = data.region || '';
|
|
21
|
-
return fetch(`https://gig.snapp.im/
|
|
21
|
+
return fetch(`https://gig.snapp.im/banner_test.php?user=${encodeURIComponent(userId)}&country=ko&ip=${ip}®ion=${encodeURIComponent(region)}`);
|
|
22
22
|
})
|
|
23
23
|
|
|
24
24
|
.then(res => res.json())
|
|
@@ -49,6 +49,7 @@ fetch('https://ipapi.co/json/')
|
|
|
49
49
|
textDiv.style.height = '600px';
|
|
50
50
|
textDiv.style.display = 'flex';
|
|
51
51
|
textDiv.style.flexDirection = 'column';
|
|
52
|
+
textDiv.style.justifyContent = 'center';
|
|
52
53
|
textDiv.style.setProperty('color', '#fff', 'important');
|
|
53
54
|
textDiv.style.setProperty('line-height', '1.4', 'important');
|
|
54
55
|
|
|
@@ -172,4 +173,4 @@ fetch('https://ipapi.co/json/')
|
|
|
172
173
|
.catch(err => {
|
|
173
174
|
console.error('배너 로드 실패:', err);
|
|
174
175
|
});
|
|
175
|
-
}
|
|
176
|
+
}
|