Skip to content

Commit

Permalink
Merge pull request gnuboard#274 from KyleDEV/fix/알뜰구매_모든링크열기_동작수정
Browse files Browse the repository at this point in the history
Fix/알뜰구매 모든링크열기 동작수정
  • Loading branch information
damaong authored Jul 8, 2024
2 parents e7b4dd3 + 016bf2b commit de62252
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
23 changes: 18 additions & 5 deletions theme/damoang/layout/basic/js/open_all_link_on_economy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,24 @@ function attachOpenAllLinkOnBtn() {
}

async function openAllLinksInUserContent() {
var userText = document.querySelector('.economy-user-text');
var links = userText.querySelectorAll('a');
var userTexts = document.querySelectorAll('.economy-user-text'); // 모든 economy-user-text 요소 선택
var allLinks = [];

for (let i = 0; i < links.length; i++) {
const url = links[i].href;
// 각 economy-user-text 요소 내의 링크 수집
userTexts.forEach(userText => {
var links = userText.querySelectorAll('a');
links.forEach(link => {
// 1) 이미지에 대한 링크 제외
// 2) 보이지않는 링크 열지 않음 - innerText가 없는 <a>태그의 링크는 제외 (글쓰기 에디터문제인지 본문에 가끔 텍스트 없는 <a>태그로 중복되는 링크가 있음)
if (!link.querySelector('img') && link.innerText.trim() !== "") {
allLinks.push(link.href);
}
});
});

// 링크들을 순차적으로 열기
for (let i = 0; i < allLinks.length; i++) {
const url = allLinks[i];
if (url) {
await new Promise(resolve => {
setTimeout(() => {
Expand All @@ -24,7 +37,7 @@ async function openAllLinksInUserContent() {
window.focus(); // 현재 탭에 포커스 유지
}
resolve();
}, i * 100); // 각 링크를 ?ms 간격으로 열기
}, i * 100); // 각 링크를 100ms 간격으로 열기
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion theme/damoang/skin/board/basic/view/basic/view.skin.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ class="btn btn-basic btn-sm ms-2" style="white-space: nowrap;">
} ?>

<?php if ($is_link || $is_attach) { ?>
<section id="bo_v_data" class="border-bottom border-top mt-5">
<section id="bo_v_data" class="border-bottom border-top mt-5 economy-user-text">
<ul class="list-group list-group-flush">
<?php if ($is_link) { ?>
<li class="list-group-item pb-1">
Expand Down

0 comments on commit de62252

Please sign in to comment.