Skip to content

Commit

Permalink
restore
Browse files Browse the repository at this point in the history
  • Loading branch information
kewool committed Dec 31, 2023
1 parent 1ceada4 commit c50f2f1
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stella_lux",
"version": "2.0.2",
"version": "2.0.3",
"description": "",
"main": "main.js",
"scripts": {
Expand Down
1 change: 0 additions & 1 deletion src/pages/main/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
</div>
</header>
<div id="panel">
<p style="color: white; font-size: 24px;">콘서트 예매도 못 하고 굿즈도 못 산 병신이 만든 앱 따위는 필요없습니다</p>
<div class="detail_background">
<div class="detail">
<img class="detail_thumnail" />
Expand Down
161 changes: 161 additions & 0 deletions src/pages/main/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,167 @@ if (user.profile) {
docQuery(".user_sign p").innerText = "로그인";
docQuery(".user_sign img").src = "../../assets/login.svg";
}
const info = ipcRenderer.sendSync("getChannelInfo");
let diffTimeTemp = {};
let nameTemp = "";
let typeTemp = "";
function detailInfoEvent() {
if (typeTemp === "stream")
ipcRenderer.send("openNewWindow", `https://www.twitch.tv/${nameTemp}`);
else if (typeTemp === "space")
ipcRenderer.send("openNewWindow", `https://x.com/i/spaces/${nameTemp}`);
}
function moreInfoEvent(element) {
// const detail = ipcRenderer.sendSync("getChannelInfoDetail", e);
const detail_background = docQuery(".detail_background");
detail_background.style.display = "block";
if (element.isStream && !element.isSpace) {
docQuery(
".detail_thumnail",
).src = `https://static-cdn.jtvnw.net/previews-ttv/live_user_${element.name}-380x213.jpg`;
docQuery(".detail_info_button p").innerText = diffTimeTemp[element.name];
nameTemp = element.name;
typeTemp = "stream";
docQuery(".detail_info_button").addEventListener("click", detailInfoEvent);
docQuery(".detail_info_button").className = "detail_info_button is_stream";
} else if (!element.isStream && element.isSpace) {
docQuery(".detail_thumnail").src =
"https://static-cdn.jtvnw.net/ttv-static/404_preview-380x213.jpg";
docQuery(".detail_info_button p").innerText = "스페이스 진행 중!";
docQuery(".detail_info_button").className = "detail_info_button is_space";
nameTemp = element.isSpace;
typeTemp = "space";
docQuery(".detail_info_button").addEventListener("click", detailInfoEvent);
} else {
docQuery(".detail_thumnail").src =
"https://static-cdn.jtvnw.net/ttv-static/404_preview-380x213.jpg";
docQuery(".detail_info_button p").innerText =
"최근 방송 " + diffTimeTemp[element.name];
nameTemp = element.name;
docQuery(".detail_info_button").className =
"detail_info_button is_not_stream";
}
docQuery(".detail_info_name").innerText = element.displayName;
docQuery(".detail_info_follows span").innerText = beautyFollows(
element.follows,
);
docId("detail_info_auto_toggle_checkbox").checked =
store.get("auto_start")[element.name].enabled;
docId("detail_info_auto_toggle_checkbox").addEventListener(
"change",
(evt) => {
store.set(`auto_start.${element.name}.enabled`, evt.target.checked);
},
);
docId("detail_info_space_toggle_checkbox").checked =
store.get("space_auto_start")[element.name].enabled;
docId("detail_info_space_toggle_checkbox").addEventListener(
"change",
(evt) => {
store.set(`space_auto_start.${element.name}.enabled`, evt.target.checked);
},
);
const channelPoint = ipcRenderer.invoke("getChannelPoint", element.name);
channelPoint.then((res) => {
docQuery(".detail_info_points span").innerText = res;
});
}

info.forEach((element, i) => {
const panel_item = docId(element.name);
let pipDelay = null;
panel_item.addEventListener("click", (evt) => {
if (evt.target.className === "panel_item_more") return;
if (!pipDelay) {
if (element.isStream && !element.isSpace) {
ipcRenderer.send("getStream", element.name);
} else if (!element.isStream && element.isSpace) {
ipcRenderer.send("getSpace", element.name);
}
pipDelay = setTimeout(() => {
pipDelay = null;
}, 5000);
}
});
const profile = document.createElement("div");
profile.className = "panel_item_profile";
if (element.isStream && !element.isSpace) profile.classList.add("is_stream");
else if (!element.isStream && element.isSpace)
profile.classList.add("is_space");
const profile_img = document.createElement("img");
profile_img.src = element.profile;
profile.append(profile_img);
panel_item.append(profile);

const panel_item_info = document.createElement("div");
panel_item_info.className = "panel_item_info";

const name = document.createElement("p");
name.innerText = element.displayName;
name.className = "panel_item_name";
panel_item_info.append(name);

const panel_item_stream_date = document.createElement("p");
panel_item_stream_date.className = "panel_item_stream_date";
const startDate = new Date(element.startDate);
const nowDate = new Date();
let diff = nowDate.getTime() - startDate.getTime();
let diffTimes = Math.floor(diff / (1000 * 60));
let diffTimeText = "";
if (element.isStream && !element.isSpace) {
if (diffTimes >= 60) {
diffTimes = Math.floor(diffTimes / 60);
diffTimeText = `${diffTimes}시간 전부터 방송 중!`;
panel_item_stream_date.innerText = diffTimeText;
} else {
panel_item_stream_date.classList.add("is_stream");
diffTimeText = `${diffTimes}분 전부터 방송 중!`;
panel_item_stream_date.innerText = diffTimeText;
}
} else if (!element.isStream && element.isSpace) {
panel_item_stream_date.classList.add("is_space");
panel_item_stream_date.innerText = "스페이스 진행 중!";
} else {
diff = nowDate.getTime() - new Date(element.lastStreamDate).getTime();
diffTimes = Math.floor(diff / (1000 * 60));
panel_item_stream_date.innerText = "최근 방송";
if (diffTimes >= 1440) {
diffTimes = Math.floor(diffTimes / 60 / 24);
diffTimeText = `${diffTimes}일 전`;
} else if (diffTimes >= 60) {
diffTimes = Math.floor(diffTimes / 60);
diffTimeText = `${diffTimes}시간 전`;
} else if (diffTimes < 60) {
diffTimeText = `${diffTimes}분 전`;
}
const lastStreamDate = document.createElement("span");
lastStreamDate.innerText = diffTimeText;
panel_item_stream_date.append(lastStreamDate);
}
diffTimeTemp[element.name] = diffTimeText;
if (element.isStream && !element.isSpace)
panel_item_stream_date.classList.add("is_stream");
else if (!element.isStream && element.isSpace)
panel_item_stream_date.classList.add("is_space");
panel_item_info.append(panel_item_stream_date);

const follows = document.createElement("p");
follows.className = "panel_item_follows";
follows.innerText += "팔로워";
const follows_span = document.createElement("span");
follows_span.innerText = beautyFollows(element.follows);
follows.append(follows_span);
panel_item_info.append(follows);
panel_item.append(panel_item_info);

const more_img = document.createElement("img");
more_img.src = "../../assets/more.svg";
more_img.className = "panel_item_more";
more_img.addEventListener("click", () => {
moreInfoEvent(element);
});
docId(element.name).append(more_img);
});

ipcRenderer.once("update_downloaded", () => {
docQuery(".header_update").style.display = "flex";
Expand Down

0 comments on commit c50f2f1

Please sign in to comment.