Skip to content
This repository has been archived by the owner on Aug 7, 2022. It is now read-only.

Commit

Permalink
編集機能完成(AltManager完成)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiro527 committed Apr 23, 2021
1 parent a8e1d98 commit 6923ebb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
6 changes: 6 additions & 0 deletions app/js/lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ module.exports.ja_JP = class {
addAccOK = "正常にアカウントを追加しました"
addAccErr = "エラー: このアカウントはすでに登録されています"
deleteAcc = "本当にアカウント %accName% を削除しますか?"
edittingAcc = "%accName% を編集中"
saveAccOK = "正常にアカウントの変更を保存しました"
saveAccErr = "エラー: アカウントの変更を保存できませんでした"
}

module.exports.en_US = class {
Expand Down Expand Up @@ -108,4 +111,7 @@ module.exports.en_US = class {
addAccOK = "Added account successfully"
addAccErr = "Error: This account has already registered"
deleteAcc = "Are you sure you want to delete the account?: %accName%"
edittingAcc = "You are editting: %accName%"
saveAccOK = "Saved account changes successfully"
saveAccErr = "Error: Couldn't save account changes"
}
4 changes: 2 additions & 2 deletions app/js/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ const insertAltManager = () => {
let signedOutHeader = document.getElementById("signedOutHeaderBar");
let mLevelCont = document.getElementById("mLevelCont");
let altManagerBtnHTMLloggedOut = `
<div class="verticalSeparator" style="height:35px;"></div>
<div class="button buttonPI lgn" style="width:200px;margin-right:0px;padding-top:3px;padding-bottom:15px" onmouseenter="playTick()" onclick="window.utils.showAltMng()">
Alt Manager <span class="material-icons" style="vertical-align:bottom;color:#fff;font-size:30px;margin-bottom:-1px;">manage_accounts</span>
</div>
<div class="verticalSeparator" style="height:35px;"></div>
`
let altManagerBtnHTMLloggedIn = `
<div class="verticalSeparator" style="height:35px;"></div>
Expand All @@ -69,7 +69,7 @@ const insertAltManager = () => {
<span class="material-icons" style="vertical-align:bottom;color:#fff;font-size:30px;margin-bottom:-1px;">logout</span>
</div>
`
signedOutHeader.insertAdjacentHTML("afterbegin", altManagerBtnHTMLloggedOut);
signedOutHeader.insertAdjacentHTML("beforeend", altManagerBtnHTMLloggedOut);
mLevelCont.insertAdjacentHTML("afterend", altManagerBtnHTMLloggedIn);
}

Expand Down
36 changes: 25 additions & 11 deletions app/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,11 @@ module.exports = class utils {
}
}

showAltMng(f=false) {
showAltMng() {
let menuWindow = document.getElementById("menuWindow");
menuWindow.style.overflowY = "auto";
let tmpHTML = `
<div id="lafAltTitle" style="font-size:30px;text-align:center;margin:5px;font-weight:700;">Alt Mamager</div>
<div id="lafAltTitle" style="font-size:30px;text-align:center;margin:3px;font-weight:700;">Alt Mamager</div>
<hr style="color:rgba(28, 28, 28, .5);">
<div style="display:flex;flex-direction:column;justify-content:center;">
`;
Expand All @@ -276,7 +276,7 @@ module.exports = class utils {
tmpHTML += "</div>"
}
generateHTML();
if (document.getElementById("windowHolder").style.display === "block" && !f) {
if (document.getElementById("windowHolder").style.display === "block") {
if (document.getElementById("windowHeader").innerText === "Alt Manager") {
document.getElementById("windowHolder").style.display = "none";
} else {
Expand All @@ -290,7 +290,7 @@ module.exports = class utils {
}
}

addAltAcc() {
addAltAcc(f=false) {
let accName = document.getElementById("accName").value;
let accPass = document.getElementById("accPass").value;
let accPassB64 = btoa(accPass);
Expand All @@ -306,7 +306,7 @@ module.exports = class utils {
} else {
let existing = false;
Object.keys(altAccounts).forEach((k) => {
if (k === accName) {
if (k === accName && !f) {
document.getElementById("accResp").innerText = langPack.addAccErr;
existing = true;
}
Expand All @@ -316,7 +316,7 @@ module.exports = class utils {
localStorage.setItem("altAccounts", JSON.stringify(altAccounts));
document.getElementById("accName").value = "";
document.getElementById("accPass").value = "";
document.getElementById("accResp").innerText = langPack.addAccOK;
document.getElementById("accResp").innerText = f ? langPack.saveAccOK : langPack.addAccOK;
}
}
}
Expand All @@ -331,13 +331,28 @@ module.exports = class utils {
window.loginAcc();
document.getElementById('accName').style.display = 'none';
document.getElementById('accPass').style.display = 'none';
document.getElementsByClassName('accountButton')[0].style.display = 'none';
document.getElementsByClassName('accountButton')[1].style.display = 'none';
document.getElementsByClassName('accountButton')[2].style.display = 'none';
document.getElementsByClassName('accountButton').forEach((k) => {
k.style.display = "none";
})
}

editAcc(accName) {
// pass
let menuWindow = document.getElementById("menuWindow");
menuWindow.innerHTML = `
<input id="accName" type="text" placeholder="Enter Username" class="accountInput" style="margin-top:0" value="${accName}" readonly="readonly">
<input id="accPass" type="password" placeholder="Enter New Password" class="accountInput">
<div id="accResp" style="margin-top:10px;font-size:18px;color:rgba(0,0,0,0.5);">${langPack.edittingAcc.replace("%accName%", accName)}</div>
<div class="accountButton" onclick="window.utils.addAltAcc(true)" style="width:100%">Save Account</div>
`
}

saveAcc() {
try {
this.addAltAcc(true);
} catch (e) {
console.error(e);
}
setTimeout(document.getElementById("windowHolder").style.display = "none", 3000);
}

deleteAcc(accName) {
Expand Down Expand Up @@ -369,7 +384,6 @@ module.exports = class utils {
}
break;
case "changeVisibility":
console.log("TEST")
let el = document.getElementById(`eye_${opt}`);
if (config.get(`${opt}_visibility`, true)) {
el.innerText = "visibility_off"
Expand Down

0 comments on commit 6923ebb

Please sign in to comment.