cdnhost 1.4.8 → 1.4.9

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.
Files changed (3) hide show
  1. package/cdnbanner.js +28 -14
  2. package/cdnbanner_.js +158 -0
  3. package/package.json +1 -1
package/cdnbanner.js CHANGED
@@ -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,6 +8,8 @@ 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
 
@@ -16,30 +19,46 @@ function loadBanner(divId = '1', userId = 'admin', width = 300, height = 250) {
16
19
  .then(res => res.json())
17
20
  .then(data => {
18
21
  const hasImage = data.image && data.image.trim() !== '';
22
+ const banner = document.createElement('div');
23
+
24
+ const targetUrl = `https://gig.snapp.im/banner2.php?link=${encodeURIComponent(data.link)}&user=${encodeURIComponent(userId)}&country=ko`;
19
25
 
20
- const banner = document.createElement('a');
21
- banner.href = `https://gig.snapp.im/banner2.php?link=${encodeURIComponent(data.link)}&user=${encodeURIComponent(userId)}&country=ko`;
22
- banner.target = "_blank";
26
+ // 배너 기본 스타일
23
27
  banner.style.background = '#000';
24
28
  banner.style.color = '#fff';
25
- banner.style.textDecoration = 'none';
26
29
  banner.style.display = 'flex';
27
30
  banner.style.overflow = 'hidden';
28
31
  banner.style.position = 'relative';
32
+ banner.style.cursor = 'pointer';
33
+
34
+ // 배너 클릭 시 링크 이동
35
+ banner.addEventListener('click', (e) => {
36
+ if (e.target.closest('.fixed-icon')) return; // 아이콘 클릭 제외
37
+ window.open(targetUrl, '_blank');
38
+ });
29
39
 
30
40
  const textDiv = document.createElement('div');
31
- textDiv.style.color = '#fff';
32
41
  textDiv.style.boxSizing = 'border-box';
33
42
  textDiv.style.padding = '10px';
34
43
  textDiv.style.overflow = 'hidden';
44
+ textDiv.style.height = '600px';
45
+ textDiv.style.display = 'flex';
46
+ textDiv.style.flexDirection = 'column';
47
+ textDiv.style.justifyContent = 'center';
48
+ textDiv.style.setProperty('color', '#fff', 'important');
49
+ textDiv.style.setProperty('line-height', '1.4', 'important');
35
50
 
36
51
  const title = document.createElement('h3');
37
52
  title.textContent = data.title;
38
53
  title.style.margin = '0 0 10px 0';
54
+ title.style.setProperty('color', '#fff', 'important');
55
+ title.style.setProperty('line-height', '1.4', 'important');
39
56
 
40
57
  const desc = document.createElement('p');
41
58
  desc.textContent = data.desc;
42
59
  desc.style.margin = '0';
60
+ desc.style.setProperty('color', '#fff', 'important');
61
+ desc.style.setProperty('line-height', '1.4', 'important');
43
62
 
44
63
  textDiv.appendChild(title);
45
64
  textDiv.appendChild(desc);
@@ -76,9 +95,6 @@ function loadBanner(divId = '1', userId = 'admin', width = 300, height = 250) {
76
95
 
77
96
  textDiv.style.flexGrow = '1';
78
97
  textDiv.style.height = imgHeight + 'px';
79
- textDiv.style.display = 'flex';
80
- textDiv.style.flexDirection = 'column';
81
- textDiv.style.justifyContent = 'center';
82
98
 
83
99
  banner.appendChild(imageDiv);
84
100
  banner.appendChild(textDiv);
@@ -94,9 +110,6 @@ function loadBanner(divId = '1', userId = 'admin', width = 300, height = 250) {
94
110
 
95
111
  textDiv.style.width = extraWidth + 'px';
96
112
  textDiv.style.height = imgHeight + 'px';
97
- textDiv.style.display = 'flex';
98
- textDiv.style.flexDirection = 'column';
99
- textDiv.style.justifyContent = 'center';
100
113
 
101
114
  banner.appendChild(imageDiv);
102
115
  banner.appendChild(textDiv);
@@ -126,14 +139,14 @@ function loadBanner(divId = '1', userId = 'admin', width = 300, height = 250) {
126
139
  banner.appendChild(imageDiv);
127
140
  }
128
141
  } else {
129
- // 이미지 없을 때: 텍스트만, 고정 높이/너비 없이 자동 크기
130
142
  banner.style.flexDirection = 'column';
131
143
  textDiv.style.display = 'block';
132
144
  banner.appendChild(textDiv);
133
145
  }
134
146
 
135
- // 고정 아이콘 (항상 표시)
147
+ // 고정 아이콘 (클릭 제외 대상)
136
148
  const fixedIcon = document.createElement('a');
149
+ fixedIcon.className = 'fixed-icon';
137
150
  fixedIcon.href = 'https://gig.snapp.im/';
138
151
  fixedIcon.target = '_blank';
139
152
  fixedIcon.style.position = 'absolute';
@@ -155,4 +168,5 @@ function loadBanner(divId = '1', userId = 'admin', width = 300, height = 250) {
155
168
  .catch(err => {
156
169
  console.error('배너 로드 실패:', err);
157
170
  });
158
- }
171
+ }
172
+
package/cdnbanner_.js ADDED
@@ -0,0 +1,158 @@
1
+ function loadBanner(divId = '1', userId = 'admin', width = 300, height = 250) {
2
+ const div = document.getElementById(divId);
3
+ if (!div) {
4
+ console.error(`Element with id="${divId}" not found.`);
5
+ return;
6
+ }
7
+
8
+ div.style.height = (typeof height === 'number' ? height + 'px' : height);
9
+ div.style.width = (typeof width === 'number' ? width + 'px' : width);
10
+ div.style.background = '#000';
11
+ div.innerHTML = '';
12
+
13
+ fetch('https://api.ipify.org?format=json')
14
+ .then(res => res.json())
15
+ .then(data => fetch(`https://gig.snapp.im/banner_test.php?user=${encodeURIComponent(userId)}&country=ko&ip=${data.ip}`))
16
+ .then(res => res.json())
17
+ .then(data => {
18
+ const hasImage = data.image && data.image.trim() !== '';
19
+
20
+ const banner = document.createElement('a');
21
+ banner.href = `https://gig.snapp.im/banner2.php?link=${encodeURIComponent(data.link)}&user=${encodeURIComponent(userId)}&country=ko`;
22
+ banner.target = "_blank";
23
+ banner.style.background = '#000';
24
+ banner.style.color = '#fff';
25
+ banner.style.textDecoration = 'none';
26
+ banner.style.display = 'flex';
27
+ banner.style.overflow = 'hidden';
28
+ banner.style.position = 'relative';
29
+
30
+ const textDiv = document.createElement('div');
31
+ textDiv.style.color = '#fff';
32
+ textDiv.style.boxSizing = 'border-box';
33
+ textDiv.style.padding = '10px';
34
+ textDiv.style.overflow = 'hidden';
35
+
36
+ const title = document.createElement('h3');
37
+ title.textContent = data.title;
38
+ title.style.margin = '0 0 10px 0';
39
+
40
+ const desc = document.createElement('p');
41
+ desc.textContent = data.desc;
42
+ desc.style.margin = '0';
43
+
44
+ textDiv.appendChild(title);
45
+ textDiv.appendChild(desc);
46
+
47
+ const widthNum = typeof width === 'number' ? width : null;
48
+ const imgWidth = 300;
49
+ const imgHeight = 250;
50
+ const isFullWidth = width.toString() === '100%';
51
+
52
+ if (hasImage) {
53
+ const imageDiv = document.createElement('div');
54
+ imageDiv.style.backgroundImage = `url('${data.image}')`;
55
+ imageDiv.style.backgroundSize = 'cover';
56
+ imageDiv.style.backgroundPosition = 'center';
57
+ imageDiv.style.flexShrink = '0';
58
+
59
+ if (widthNum === imgWidth && height === imgHeight) {
60
+ banner.style.width = imgWidth + 'px';
61
+ banner.style.height = imgHeight + 'px';
62
+ banner.style.flexDirection = 'column';
63
+
64
+ imageDiv.style.width = imgWidth + 'px';
65
+ imageDiv.style.height = imgHeight + 'px';
66
+
67
+ banner.appendChild(imageDiv);
68
+
69
+ } else if (isFullWidth) {
70
+ banner.style.width = '100%';
71
+ banner.style.height = imgHeight + 'px';
72
+ banner.style.flexDirection = 'row';
73
+
74
+ imageDiv.style.width = imgWidth + 'px';
75
+ imageDiv.style.height = imgHeight + 'px';
76
+
77
+ textDiv.style.flexGrow = '1';
78
+ textDiv.style.height = imgHeight + 'px';
79
+ textDiv.style.display = 'flex';
80
+ textDiv.style.flexDirection = 'column';
81
+ textDiv.style.justifyContent = 'center';
82
+
83
+ banner.appendChild(imageDiv);
84
+ banner.appendChild(textDiv);
85
+
86
+ } else if (widthNum !== null && widthNum > imgWidth) {
87
+ const extraWidth = widthNum - imgWidth;
88
+ banner.style.width = widthNum + 'px';
89
+ banner.style.height = imgHeight + 'px';
90
+ banner.style.flexDirection = 'row';
91
+
92
+ imageDiv.style.width = imgWidth + 'px';
93
+ imageDiv.style.height = imgHeight + 'px';
94
+
95
+ textDiv.style.width = extraWidth + 'px';
96
+ textDiv.style.height = imgHeight + 'px';
97
+ textDiv.style.display = 'flex';
98
+ textDiv.style.flexDirection = 'column';
99
+ textDiv.style.justifyContent = 'center';
100
+
101
+ banner.appendChild(imageDiv);
102
+ banner.appendChild(textDiv);
103
+
104
+ } else if (typeof height === 'number' && height > imgHeight) {
105
+ const extraHeight = height - imgHeight;
106
+ banner.style.width = imgWidth + 'px';
107
+ banner.style.height = height + 'px';
108
+ banner.style.flexDirection = 'column';
109
+
110
+ imageDiv.style.width = imgWidth + 'px';
111
+ imageDiv.style.height = imgHeight + 'px';
112
+
113
+ textDiv.style.width = imgWidth + 'px';
114
+ textDiv.style.height = extraHeight + 'px';
115
+
116
+ banner.appendChild(imageDiv);
117
+ banner.appendChild(textDiv);
118
+ } else {
119
+ banner.style.width = (typeof width === 'number' ? width + 'px' : width);
120
+ banner.style.height = (typeof height === 'number' ? height + 'px' : height);
121
+ banner.style.flexDirection = 'column';
122
+
123
+ imageDiv.style.width = (typeof width === 'number' ? width + 'px' : width);
124
+ imageDiv.style.height = (typeof height === 'number' ? height + 'px' : height);
125
+
126
+ banner.appendChild(imageDiv);
127
+ }
128
+ } else {
129
+ // 이미지 없을 때: 텍스트만, 고정 높이/너비 없이 자동 크기
130
+ banner.style.flexDirection = 'column';
131
+ textDiv.style.display = 'block';
132
+ banner.appendChild(textDiv);
133
+ }
134
+
135
+ // 고정 아이콘 (항상 표시)
136
+ const fixedIcon = document.createElement('a');
137
+ fixedIcon.href = 'https://gig.snapp.im/';
138
+ fixedIcon.target = '_blank';
139
+ fixedIcon.style.position = 'absolute';
140
+ fixedIcon.style.top = '5px';
141
+ fixedIcon.style.right = '5px';
142
+ fixedIcon.style.width = '30px';
143
+ fixedIcon.style.zIndex = '10';
144
+
145
+ const fixedImg = document.createElement('img');
146
+ fixedImg.src = 'https://cdn.jsdelivr.net/npm/cdnhost@0.1.4/l2.png';
147
+ fixedImg.alt = 'a';
148
+ fixedImg.style.width = '100%';
149
+
150
+ fixedIcon.appendChild(fixedImg);
151
+ banner.appendChild(fixedIcon);
152
+
153
+ div.appendChild(banner);
154
+ })
155
+ .catch(err => {
156
+ console.error('배너 로드 실패:', err);
157
+ });
158
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cdnhost",
3
- "version": "1.4.8",
3
+ "version": "1.4.9",
4
4
  "description": "cdnhost",
5
5
  "main": "index.js",
6
6
  "scripts": {